Ignore:
Timestamp:
Oct 15, 2012, 12:00:39 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON mcd online. improved interface for time (earth and mars). improved titles.

File:
1 edited

Legend:

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

    r800 r805  
    9393        self.getdustlabel()
    9494        self.title = self.name + " with " + self.dustlabel + "."
     95        if self.lats is None:  self.title = self.title + " Latitude " + str(self.lat) + "E"
     96        if self.lons is None:  self.title = self.title + " Longitude " + str(self.lon) + "N"
     97        if self.xzs is None:   
     98            self.vertunits()
     99            self.title = self.title + " Altitude " + str(self.xz) + " " + self.vunits
     100        if self.locts is None: self.title = self.title + " Local time " + str(self.loct) + "h"
    95101
    96102    def getextvarlab(self,num):
     
    231237        print "Zonal wind = %5.3f meters per second." % (self.zonwind)
    232238        print "Meridional wind = %5.3f meters per second." % (self.merwind)
     239        print "Total horizontal wind = %5.3f meters per second." % ( np.sqrt(self.zonwind**2 + self.merwind**2) )
    233240
    234241    def printextvar(self,num):
     
    311318      elif self.zkey == 5: self.xlabel = "altitude above mean Mars Radius(=3396000m) (m)"
    312319
     320    def vertunits(self):
     321      if self.zkey == 1:   self.vunits = "m CP"
     322      elif self.zkey == 2: self.vunits = "m AMR"
     323      elif self.zkey == 3: self.vunits = "m ALS"
     324      elif self.zkey == 4: self.vunits = "Pa"
     325      elif self.zkey == 5: self.vunits = "m AMMRad"
     326
    313327###################
    314328### 1D analysis ###
     
    326340    def diurnal(self,nd=13):
    327341    ### retrieve a local time slice
     342      save = self.loct
    328343      self.xlabel = "Local time (Martian hour)"
    329344      self.prepare(ndx=nd) ; self.ininterv(0.,24.,nd,start=self.locts,end=self.locte)
    330345      for i in range(nd): self.loct = self.xcoord[i] ; self.update() ; self.put1d(i)
     346      self.loct = save
    331347
    332348    def zonal(self,nd=37):
    333349    ### retrieve a longitude slice
     350      save = self.lon
    334351      self.xlabel = "East longitude (degrees)"
    335352      self.prepare(ndx=nd) ; self.ininterv(-180.,180.,nd,start=self.lons,end=self.lone)
    336353      for i in range(nd): self.lon = self.xcoord[i] ; self.update() ; self.put1d(i)
     354      self.lon = save
    337355
    338356    def meridional(self,nd=19):
    339357    ### retrieve a latitude slice
     358      save = self.lat
    340359      self.xlabel = "North latitude (degrees)"
    341360      self.prepare(ndx=nd) ; self.ininterv(-90.,90.,nd,start=self.lats,end=self.late)
    342361      for i in range(nd): self.lat = self.xcoord[i] ; self.update() ; self.put1d(i)
     362      self.lat = save
    343363
    344364    def profile(self,nd=20,tabperso=None):
    345365    ### retrieve an altitude slice (profile)
     366      save = self.xz
    346367      self.vertlabel()
    347368      self.vertplot = True
     
    351372      if tabperso is not None: self.xcoord = tabperso
    352373      for i in range(nd): self.xz = self.xcoord[i] ; self.update() ; self.put1d(i)
     374      self.xz = save
    353375
    354376    def seasonal(self,nd=12):
    355377    ### retrieve a seasonal slice
     378      save = self.xdate
    356379      self.xlabel = "Areocentric longitude (degrees)"
    357380      self.prepare(ndx=nd) ; self.ininterv(0.,360.,nd,start=self.xdates,end=self.xdatee)
    358381      for i in range(nd): self.xdate = self.xcoord[i] ; self.update() ; self.put1d(i)
     382      self.xdate = save
    359383
    360384    def makeplot1d(self,choice):
     
    407431    ### retrieve a latitude/longitude slice
    408432    ### default is: local time is not fixed. user-defined local time is at longitude 0.
     433      save1 = self.lon ; save2 = self.lat ; save3 = self.loct
    409434      self.xlabel = "East longitude (degrees)" ; self.ylabel = "North latitude (degrees)"
    410435      self.prepare(ndx=ndx,ndy=ndy)
     
    415440       for j in range(ndy):
    416441         self.lon = self.xcoord[i] ; self.lat = self.ycoord[j]
    417          if not fixedlt: self.loct = (umst + self.lon/15.) % 24
     442         if not fixedlt:
     443           if self.lons is not None and self.lone is not None: self.loct = (umst + (self.lons+self.lone)/30.) % 24
     444           else:                                               self.loct = (umst + self.lon/15.) % 24
    418445         self.update() ; self.put2d(i,j)
    419446      if not fixedlt: self.loct = umst
     447      self.lon = save1 ; self.lat = save2 ; self.loct = save3
    420448
    421449    def put2d(self,i,j):
     
    503531        # contour field
    504532        c = yeah.contourf( x, y, what_I_plot, zelevels, cmap = palette, alpha = trans )
    505         Figure.colorbar(fig,c,orientation='vertical',format="%.1e")
     533        clb = Figure.colorbar(fig,c,orientation='vertical',format="%.1e")
     534        clb.set_label(fieldlab)
    506535        ax = fig.gca() ; ax.set_title(fieldlab) ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude")
    507536        ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone)
Note: See TracChangeset for help on using the changeset viewer.