Re: splitting netcdf files into season

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 3 Aug 2006 15:52:45 -0600 (MDT)

I replied but neglected to cc ncl-talk
**************************************

> I want to filter a netcdf file containing daily time series
> data from 1998 - 2005 into seasons ( separate netcdf file ..
> Nov-Mar May-Oct). Is there any shorter way to do it, or I need
> to convert this to ascii and then convert the
> filtered season data back to netcdf.

no need to convert to ascii

>
>netcdf lt2s180w.dat.new.nc.flt {
>dimensions:
> time = UNLIMITED ; // (2922 currently)
>variables:
> double time(time) ;
> time:units = "days since 0000-1-1 00:00:00" ;
> time:long_name = "Time" ;
> time:_FillValue = -9999. ;
> float lt(time) ;
> lt:long_name = "Latent Heat" ;
> lt:units = "Watts" ;
> lt:_FillValue = -999.99f ;
>
>// global attributes:
> :creation_date = "Tue Aug 1 17:21:28 PDT 2006" ;
> :title = "Filtered (20-100 days) Latent heat "
>
>2)I want all the nov,dec,jan,feb,march,april of all years(1998-2005) in one
>file, the same for months may,june jul,august,september,october in another
>file.
>
>3) the final variable would be lt(time)
>
> Let me know whether I need to provide more information.

--------------------------

The following sample script uses

  http://www.ncl.ucar.edu/Document/Functions/Built-in/ut_calendar.shtml
  http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml

Something like the following untested script

   f= addfile ("lt2s180w.dat.new.nc.flt"+".nc" , "r")
                                       ;^^^^^^
                                       ;NCL needs this file extension

   TIME = f->time
   ymd = ut_calendar(TIME, -2) ; year-month-day
   
   year = ymd/10000
   md = ymd - year*10000
   mon = md/100
   
   i = ind(mon.eq.11 .or. mon.eq.12 .or. \
              mon.eq.1 .or. mon.eq. 2 .or. mon.eq.3)
              
   diro = "./"
   filo = "lt2s180w.Nov-Mar.nc:
   system("'rm' -f "+diro+filo)
   fo = addfile(diro+filo, "c")
   fo_at_title = "lt: Nov-Dec:
   fo_at_creation_date = systemfunc("date")
   
   filedimdef(fo, "time", -1, True) ; make time unlimited
   
   fo->lt = f->lt(i) ; Nov-Mar
   fo->yyyymmdd = ymd(i)
   
 ==========================================
 
 FWIW ... my advice
 
 Keep the file "as-is"
 
  SEASON = "WINTER" ; "SUMMER"

  TIME = f->time
  ymd = ut_calendar(TIME, -2) ; year-month-day
   
  year = ymd/10000
  md = ymd - year*10000
  mon = md/100
  
  if (SEASON.eq."WINTER") the
      i = ind(mon.eq.11 .or. mon.eq.12 .or. \
              mon.eq.1 .or. mon.eq. 2 .or. mon.eq.3)
  else
      i = ind(mon.eq.5 .or. mon.eq.6 .or. mon.eq.7 \
              mon.eq.8 .or. mon.eq.9 .or. mon.eq.10)
  end if
  
  lt = f->lt(i) ; read daily data for specified season
     
   
good luck
D

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 03 2006 - 15:52:45 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 04 2006 - 10:26:31 MDT