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 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 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 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 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 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 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 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 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 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,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() h=self.header.get() if h=='': h=0 else: h=eval(h) sep=self.separators.get() if sep=="": sep=[] else: sep=sep.split() id=self.id.get() if id=="": id=None else: id=id.replace("'","") id=id.replace('"',"") id=id.split(',') id=' '.join(id) id=id.split() sh=self.shape.get() print sh if sh=="": sh=None else: sh=sh.split(',') sh=' '.join(sh) sh=sh.split('(') sh=' '.join(sh) sh2=sh.split(')') sh=[] for s in sh2: if s.strip!='': tmp = eval('(%s)' % ','.join(s.split())) if not isinstance(tmp,tuple): tmp=(tmp,) sh.append(tmp) print 'out:',sh vs=self.vs.get() if vs=="": vs=None vars=read( file ,header=h, ids=id, shape=sh, next=vs,separators=sep) gui_control.record_command( parent, "\n# PCMDI's read ASCII Tool\nimport genutil\n", 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( v.id) ids+=v.id+', ' ids_lst+=repr(v.id)+', ' gui_user_menus.user_menus_put( v.id, v ) gui_control.record_command( parent, "%s = genutil.ASCII.readAscii(%s, header=%s, ids= %s, shape=%s, separators=%s, next=%s)" % (ids[:-2], repr(file), repr(h), '[ '+ids_lst[:-2]+' ]', repr(sh), repr(sep),repr(vs)), 1 ) ## gui_busy.busyEnd( self, parent ) ## except Exception, err: ## gui_busy.busyEnd( self, parent ) ## gui_message.error( "The 'ASCII Read Tool' could not complete its function\nError:\n"+str(err)) self.dialog.destroy()
def execute(self, parent,button): if button=='OK': ## gui_busy.busyStart( self, parent ) ## try: ## File selection file=self.file.get() while file=="": file=self.evt_icon_open_file(self.parent,None) file=self.file.get() ## header skipping ? h=self.header.get() if h=='': h=0 else: h=eval(h) ## Characters skip cskip=self.cskip.getvalue() if cskip=="": cskip=0 else: cskip=string.atoi(cskip) ## Character skip type cskip_type=self.cskip_type.getvalue() ## values separation sep=self.separators.get() if sep=="": sep=[] else: sep=sep.split() ## ids id=self.id.get() if id=="": id=None else: id=id.split(',') id=string.join(id) id=id.split() ## stored in first row ? idrow=self.idrow.getvalue() if len(idrow)>0: idrow=True else: idrow=False ## Axis values passed ? axis=self.axis.getvalue() if axis=='Yes': axis=True else: axis=False vars=read( file ,header=h, cskip=cskip, cskip_type=cskip_type, axis=axis, ids=id, idrow=idrow, separators=sep) gui_control.record_command( parent, "\n# PCMDI's read ASCII Tool\nimport genutil\n", 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( v.id) ids+=v.id+', ' ids_lst+=repr(v.id)+', ' gui_user_menus.user_menus_put( v.id, v ) gui_control.record_command( parent, "%s = genutil.ASCII.read_col(%s, header=%s, cskip=%s, cskip_type=%s, axis=%s, ids=%s, idrow=%s, separators=%s)" % (ids[:-2], repr(file), repr(h), repr(cskip), repr(cskip_type), str(axis), '[ '+ids_lst[:-2]+' ]', repr(idrow), repr(sep)), 1 ) ## gui_busy.busyEnd( self, parent ) ## except Exception, err: ## gui_busy.busyEnd( self, parent ) ## gui_message.error( "The 'ASCII Read Tool' could not complete its function\nError:\n"+str(err)) self.dialog.destroy()
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))
def execute(self, parent, button): if button == 'OK': ## gui_busy.busyStart( self, parent ) ## try: ## File selection file = self.file.get() while file == "": file = self.evt_icon_open_file(self.parent, None) file = self.file.get() ## header skipping ? h = self.header.get() if h == '': h = 0 else: h = eval(h) ## Characters skip cskip = self.cskip.getvalue() if cskip == "": cskip = 0 else: cskip = string.atoi(cskip) ## Character skip type cskip_type = self.cskip_type.getvalue() ## values separation sep = self.separators.get() if sep == "": sep = [] else: sep = sep.split() ## ids id = self.id.get() if id == "": id = None else: id = id.split(',') id = string.join(id) id = id.split() ## stored in first row ? idrow = self.idrow.getvalue() if len(idrow) > 0: idrow = True else: idrow = False ## Axis values passed ? axis = self.axis.getvalue() if axis == 'Yes': axis = True else: axis = False vars = read(file, header=h, cskip=cskip, cskip_type=cskip_type, axis=axis, ids=id, idrow=idrow, separators=sep) gui_control.record_command( parent, "\n# PCMDI's read ASCII Tool\nimport genutil\n", 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(v.id) ids += v.id + ', ' ids_lst += repr(v.id) + ', ' gui_user_menus.user_menus_put(v.id, v) gui_control.record_command( parent, "%s = genutil.ASCII.read_col(%s, header=%s, cskip=%s, cskip_type=%s, axis=%s, ids=%s, idrow=%s, separators=%s)" % (ids[:-2], repr(file), repr(h), repr(cskip), repr(cskip_type), str(axis), '[ ' + ids_lst[:-2] + ' ]', repr(idrow), repr(sep)), 1) ## gui_busy.busyEnd( self, parent ) ## except Exception, err: ## gui_busy.busyEnd( self, parent ) ## gui_message.error( "The 'ASCII Read Tool' could not complete its function\nError:\n"+str(err)) self.dialog.destroy()