Esempio n. 1
0
 def execute(self,parent,type,button):
     if button=='OK':
         if type=='Xhourly':
             entry=self.entry.getvalue()
             if entry!='':
                 entry=eval(self.entry.getvalue())
             else:
                 gui_message.error('Please Fill the Entry Field')
                 return
             
             gui_busy.busyStart( self, parent )
             fqcy=24./int(entry)
             try:
                 var=parent.panelDV.lst1[ parent.panelDV.selected]
             except Exception,err:
                 var=None
             if var is None: 
                 gui_busy.busyEnd( self, parent )
                 gui_message.error( "The 'Set Bounds Time Tool' could not complete its function, because a variable was not selected.\nError:\n"+str(err) )
                 return
             cdutil.setTimeBoundsDaily(var,frequency=fqcy)
             gui_control.record_command( parent, "\n# X-Daily Data Bounds Set Function" , 1 )
             gui_control.record_command( parent, "cdutil.times.setTimeBoundsDaily( %s, frequency=%s )" % (var.id,str(fqcy)), 1 )            
             
         gui_busy.busyEnd( self, parent )
         self.dialog.destroy()
 def setTimeBounds( self, var ):
     time_axis = var.getTime()
     if time_axis._bounds_ == None:
         try:
             time_unit = time_axis.units.split(' since ')[0].strip()
             if time_unit == 'hours':
                 values = time_axis.getValue()
                 freq = 24/( values[1]-values[0] )
                 cdutil.setTimeBoundsDaily( time_axis, freq )
             elif time_unit == 'days':
                 cdutil.setTimeBoundsDaily( time_axis )
             elif time_unit == 'months':
                 cdutil.setTimeBoundsMonthly( time_axis )
             elif time_unit == 'years':
                 cdutil.setTimeBoundsYearly( time_axis )
         except Exception, err:
             wpsLog.debug( "Exception in setTimeBounds:\n " + traceback.format_exc() )
Esempio n. 3
0
##------------------------------------------------------------##

## scan the files from the search string for date range
## returns an iofilescan object
fs = ioT.scan(searchStr, date1, date2)

## print some diagnostics
print fs

## Extract the variable
print "Extracting %s ..." % varName
var = fs(varName)

## To average over time, you need to setup
## the time axis' bounds
cdutil.setTimeBoundsDaily(var.getTime(), frequency=24)

## average over the 0th axis, ie. time
var_average = ioT.binAverager(var, 0)

## change metadata
varDesc = "%s variable -- daily average" % varName
var_average.IOmodVar(desc=varDesc)

## print time axes
print "original data time axis:"
print var.getTime()

print "average data time axis:"
print var_average.getTime()
Esempio n. 4
0
## scan the files from the search string for date range
## returns an iofilescan object
fs = ioT.scan(searchStr, date1, date2)

## print some diagnostics
print fs

## Extract the variable
print "Extracting %s ..." %varName
var = fs(varName)


## To average over time, you need to setup
## the time axis' bounds
cdutil.setTimeBoundsDaily(var.getTime(), frequency=24)

## average over the 0th axis, ie. time
var_average = ioT.binAverager(var, 0)

## change metadata
varDesc = "%s variable -- daily average" %varName
var_average.IOmodVar(desc=varDesc)

## print time axes
print "original data time axis:"
print var.getTime()

print "average data time axis:"
print var_average.getTime()
Esempio n. 5
0
#convective_onset_statistics(cwv, precip,'sondes')


out_file = cdms2.open('prw_nauru_sondes_Apr2001_Aug2006.nc','w')
start = "2001-04-01 00:00:00"
nTimes = cwv.shape[0]
time = cdms2.createAxis(range(nTimes))
time.units = "hours since {}".format(start)
time.designateTime()
time.id = 'time'
data = MV2.array(np.arange(nTimes))
data[:] = cwv
data.setAxis(0,time)
data.id = "prw"
data.units = "mm"
cdutil.setTimeBoundsDaily(data, 24)
out_file.comment = "1 hourly averaged column water vapor derived from sondes from Apr2001_Aug2006.nc, postprocessed based on datastream-name"
out_file.timeperiod = 'time period for data'
out_file.write(data)

out_file = cdms2.open('pr_nauru_matchedtosondes_Apr2001_Aug2006.nc','w')
start = "2001-04-01 00:00:00"
nTimes = precip.shape[0]
time = cdms2.createAxis(range(nTimes))
time.units = "hours since {}".format(start)
time.designateTime()
time.id = 'time'
data = MV2.array(np.arange(nTimes))
data[:] = precip
data.setAxis(0,time)
data.id = "pr"