Ignore:
Timestamp:
Jan 8, 2013, 9:33:07 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON MCDonline. Support for MCD5. Added eps figures. Various other informations added (diapo mode, text file with web arborescence).

File:
1 edited

Legend:

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

    r827 r859  
    88
    99import numpy as np
    10 import fmcd
    1110import matplotlib.pyplot as mpl
    1211import myplot
     
    8483        self.dpi = 80.
    8584
     85    def toversion5(self):
     86        self.name      = "MCD v5.0"
     87        self.dset      = '/home/marshttp/MCD_v5.0/data/'
     88        self.extvarkey = np.ones(100)
     89
    8690    def viking1(self): self.name = "Viking 1 site. MCD v4.3 output" ; self.lat = 22.48 ; self.lon = -49.97 ; self.xdate = 97.
    8791    def viking2(self): self.name = "Viking 2 site. MCD v4.3 output" ; self.lat = 47.97 ; self.lon = -225.74 ; self.xdate = 117.6
    8892
    8993    def getdustlabel(self):
    90         if self.dust == 1: self.dustlabel = "MY24 minimum solar scenario"
    91         elif self.dust == 2: self.dustlabel = "MY24 average solar scenario"
    92         elif self.dust == 3: self.dustlabel = "MY24 maximum solar scenario"
     94        if self.dust == 1: self.dustlabel = "climatology minimum solar scenario"
     95        elif self.dust == 2: self.dustlabel = "climatology average solar scenario"
     96        elif self.dust == 3: self.dustlabel = "climatology maximum solar scenario"
    9397        elif self.dust == 4: self.dustlabel = "dust storm minimum solar scenario"
    9498        elif self.dust == 5: self.dustlabel = "dust storm average solar scenario"
     
    140144        17: "daily min mean surface temperature (K)",\
    141145        18: "surf. temperature RMS day to day variations (K)",\
    142         19: "surface pressure (high resolution if hireskey=1)",\
     146        19: "surface pressure (Pa)",\
    143147        20: "GCM surface pressure (Pa)",\
    144148        21: "atmospheric pressure RMS day to day variations (Pa)",\
     
    173177        50: "Air viscosity estimation (N s m-2)"
    174178        }
     179        ### MCD version 5 new variables. AS 12/2012.
     180        if "v5" in self.name:
     181          whichfield[29] = "not used (set to zero)"
     182          whichfield[30] = "Surface roughness length z0 (m)"
     183          whichfield[37] = "DOD RMS day to day variations"
     184          whichfield[38] = "Dust mass mixing ratio (kg/kg)"
     185          whichfield[39] = "Dust effective radius (m)"
     186          whichfield[44] =  whichfield[43]
     187          whichfield[43] =  whichfield[42]
     188          whichfield[42] =  whichfield[41]
     189          whichfield[41] =  whichfield[40]
     190          whichfield[40] = "Dust deposition on flat surface (kg m-2 s-1)"
     191          whichfield[45] = "Water ice effective radius (m)"
     192          whichfield[46] = "Convective PBL height (m)"
     193          whichfield[47] = "Max. upward convective wind within the PBL (m/s)"
     194          whichfield[48] = "Max. downward convective wind within the PBL (m/s)"
     195          whichfield[49] = "Convective vertical wind variance at level z (m2/s2)"
     196          whichfield[50] = "Convective eddy vertical heat flux at level z (m/s/K)"
     197          whichfield[51] = "Surface wind stress (Kg/m/s2)"
     198          whichfield[52] = "Surface sensible heat flux (W/m2) (<0 when flux from surf to atm.)"
     199          whichfield[53] = "R: Molecular gas constant (J K-1 kg-1)"
     200          whichfield[54] = "Air viscosity estimation (N s m-2)"
     201          whichfield[55] = "not used (set to zero)"
     202          whichfield[56] = "not used (set to zero)"
     203          whichfield[57] = "[CO2] vol. mixing ratio (mol/mol)"
     204          whichfield[58] = "[N2] vol. mixing ratio (mol/mol)"
     205          whichfield[59] = "[Ar] vol. mixing ratio (mol/mol)"
     206          whichfield[60] = "[CO] vol. mixing ratio (mol/mol)"
     207          whichfield[61] = "[O] vol. mixing ratio (mol/mol)"
     208          whichfield[62] = "[O2] vol. mixing ratio (mol/mol)"
     209          whichfield[63] = "[O3] vol. mixing ratio (mol/mol)"
     210          whichfield[64] = "[H] vol. mixing ratio (mol/mol)"
     211          whichfield[65] = "[H2] vol. mixing ratio (mol/mol)"
     212          whichfield[66] = "[electron] vol. mixing ratio (mol/mol)"
     213          whichfield[67] = "CO2 column (kg/m2)"
     214          whichfield[68] = "N2 column (kg/m2)"
     215          whichfield[69] = "Ar column (kg/m2)"
     216          whichfield[70] = "CO column (kg/m2)"
     217          whichfield[71] = "O column (kg/m2)"
     218          whichfield[72] = "O2 column (kg/m2)"
     219          whichfield[73] = "O3 column (kg/m2)"
     220          whichfield[74] = "H column (kg/m2)"
     221          whichfield[75] = "H2 column (kg/m2)"
     222          whichfield[76] = "electron column (kg/m2)"
    175223        if num not in whichfield: myplot.errormess("Incorrect subscript in extvar.")
    176 
    177224        dastuff = whichfield[num]
    178  
    179225        if "(K)" in dastuff:      self.fmt="%.0f"
    180226        elif "(Pa)" in dastuff:   self.fmt="%.1f"
    181227        elif "(W/m2)" in dastuff: self.fmt="%.0f"
    182228        elif "(m/s)" in dastuff:  self.fmt="%.1f"
     229        elif "(m)" in dastuff:    self.fmt="%.0f"
    183230        else:                     self.fmt="%.2e"
    184 
    185231        return dastuff
    186232
     
    197243        elif num == "ps": num = 19
    198244        elif num == "tau": num = 36
    199         elif num == "mtot": num = 40
    200         elif num == "icetot": num = 42
     245        elif num == "mtot":
     246            if "v5" in self.name:  num = 41
     247            else:                  num = 40
     248        elif num == "icetot":
     249            if "v5" in self.name:  num = 43
     250            else:                  num = 42
    201251        elif num == "ps_ddv": num = 22
    202         elif num == "h2ovap": num = 41
    203         elif num == "h2oice": num = 43
     252        elif num == "h2ovap":
     253            if "v5" in self.name:  num = 42
     254            else:                  num = 41
     255        elif num == "h2oice":
     256            if "v5" in self.name:  num = 44
     257            else:                  num = 43
    204258        elif num == "cp": num = 8
    205259        elif num == "rho_ddv": num = 10
     
    210264        elif num == "lwup": num = 33
    211265        elif num == "swup": num = 34
    212         elif num == "o3": num = 44
    213         elif num == "o": num = 46
    214         elif num == "co": num = 48
    215         elif num == "visc": num = 50
     266        elif num == "o3":
     267            if "v5" in self.name:  num = 63
     268            else:                  num = 44
     269        elif num == "o":
     270            if "v5" in self.name:  num = 61
     271            else:                  num = 46
     272        elif num == "co":
     273            if "v5" in self.name:  num = 60
     274            else:                  num = 48
     275        elif num == "visc":
     276            if "v5" in self.name:  num = 54
     277            else:                  num = 50
    216278        elif num == "co2ice": num = 35
     279        elif num == "pbl":
     280            if "v5" in self.name:  num = 46
     281            else:                  num = 30 # an undefined variable to avoid misleading output
     282        elif num == "updraft":
     283            if "v5" in self.name:  num = 47
     284            else:                  num = 30 # an undefined variable to avoid misleading output
     285        elif num == "downdraft":
     286            if "v5" in self.name:  num = 48
     287            else:                  num = 30 # an undefined variable to avoid misleading output
     288        elif num == "pblwvar":
     289            if "v5" in self.name:  num = 49
     290            else:                  num = 30 # an undefined variable to avoid misleading output
     291        elif num == "pblhvar":
     292            if "v5" in self.name:  num = 50
     293            else:                  num = 30 # an undefined variable to avoid misleading output
     294        elif num == "stress":
     295            if "v5" in self.name:  num = 51
     296            else:                  num = 30 # an undefined variable to avoid misleading output
     297        elif num == "ar":
     298            if "v5" in self.name:  num = 59
     299            else:                  num = 30 # an undefined variable to avoid misleading output
    217300        elif not isinstance(num, np.int): myplot.errormess("field reference not found.")
    218301        return num
     
    230313            self.locte = abs(self.locte)%24
    231314            if self.locts == self.locte: self.locte = self.locts + 24
    232         if self.lat > 90.: self.lat = 90.
    233         if self.lat < -90.: self.lat = -90.
    234         if self.lats is not None and self.late is not None:
    235             if abs(self.lats) > 90.: self.lats = 90.
    236             if abs(self.late) > 90.: self.late = 90.
    237             if abs(self.lats) < -90.: self.lats = -90.
    238             if abs(self.late) < -90.: self.late = -90.
    239315        ## now MCD request
     316        if "v5" in self.name: from fmcd5 import call_mcd
     317        else:                 from fmcd import call_mcd
    240318        (self.pres, self.dens, self.temp, self.zonwind, self.merwind, \
    241319         self.meanvar, self.extvar, self.seedout, self.ierr) \
    242320         = \
    243          fmcd.call_mcd(self.zkey,self.xz,self.lon,self.lat,self.hrkey, \
     321         call_mcd(self.zkey,self.xz,self.lon,self.lat,self.hrkey, \
    244322             self.datekey,self.xdate,self.loct,self.dset,self.dust, \
    245323             self.perturkey,self.seedin,self.gwlength,self.extvarkey )
     
    262340        strloct = str(self.loct)+str(self.locts)+str(self.locte)
    263341        name = str(self.zkey)+strxz+strlon+strlat+str(self.hrkey)+str(self.datekey)+str(self.xdate)+strloct+str(self.dust)
     342        if "v5" in self.name: name = "v5beta_" + name
    264343        return name
    265344
     
    286365    def printallextvar(self):
    287366    # print all extra MCD variables   
    288         for i in range(50): self.printextvar(i+1)
     367        if "v5" in self.name:  limit=76
     368        else:                  limit=50
     369        for i in range(limit): self.printextvar(i+1)
    289370
    290371    def htmlprinttabextvar(self,tabtodo):
     
    813894      canvas.print_figure(figname, dpi=self.dpi)
    814895
    815 
    816896    ### TODO: makeplot2d, plot2d, passer plot settings
    817897
Note: See TracChangeset for help on using the changeset viewer.