Changeset 1295 for trunk/monitor
- Timestamp:
- 11/06/06 22:22:03 (18 years ago)
- Location:
- trunk/monitor/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/monitor/cgi-bin/asapmon.py
r1083 r1295 10 10 abspath= "/var/www/asapmon/" 11 11 cgiloc = "/cgi-bin/asapmon/" 12 tmppath = abspath+"tmp/"12 tmppath = os.path.join(abspath,"tmp/") 13 13 htmlloc = "/asapmon/" 14 14 tmploc = "/asapmon/tmp/" … … 25 25 logsink = WritableObject() 26 26 logsink2 = WritableObject() 27 sys.stdout = logsink27 sys.stdout = logsink 28 28 sys.stderr = logsink2 29 29 import asap … … 53 53 out = [] 54 54 for i in fi: 55 out.append( p+"/"+fl.files[i])55 out.append(os.path.join(p,fl.files[i])) 56 56 return out 57 57 58 58 def decodeWindow(self,window): 59 59 if not len(window.strip()): return None,None 60 x = window.split(", ")61 return [float(x[0].strip()), float(x[1].strip())]62 63 def decodeWindows(self, window):60 x = window.split(", ") 61 return [float(x[0].strip()), float(x[1].strip())] 62 63 def decodeWindows(self, window): 64 64 import re 65 65 p = re.compile("(\\[*\d+\\.*\d*,\d+\\.*\d*\\]*)") 66 66 r = re.compile("[\\[\\]]") 67 return [self.decodeWindow(re.sub(r, '',s)) for s in re.findall(p,window)]67 return [self.decodeWindow(re.sub(r, '', s)) for s in re.findall(p, window)] 68 68 69 69 def setDefaultFields(self): … … 80 80 self.fields['imagename'] = "" 81 81 self.fields['cunit'] = 0 82 self.fields['units'] = ["channel", "km/s","GHz"]82 self.fields['units'] = ["channel", "km/s", "GHz"] 83 83 self.fields['baseline'] = 0 84 84 self.fields['cpolyorder'] = 0 … … 87 87 self.fields['doppler'] = "RADIO" 88 88 self.fields['frame'] = "LSRK" 89 self.fields['restn'] = [11, 1]89 self.fields['restn'] = [11, 1] 90 90 self.fields['stokes'] = 0 91 91 self.fields['summary'] = "" … … 98 98 99 99 def getFormFields(self): 100 self.fields['cunit'] = int(self.form.getfirst("unit", 0))101 self.fields['frame'] = self.form.getfirst("frame", "TOPO")102 self.fields['doppler'] = self.form.getfirst("doppler", "RADIO")100 self.fields['cunit'] = int(self.form.getfirst("unit", 0)) 101 self.fields['frame'] = self.form.getfirst("frame", "TOPO") 102 self.fields['doppler'] = self.form.getfirst("doppler", "RADIO") 103 103 self.fields['restn'] = [] 104 104 105 self.fields['plotwindow'] = self.form.getfirst("plotwindow", "")105 self.fields['plotwindow'] = self.form.getfirst("plotwindow", "") 106 106 self.fields['baseline'] = int(self.form.has_key("baseline")) 107 self.fields['cpolyorder'] = int(self.form.getfirst("polyorder", 0))107 self.fields['cpolyorder'] = int(self.form.getfirst("polyorder", 0)) 108 108 self.fields['quotient'] = int(self.form.has_key("quotient")) 109 self.fields['doppler'] = self.form.getfirst("doppler", "RADIO")110 self.fields['frame'] = self.form.getfirst("frame", "LSRK")111 self.fields['cdir'] = int(self.form.getfirst("dlist", None))109 self.fields['doppler'] = self.form.getfirst("doppler", "RADIO") 110 self.fields['frame'] = self.form.getfirst("frame", "LSRK") 111 self.fields['cdir'] = int(self.form.getfirst("dlist", None)) 112 112 self.fields['cfile'] = [int(k) for k in self.form.getlist("list")] 113 113 self.fields['average'] = int(self.form.has_key("average")) … … 115 115 self.fields['bin'] = int(self.form.has_key("bin")) 116 116 self.fields['debug'] = ""#self.fields['restn'] 117 self.fields['csource'] = self.form.getfirst("csource", "")117 self.fields['csource'] = self.form.getfirst("csource", "") 118 118 119 119 def getRest(self): … … 140 140 for i in self.fields['nif']: 141 141 name = "rest%d" % i 142 self.fields['restn'].append(int(self.form.getfirst(name, 0)))142 self.fields['restn'].append(int(self.form.getfirst(name, 0))) 143 143 restfs = self.getRest() 144 144 … … 151 151 if i: 152 152 # filter off scans 153 i = not re.search(re.compile("_[R, e,w]$"),i) and i153 i = not re.search(re.compile("_[R, e, w]$"), i) and i 154 154 if i: 155 155 self.fields['sourcenames'].append(i) … … 162 162 if cs in self.fields['sourcenames']: 163 163 ss = s.get_scan(self.fields['csource']) 164 if isinstance(ss, asap.scantable):164 if isinstance(ss, asap.scantable): 165 165 s = ss 166 166 del ss … … 172 172 if self.fields['cunit'] == 1: 173 173 srest = s._getrestfreqs() 174 if isinstance(srest, tuple) and len(srest) != s.nif():175 s.set_restfreqs(restfs, unit="GHz")174 if isinstance(srest, tuple) and len(srest) != s.nif(): 175 s.set_restfreqs(restfs, unit="GHz") 176 176 s.set_unit(self.fields['units'][self.fields['cunit']]) 177 s.set_freqframe(self.form.getfirst("frame", "LSRK"))178 s.set_doppler(self.form.getfirst("doppler", "RADIO"))177 s.set_freqframe(self.form.getfirst("frame", "LSRK")) 178 s.set_doppler(self.form.getfirst("doppler", "RADIO")) 179 179 180 180 # baseline … … 189 189 self.fields['brangewindow'] = brstr 190 190 m = s.create_mask(brange) 191 s.poly_baseline(mask=m, order=order)191 s.poly_baseline(mask=m, order=order) 192 192 else: 193 193 s.auto_poly_baseline(order=order) … … 217 217 asap.plotter = asap.asapplotter(False) 218 218 if outscans.nif() > 1: 219 asap.plotter.set_mode("p", "i")219 asap.plotter.set_mode("p", "i") 220 220 else: 221 221 if outscans.npol() > 2: 222 asap.plotter.set_mode("t", "p")222 asap.plotter.set_mode("t", "p") 223 223 else: 224 asap.plotter.set_mode("p", "t")224 asap.plotter.set_mode("p", "t") 225 225 asap.plotter.plot(outscans) 226 226 if self.fields['stokes']: … … 231 231 sel.set_polarisations(pols) 232 232 asap.plotter.set_selection(sel) 233 x0, x1 = self.decodeWindow(self.fields['plotwindow'])234 asap.plotter.set_range(x0, x1)233 x0, x1 = self.decodeWindow(self.fields['plotwindow']) 234 asap.plotter.set_range(x0, x1) 235 235 imname = tmppath+"plot.png" 236 asap.plotter.save(imname, dpi=96)236 asap.plotter.save(imname, dpi=96) 237 237 self.fields['imagename'] = tmploc+"plot.png" 238 except RuntimeError, e:238 except RuntimeError, e: 239 239 self.fields['debug'] = e 240 240 return -
trunk/monitor/cgi-bin/filelist.py
r739 r1295 1 1 #!/usr/bin/python 2 2 import os 3 import sre 3 4 from obsconfig import observatory 4 5 5 6 class FileList: 6 7 7 def __init__(self, loc=None ):8 def __init__(self, loc=None, projectcode=None): 8 9 self.message ="""Content-Type: text/xml 9 10 10 11 <?xml version="1.0" encoding="ISO-8859-1"?>""" 11 12 12 self.error = None 13 13 if loc is None: … … 21 21 loc = observatory['rpfpath'][loc] 22 22 if os.path.exists(loc) and os.path.isdir(loc): 23 self.files = filter(lambda x: x.lower().endswith("rpf"), os.listdir(loc)) 23 rx = sre.compile("\d{4}-\d{2}-d{2}_\d{4}-M\d{3}.rpf.*") 24 self.files = [ f for f in os.listdir(loc) if sre.match(rx, f) ] 25 if projectcode is not None: 26 self.files = [ f for f in self.files if sre.match(projectcode, 27 f) ] 24 28 if len(self.files) == 0: 25 29 self.error = "No rpfits files found" … … 42 46 import cgi 43 47 form = cgi.FieldStorage() 48 pfilter = None 49 if form.has_key('project'): 50 pfilter = form.getfirst("project", None) 44 51 if form.has_key('path'): 45 52 pathindex = form.getfirst("path",0) 46 print FileList(pathindex )53 print FileList(pathindex, pfilter) 47 54 else: 48 55 print FileList()
Note:
See TracChangeset
for help on using the changeset viewer.