Ignore:
Timestamp:
Oct 22, 2012, 8:05:55 PM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON
MCD interface and online version.

  • corrected a bug introduced recently for fixed / not fixed LT
  • clearer location for the fixed LT / not fixed LT option
  • submitting with a button on the beginner's column automatically reset the form with default values so that no risk to make mistake
  • now the button reset is a real reset. clicking on the Mars panorama also reset
  • display MCD version, coordinates etc... for values-only output
  • the plot is shown on a new window
  • added Ls or julian date in the title (automatic)
  • made the title to be on two lines
  • displayed values on colorbars are now adapted. e.g. if the unit is K then we use the format "%.0f"
  • clearer mention of vertical coordinates on the webpage. removed the possibility for above 3396 km from Mars Center
  • more points on vertical profiles and sections
  • added separator : and rewrote this part of the code so that it is easy to add othe separators
  • added a protection so that slightly negative values from the MCD are set to 0 (apply to mol/mol, kg/kg, kg/m2, W/m2 quantities)
  • better naming for RMS values

TODO (from easier to more difficult i.e. requiring more work)

  • more color palettes
  • fix ugly spacing when asking for 4 sections
  • zonal means
  • alert to user rather than modulo or bounds for time and coordinates
  • Hovmoller plots
  • test to prevent user to use a bad separator (for instance -)
Location:
trunk/UTIL/PYTHON/mcd/proto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py

    r811 r812  
    2626from PIL import Image
    2727
     28
     29
     30### a function to read HTML arguments for coordinates
     31def 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
    2848# for debugging in web browser
    2949cgitb.enable()
     
    3656query=mcd.mcd() #FG: import from module mcd
    3757
    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"
    6759try: query.zkey = int(form.getvalue("zkey"))
    6860except: 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)
     61if query.zkey == 2:    minxz = -5000.   ; maxxz = 100000.
     62elif query.zkey == 3:  minxz = 0.       ; maxxz = 120000.
     63elif query.zkey == 5:  minxz = -5000.   ; maxxz = 100000.
     64elif query.zkey == 4:  minxz = 1000.    ; maxxz = 0.001
     65elif query.zkey == 1:  minxz = 3396000. ; maxxz = 3596000.
     66
     67# Get data from user-defined fields and define free dimensions
     68islatfree,  query.lat,  query.lats,  query.late  = gethtmlcoord( form.getvalue("latitude"),   -90.,  90. )
     69islonfree,  query.lon,  query.lons,  query.lone  = gethtmlcoord( form.getvalue("longitude"), -180., 180. )
     70isloctfree, query.loct, query.locts, query.locte = gethtmlcoord( form.getvalue("localtime"),    0.,  24. )
     71isaltfree,  query.xz,   query.xzs,   query.xze   = gethtmlcoord( form.getvalue("altitude"),  minxz, maxxz)
    8472
    8573sumfree = islatfree + islonfree + isloctfree + isaltfree
     
    143131    ### getting data
    144132    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)   
    148136    else:                       exit() 
    149137
     
    184172#print "<br />"
    185173
    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>"
    187177
    188178## Now the part which differs
     
    191181elif sumfree == 1:     
    192182    print "<a href='"+txtname+"'>Click here to download an ASCII file containing data</a><br />"
     183    print "<hr>"
    193184    print "<img src='"+figname+"'><br />"
    194185else:                   print "<h1>ERROR : sumfree is not or badly defined ...</h1></body></html>"
     
    230221## Close opend file
    231222#fo.close()
     223
  • trunk/UTIL/PYTHON/mcd/proto/index.html

    r805 r812  
    1515<!-- aussi possible: get a la place de post. pour avoir un beau lien -->
    1616
    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">-->
    1919
    2020<center>
    2121<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>
    2324</center>
    2425
     
    5455Solar longitude <input type="text" size="3" name="ls"> degrees<br />
    5556Local Time <input type="text" size="4" name="localtime" value="0."> Martian hour<br />
     57<br />
    5658<input type="radio" name="datekeyhtml" value="0">
    5759<b><font color="blue">EARTH date</font></b>
     
    6264</td>
    6365<td align="center">
     66Option 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>
    6470Earth Julian Date <input type="text" size="6" name="julian" readonly="readonly"><br />
    65 Martian year <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 />
     71Mars 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 />
    6874<input type="button" value="EARTH DATE >>> MARS DATE" onClick="Convert2Ls();"><br />
    6975</td>
     
    107113<li>Longitude <input type="text" size="7" name="longitude" value="0."> degree East
    108114<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-->
    114122</select>
    115123<!--
     
    189197<option value="h2ovap"        >Water vapor vol. mixing ratio (mol/mol)</option>
    190198<option value="h2oice"        >Water ice mixing ratio (mol/mol)</option>
    191 <option value="ps_ddv"        >Surface pressure DTD RMS (Pa)</option>
     199<option value="ps_ddv"        >Surf. pres. day to day variability (Pa)</option>
    192200<option value="co2ice"        >surface CO2 ice layer (kg/m2)</option>
    193201<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>
    195203<option value="tsurfmx"       >daily max mean surf temperature (K)</option>
    196204<option value="tsurfmn"       >daily min mean surf temperature (K)</option>
     
    218226<option value="h2ovap"        >Water vapor vol. mixing ratio (mol/mol)</option>
    219227<option value="h2oice"        >Water ice mixing ratio (mol/mol)</option>
    220 <option value="ps_ddv"        >Surface pressure DTD RMS (Pa)</option>
     228<option value="ps_ddv"        >Surf. pres. day to day variability (Pa)</option>
    221229<option value="co2ice"        >surface CO2 ice layer (kg/m2)</option>
    222230<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>
    224232<option value="tsurfmx"       >daily max mean surf temperature (K)</option>
    225233<option value="tsurfmn"       >daily min mean surf temperature (K)</option>
     
    247255<option value="h2ovap"        >Water vapor vol. mixing ratio (mol/mol)</option>
    248256<option value="h2oice"        >Water ice mixing ratio (mol/mol)</option>
    249 <option value="ps_ddv"        >Surface pressure DTD RMS (Pa)</option>
     257<option value="ps_ddv"        >Surf. pres. day to day variability (Pa)</option>
    250258<option value="co2ice"        >surface CO2 ice layer (kg/m2)</option>
    251259<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>
    253261<option value="tsurfmx"       >daily max mean surf temperature (K)</option>
    254262<option value="tsurfmn"       >daily min mean surf temperature (K)</option>
     
    276284<option value="h2ovap"        >Water vapor vol. mixing ratio (mol/mol)</option>
    277285<option value="h2oice"        >Water ice mixing ratio (mol/mol)</option>
    278 <option value="ps_ddv"        >Surface pressure DTD RMS (Pa)</option>
     286<option value="ps_ddv"        >Surf. pres. day to day variability (Pa)</option>
    279287<option value="co2ice"        >surface CO2 ice layer (kg/m2)</option>
    280288<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>
    282290<option value="tsurfmx"       >daily max mean surf temperature (K)</option>
    283291<option value="tsurfmn"       >daily min mean surf temperature (K)</option>
     
    298306<input type="radio" name="iswind" value="off" checked /> No
    299307<input type="radio" name="iswind" value="on"          /> Yes</li> 
     308<!--
    300309<li> Set same LT on whole planet
    301310<input type="radio" name="isfixedlt" value="off" checked /> No
    302311<input type="radio" name="isfixedlt" value="on"          /> Yes</li>
     312-->
    303313<!--
    304314<li> Add another variable
     
    320330<tr>
    321331<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 />
    326336</td>
    327337<td align="center">
    328338<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 />
    330341</td>
    331342<td align="center">
  • trunk/UTIL/PYTHON/mcd/proto/martian_time.js

    r761 r812  
    450450}
    451451
     452
     453function submit_form_beginner() {
     454document.calendar.submit();
     455document.calendar.reset();
     456DefaultDateValues();
     457DefaultTimeValues();
     458Convert2Ls();
     459PlaceValues(0.,0.);
     460DefaultSpaceTime()
     461}
     462
Note: See TracChangeset for help on using the changeset viewer.