Changeset 859 for trunk/UTIL/PYTHON/mcd
- Timestamp:
- Jan 8, 2013, 9:33:07 AM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/mcd
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/mcd.py
r827 r859 8 8 9 9 import numpy as np 10 import fmcd11 10 import matplotlib.pyplot as mpl 12 11 import myplot … … 84 83 self.dpi = 80. 85 84 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 86 90 def viking1(self): self.name = "Viking 1 site. MCD v4.3 output" ; self.lat = 22.48 ; self.lon = -49.97 ; self.xdate = 97. 87 91 def viking2(self): self.name = "Viking 2 site. MCD v4.3 output" ; self.lat = 47.97 ; self.lon = -225.74 ; self.xdate = 117.6 88 92 89 93 def getdustlabel(self): 90 if self.dust == 1: self.dustlabel = " MY24minimum solar scenario"91 elif self.dust == 2: self.dustlabel = " MY24average solar scenario"92 elif self.dust == 3: self.dustlabel = " MY24maximum 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" 93 97 elif self.dust == 4: self.dustlabel = "dust storm minimum solar scenario" 94 98 elif self.dust == 5: self.dustlabel = "dust storm average solar scenario" … … 140 144 17: "daily min mean surface temperature (K)",\ 141 145 18: "surf. temperature RMS day to day variations (K)",\ 142 19: "surface pressure ( high resolution if hireskey=1)",\146 19: "surface pressure (Pa)",\ 143 147 20: "GCM surface pressure (Pa)",\ 144 148 21: "atmospheric pressure RMS day to day variations (Pa)",\ … … 173 177 50: "Air viscosity estimation (N s m-2)" 174 178 } 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)" 175 223 if num not in whichfield: myplot.errormess("Incorrect subscript in extvar.") 176 177 224 dastuff = whichfield[num] 178 179 225 if "(K)" in dastuff: self.fmt="%.0f" 180 226 elif "(Pa)" in dastuff: self.fmt="%.1f" 181 227 elif "(W/m2)" in dastuff: self.fmt="%.0f" 182 228 elif "(m/s)" in dastuff: self.fmt="%.1f" 229 elif "(m)" in dastuff: self.fmt="%.0f" 183 230 else: self.fmt="%.2e" 184 185 231 return dastuff 186 232 … … 197 243 elif num == "ps": num = 19 198 244 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 201 251 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 204 258 elif num == "cp": num = 8 205 259 elif num == "rho_ddv": num = 10 … … 210 264 elif num == "lwup": num = 33 211 265 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 216 278 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 217 300 elif not isinstance(num, np.int): myplot.errormess("field reference not found.") 218 301 return num … … 230 313 self.locte = abs(self.locte)%24 231 314 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.239 315 ## now MCD request 316 if "v5" in self.name: from fmcd5 import call_mcd 317 else: from fmcd import call_mcd 240 318 (self.pres, self.dens, self.temp, self.zonwind, self.merwind, \ 241 319 self.meanvar, self.extvar, self.seedout, self.ierr) \ 242 320 = \ 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, \ 244 322 self.datekey,self.xdate,self.loct,self.dset,self.dust, \ 245 323 self.perturkey,self.seedin,self.gwlength,self.extvarkey ) … … 262 340 strloct = str(self.loct)+str(self.locts)+str(self.locte) 263 341 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 264 343 return name 265 344 … … 286 365 def printallextvar(self): 287 366 # 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) 289 370 290 371 def htmlprinttabextvar(self,tabtodo): … … 813 894 canvas.print_figure(figname, dpi=self.dpi) 814 895 815 816 896 ### TODO: makeplot2d, plot2d, passer plot settings 817 897 -
trunk/UTIL/PYTHON/mcd/mcdtest.py
r639 r859 3 3 from mcd import mcd 4 4 5 5 6 query = mcd() 7 8 query.toversion5() 9 query.loct = 12. 10 6 11 query.update() 7 12 query.printcoord() … … 12 17 query.xz = 30000. 13 18 query.printmcd() 19 query.printextvar(94) 20 query.printextvar(95) 21 22 end 14 23 15 24 query.viking1() -
trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py
r827 r859 73 73 query=mcd.mcd() 74 74 75 # set MCD version changes if needed 76 betatest = form.getvalue("betatest") 77 if betatest == "on": query.toversion5() 78 75 79 # Get the kind of vertical coordinates and choose default behavior for "all" 76 80 try: query.zkey = int(form.getvalue("zkey")) … … 93 97 if query.datekey == 1: 94 98 try: query.xdate = float(form.getvalue("ls")) 95 except: query.xdate = float(1) ; badlschar = True 99 except: query.xdate = float(1) ; badlschar = True # comment the second part if in debug command line mode 96 100 else: 97 101 try: query.xdate = float(form.getvalue("julian")) … … 161 165 except: query.max2d = None 162 166 163 try: query.dpi = f loat(form.getvalue("dpi"))167 try: query.dpi = form.getvalue("dpi") 164 168 except: query.dpi = 80. 165 169 if query.dpi == "eps": yeaheps = True ; query.dpi = 300. 170 else: yeaheps = False ; query.dpi = float(query.dpi) 166 171 167 172 # Get variables to plot … … 194 199 195 200 # reference name (to test which figures are already in the database) 196 reference = query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt)+str(iszonmean)+query.colorm+str(query.min2d)+str(query.max2d)+str(query.dpi) 197 figname = '../img/'+reference+'.png' 201 try: reference = query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt)+str(iszonmean)+query.colorm+str(query.min2d)+str(query.max2d)+str(query.dpi) 202 except: reference = "test" 203 if yeaheps: figname = '../img/'+reference+'.eps' 204 else: figname = '../img/'+reference+'.png' 198 205 txtname = '../txt/'+reference+'.txt' 199 206 testexist = daos.path.isfile(figname) … … 234 241 235 242 header="""<html><head><title>Mars Climate Database: The Web Interface</title></head><body>""" 243 if betatest == "on": 244 print "<b>!!! THIS IS A BETA VERSION. RESULTS ARE NOT VALIDATED !!!</b>" 245 if sumfree == 2: print "<br>" 236 246 237 247 print header … … 248 258 else: 249 259 if sumfree == 0: query.update() ; query.htmlprinttabextvar(vartoplot) 250 elif sumfree == 2: print "<img src='"+figname+"'><br />" 260 elif sumfree == 2: 261 if yeaheps: print "<hr><a href='"+figname+"'>!!!! Click here to download the EPS figure file !!!!</a><br /><hr>" 262 else: print "<img src='"+figname+"'><br />" 251 263 elif sumfree == 1: 252 264 print "<a href='"+txtname+"'>Click here to download an ASCII file containing data</a><br />" 253 265 print "<hr>" 254 print "<img src='"+figname+"'><br />" 266 if yeaheps: print "<hr><a href='"+figname+"'>!!!! Click here to download the EPS figure file !!!!</a><br /><hr>" 267 else: print "<img src='"+figname+"'><br />" 255 268 256 269 ## This is quite common -
trunk/UTIL/PYTHON/mcd/proto/index.html
r827 r859 108 108 <ul> 109 109 <li>Dust scenario <select name="dust"> 110 <option value="1" > MY24min solar</option>111 <option value="2" selected> MY24ave solar</option>112 <option value="3" > MY24max solar</option>113 <option value="4" >dust storm tau=4min solar</option>114 <option value="5" >dust storm tau=4ave solar</option>115 <option value="6" >dust storm tau=4max solar</option>116 <option value="7" >warm scenario(dusty, max solar)</option>117 <option value="8" >cold scenario(low dust, min solar)</option>110 <option value="1" >climatology min solar</option> 111 <option value="2" selected>climatology ave solar</option> 112 <option value="3" >climatology max solar</option> 113 <option value="4" >dust storm min solar</option> 114 <option value="5" >dust storm ave solar</option> 115 <option value="6" >dust storm max solar</option> 116 <option value="7" >warm (dusty, max solar)</option> 117 <option value="8" >cold (low dust, min solar)</option> 118 118 </select></li> 119 119 <li>Interpolate using MOLA topography <input type="radio" name="hrkey" value="1" checked /> on <input type="radio" name="hrkey" value="0" /> off </li> 120 <li> <span style="font-size: 80%;"> Beta-testing (only for developers) 121 <input type="radio" name="betatest" value="off" checked /> off 122 <input type="radio" name="betatest" value="on" /> on 123 </span> 124 </li> 120 125 </ul> 121 126 </td> … … 163 168 <option value="co" >[CO] vol. mixing ratio (mol/mol)</option> 164 169 <option value="visc" >Air viscosity estimation (N s m-2)</option> 170 <option value="pbl" >(beta) Convective PBL height (m)</option> 171 <option value="stress" >(beta) Surf. wind stress (Kg/m/s2)</option> 172 <option value="ar" >(beta) Ar vol.mix.rat. (mol/mol)</option> 173 <option value="updraft" >(beta) Max PBL updraft wind (m/s)</option> 174 <option value="downdraft" >(beta) Max PBL downdraft wind (m/s)</option> 175 <option value="pblwvar" >(beta) PBL vert wind variance (m2/s2)</option> 176 <option value="pblhvar" >(beta) PBL eddy vert heat flux (m/s/K)</option> 165 177 </select> 166 178 <br /> … … 192 204 <option value="co" >[CO] vol. mixing ratio (mol/mol)</option> 193 205 <option value="visc" >Air viscosity estimation (N s m-2)</option> 206 <option value="pbl" >(beta) Convective PBL height (m)</option> 207 <option value="stress" >(beta) Surf. wind stress (Kg/m/s2)</option> 208 <option value="ar" >(beta) Ar vol.mix.rat. (mol/mol)</option> 209 <option value="updraft" >(beta) Max PBL updraft wind (m/s)</option> 210 <option value="downdraft" >(beta) Max PBL downdraft wind (m/s)</option> 211 <option value="pblwvar" >(beta) PBL vert wind variance (m2/s2)</option> 212 <option value="pblhvar" >(beta) PBL eddy vert heat flux (m/s/K)</option> 194 213 </select> 195 214 <br /> … … 221 240 <option value="co" >[CO] vol. mixing ratio (mol/mol)</option> 222 241 <option value="visc" >Air viscosity estimation (N s m-2)</option> 242 <option value="pbl" >(beta) Convective PBL height (m)</option> 243 <option value="stress" >(beta) Surf. wind stress (Kg/m/s2)</option> 244 <option value="ar" >(beta) Ar vol.mix.rat. (mol/mol)</option> 245 <option value="updraft" >(beta) Max PBL updraft wind (m/s)</option> 246 <option value="downdraft" >(beta) Max PBL downdraft wind (m/s)</option> 247 <option value="pblwvar" >(beta) PBL vert wind variance (m2/s2)</option> 248 <option value="pblhvar" >(beta) PBL eddy vert heat flux (m/s/K)</option> 223 249 </select> 224 250 <br /> … … 250 276 <option value="co" >[CO] vol. mixing ratio (mol/mol)</option> 251 277 <option value="visc" >Air viscosity estimation (N s m-2)</option> 278 <option value="pbl" >(beta) Convective PBL height (m)</option> 279 <option value="stress" >(beta) Surf. wind stress (Kg/m/s2)</option> 280 <option value="ar" >(beta) Ar vol.mix.rat. (mol/mol)</option> 281 <option value="updraft" >(beta) Max PBL updraft wind (m/s)</option> 282 <option value="downdraft" >(beta) Max PBL downdraft wind (m/s)</option> 283 <option value="pblwvar" >(beta) PBL vert wind variance (m2/s2)</option> 284 <option value="pblhvar" >(beta) PBL eddy vert heat flux (m/s/K)</option> 252 285 </select> 253 286 </td> … … 257 290 <input type="radio" name="dpi" value="80" checked> medium 258 291 <input type="radio" name="dpi" value="160"> high 292 <input type="radio" name="dpi" value="eps"> eps 259 293 </li> 260 294 <li> Set colormap -
trunk/UTIL/PYTHON/mcd/proto/martian_time.js
r821 r859 462 462 Convert2Ls(); 463 463 PlaceValues(0.,0.); 464 DefaultSpaceTime() 464 DefaultSpaceTime(); 465 465 } 466 466 … … 469 469 document.calendar.submit(); 470 470 } 471
Note: See TracChangeset
for help on using the changeset viewer.