- Timestamp:
- 03/29/12 15:20:23 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/opacity.py
r1927 r2447 7 7 from asap.selector import selector 8 8 from asap._asap import atmosphere 9 9 from asap import rcParams 10 10 11 11 class model(object): … … 151 151 plot: Plot each fit (airmass vs. Tsys). Default is 'False' 152 152 """ 153 if plot: 154 from matplotlib import pylab 155 scan = _import_data(data) 156 f = fitter() 157 f.set_function(poly=1) 158 sel = selector() 159 basesel = scan.get_selection() 160 inos = scan.getifnos() 161 pnos = scan.getpolnos() 162 opacities = [] 163 om = model(temperature, pressure, humidity) 164 for ino in inos: 165 sel.set_ifs(ino) 166 opacity = [] 167 fits = [] 168 airms = [] 169 tsyss = [] 153 # quiten output 154 verbose = rcParams["verbose"] 155 rcParams["verbose"] = False 156 try: 170 157 if plot: 171 pylab.cla() 172 pylab.ioff() 173 pylab.clf() 174 pylab.xlabel("Airmass") 175 pylab.ylabel(r"$T_{sys}$") 176 for pno in pnos: 177 sel.set_polarisations(pno) 178 scan.set_selection(basesel+sel) 179 freq = scan.get_coordinate(0).get_reference_value()/1e9 180 freqstr = "%0.4f GHz" % freq 181 tsys = scan.get_tsys() 182 elev = scan.get_elevation() 183 airmass = [ 1./math.sin(i) for i in elev ] 184 airms.append(airmass) 185 tsyss.append(tsys) 186 f.set_data(airmass, tsys) 187 f.fit() 188 fits.append(f.get_fit()) 189 params = f.get_parameters()["params"] 190 opacity.append(params[1]/tsky) 191 if averagepol: 192 opacities.append(sum(opacity)/len(opacity)) 193 else: 194 opacities += opacity 158 from matplotlib import pylab 159 scan = _import_data(data) 160 f = fitter() 161 f.set_function(poly=1) 162 sel = selector() 163 basesel = scan.get_selection() 164 inos = scan.getifnos() 165 pnos = scan.getpolnos() 166 opacities = [] 167 om = model(temperature, pressure, humidity) 168 for ino in inos: 169 sel.set_ifs(ino) 170 opacity = [] 171 fits = [] 172 airms = [] 173 tsyss = [] 174 if plot: 175 pylab.cla() 176 pylab.ioff() 177 pylab.clf() 178 pylab.xlabel("Airmass") 179 pylab.ylabel(r"$T_{sys}$") 180 for pno in pnos: 181 sel.set_polarisations(pno) 182 scan.set_selection(basesel+sel) 183 freq = scan.get_coordinate(0).get_reference_value()/1e9 184 freqstr = "%0.4f GHz" % freq 185 tsys = scan.get_tsys() 186 elev = scan.get_elevation() 187 airmass = [ 1./math.sin(i) for i in elev ] 188 airms.append(airmass) 189 tsyss.append(tsys) 190 f.set_data(airmass, tsys) 191 f.fit() 192 fits.append(f.get_fit()) 193 params = f.get_parameters()["params"] 194 opacity.append(params[1]/tsky) 195 if averagepol: 196 opacities.append(sum(opacity)/len(opacity)) 197 else: 198 opacities += opacity 199 if plot: 200 colors = ['b','g','k'] 201 n = len(airms) 202 for i in range(n): 203 pylab.plot(airms[i], tsyss[i], 'o', color=colors[i]) 204 pylab.plot(airms[i], fits[i], '-', color=colors[i]) 205 pylab.figtext(0.7,0.3-(i/30.0), 206 r"$\tau_{fit}=%0.2f$" % opacity[i], 207 color=colors[i]) 208 if averagepol: 209 pylab.figtext(0.7,0.3-(n/30.0), 210 r"$\tau_{avg}=%0.2f$" % opacities[-1], 211 color='r') 212 n +=1 213 pylab.figtext(0.7,0.3-(n/30.0), 214 r"$\tau_{model}=%0.2f$" % om.get_opacities(freq*1e9), 215 color='grey') 216 217 pylab.title("IF%d : %s" % (ino, freqstr)) 218 219 pylab.ion() 220 pylab.draw() 221 raw_input("Hit <return> for next fit...") 222 sel.reset() 223 224 scan.set_selection(basesel) 195 225 if plot: 196 colors = ['b','g','k'] 197 n = len(airms) 198 for i in range(n): 199 pylab.plot(airms[i], tsyss[i], 'o', color=colors[i]) 200 pylab.plot(airms[i], fits[i], '-', color=colors[i]) 201 pylab.figtext(0.7,0.3-(i/30.0), 202 r"$\tau_{fit}=%0.2f$" % opacity[i], 203 color=colors[i]) 204 if averagepol: 205 pylab.figtext(0.7,0.3-(n/30.0), 206 r"$\tau_{avg}=%0.2f$" % opacities[-1], 207 color='r') 208 n +=1 209 pylab.figtext(0.7,0.3-(n/30.0), 210 r"$\tau_{model}=%0.2f$" % om.get_opacities(freq*1e9), 211 color='grey') 212 213 pylab.title("IF%d : %s" % (ino, freqstr)) 214 215 pylab.ion() 216 pylab.draw() 217 raw_input("Hit <return> for next fit...") 218 sel.reset() 219 220 scan.set_selection(basesel) 221 if plot: 222 pylab.close() 223 return opacities 226 pylab.close() 227 return opacities 228 finally: 229 rcParams["verbose"] = verbose
Note:
See TracChangeset
for help on using the changeset viewer.