def do_plot( self, id ): parent = self.eself # Parent is equal to root found in tk_cdat.py gui_busy.busyStart( self, parent ) # Set the pointer to a watch # remembers the external function for replotting later parent.external_plot_functions[id] = parent.external_plot # If you already have a plot displayed and you are changing a primary object, then # turn the display off first, then replace the object. # # Note to Dean: # Must check later to see if the array's are being freed. See the array = ['plot_1'] # in the display.list() if ((self.form[id].__dict__.has_key('display')) and (self.form[id].display is not None)): if isinstance(self.form[id].display,list): displays = self.form[id].display else: displays = [self.form[id].display,] for display in displays: try: display.off = 1 self.eself.vcs[ self.eself.vcs_id ].remove_display_name( display.name ) except Exception,err: if parent.show_debug: print err pass try: del self.form[id].display except Exception,err: ## print err pass
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 background(self,parent): vars = get_vars(parent) if len(vars)!=2: gui_message.error('Background computation requires 2 variables') return try: W,splits,bg = prepW(parent) gui_busy.busyStart( self, parent ) bg = W.background(vars[0],vars[1],wavenumber_smoothing_windows=bg[0],frequencies_smoothing_windows=bg[1]) gui_user_menus.user_menus_put( bg.id,bg) except Exception,err: gui_message.error('Error computing background:\n%s' % err) gui_busy.busyEnd( self, parent ) return
def lapse(self,parent): gui_busy.busyStart( self, parent ) vars = gui_wk.get_vars(parent) doc = thermo.gammaw.__doc__ if len(vars)!=3: gui_message.error('This computation requires 3 variables\n%s' % doc) gui_busy.busyEnd( self, parent ) return try: es = thermo.gammaw(vars[0],vars[1],vars[2]) gui_user_menus.user_menus_put( "moist_adiabatic_lapse_rate_from_%s_%s_%s" % (vars[0].id,vars[1].id,vars[2].id),es) except Exception,err: gui_message.error('Error computing lapse rate:\n%s\n%s' % (err,doc)) gui_busy.busyEnd( self, parent ) return
def power(self, parent): vars = get_vars(parent) if len(vars) > 1: gui_message.error('Power computation requires one variable only') return try: W, splits, bg = prepW(parent) gui_busy.busyStart(self, parent) power = W.process(vars[0]) gui_user_menus.user_menus_put(power.id, power) except Exception, err: gui_message.error('Error computing power:\n%s' % err) gui_busy.busyEnd(self, parent) return
def dewpoint(self,parent): gui_busy.busyStart( self, parent ) vars = gui_wk.get_vars(parent) doc = thermo.Dewpoint.__doc__ if len(vars)!=2: gui_message.error('This computation requires 2 variables\n%s' % doc) gui_busy.busyEnd( self, parent ) return try: es = thermo.Dewpoint(vars[0],vars[1]) gui_user_menus.user_menus_put( "dewpoint_from_%s_%s" % (vars[0].id,vars[1].id),es) except Exception,err: gui_message.error('Error computing Dewpoint:\n%s\n%s' % (err,doc)) gui_busy.busyEnd( self, parent ) return
def es(self,parent): gui_busy.busyStart( self, parent ) vars = gui_wk.get_vars(parent) doc = thermo.Es.__doc__ if len(vars)!=1: gui_message.error('This computation requires one variable only\n%s' % doc) gui_busy.busyEnd( self, parent ) return try: es =thermo.Es(vars[0]) gui_user_menus.user_menus_put( "saturated_pressure_from_%s" % vars[0].id,es) except Exception,err : gui_message.error('Error computing Es:\n%s\n%s' % (err,doc)) gui_busy.busyEnd( self, parent ) return
def ws(self,parent): gui_busy.busyStart( self, parent ) vars = gui_wk.get_vars(parent) doc = thermo.Ws.__doc__ if len(vars)!=2: gui_message.error('This computation requires 2 variables\n%s' % doc) gui_busy.busyEnd( self, parent ) return try: es =thermo.Ws(vars[0],vars[1]) gui_user_menus.user_menus_put( "saturated_mixing_ratio_from_%s_and_%s" % (vars[0].id,vars[1].id),es) except Exception,err: gui_message.error('Error computing Ws:\n%s\n%s' % (err,doc)) gui_busy.busyEnd( self, parent ) return
def power(self,parent): vars = get_vars(parent) if len(vars)>1: gui_message.error('Power computation requires one variable only') return try: W,splits,bg = prepW(parent) gui_busy.busyStart( self, parent ) power = W.process(vars[0]) gui_user_menus.user_menus_put( power.id,power) except Exception,err: gui_message.error('Error computing power:\n%s' % err) gui_busy.busyEnd( self, parent ) return
def split(self,parent): vars = get_vars(parent) if len(vars)>1: gui_message.error('Split computation requires one variable only') return try: W,splits,bg = prepW(parent) gui_busy.busyStart( self, parent ) S,A = W.split(vars[0],compresstime=splits[0],smooth=splits[1]) gui_user_menus.user_menus_put( A.id,A) gui_user_menus.user_menus_put( S.id,S) except Exception,err: gui_message.error('Error computing split:\n%s' % err) gui_busy.busyEnd( self, parent ) return
def lift(self,parent): gui_busy.busyStart( self, parent ) vars = gui_wk.get_vars(parent) doc = thermo.gammaw.__doc__ if len(vars)!=3: gui_message.error('This computation requires 3 variables\n%s' % doc) gui_busy.busyEnd( self, parent ) return try: T,P = thermo.LiftWet(vars[0],vars[1],vars[2]) gui_user_menus.user_menus_put( "%s_lifted_moist_adiabatically_from_%s_to_%s" % (vars[0].id,vars[1].id,vars[2].id),T) gui_user_menus.user_menus_put( "%s_lifted_moist_adiabatically_from_%s_to_%s_pressures" % (vars[0].id,vars[1].id,vars[2].id),P) except Exception,err: gui_message.error('Error computing lapse rate:\n%s\n%s' % (err,doc)) gui_busy.busyEnd( self, parent ) return
def split(self, parent): vars = get_vars(parent) if len(vars) > 1: gui_message.error('Split computation requires one variable only') return try: W, splits, bg = prepW(parent) gui_busy.busyStart(self, parent) S, A = W.split(vars[0], compresstime=splits[0], smooth=splits[1]) gui_user_menus.user_menus_put(A.id, A) gui_user_menus.user_menus_put(S.id, S) except Exception, err: gui_message.error('Error computing split:\n%s' % err) gui_busy.busyEnd(self, parent) return
def dewpoint(self, parent): gui_busy.busyStart(self, parent) vars = gui_wk.get_vars(parent) doc = thermo.Dewpoint.__doc__ if len(vars) != 2: gui_message.error('This computation requires 2 variables\n%s' % doc) gui_busy.busyEnd(self, parent) return try: es = thermo.Dewpoint(vars[0], vars[1]) gui_user_menus.user_menus_put( "dewpoint_from_%s_%s" % (vars[0].id, vars[1].id), es) except Exception, err: gui_message.error('Error computing Dewpoint:\n%s\n%s' % (err, doc)) gui_busy.busyEnd(self, parent) return
def ws(self, parent): gui_busy.busyStart(self, parent) vars = gui_wk.get_vars(parent) doc = thermo.Ws.__doc__ if len(vars) != 2: gui_message.error('This computation requires 2 variables\n%s' % doc) gui_busy.busyEnd(self, parent) return try: es = thermo.Ws(vars[0], vars[1]) gui_user_menus.user_menus_put( "saturated_mixing_ratio_from_%s_and_%s" % (vars[0].id, vars[1].id), es) except Exception, err: gui_message.error('Error computing Ws:\n%s\n%s' % (err, doc)) gui_busy.busyEnd(self, parent) return
def background(self, parent): vars = get_vars(parent) if len(vars) != 2: gui_message.error('Background computation requires 2 variables') return try: W, splits, bg = prepW(parent) gui_busy.busyStart(self, parent) bg = W.background(vars[0], vars[1], wavenumber_smoothing_windows=bg[0], frequencies_smoothing_windows=bg[1]) gui_user_menus.user_menus_put(bg.id, bg) except Exception, err: gui_message.error('Error computing background:\n%s' % err) gui_busy.busyEnd(self, parent) return
def es(self, parent): gui_busy.busyStart(self, parent) vars = gui_wk.get_vars(parent) doc = thermo.Es.__doc__ if len(vars) != 1: gui_message.error('This computation requires one variable only\n%s' % doc) gui_busy.busyEnd(self, parent) return try: es = thermo.Es(vars[0]) gui_user_menus.user_menus_put( "saturated_pressure_from_%s" % vars[0].id, es) except Exception, err: gui_message.error('Error computing Es:\n%s\n%s' % (err, doc)) gui_busy.busyEnd(self, parent) return
def lapse(self, parent): gui_busy.busyStart(self, parent) vars = gui_wk.get_vars(parent) doc = thermo.gammaw.__doc__ if len(vars) != 3: gui_message.error('This computation requires 3 variables\n%s' % doc) gui_busy.busyEnd(self, parent) return try: es = thermo.gammaw(vars[0], vars[1], vars[2]) gui_user_menus.user_menus_put( "moist_adiabatic_lapse_rate_from_%s_%s_%s" % (vars[0].id, vars[1].id, vars[2].id), es) except Exception, err: gui_message.error('Error computing lapse rate:\n%s\n%s' % (err, doc)) gui_busy.busyEnd(self, parent) return
def lift(self, parent): gui_busy.busyStart(self, parent) vars = gui_wk.get_vars(parent) doc = thermo.gammaw.__doc__ if len(vars) != 3: gui_message.error('This computation requires 3 variables\n%s' % doc) gui_busy.busyEnd(self, parent) return try: T, P = thermo.LiftWet(vars[0], vars[1], vars[2]) gui_user_menus.user_menus_put( "%s_lifted_moist_adiabatically_from_%s_to_%s" % (vars[0].id, vars[1].id, vars[2].id), T) gui_user_menus.user_menus_put( "%s_lifted_moist_adiabatically_from_%s_to_%s_pressures" % (vars[0].id, vars[1].id, vars[2].id), P) except Exception, err: gui_message.error('Error computing lapse rate:\n%s\n%s' % (err, doc)) gui_busy.busyEnd(self, parent) return
def process(self,parent): vars = get_vars(parent) if len(vars)>1: gui_message.error('WK computations requires one variable only') return try: W,splits,bg = prepW(parent) gui_busy.busyStart( self, parent ) power = W.process(vars[0]) S,A = W.split(power,compresstime=splits[0],smooth=splits[1]) bg = W.background(S,A,wavenumber_smoothing_windows=bg[0],frequencies_smoothing_windows=bg[1]) gui_user_menus.user_menus_put( power.id,power) gui_user_menus.user_menus_put( A.id,A) gui_user_menus.user_menus_put( S.id,S) gui_user_menus.user_menus_put( bg.id,bg) except Exception,err: gui_message.error('Error computing power:\n%s' % err) gui_busy.busyEnd( self, parent ) return
def process(self, parent): vars = get_vars(parent) if len(vars) > 1: gui_message.error('WK computations requires one variable only') return try: W, splits, bg = prepW(parent) gui_busy.busyStart(self, parent) power = W.process(vars[0]) S, A = W.split(power, compresstime=splits[0], smooth=splits[1]) bg = W.background(S, A, wavenumber_smoothing_windows=bg[0], frequencies_smoothing_windows=bg[1]) gui_user_menus.user_menus_put(power.id, power) gui_user_menus.user_menus_put(A.id, A) gui_user_menus.user_menus_put(S.id, S) gui_user_menus.user_menus_put(bg.id, bg) except Exception, err: gui_message.error('Error computing power:\n%s' % err) gui_busy.busyEnd(self, parent) return
def execute(self,parent,filter_type,var,button): if button=='OK': dim=self.radio.index(self.radio.getvalue()) if filter_type!='121': 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 ) if filter_type=='RunningAverage': slab=genutil.filters.runningaverage(var,entry,axis=dim) filter_name='RunningAverage_'+str(entry)+'_'+self.radio.getvalue() options=str(entry)+', axis = '+str(dim) fname='runningaverage' elif filter_type=='Custom': slab=genutil.filters.custom1D(var,entry,axis=dim) filter_name='Custom_'+self.radio.getvalue() options='filter = '+str(entry)+', axis = '+str(dim) fname='custom1D' elif filter_type=='121': slab=genutil.filters.smooth121(var,axis=dim) filter_name='121_'+self.radio.getvalue() options='axis = '+str(dim) fname='smooth121' gui_busy.busyEnd( self, parent ) parent.menu.pcmdi_tools_menu.evt_filters(parent,slab,filter_name,fname,var.id,options) self.dialog.destroy() else: self.dialog.destroy() return
def execute(self, parent,button): if button=='OK': gui_busy.busyStart( self, parent ) try: file=self.file.get() while file=="": file=self.evt_icon_open_file(self.parent,None) file=self.file.get() e=self.endian.index(self.endian.getvalue()) endians=['@','=','<','>'] e=endians[e] f=self.format.get() try: struct.calcsize(f) except: Pmw.Dialog(self.parent, title = "Wrong Format !", buttons = ('OK',), ) gui_busy.busyEnd( self, parent ) return id=self.id.get() if id=="": id=[] else: id=id.split(',') id=string.join(id) id=id.split() sh=self.shape.get() if sh=="": sh=[] else: sh=sh.strip() if sh[0]=='(': sh=eval(sh) else: sh=sh.split(',') sh=string.join(sh) sh=sh.split('(') sh=string.join(sh) sh=sh.split(')') sh=string.join(sh) sh2=sh.split() sh=[] for s in sh2: sh.append(eval(s)) sh=[list(sh),] datatype=self.datatype.index(self.datatype.getvalue()) dtp=['c','b','B','h','H','i','I','l','L','f','d'] datatype=dtp[datatype] vs=self.vs.get() try: struct.calcsize(vs) except: Pmw.Dialog(self.parent, title = "Wrong Format for Variable Separators !", buttons = ('OK',), ) gui_busy.busyEnd( self, parent ) return vars=read( file ,format=f, endian=e, datatype=datatype, ids=id, shape=sh,separator=vs) gui_control.record_command( parent, "\n# PCMDI's read Binary Tool\nimport browser", 1 ) ids='' ids_lst='' if isinstance(vars,list): for v in vars: v.id = self.Self.return_unique_name( v.id) ids+=v.id+', ' ids_lst+=repr(v.id)+', ' gui_user_menus.user_menus_put( v.id, v ) else: v=vars v.id = self.Self.return_unique_name( vars.id) ids+=v.id+', ' ids_lst+=repr(v.id)+', ' gui_user_menus.user_menus_put( v.id, v ) gui_control.record_command( parent, "%s = browser.gui_read_Struct.read(%s, format=%s, endian=%s, datatype=%s, ids= %s, shape=%s, separator=%s)" % (ids[:-2], repr(file), repr(f), repr(e), repr(datatype), '[ '+ids_lst[:-2]+' ]', str(sh), repr(vs)), 1 ) gui_busy.busyEnd( self, parent ) except Exception, err: gui_busy.busyEnd( self, parent ) gui_message.error( "The 'Binary Read Tool' could not complete its function\nError:\n"+str(err))