[Thread Prev][Thread Next][Index]

RE: [ferret_users] How to modify time axis



Dear Ansley,

It is perfect and thanks for the solution. I have another question:

If I have around 10 files, each contains 12 months data for same variables (ocean.19900101.nc, ocean.19910101.nc upto ocean.19990101.nc). These files have noleap calender. I want to handle their entire time period and work with some particular variable and plot its time series. I don't want first to save particular variable in one file and then open this new file to work with (It will take longer time). Actually my intention is to open all the input files and define their entire time period and then change this entire time axes to a newer time axis which you explained in you last email.
Regarding merging all files, I could use cdo or nco but I don't want to work this way because the resultant merged file is very big in size (around 70 GB). Actually this question is continuation of last question regarding changing time axes.

In short I just wanted to open all these files in Ferret and wanted to use their entire time and bring my required variable on new time axis as we you explained it already.



Date: Fri, 11 Jan 2013 12:46:04 -0800
From: ansley.b.manke@xxxxxxxx
To: couragetoknowgc@xxxxxxxxxxx
Subject: Re: [ferret_users] How to modify time axis

Hi,
To do what I suggested, you would add the /NOLEAP qualifier to the DEFINE AXIS command.

We can get information about this axis using the unix tool "ncdump".  This command will list the netcdf header and the variables time and time_bnds.

/home/users/ansley> ncdump -v time,time_bnds temp.nc

The header shows the attributes of the time axis are these, so you can see the calendar attribute and the units and origin of the axis.

        double time(time) ;
                time:standard_name = "time" ;
                time:bounds = "time_bnds" ;
                time:units = "days since 1990-01-01 00:00:00" ;
                time:calendar = "365_day" ;

In the data section of the listing are the time coordinates and the time bounds:

 time = 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 424,
    455, 485, 516, 546, 577, 608, 638, 669, 699, 730 ;

 time_bnds =
  0, 31,
  31, 59,
  59, 90,
  90, 120,
  120, 151,
  151, 181,
  181, 212,
  212, 243,
  243, 273,  ...

So, the first coordinate value on the time axis is 31 days since 1-jan-1990, and that's Feb 1.  This is an unusual definition, having the time coordinates at the end of each grid cell.  More typically, the time coordinate would be in the middle of each grid cell.  So more often a time axis would have something like time = 15.5, 45, ...

If you want to change this, you could use the bounds to redefine the axis, using the coordinate data from the file. Monthly axes are always tricky because the months are not the same length.  To put the time coordinate in the middle of the grid cell, you could use the /edges qualifier on the define command,

yes? use temp.nc
yes? define axis/edges/t0=1-jan-2000/units=days time = tboxlo[gt=temp]

Although this isn't quite everything we need.  It doesn't give us the upper limit of the last grid cell.  So, try this script. Does it give you what you want?

yes? use temp
 
! variables with the lower and higher limits of each month
yes? let tlo =  tboxlo[gt=temp]
yes? let thi = tboxhi[gt=temp]
yes? list tlo,thi

! variable with just the upper limit of the last grid cell
yes? let highest = thi[t=@max]

! variable with the edges of all the months in the data
yes? let box_edges = tcat(tlo, highest)
yes? list box_edges

! Define an axis starting in jan 2000, with these numbers as the edges of the month.
! the coordinates of the time axis will be in mid-month.

yes? define axis/noleap/edges/t0=1-jan-2000/units=days time = box_edges

I can help with more ideas if you want.

On 1/11/2013 1:24 AM, Star Physicist wrote:
Dear Ansley,

Thanks very much for such a nice demonstration. There is one one issue in my data set. It is CM2.1 model output which uses noleap calender. 2ndly I don't know why FERRET displays first time step as 01 Feb instead of 01 Jan month. I am attaching a netcdf file for monthly potential temperature for two years. Please have a look on this file and guide me if I want to shift this time axis to some new time axes along with managing these edges of the months.

Thanks,

Mubashar



Date: Wed, 9 Jan 2013 16:37:30 -0800
From: ansley.b.manke@xxxxxxxx
To: couragetoknowgc@xxxxxxxxxxx
CC: ferret_users@xxxxxxxx
Subject: Re: [ferret_users] How to modify time axis

Hi Mubashar
You can change the definition of the time axis with a DEFINE AXIS command, using the name of the time axis from the file. Then the data will be used as if it were on the new time axis.  What happens is that the data in the file will be interpreted using the time information in the new time axis.  The old definition is lost to Ferret during that session, but the input file you are reading is unchanged.  So, let's make an example:

! define a time axis and set up a variable on that axis
! Write it to an example file

yes? define axis/t=1-jan-1990:31-dec-1999:1/units=days time
yes? let var = sin(t[gt=time]/100)
yes? plot var
yes? save/clobber/file=timevar.nc var

yes? cancel variable/all
yes? cancel axis time

! Now open the file, as if we are in a new Ferret session.

yes? use timevar.nc
yes? plot var  ! it's on the 1990-1999 time axis

! redefine the time axis.  The last bit of syntax gets the name
! of the time axis for the variable "var".


yes? define axis/t=1-jan-2000:31-dec-2009:1/units=days `var,return=taxis`
Replacing definition of axis TIME
 *** NOTE: grid  used by data set timevar
 *** NOTE: Redefinition may alter apparent contents of data set

yes? plot var  ! it's on the 2000-2009 time axis

yes? save/clobber/file=timevar2000.nc/t=1-jan-2008:31-dec-2009 var
Try some more experiments. What if you redefine the axis like this (an axis with a lot more coordinate points)?  The data will be read onto the first part of the axis
yes? cancel data/all
yes? use timevar.nc
yes? define axis/t=1-jan-2000:31-jan-2001:1/units=minutes `var,return=taxis`
yes? plot var
How about this one:
yes? cancel data/all
yes? use timevar.nc
yes? define axis/t=1-jan-2000:1-jan-2002:1/units=days `var,return=taxis`
yes? plot var
On 1/9/2013 2:37 PM, Star Physicist wrote:
Dear Ferret users,

I am new to FERRET and wanted to modify time axis in my netcdf file. I have a netcdf file (with many variables) containing monthly data from jan1990 to dec1999. Can I create a netcdf file using FERRET (having all variables) after modifying the time axis to jan2000 till dec2009 instead of jan1990 to dec1999.

Thanks,

Mubashar



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

Privacy Policy | Disclaimer | Accessibility Statement