[idvusers] mixed accumulation/average times

Hi All-

I've been trying to deal with fields like Total Accumulated Precip in the GFS model which is on mixed intervals of accumulation. For example, the 3hr forecast is a 3 hr accumulation and the 6hr forecast is a 6 hour accumulation, 9hr fcst is 3 hr, 12h fcst is 6 hr, etc. There are also fields like Longwave radiation (OLR) which is on mixed averaging intervals. Similar to the precip, but it's an average, not an accumulation. I've written a little Jython routine to "unmix" the intervals which I thought I'd share. You pass in the grid, the accumulation interval you want to unmix (default 6hr) and whether it's an accumulation (1) or an average (0). Please share any improvements you might make with the community:

def unmixIntervals(grid,cumTime=6,accum=True):
  from ucar.visad.data import CalendarDateTime as cdt
  from java.util import TimeZone as tz
  ugrid = grid.clone()
  timeSet = GridUtil.getTimeSet(grid)
  timeArray = cdt.timeSetToArray(timeSet)
  for time in range(len(timeArray)):
     if (time > 0):
prevhour = int(timeArray[time-1].formattedString("HH",tz.getTimeZone("GMT"))) nowhour = int(timeArray[time].formattedString("HH",tz.getTimeZone("GMT")))
        if (nowhour%cumTime == 0 and prevhour%cumTime != 0):
          if (accum):
             tsgrid = sub(grid.getSample(time),grid.getSample(time-1))
          else:
              tsgrid = sub(2*grid.getSample(time),grid.getSample(time-1))
          ugrid.setSample(time,tsgrid)
  return ugrid



Enjoy!

Don
--
Don Murray
NOAA/ESRL/PSD and CU-CIRES
303-497-3596
http://www.esrl.noaa.gov/psd/people/don.murray/



  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the idvusers archives: