Changeset 812 for trunk/UTIL/PYTHON/mcd/proto
- Timestamp:
- Oct 22, 2012, 8:05:55 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/mcd/proto
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py
r811 r812 26 26 from PIL import Image 27 27 28 29 30 ### a function to read HTML arguments for coordinates 31 def gethtmlcoord(userinput,defmin,defmax): 32 # accepted separators 33 separators = [":",";",",","/"] 34 # initial values 35 val = -9999. ; vals = None ; vale = None ; foundinterv = False 36 if userinput == None: userinput = "1" 37 # the main work. either all -- or an interval -- or a single value. 38 if userinput == "all": isfree = 1 ; vals = defmin ; vale = defmax ; foundinterv = True 39 else: 40 for sep in separators: 41 isfree = 1 ; ind = userinput.find(sep) 42 if ind != -1: vals = float(userinput[:ind]) ; vale = float(userinput[ind+1:]) ; foundinterv = True 43 if not foundinterv: isfree = 0 ; val = float(userinput) 44 # return values 45 return isfree, val, vals, vale 46 47 28 48 # for debugging in web browser 29 49 cgitb.enable() … … 36 56 query=mcd.mcd() #FG: import from module mcd 37 57 38 # Get data from user-defined fields and define free dimensions 39 # FG: add tests if var==None to have values in local without forms ones 40 query.lat = -9999. 41 getlat = form.getvalue("latitude") 42 if getlat == None: getlat = "1" 43 if getlat == "all": islatfree = 1 ; query.lats = -90. ; query.late = 90. 44 elif ";" in getlat: islatfree = 1 ; ind = getlat.find(";") ; query.lats = float(getlat[:ind]) ; query.late = float(getlat[ind+1:]) 45 elif "," in getlat: islatfree = 1 ; ind = getlat.find(",") ; query.lats = float(getlat[:ind]) ; query.late = float(getlat[ind+1:]) 46 elif "/" in getlat: islatfree = 1 ; ind = getlat.find("/") ; query.lats = float(getlat[:ind]) ; query.late = float(getlat[ind+1:]) 47 else: islatfree = 0 ; query.lat = float(getlat) 48 49 query.lon = -9999. 50 getlon = form.getvalue("longitude") 51 if getlon == None: getlon = "1" 52 if getlon == "all": islonfree = 1 ; query.lons = -180. ; query.lone = 180. 53 elif ";" in getlon: islonfree = 1 ; ind = getlon.find(";") ; query.lons = float(getlon[:ind]) ; query.lone = float(getlon[ind+1:]) 54 elif "," in getlon: islonfree = 1 ; ind = getlon.find(",") ; query.lons = float(getlon[:ind]) ; query.lone = float(getlon[ind+1:]) 55 elif "/" in getlon: islonfree = 1 ; ind = getlon.find("/") ; query.lons = float(getlon[:ind]) ; query.lone = float(getlon[ind+1:]) 56 else: islonfree = 0 ; query.lon = float(getlon) 57 58 query.loct = -9999. 59 getloct = form.getvalue("localtime") 60 if getloct == None: getloct = "1" 61 if getloct == "all": isloctfree = 1 ; query.locts = 0. ; query.locte = 24. 62 elif ";" in getloct: isloctfree = 1 ; ind = getloct.find(";") ; query.locts = float(getloct[:ind]) ; query.locte = float(getloct[ind+1:]) 63 elif "," in getloct: isloctfree = 1 ; ind = getloct.find(",") ; query.locts = float(getloct[:ind]) ; query.locte = float(getloct[ind+1:]) 64 elif "/" in getloct: isloctfree = 1 ; ind = getloct.find("/") ; query.locts = float(getloct[:ind]) ; query.locte = float(getloct[ind+1:]) 65 else: isloctfree = 0 ; query.loct = float(getloct) 66 58 # Get the kind of vertical coordinates and choose default behavior for "all" 67 59 try: query.zkey = int(form.getvalue("zkey")) 68 60 except: query.zkey = int(3) 69 70 query.xz = -9999. 71 getalt = form.getvalue("altitude") 72 if getalt == None: getalt = "1" 73 if getalt == "all": 74 isaltfree = 1 75 if query.zkey == 2: query.xzs = -5000. ; query.xze = 100000. 76 elif query.zkey == 3: query.xzs = 0. ; query.xze = 120000. 77 elif query.zkey == 5: query.xzs = -5000. ; query.xze = 100000. 78 elif query.zkey == 4: query.xzs = 1000. ; query.xze = 0.001 79 elif query.zkey == 1: query.xzs = 3396000. ; query.xze = 3596000. 80 elif ";" in getalt: isaltfree = 1 ; ind = getalt.find(";") ; query.xzs = float(getalt[:ind]) ; query.xze = float(getalt[ind+1:]) 81 elif "," in getalt: isaltfree = 1 ; ind = getalt.find(",") ; query.xzs = float(getalt[:ind]) ; query.xze = float(getalt[ind+1:]) 82 elif "/" in getalt: isaltfree = 1 ; ind = getalt.find("/") ; query.xzs = float(getalt[:ind]) ; query.xze = float(getalt[ind+1:]) 83 else: isaltfree = 0 ; query.xz = float(getalt) 61 if query.zkey == 2: minxz = -5000. ; maxxz = 100000. 62 elif query.zkey == 3: minxz = 0. ; maxxz = 120000. 63 elif query.zkey == 5: minxz = -5000. ; maxxz = 100000. 64 elif query.zkey == 4: minxz = 1000. ; maxxz = 0.001 65 elif query.zkey == 1: minxz = 3396000. ; maxxz = 3596000. 66 67 # Get data from user-defined fields and define free dimensions 68 islatfree, query.lat, query.lats, query.late = gethtmlcoord( form.getvalue("latitude"), -90., 90. ) 69 islonfree, query.lon, query.lons, query.lone = gethtmlcoord( form.getvalue("longitude"), -180., 180. ) 70 isloctfree, query.loct, query.locts, query.locte = gethtmlcoord( form.getvalue("localtime"), 0., 24. ) 71 isaltfree, query.xz, query.xzs, query.xze = gethtmlcoord( form.getvalue("altitude"), minxz, maxxz) 84 72 85 73 sumfree = islatfree + islonfree + isloctfree + isaltfree … … 143 131 ### getting data 144 132 if isloctfree == 1: query.diurnal(nd=24) 145 elif islonfree == 1: query.zonal( )146 elif islatfree == 1: query.meridional( )147 elif isaltfree == 1: query.profile( )133 elif islonfree == 1: query.zonal(nd=64) 134 elif islatfree == 1: query.meridional(nd=48) 135 elif isaltfree == 1: query.profile(nd=35) 148 136 else: exit() 149 137 … … 184 172 #print "<br />" 185 173 186 print "<a href='../index.html'>Click here to start a new query</a><br />" 174 175 #print "<a href='../index.html'>Click here to start a new query</a><br />" 176 #print "<hr>" 187 177 188 178 ## Now the part which differs … … 191 181 elif sumfree == 1: 192 182 print "<a href='"+txtname+"'>Click here to download an ASCII file containing data</a><br />" 183 print "<hr>" 193 184 print "<img src='"+figname+"'><br />" 194 185 else: print "<h1>ERROR : sumfree is not or badly defined ...</h1></body></html>" … … 230 221 ## Close opend file 231 222 #fo.close() 223 -
trunk/UTIL/PYTHON/mcd/proto/index.html
r805 r812 15 15 <!-- aussi possible: get a la place de post. pour avoir un beau lien --> 16 16 17 <!--<form name="calendar" action="/marscgi-bin/mcdcgi.py" method="post" > <!--target="_new">-->18 <form name="calendar" action="./cgi-bin/mcdcgi.py" method="post" > <!--target="_new">-->17 <!--<form name="calendar" action="/marscgi-bin/mcdcgi.py" method="post"--> 18 <form name="calendar" action="./cgi-bin/mcdcgi.py" method="post" target="_blank"> <!--target="_new">--> 19 19 20 20 <center> 21 21 <b style="font-size: 125%;">Mars Climate Database: The Web Interface</b><br> 22 <img src="PIA03610_red.jpg" height=80 width=1200><br> 22 <!--Welcome! To reset your query, click on the Mars panorama.--> 23 <a href="index.html"><img src="PIA03610_red.jpg" height=80 width=1200></a><br> 23 24 </center> 24 25 … … 54 55 Solar longitude <input type="text" size="3" name="ls"> degrees<br /> 55 56 Local Time <input type="text" size="4" name="localtime" value="0."> Martian hour<br /> 57 <br /> 56 58 <input type="radio" name="datekeyhtml" value="0"> 57 59 <b><font color="blue">EARTH date</font></b> … … 62 64 </td> 63 65 <td align="center"> 66 Option for 2D maps: local time value is<br /> 67 <input type="radio" name="isfixedlt" value="off" checked /> at longitude 0 68 <input type="radio" name="isfixedlt" value="on" /> fixed for the whole planet<br /> 69 <hr> 64 70 Earth Julian Date <input type="text" size="6" name="julian" readonly="readonly"><br /> 65 Mar tianyear <input type="text" size="1" name="martianyear" readonly="readonly">66 month <input type="text" size="1" name="martianmonth" readonly="readonly"> / 12 <br />67 Martian sol <input type="text" size="2" name="sol" readonly="readonly"> / 669<br />71 Mars year <input type="text" size="1" name="martianyear" readonly="readonly"> 72 - month <input type="text" size="1" name="martianmonth" readonly="readonly"><span style="font-size: 75%;"> / 12</span> 73 - sol <input type="text" size="2" name="sol" readonly="readonly"><span style="font-size: 75%;"> / 669</span><br /> 68 74 <input type="button" value="EARTH DATE >>> MARS DATE" onClick="Convert2Ls();"><br /> 69 75 </td> … … 107 113 <li>Longitude <input type="text" size="7" name="longitude" value="0."> degree East 108 114 <li>Altitude <input type="text" size="9" name="altitude" value="10."> <select name="zkey"> 109 <option value="1" >m (O: Mars center)</option> 110 <option value="2" >m (O: "sea level")</option> 111 <option value="3" selected>m (O: surface)</option> 112 <option value="4" >Pa (pressure)</option> 113 <option value="5" >m (O: 3396 km)</option> 115 <option value="3" selected>m above surface</option> 116 <option value="2" >m above "sea level"</option> 117 <option value="1" >m from Mars center</option> 118 <option value="4" >Pa (pressure level)</option> 119 <!-- 120 <option value="5" >above 3396 km from Mars center</option> 121 --> 114 122 </select> 115 123 <!-- … … 189 197 <option value="h2ovap" >Water vapor vol. mixing ratio (mol/mol)</option> 190 198 <option value="h2oice" >Water ice mixing ratio (mol/mol)</option> 191 <option value="ps_ddv" >Surf ace pressure DTD RMS(Pa)</option>199 <option value="ps_ddv" >Surf. pres. day to day variability (Pa)</option> 192 200 <option value="co2ice" >surface CO2 ice layer (kg/m2)</option> 193 201 <option value="cp" >Air heat capacity Cp (J kg-1 K-1)</option> 194 <option value="rho_ddv" >density DTD RMS(kg/m^3)</option>202 <option value="rho_ddv" >density day to day variability (kg/m^3)</option> 195 203 <option value="tsurfmx" >daily max mean surf temperature (K)</option> 196 204 <option value="tsurfmn" >daily min mean surf temperature (K)</option> … … 218 226 <option value="h2ovap" >Water vapor vol. mixing ratio (mol/mol)</option> 219 227 <option value="h2oice" >Water ice mixing ratio (mol/mol)</option> 220 <option value="ps_ddv" >Surf ace pressure DTD RMS(Pa)</option>228 <option value="ps_ddv" >Surf. pres. day to day variability (Pa)</option> 221 229 <option value="co2ice" >surface CO2 ice layer (kg/m2)</option> 222 230 <option value="cp" >Air heat capacity Cp (J kg-1 K-1)</option> 223 <option value="rho_ddv" >density DTD RMS(kg/m^3)</option>231 <option value="rho_ddv" >density day to day variability (kg/m^3)</option> 224 232 <option value="tsurfmx" >daily max mean surf temperature (K)</option> 225 233 <option value="tsurfmn" >daily min mean surf temperature (K)</option> … … 247 255 <option value="h2ovap" >Water vapor vol. mixing ratio (mol/mol)</option> 248 256 <option value="h2oice" >Water ice mixing ratio (mol/mol)</option> 249 <option value="ps_ddv" >Surf ace pressure DTD RMS(Pa)</option>257 <option value="ps_ddv" >Surf. pres. day to day variability (Pa)</option> 250 258 <option value="co2ice" >surface CO2 ice layer (kg/m2)</option> 251 259 <option value="cp" >Air heat capacity Cp (J kg-1 K-1)</option> 252 <option value="rho_ddv" >density DTD RMS(kg/m^3)</option>260 <option value="rho_ddv" >density day to day variability (kg/m^3)</option> 253 261 <option value="tsurfmx" >daily max mean surf temperature (K)</option> 254 262 <option value="tsurfmn" >daily min mean surf temperature (K)</option> … … 276 284 <option value="h2ovap" >Water vapor vol. mixing ratio (mol/mol)</option> 277 285 <option value="h2oice" >Water ice mixing ratio (mol/mol)</option> 278 <option value="ps_ddv" >Surf ace pressure DTD RMS(Pa)</option>286 <option value="ps_ddv" >Surf. pres. day to day variability (Pa)</option> 279 287 <option value="co2ice" >surface CO2 ice layer (kg/m2)</option> 280 288 <option value="cp" >Air heat capacity Cp (J kg-1 K-1)</option> 281 <option value="rho_ddv" >density DTD RMS(kg/m^3)</option>289 <option value="rho_ddv" >density day to day variability (kg/m^3)</option> 282 290 <option value="tsurfmx" >daily max mean surf temperature (K)</option> 283 291 <option value="tsurfmn" >daily min mean surf temperature (K)</option> … … 298 306 <input type="radio" name="iswind" value="off" checked /> No 299 307 <input type="radio" name="iswind" value="on" /> Yes</li> 308 <!-- 300 309 <li> Set same LT on whole planet 301 310 <input type="radio" name="isfixedlt" value="off" checked /> No 302 311 <input type="radio" name="isfixedlt" value="on" /> Yes</li> 312 --> 303 313 <!-- 304 314 <li> Add another variable … … 320 330 <tr> 321 331 <td align="center"> 322 <input type=" submit" value="Values" style="font-weight:bold"/>323 <input type=" submit" value="Daily cycle" style="font-weight:bold" onClick="PlaceValues2('all')"/><br />324 <input type=" submit" value="Vertical profile" style="font-weight:bold" onClick="PlaceValues3('all')"/>325 <input type=" submit" value="Global map" style="font-weight:bold" onClick="PlaceValues('all','all')"/><br />332 <input type="button" value="Values" style="font-weight:bold" onClick="submit_form_beginner()"/> 333 <input type="button" value="Daily cycle" style="font-weight:bold" onClick="PlaceValues2('all');submit_form_beginner()"/><br /> 334 <input type="button" value="Vertical profile" style="font-weight:bold" onClick="PlaceValues3('all');submit_form_beginner()"/> 335 <input type="button" value="Global map" style="font-weight:bold" onClick="PlaceValues('all','all');submit_form_beginner()"/><br /> 326 336 </td> 327 337 <td align="center"> 328 338 <input type="submit" value="SUBMIT" style="font-weight:bold"/> 329 <input type="button" value="RESET" style="font-weight:bold" onClick="DefaultDateValues();DefaultTimeValues();Convert2Ls();PlaceValues(0.,0.);DefaultSpaceTime()"/><br /> 339 <!--<input type="button" value="RESET" style="font-weight:bold" onClick="DefaultDateValues();DefaultTimeValues();Convert2Ls();PlaceValues(0.,0.);DefaultSpaceTime()"/><br />--> 340 <input type="button" value="RESET" style="font-weight:bold" onClick="window.open('index.html','_self')"/><br /> 330 341 </td> 331 342 <td align="center"> -
trunk/UTIL/PYTHON/mcd/proto/martian_time.js
r761 r812 450 450 } 451 451 452 453 function submit_form_beginner() { 454 document.calendar.submit(); 455 document.calendar.reset(); 456 DefaultDateValues(); 457 DefaultTimeValues(); 458 Convert2Ls(); 459 PlaceValues(0.,0.); 460 DefaultSpaceTime() 461 } 462
Note: See TracChangeset
for help on using the changeset viewer.