Changeset 761 for trunk/UTIL/PYTHON/mcd/proto/cgi-bin
- Timestamp:
- Aug 19, 2012, 12:19:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py
r639 r761 4 4 ################################################## 5 5 ### A Python CGI for the Mars Climate Database ### 6 ### ------------------------------------------ -###7 ### Aymeric SPIGA 18-19/04/2012 8 ### ------------------------------------------ -###6 ### ------------------------------------------ ### 7 ### Aymeric SPIGA 18-19/04/2012 ~ 11/08/2012 ### 8 ### ------------------------------------------ ### 9 9 ### (see mcdtest.py for examples of use) ### 10 10 ################################################## … … 27 27 query = mcd() 28 28 29 # Get data from user-defined fields 30 query.lat = float(form.getvalue("latitude")) 31 query.lon = float(form.getvalue("longitude")) 32 query.loct = float(form.getvalue("localtime")) 29 # Get data from user-defined fields and define free dimensions 30 getlat = form.getvalue("latitude") 31 if getlat == "all": islatfree = 1 ; query.lat = -9999. 32 else: islatfree = 0 ; query.lat = float(getlat) 33 getlon = form.getvalue("longitude") 34 if getlon == "all": islonfree = 1 ; query.lon = -9999. 35 else: islonfree = 0 ; query.lon = float(getlon) 36 getloct = form.getvalue("localtime") 37 if getloct == "all": isloctfree = 1 ; query.loct = -9999. 38 else: isloctfree = 0 ; query.loct = float(getloct) 39 getalt = form.getvalue("altitude") 40 if getalt == "all": isaltfree = 1 ; query.xz = -9999. 41 else: isaltfree = 0 ; query.xz = float(getalt) 42 sumfree = islatfree + islonfree + isloctfree + isaltfree 43 if sumfree > 2: exit() ## only 1D or 2D plots for the moment 33 44 query.xdate = float(form.getvalue("ls")) 34 query.xz = float(form.getvalue("altitude"))35 45 query.hrkey = int(form.getvalue("hrkey")) 36 46 query.dust = int(form.getvalue("dust")) … … 40 50 # self.gwlength = 0. #gravity Wave wavelength (unused if perturkey=0) 41 51 42 # Get free dimensions 43 islatfree = float(form.getvalue("islatfree")) 44 islonfree = float(form.getvalue("islonfree")) 45 isloctfree = float(form.getvalue("isloctfree")) 46 isaltfree = float(form.getvalue("isaltfree")) 47 sumfree = islatfree + islonfree + isloctfree + isaltfree 48 if sumfree > 2: exit() ## only 1D or 2D plots for the moment 52 # Get variables to plot 53 var1 = form.getvalue("var1") 54 var2 = form.getvalue("var2") 55 var3 = form.getvalue("var3") 56 var4 = form.getvalue("var4") 57 vartoplot = [var1] 58 if var2 != "none": vartoplot = np.append(vartoplot,var2) 59 if var3 != "none": vartoplot = np.append(vartoplot,var3) 60 if var4 != "none": vartoplot = np.append(vartoplot,var4) 61 iswind = form.getvalue("iswind") 62 if iswind == "on": iswindlog = True 63 else: iswindlog = False 64 isfixedlt = form.getvalue("isfixedlt") 65 if isfixedlt == "on": input_fixedlt=True 66 else: input_fixedlt=False 49 67 50 68 # reference name (to test which figures are already in the database) 51 reference = str(islatfree)+str(islonfree)+str(isloctfree)+str(isaltfree)+query.getnameset() 69 reference = str(islatfree)+str(islonfree)+str(isloctfree)+str(isaltfree)+query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt) 52 70 figname = 'img/'+reference+'.jpg' 53 71 testexist = daos.path.isfile(figname) … … 67 85 68 86 ### generic building of figure 69 query.plot1d(["t","p","u","v"],vertplot=isaltfree) 87 #query.plot1d(["t","p","u","v"],vertplot=isaltfree) 88 query.plot1d(vartoplot,vertplot=isaltfree) 70 89 mpl.savefig("img/temp.png",dpi=85,bbox_inches='tight',pad_inches=0.25) 71 90 Image.open("img/temp.png").save(figname,'JPEG') … … 77 96 if islatfree == 1 and islonfree == 1: query.latlon() 78 97 else: exit() 79 80 query.map2d(["t","u"]) 98 99 ### figure 100 query.map2d(vartoplot,incwind=iswindlog,fixedlt=input_fixedlt) 81 101 mpl.savefig("img/temp.png",dpi=110,bbox_inches='tight',pad_inches=0.4) 82 102 Image.open("img/temp.png").save(figname,'JPEG') ##lighter images … … 92 112 93 113 ## Now the part which differs 94 if sumfree == 0: query.update() ; query. printmeanvar()114 if sumfree == 0: query.update() ; query.htmlprinttabextvar(vartoplot) #query.printmeanvar() 95 115 elif sumfree >= 1: print "<img src='../"+figname+"'><br />" 96 116 else: exit() 97 117 98 118 ## This is quite common 99 print "Based on the <a href='http://www-mars.lmd.jussieu.fr'>Mars Climate Database</a> (c) LMD/OU/IAA/ESA/CNES.<br />"119 #print "Based on the <a href='http://www-mars.lmd.jussieu.fr'>Mars Climate Database</a> (c) LMD/OU/IAA/ESA/CNES.<br />" 100 120 print "<hr>" 101 query.printset() 121 print "<a href='../index.html'>Click here to start a new query</a>." 122 #query.printset() 123 print "<hr>" 102 124 print "</body>" 103 125 print "</html>"
Note: See TracChangeset
for help on using the changeset viewer.