[NARCCAP-discuss] using ncea to generate averages

Seth McGinnis mcginnis at ucar.edu
Tue Mar 6 16:31:03 MST 2012


Hi Jamie,

For creating time averages, you will want to use ncra rather than ncea.  See
section 2.6.2 in the NCO User's Guide for an explanation of the difference
between the two of them: http://nco.sourceforge.net/nco.html#Averaging

That probably will solve your problem, but I would like to take advantage of
your question to offer some general advice to the list about dealing with
times.  With regard to specifying the averaging period, I will strongly
recommend to every NARCCAP user something I have learned from painful
experience:

If the tools you're using will allow it, *always specify time periods using
dates*, rather than by counting an offset from the beginning of the file.  The
different GCMs use different, non-Gregorian calendars, and it's really easy to
get things wrong.

If you have NCO installed with udunits support, you can generate an average for
February like this:
     ncra -d time,"2041-02-01 00:00:01","2041-03-01 00:00:01" infile.nc
outfile.nc

This works correctly regardless of how many days are in February, and has the
added benefit that the averaging period is recorded in human-readable form in
the metadata of the file.

(Note that because there's a timestep at midnight on the last / first day of
each month, you have to decide which month it belongs to.  Allocating it to the
month that just ended, as above, allows you to ignore the number of days in the
month, which is highly convenient, and is consistent with the definition of
variables like precip as being the average value for the preceding three hours.
 If you specify the boundary as being exactly at midnight, the timestep will
get double-counted as part of both months, because NCO uses closed intervals
for the -d flag.)

If you can't get udunits support compiled in for your NCO install, or your
toolkit of choice can't interpret the time coordinates in the netcdf files,
then your best bet is to count carefully, print out the attributes of the time
variables, and bookmark the page on our website that lists the calendars used
by each driving model:  http://www.narccap.ucar.edu/about/time-periods.html

Hope that helps!  Cheers,

--Seth


On Tue, 6 Mar 2012 15:44:37 -0500
 "Cajka, James C." <jcajka at rti.org> wrote:
>Hello,
>
> 
>
>I am new to NetCDF data and the associated tools.  I have downloaded
>some files containing 5 years worth of data, and want to create monthly
>averages.  I am using the ncea utility which is part of the nco suite.
>Although I have read through the syntax, I don't think the output files
>are quite right.  Does anyone have any experience doing this?  I used 
>
>"ncea -F -d time,1,248,1 tas_MM5I_ccsm_2041010103.nc tas_jan_2041.nc" 
>
>and this seemed to work, but to create one for February I tried 
>
>"ncea -F -d time,249,472,1 tas_MM5I_ccsm_2041010103.nc tas_feb_2041.nc".
>
>
>The data is in 3 hour increments, so for January I thought I needed 8 X
>31 or the first 248 time slices.  Maybe I'm not understanding the data
>format correctly.
>
> 
>
>Any guidance would be appreciated!
>
> 
>
>Thanks,
>
>Jamie
>
> 
>
>========================
>
>Jamie Cajka
>
>RTI International
>
>3040 Cornwallis Rd.
>
>RTP, NC 27709
>
>email: jcajka at rti.org <mailto:jcajka at rti.org> 
>
>voice: (919)541-6470
>
> 
>
>RTI International is an independent 
>
>nonprofit research institute.  Learn 
>
>more at http://www.rti.org/ <http://www.rti.org/> 
>
> 
>
>_______________________________________________
>narccap-discuss mailing list
>narccap-discuss at mailman.ucar.edu
>http://mailman.ucar.edu/mailman/listinfo/narccap-discuss



More information about the narccap-discuss mailing list