示例#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()
示例#2
0
文件: gui_wk.py 项目: AZed/uvcdat
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
示例#3
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
示例#4
0
文件: gui_wk.py 项目: AZed/uvcdat
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
示例#5
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
示例#6
0
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
示例#7
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
示例#8
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
示例#9
0
文件: gui_wk.py 项目: AZed/uvcdat
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
示例#10
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
示例#11
0
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
示例#12
0
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
示例#13
0
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
示例#14
0
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
示例#15
0
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
示例#16
0
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
示例#17
0
文件: gui_wk.py 项目: AZed/uvcdat
def get_vars(parent):
    vars = []
    try:
        if (parent.panelDM.var3 is not None):
            vars.append(gui_formulate.data( parent, d_name = parent.panelDM.var3))
        else:
            from_selected = 1
            if (len(parent.panelDV.selected) == 0):
                gui_message.error('Must first select a variable from the "Select Variable" panel above or from the "Defined Variables" list window below.')
                return vars
            lst = parent.panelDV.selected_list.keys()
            for v in lst:
                vars.append(gui_formulate.data( parent, var = parent.panelDV.lst1[ parent.panelDV.selected_list[ v ] ]))
    except Exception,err:
        gui_message.error( 'Invalid data or no variable selected. Cannot compute field.\nError:\n'+str(err) )
        gui_busy.busyEnd( self, parent )
        return []
示例#18
0
文件: gui_wk.py 项目: AZed/uvcdat
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
示例#19
0
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
示例#20
0
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
示例#22
0
   def evt_replace_data( self, pe, id, data_entry, parent, event ):
      # Stop the replotting of data when the template editor is in use.
      if (parent.vcs[ parent.vcs_id ].SCREEN_MODE() == "TEDITOR"):
          gui_message.error("You must cancel the 'Template Editor' GUI before replacing the data.")
          return "break"

      if data_entry == 1:
          data = self.form[id].data1
      elif data_entry == 2:
          data = self.form[id].data2
      elif data_entry > 2:
           data = self.form[id].datas[data_entry-3]

      if pe == 1:
           try:
             if self.eself.panelDV.selected == []: 
                data.setentry( "" )
                gui_message.error( "Must first select a variable from the 'Defined Variables' window located above." )
                return "break"
             else:
                data.setentry( string.split(self.eself.panelDV.data_bin_name," ")[0] )
           except:
             pass

           if self.eself.panelDV.bin_type in [ "Vector", "Scatter", "XvsY","Meshfill"]:
              if (self.form[id].data1.get() != "") and (self.form[id].data2.get() != ""):
                 self.do_plot( id )
                 return "break"
           if self.eself.panelDV.bin_type in ["Meshfill"]:
              try:
                 self.do_plot( id )
              except Exception,err:
                 gui_busy.busyEnd( self, self.eself )
                 return "break"
           else:
              self.do_plot( id )
示例#23
0
def get_vars(parent):
    vars = []
    try:
        if (parent.panelDM.var3 is not None):
            vars.append(gui_formulate.data(parent, d_name=parent.panelDM.var3))
        else:
            from_selected = 1
            if (len(parent.panelDV.selected) == 0):
                gui_message.error(
                    'Must first select a variable from the "Select Variable" panel above or from the "Defined Variables" list window below.'
                )
                return vars
            lst = parent.panelDV.selected_list.keys()
            for v in lst:
                vars.append(
                    gui_formulate.data(parent,
                                       var=parent.panelDV.lst1[
                                           parent.panelDV.selected_list[v]]))
    except Exception, err:
        gui_message.error(
            'Invalid data or no variable selected. Cannot compute field.\nError:\n'
            + str(err))
        gui_busy.busyEnd(self, parent)
        return []
示例#24
0
    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))
示例#25
0
              if (string.split(j, ' ')[0] == data2):   # Match up the variable's dimensions
                 d2 = parent.panelDV.lst1[ j ]

        elif (gm_type not in ['Vector', 'Scatter', 'XvsY', "Meshfill"]) or (gm_type == "Meshfill" and data2 == ''): # Not Vector, Scatter, or XvsY graphics method
          if (parent.panelDM.var3 is None) and (parent.panelDV.selected == []):
             d1 = __main__.__dict__[ data1 ]  # Get Data defined in Page Layout Form
          elif (parent.panelDM.var3 is not None) or (string.split( parent.panelDV.selected, ' ')[0] != data1):
             d1 = __main__.__dict__[ data1 ]  # Get Data defined in memory
          else:                               # Get Data that has been modified by the dimensions panel
             d1=gui_formulate.data( parent, var = parent.panelDV.lst1[ parent.panelDV.selected ])
          d2 = None           
        else:  # Get the two data name defined in the "Page Description form"
           try:
              d1 = __main__.__dict__[ data1 ]  # Get the first defined variable
           except:
              gui_busy.busyEnd( self, parent )
              return
           for j in parent.panelDV.number_lst1.keys():
              if (string.split(j, ' ')[0] == data2):   # Match up the variable's dimensions
                 d2 = d1
                 d1 = parent.panelDV.lst1[ j ]
                 x_axis_store = d1.getAxis( -1 )
                 y_axis_store = d1.getAxis( -2 )
                 if gm_type!='Meshfill':
                    d1.setAxis( -1, d2.getAxis( -1 ) )
                    d1.setAxis( -2, d2.getAxis( -2 ) )
       else:
        d1 = None
        d2 = None

       # Plot the data accordingly
示例#26
0
文件: gui_thermo.py 项目: AZed/uvcdat
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
    gui_busy.busyEnd( self, parent )

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 )