[Thread Prev][Thread Next][Index]

Re: [ferret_users] regriding from discontinuous time axis



Hi Bruno,
It seems we have a bug in the XACT function, with double-precision Ferret when working with these time axes that use lots of precision.  Note that the script below wouldn't have worked with single-precision Ferret, because the definition of the variable "time" would have been done as a single precision variable and so we'd lose the needed precision to define the axis.

But in double precision, the exact-coordinate matching done in the XACT regridding wasn't done correctly. Simple examples work ok but this example where we are making use of more precision were wrong.  I have a fix for this bug and we'll get it into the next release.

By the way, in any regridding involving time axes, you do not have to have the same time origin for both axes.  Ferret translates between time coordinates and dates for these operations. 

To demonstrate that Russ's idea does work, here is a workaround which does the same operations as what you have in the script, but uses time coordinates with more-recent time origins - one in 2010, one in 2000. This script will work correctly with Ferret v6.82.

DEFINE AXIS/t="02-nov-2011:07:54:36":"02-nov-2011:08:03:36":60/units=seconds/T0=1-JAN-2010 my_axis

let time = t[gt=my_axis]
Let var = TSEQUENCE( RANDU( time ) )
Let fake_var = T[GT=my_axis]
Let var_regrid = RESHAPE( var, fake_var )

List /T="2-nov-2011 07:54":"2-nov-2011 08:04" var_regrid
! Here I obtain 10 values

! New time axis
Define Axis /T="01-NOV-2011 00:00":"30-NOV-2011 23:00":1 /Units=seconds /T0=1-JAN-2000 t_axis_seconds

Let var_sec = var_regrid[ GT=t_axis_seconds@XACT ]

List /T="2-nov-2011 07:54":"2-nov-2011 08:04" var_sec
! has 10 non-missing values



On 9/11/2012 8:28 AM, Bruno Levier wrote:
Hi Ferreters

I've tried Russ' solution, but I can not make it work (the XACT transformation doesn't work in my case).

Here is an example again :

Let time = {\
 22585.3295833333,\
 22585.3302777778,\
 22585.3309722222,\
 22585.3316666667,\
 22585.3323611111,\
 22585.3330555556,\
 22585.33375,\
 22585.3344444444,\
 22585.3351388889,\
 22585.3358333333}

Define Axis /T /From /T0=1-JAN-1950 /Units=days my_axis = time

Let var = TSEQUENCE( RANDU( time ) )
Let fake_var = T[GT=my_axis]
Let var_regrid = RESHAPE( var, fake_var )

List /T="2-nov-2011 07:54":"2-nov-2011 08:04" var_regrid
! Here I obtain 10 values

! New time axis
Define Axis /T="01-NOV-2011 00:00":"30-NOV-2011 23:00":1 /Units=seconds /T0=1-JAN-1950 t_axis_seconds

Let var_sec = var_regrid[ GT=t_axis_seconds@XACT ]

List /T="2-nov-2011 07:54":"2-nov-2011 08:04" var_sec
! Here I obtain 600 missing values and no good ones (I should have 10)



I use Ferret 6.82.

What's wrong ?

Thank you for your help,

Bruno Levier



On 09/10/2012 04:46 AM, Russ Fiedler wrote:
Hi Bruno,

If you define a continuous grid which contains the original points as a
subset you can use the @XACT remapping. In your example this would
require a time grid with intervals of half a day.

Def Axis/T=01-JAN-2000:13-JAN-2000:0.5/Units=days/T0=1-JAN-2000
my_axis_1dAV_half

Plot /Over /Line /Sym=20 /Co=2 var_regrid[ GT=my_axis_1dAV_half@XACT ]

To go to a daily grid I think remapping in 2 steps may be what you want

! Data at half day intervals. Missing vals if we don't match.
let tempvar_half = var_regrid[ GT=my_axis_1dAV_half@XACT ]
! Average onto a daily grid.
let tempvar_full = tempvar_half [ GT=my_axis_1dAV@AVE ]

Russ


On Fri, 2012-09-07 at 18:39 +1000, Bruno Levier wrote:
  
Hi Ferreters

I would like to regrid a variable on a new time axis. The problem is
that the source grid is discontinuous (with gaps of several days) ; the
tranformation fills the gap with interpolated or averaged values
(depending of the transformation used). Is it possible to avoid this
behaviour (I mean fill the gap with missing values) ?

Here is an example :
! Discontinuous time axis from January 1 to January 12 (no values from 3
to 10)
Let time = {0,0.5,1.0,1.5,2.0,10.0,10.5,11.0,11.5,12.0}
Define Axis /T /From /T0=1-JAN-2000 /Units=days my_axis = time

Let var = TSEQUENCE( RANDU( time ) )
Let fake_var = T[GT=my_axis]
Let var_regrid = RESHAPE( var, fake_var )

! New time axis
Define Axis /T=01-JAN-2000:13-JAN-2000:1 /Units=days /T0=1-JAN-2000
my_axis_1dAV

Plot /Line /Sym=18 var_regrid
! Now each day has a good value
Plot /Over /Line /Sym=20 /Co=2 var_regrid[ GT=my_axis_1dAV@AVE ]

Thanks !

Bruno

    


  



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement