Changeset 797


Ignore:
Timestamp:
Oct 1, 2012, 8:45:43 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON: mcd interface, a more compact code. and added online handling of various vertical coordinates.

Location:
trunk/UTIL/PYTHON/mcd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/mcd/mcd.py

    r796 r797  
    4141        self.locte     = None
    4242        self.xdate     = 0.  # see datekey
     43        self.xdates    = None
     44        self.xdatee    = None
    4345        self.xz        = 10. # see zkey
    4446        self.xzs       = None
     
    4648        ## 1bis. related settings
    4749        self.zkey      = 3  # specify that xz is the altitude above surface (m)
     50                            # zkey  : <integer>   type of vertical coordinate xz
     51                            # 1 = radius from centre of planet (m)
     52                            # 2 = height above areoid (m) (MOLA zero datum)
     53                            # 3 = height above surface (m)
     54                            # 4 = pressure level (Pa)
     55                            # 5 = altitude above mean Mars Radius(=3396000m) (m)
    4856        self.datekey   = 1  # 0 = "Earth time": xdate is given in Julian days (localtime must be set to zero)
    4957                            # 1 = "Mars date": xdate is the value of Ls
     
    256264      return field,fieldlab
    257265
     266    def ininterv(self,dstart,dend,nd,start=None,end=None,yaxis=False):
     267    ### user-defined start and end are used to create xcoord (or ycoord) vector
     268      if start is not None and end is not None:  first, second = self.correctbounds(start,end)
     269      else:                                      first, second = self.correctbounds(dstart,dend) 
     270      if not yaxis: self.xcoord = np.linspace(first,second,nd)
     271      else:         self.ycoord = np.linspace(first,second,nd)
     272      ## here we should code the log axis for pressure
     273
     274    def correctbounds(self,start,end):
     275      if self.zkey != 4:
     276        # regular altitudes
     277        if start > end: first = end ; second = start
     278        else:           first = start ; second = end
     279      else:
     280        # pressure: reversed avis
     281        if start < end: first = end ; second = start
     282        else:           first = start ; second = end
     283      return first, second
     284
    258285###################
    259286### 1D analysis ###
     
    272299    ### retrieve a local time slice
    273300      self.xlabel = "Local time (Martian hour)"
    274       self.prepare(ndx=nd)
    275       if self.locts is not None and self.locte is not None:
    276           if self.locts > self.locte: yeah = self.locts ; self.locts = self.locte ; self.locte = yeah
    277           self.xcoord = np.linspace(self.locts,self.locte,nd)
    278       else:
    279           self.xcoord = np.linspace(0.,24.,nd)
     301      self.prepare(ndx=nd) ; self.ininterv(0.,24.,nd,start=self.locts,end=self.locte)
    280302      for i in range(nd): self.loct = self.xcoord[i] ; self.update() ; self.put1d(i)
    281303
     
    283305    ### retrieve a longitude slice
    284306      self.xlabel = "East longitude (degrees)"
    285       self.prepare(ndx=nd)
    286       if self.lons is not None and self.lone is not None:
    287           if self.lons > self.lone: yeah = self.lons ; self.lons = self.lone ; self.lone = yeah
    288           self.xcoord = np.linspace(self.lons,self.lone,nd)
    289       else:
    290           self.xcoord = np.linspace(-180.,180.,nd)
     307      self.prepare(ndx=nd) ; self.ininterv(-180.,180.,nd,start=self.lons,end=self.lone)
    291308      for i in range(nd): self.lon = self.xcoord[i] ; self.update() ; self.put1d(i)
    292309
     
    294311    ### retrieve a latitude slice
    295312      self.xlabel = "North latitude (degrees)"
    296       self.prepare(ndx=nd)
    297       if self.lats is not None and self.late is not None:
    298           if self.lats > self.late: yeah = self.lats ; self.lats = self.late ; self.late = yeah
    299           self.xcoord = np.linspace(self.lats,self.late,nd)
    300       else:                                               
    301           self.xcoord = np.linspace(-90.,90.,nd)
     313      self.prepare(ndx=nd) ; self.ininterv(-90.,90.,nd,start=self.lats,end=self.late)
    302314      for i in range(nd): self.lat = self.xcoord[i] ; self.update() ; self.put1d(i)
    303315
     
    306318      self.xlabel = "Altitude (m)"
    307319      if tabperso is not None: nd = len(tabperso)
    308       self.prepare(ndx=nd)
    309       if tabperso is not None:
    310           self.xcoord = tabperso
    311       elif self.xzs is not None and self.xze is not None:
    312           ## here we should code the log axis for pressure
    313           self.xcoord = np.linspace(self.xzs,self.xze,nd)
    314       else:
    315           self.xcoord = np.linspace(0.,120000.,nd)
     320      correct = False
     321      self.prepare(ndx=nd) ; self.ininterv(0.,120000.,nd,start=self.xzs,end=self.xze)
     322      if tabperso is not None: self.xcoord = tabperso
    316323      for i in range(nd): self.xz = self.xcoord[i] ; self.update() ; self.put1d(i)
    317324
    318     def seasonal(self,nd=12,start=0.,end=360.):
     325    def seasonal(self,nd=12):
    319326    ### retrieve a seasonal slice
    320327      self.xlabel = "Areocentric longitude (degrees)"
    321       self.prepare(ndx=nd) ; self.xcoord = np.linspace(start,end,nd)
     328      self.prepare(ndx=nd) ; self.ininterv(0.,360.,nd,start=self.xdates,end=self.xdatee)
    322329      for i in range(nd): self.xdate = self.xcoord[i] ; self.update() ; self.put1d(i)
    323330
     
    369376      self.xlabel = "East longitude (degrees)" ; self.ylabel = "North latitude (degrees)"
    370377      self.prepare(ndx=ndx,ndy=ndy)
    371       if self.lons is not None and self.lone is not None:
    372           if self.lons > self.lone: yeah = self.lons ; self.lons = self.lone ; self.lone = yeah
    373           self.xcoord = np.linspace(self.lons,self.lone,ndx)
    374       else:
    375           self.xcoord = np.linspace(-180.,180.,ndx)
    376       if self.lats is not None and self.late is not None:
    377           if self.lats > self.late: yeah = self.lats ; self.lats = self.late ; self.late = yeah
    378           self.ycoord = np.linspace(self.lats,self.late,ndy)
    379       else:
    380           self.ycoord = np.linspace(-90.,90.,ndy)
     378      self.ininterv(-180.,180.,ndx,start=self.lons,end=self.lone)
     379      self.ininterv(-90.,  90.,ndy,start=self.lats,end=self.late,yaxis=True)
    381380      if not fixedlt: umst = self.loct
    382381      for i in range(ndx):
  • trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py

    r796 r797  
    7575try: query.dust = int(form.getvalue("dust"))
    7676except: query.dust  = int(1)
    77 #        self.zkey      = 3  # specify that xz is the altitude above surface (m)
     77try: query.zkey = int(form.getvalue("zkey"))
     78except: query.zkey = int(3)
    7879#        self.perturkey = 0  #integer perturkey ! perturbation type (0: none)
    7980#        self.seedin    = 1  #random number generator seed (unused if perturkey=0)
     
    154155
    155156print header
     157#print query.printset()
     158#print "<br />"
    156159
    157160## Now the part which differs
  • trunk/UTIL/PYTHON/mcd/proto/index.html

    r796 r797  
    9696<td align="center">
    9797<b>CUSTOMIZE COORDINATES ON MARS</b><br />
    98 please give: a value (or) a range val1;val2 (or) 'all'<br />
     98write a value (or) a range val1;val2 (or) 'all'<br />
    9999<ul>
    100 <li>North Latitude <input type="text" size="7" name="latitude" value="0.">
    101 <li>East Longitude <input type="text" size="7" name="longitude" value="0.">
    102 <li>Local Time <input type="text" size="7" name="localtime" value="0.">
    103 <li>Altitude (m) <input type="text" size="7" name="altitude" value="10.">
     100<li>Latitude <input type="text" size="7" name="latitude" value="0."> degree North
     101<li>Longitude <input type="text" size="7" name="longitude" value="0."> degree East
     102<li>Local Time <input type="text" size="7" name="localtime" value="0."> Martian hour
     103<li>Altitude <input type="text" size="9" name="altitude" value="10."> <select name="zkey">
     104<option value="1"         >m (O: Mars center)</option>
     105<option value="2"         >m (O: "sea level")</option>
     106<option value="3" selected>m (O: surface)</option>
     107<option value="4"         >Pa (pressure)</option>
     108<option value="5"         >m (O: 3396 km)</option>
     109</select>
    104110<!--
    105111<li>Latitude   
Note: See TracChangeset for help on using the changeset viewer.