# Re: [ferret_users] Regridding 20 year time axis

```Hi Paul,
You were almost there...but missed an important rule.....see
the description for case two in my original email :

http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2007/msg00489.html

What is happening here? Remember that Ferret evaluates any expression/s only
when it hits an action command (eg. plot, fill, save etc., Ch3 Sec2.
EXPRESSIONS). You loads the data, assigns a time axis regridding step and
then trying to write the data out in a REPEAT loop over time. The time axis
assignment will be evaluated within the repeat loop, and this is the sole
reason for the error message. This is why i specifically described two
different cases in above mentioned posting. FIX: Use any other axes (Z,Y or
X) for the REPEAT loop.

What exactly is the reason for getting precise mid-month values for your
time axis? For most of the calculation purposes, you could just pretend the
time axis either GREGORIAN or 360_DAY since you are dealing with a monthly
mean dataset. In this case, you can just make a descriptor file with one
stepfile entry and use it in Ferret....save disk space and time !!

NOTE: Beware about transformations (ie finding climatology or even
extending climatology data onto an interannual time axis to find anomalies
and all).....they are always tricky with calendars like NOLEAP and JULIAN.
The most user friendly calendar is 360_DAY and then GREGORIAN. Use them,
if you can....

Just for the fun, here is an easy way of creating a time axis like what
you trying to make :

!--------------------------------------------------------------------
let nyrs      = 20         ! number of total years
! days in each month
let mdays     = TSEQUENCE({31,28,31,30,31,30,31,31,30,31,30,31})
! repeat the monthly values for all the years
let ids       = L[L=1:`nyrs*12`:1]       ! month indices, 1,2,3,.....240.
let mon_ids   = ids - INT((ids-1)/12)*12 ! respective month (1,2,..12,1,2...12,1,2..)
let mdays_all = SAMPLEL(mdays, mon_ids)  ! series of mdays, for all years
let tvals     = mdays_all[l=@RSUM] - mdays_all/2 ! mid-month time value for all months
! to be accurate, keep T0 as 31-DEC of previous year
define axis/T/T0=31-DEC-2000/from_data/units=days/calendar=noleap tax_jday=tvals

show axis tax_jday
!--------------------------------------------------------------------

Please let me know if you have any questions,

Thanks and Regards,

Jaison

> Dear ferret users,
>
> I am having problems regridding the time axis of a 20 year time series
> of monthly mean model output. Here's what I am doing:
>
> 	yes? use my_Z_data_20yr.nc
>
> 	!Read in data containing Julian day values for 20 years on a "noleap"
> calendar
> 	yes? file/variable=jday/columns=12/type=numeric "20year_axis.dat"
>
> 	!Define new time axis
> 	yes? define axis/t0=31-Dec-2000/from_data/units=days/calendar=noleap
> tax_jday=tjday
>
> 	!Regrid original variable to tax_jday
> 	yes? let new_var = old_var[gt=tax_jday@asn]
>
> 	!Save new variable (using Jaison Kurian's memory tricks)
> 	yes? let l_start = `new_var,r=lstart`
>          yes? let l_end = `new_var,r=lend`
> 	yes? let slices = l_end - l_start + 1
> 	yes? REPEAT/L=`l_start`:`l_end`:1 (;\
> 			save/file="my_outfile.nc"/append/quiet new_var ; \
> 			say " Time slice `(L-l_start+1)`/`slices`" ;\
> 			)
>
> I then get the following error message:
>
> 	!-> REPEAT: L=1
> 		**TMAP ERR: error in line definition
> 			disordered output coordinate value: 15.500 Axis: TAX
> 	LIST/FORMAT=CDF/file="my_outfile.nc"/append/quiet new_var
> 	Command file, command group, or REPEAT execution aborted
>
> (I'm guessing TAX is a truncation of tax_jday?).
>
> Just to confirm that the old and new time axes are of the same size:
>
> 	yes? show axis time
> 	name 	  axis 	  # pts      start 		  end
> 	TIME 	  TIME 	  240 i      01-FEB-2001 00:00 	  01-JAN-2021 00:00
> 	T0 = 01-SEP-2000 00:00:00
> 	CALENDAR = NOLEAP
> 	Axis span (to cell edges) = 7300
>
> 	yes? show axis tax_jday
>   	name      axis    # pts      start  		  end
>     	TAX_JDAY  TIME    240 i      15-JAN-2001 12:00    15-DEC-2020 12:00
> 	T0 = 31-DEC-2000
> 	CALENDAR = NOLEAP
>     	Axis span (to cell edges) = 7299
>
> A related question: Is there a way to generate tax_jday in ferret,
> array of mid month, Julian day values (midmonth = {15.5, 45.0, 74.5,
> 105.0, 135.5, 166.0, 196.5, 227.5, 258.0, 288.5, 319.0, 349.5}) to get
> the 240 element array, but I couldn't think how to do it in ferret. Is
> it possible to concatenate user defined arrays into one variable (e.g.
> like let big_array={array1,array2,....,arrayN})? I don't have XCAT etc
> on my version of ferret, though I guess that might be the solution....
>
> Thanks for any help,
>
> Paul
>
>
> -----
> Paul Young
>
> Chemistry and Climate Processes
> Chemical Sciences Division
> NOAA Earth System Research Laboratory
> Boulder CO 80305-3328
> USA
>
> Tel:   +1 303-497-4943
> Fax:   +1 303-497-5686
> Email: paul.j.young@xxxxxxxx
> Web:   http://www.esrl.noaa.gov/csd/
>
>

```