Changeset 1343 for trunk/UTIL


Ignore:
Timestamp:
Aug 26, 2014, 11:53:30 PM (10 years ago)
Author:
aslmd
Message:

python. mcd. bug fixes to improve ticks intervals, and max/min, and add warning if no latitude (tbd for others)

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

Legend:

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

    r944 r1343  
    987987                      zevmax = mean(fieldcalc) + dev  ### for continuity           
    988988    ###
    989     if zevmin < 0. and min(fieldcalc) > 0.: zevmin = 0.
     989    if zevmin < min(fieldcalc): zevmin = min(fieldcalc)
     990    if zevmax > max(fieldcalc): zevmax = max(fieldcalc)
     991    #if zevmin < 0. and min(fieldcalc) > 0.: zevmin = 0.
    990992    #print "BOUNDS field ", min(fieldcalc), max(fieldcalc), " //// adopted", zevmin, zevmax
    991993    return zevmin, zevmax
  • trunk/UTIL/PYTHON/mcd/inimeso/inimeso5.py

    r1075 r1343  
    77from mcd import mcd
    88
     9rho_dust = 2500.  # Mars dust density (kg.m-3)
     10grav = 3.72
     11ksi = 3. / 4. / rho_dust / grav
     12nueff = 0.5
     13
    914### MCD INSTANCE and SETTINGS (actually, default. but one never knows)
    1015query = mcd() ; query.zkey = 3 ; query.dust = 2 ; query.hrkey = 1
    11 
    1216query.toversion5()
    1317
     
    2024### OPEN FILES TO BE WRITTEN
    2125sounding = open("input_sounding", "w") ; additional = open("input_therm", "w") ; more = open("input_more", "w")
     26dust = open("input_dust", "w")
    2227
    2328### GET and WRITE SURFACE VALUES
    2429query.xz = 0.1 ; query.update() ; query.printmeanvar()
    25 sounding.write( "%10.2f%12.2f%12.2f\n" % (query.pres/100.,query.temp*(610./query.pres)**(1.0/3.9),0.) )
     30query.extvar[42] = 1.5*1e-3
     31query.extvar[44] = 0.0
     32sounding.write( "%10.2f%12.2f%12.2f\n" % (query.pres/100.,query.temp*(610./query.pres)**(1.0/3.9),(query.extvar[42]+query.extvar[44])*1e3) )
    2633more.write( "%10.2f%10.2f" % (query.extvar[1],query.extvar[14]) ) ; more.close()
    2734
     
    2936query.profile( tabperso = np.append([0.1,5,10,20,50,100],np.linspace(200.,float(split(lines[4])[0])*1000.,float(split(lines[5])[0]))) )
    3037for iz in range(len(query.prestab)):
     38
     39    query.extvartab[iz,42] = 1.5*1e-3
     40    query.extvartab[iz,44] = 0.0
     41
    3142    sounding.write(   "%10.2f%12.2f%12.2f%12.2f%12.2f\n" % ( \
    3243                      query.extvartab[iz,2],query.temptab[iz]*(610./query.prestab[iz])**(1.0/3.9),\
    33                       0.,query.zonwindtab[iz],query.merwindtab[iz]) )
     44                      (query.extvartab[iz,42]+query.extvartab[iz,44])*1e3,\
     45                      query.zonwindtab[iz],query.merwindtab[iz]) )
    3446    additional.write( "%12.2f%12.2f%18.6e%18.6e%12.2f\n" % ( \
    3547                      query.extvartab[iz,53],query.extvartab[iz,8],\
    3648                      query.prestab[iz],query.denstab[iz],query.temptab[iz]) )
    3749
     50    ### DUST PROFILES
     51    q = query.extvartab[iz,38] # extvar(38)= Dust mass mixing ratio (kg/kg)
     52    reff = query.extvartab[iz,39] # extvar(39)= Dust effective radius (m)
     53    print q,reff
     54    N = (grav*ksi*((1+nueff)**3)/np.pi)*q/(reff**3)
     55    dust.write( "%18.6e%18.6e\n" % (q,N) )
     56
    3857### FINISH
    39 sounding.close() ; additional.close()
    40 query.plot1d(["p","t","u","v"]) ; mpl.show()
     58sounding.close() ; additional.close() ; dust.close()
     59query.plot1d(["p","t","u","v","h2ovap","h2oice"]) ; mpl.show()
     60
  • trunk/UTIL/PYTHON/mcd/mcd.py

    r1338 r1343  
    512512
    513513    def vertlabel(self):
     514#      if self.zkey == 1:   self.xlabel = "radius from centre of planet (m)"
     515#      elif self.zkey == 2: self.xlabel = "height above areoid (m) (MOLA zero datum)"
     516#      elif self.zkey == 3: self.xlabel = "height above surface (m)"
     517#      elif self.zkey == 4: self.xlabel = "pressure level (Pa)"
     518#      elif self.zkey == 5: self.xlabel = "altitude above mean Mars Radius(=3396000m) (m)"
    514519      if self.zkey == 1:   self.xlabel = "radius from centre of planet (m)"
    515       elif self.zkey == 2: self.xlabel = "height above areoid (m) (MOLA zero datum)"
     520      elif self.zkey == 2: self.xlabel = "altitude above MOLA$_0$ (m)"
    516521      elif self.zkey == 3: self.xlabel = "height above surface (m)"
    517       elif self.zkey == 4: self.xlabel = "pressure level (Pa)"
    518       elif self.zkey == 5: self.xlabel = "altitude above mean Mars Radius(=3396000m) (m)"
     522      elif self.zkey == 4: self.xlabel = "pressure (Pa)"
     523      elif self.zkey == 5: self.xlabel = "altitude above mean Mars radius (m)"
    519524
    520525    def vertunits(self):
     
    665670        if not self.vertplot and self.islog: ax.set_yscale('log')
    666671        if self.vertplot and self.islog: ax.set_xscale('log')
     672
     673        #ax.ticklabel_format(useOffset=False,axis='x')
     674        #ax.ticklabel_format(useOffset=False,axis='y')
    667675
    668676        if self.lats is not None:      ax.set_xticks(np.arange(-90,91,15)) ; ax.set_xbound(lower=self.lats, upper=self.late)
     
    815823      for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1) ; self.makemap2d(tabtodo[i],incwind=incwind,proj=proj)
    816824
     825    def makeinterv(self):
     826      self.latinterv = 30.
     827      self.loninterv = 45.
     828      if self.lats is not None:
     829        if (abs(self.late-self.lats) < 90.): self.latinterv = 10.
     830        if (abs(self.late-self.lats) < 10.): self.latinterv = 1.
     831      if self.lons is not None:
     832        if (abs(self.lone-self.lons) < 135.): self.loninterv = 15.
     833        if (abs(self.lone-self.lons) < 15.): self.loninterv = 1.
     834
    817835    def htmlmap2d(self,tabtodo,incwind=False,figname="temp.png",back="zMOL"):
    818836    ### complete 2D figure with possible multiplots
     
    890908          [x2d,y2d] = np.meshgrid(x,y)
    891909          yeah.quiver(x2d,y2d,np.transpose(windx),np.transpose(windy))
     910
    892911        ax = fig.gca() ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude")
    893         ax.set_xticks(np.arange(-360,361,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone)
    894         ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late)
     912
     913        # make intervals
     914        self.makeinterv()
     915        ax.set_xticks(np.arange(-360,361,self.loninterv)) ; ax.set_xbound(lower=self.lons, upper=self.lone)
     916        ax.set_yticks(np.arange(-90,91,self.latinterv)) ; ax.set_ybound(lower=self.lats, upper=self.late)
    895917      self.gettitle()
    896918      fig.text(0.5, 0.95, self.title, ha='center')
     
    952974        ax = fig.gca() ; ax.set_ylabel(self.ylabel) ; ax.set_xlabel(self.xlabel)
    953975
    954         if self.lons is not None:   ax.set_xticks(np.arange(-360,361,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone)
    955         elif self.lats is not None: ax.set_xticks(np.arange(-90,91,30)) ; ax.set_xbound(lower=self.lats, upper=self.late)
     976        self.makeinterv()
     977        if self.lons is not None:   ax.set_xticks(np.arange(-360,361,self.loninterv)) ; ax.set_xbound(lower=self.lons, upper=self.lone)
     978        elif self.lats is not None: ax.set_xticks(np.arange(-90,91,self.latinterv)) ; ax.set_xbound(lower=self.lats, upper=self.late)
    956979
    957980        if self.locts is not None:
  • trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py

    r1277 r1343  
    9898
    9999# Get data from user-defined fields and define free dimensions
    100 islatfree,  query.lat,  query.lats,  query.late  = gethtmlcoord( form.getvalue("latitude"),   -90.,  90. )
     100getlat = form.getvalue("latitude")
     101if getlat is None:
     102  errormess = errormess+"<li>A value or interval for latitude is missing. Please correct."
     103  islatfree = False ; query.lat = 0. ; query.lats = 0. ; query.late = 0.
     104else:
     105  islatfree,  query.lat,  query.lats,  query.late  = gethtmlcoord( getlat,   -90.,  90. )
    101106islonfree,  query.lon,  query.lons,  query.lone  = gethtmlcoord( form.getvalue("longitude"), -180., 180. )
    102107isloctfree, query.loct, query.locts, query.locte = gethtmlcoord( form.getvalue("localtime"),    0.,  24. )
Note: See TracChangeset for help on using the changeset viewer.