- Timestamp:
- 04/27/10 15:48:24 (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/CHANGELOG
r1600 r1725 2 2 ========= 3 3 4 Release 3.0.0 [ ]4 Release 3.0.0 [2010-04-??] 5 5 6 * Ticket #177 Added function skydip to determine opacities. 7 * Ticket #172 Fixed non-working scantable.resample 6 8 * Ticket #155 Better output filenames. Ignore non-existsing beams/pols/ifs/scans 7 9 * Ticket #157 numpy >= 1.1 support 8 10 * Ticket #158 fixed plotter.set_font 9 * Ticket #160 Aspect ration of pplotter customisable 10 * Ticket #162 - fill in 11 * Ticket #160 Aspect ratio of plotter is customisable now 11 12 * Ticket #163 fixed for scantable.set_sourcetype 12 13 * Ticket #164 Upgrade note in wiki FAQ … … 22 23 * Interactive plotting annotations via optional argument interactive=True 23 24 * Interactive creation of masks on the plotter - plotter.create_mask 25 * Tidy up date range in asapplotter.plotazel/plotpointings 24 26 25 27 Release 2.3.1 [2009-03-25] -
trunk/python/__init__.py
r1721 r1725 393 393 from linecatalog import linecatalog 394 394 from opacity import skydip 395 from opacity import model as opacity_model 395 396 396 397 if rcParams['useplotter']: … … 412 413 413 414 def is_ipython(): 414 return ' __IP' in dir(sys.modules["__main__"])415 return 'IPython' in sys.modules.keys() 415 416 416 417 if is_ipython(): … … 630 631 scantable.create_mask 631 632 skydip - gain opacity values from a sky dip observation 633 opacity_model - compute opacities fro given frequencies based on 634 atmospheric model 632 635 633 636 Note: -
trunk/python/opacity.py
r1722 r1725 6 6 from asap import selector 7 7 from asap import rcParams 8 from asap import xyplotter 8 from asap._asap import atmosphere 9 10 11 class model(object): 12 def _to_pascals(self, val): 13 if val > 2000: 14 return val 15 return val*100 16 17 def __init__(self, temperature=288, pressure=101325., humidity=0.5, 18 elevation=700.): 19 """ 20 This class implements opacity/atmospheric brightness temperature model 21 equivalent to the model available in MIRIAD. The actual math is a 22 convertion of the Fortran code written by Bob Sault for MIRIAD. 23 It implements a simple model of the atmosphere and Liebe's model (1985) 24 of the complex refractive index of air. 25 26 The model of the atmosphere is one with an exponential fall-off in 27 the water vapour content (scale height of 1540 m) and a temperature 28 lapse rate of 6.5 mK/m. Otherwise the atmosphere obeys the ideal gas 29 equation and hydrostatic equilibrium. 30 31 Note, the model includes atmospheric lines up to 800 GHz, but was not 32 rigorously tested above 100 GHz and for instruments located at 33 a significant elevation. For high-elevation sites it may be necessary to 34 adjust scale height and lapse rate. 35 36 Parameters: 37 temperature: air temperature at the observatory (K) 38 pressure: air pressure at the sea level if the observatory 39 elevation is set to non-zero value (note, by 40 default is set to 700m) or at the observatory 41 ground level if the elevation is set to 0. (The 42 value is in Pascals or hPa, default 101325 Pa 43 humidity: air humidity at the observatory (fractional), 44 default is 0.5 45 elevation: observatory elevation about sea level (in meters) 46 """ 47 self._atm = atmosphere(temp, self._to_pascals(pressure), humidity) 48 self.set_observatory_elevation(elevation): 49 50 def get_opacities(self, freq, elevation=None): 51 """Get the opacity value(s) for the fiven frequency(ies). 52 If no elevation is given the opacities for the zenith are returned. 53 If an elevation is specified refraction is also taken into account. 54 Parameters: 55 freq: a frequency value in Hz, or a list of frequency values. 56 One opacity value per frequency is returned as a scalar 57 or list. 58 elevation: the elevation at which to compute the opacity. If `None` 59 is given (default) the zenith opacity is returned. 60 61 62 """ 63 func = None 64 if isinstance(freq, (list, tuple)): 65 if elevation is None: 66 return self._atm.zenith_opacities(freq) 67 else: 68 elevation *= math.pi/180. 69 return self._atm.opacities(freq, elevation) 70 else: 71 if elevation is None: 72 return self._atm.zenith_opacity(freq) 73 else: 74 elevation *= math.pi/180. 75 return self._atm.opacity(freq, elevation) 76 77 def set_weather(self, temperature, pressure, humidity): 78 """Update the model using the given environmental parameters. 79 Parameters: 80 temperature: air temperature at the observatory (K) 81 pressure: air pressure at the sea level if the observatory 82 elevation is set to non-zero value (note, by 83 default is set to 700m) or at the observatory 84 ground level if the elevation is set to 0. (The 85 value is in Pascals or hPa, default 101325 Pa 86 humidity: air humidity at the observatory (fractional), 87 default is 0.5 88 """ 89 pressure = self._to_pascals(pressure) 90 self._atm.set_weather(temperature, pressure, humidity) 91 92 def set_observatory_elevation(self, elevation: 93 """Update the model using the given the observatory elevation 94 Parameters: 95 elevation: the elevation at which to compute the opacity. If `None` 96 is given (default) the zenith opacity is returned. 97 """ 98 self._atm.set_observatory_elevation(el) 99 9 100 10 101 def _import_data(data): … … 27 118 return merge(tables) 28 119 29 def skydip(data, averagepol=True, tsky=300., plot=False): 120 def skydip(data, averagepol=True, tsky=300., plot=False, 121 temperature=288, pressure=101325., humidity=0.5): 30 122 """Determine the opacity from a set of 'skydip' obervations. 31 123 This can be any set of observations over a range of elevations, … … 60 152 rcsave = rcParams['verbose'] 61 153 rcParams['verbose'] = False 154 if plot: 155 from matplotlib import pylab 62 156 scan = _import_data(data) 63 157 f = fitter() … … 68 162 pnos = scan.getpolnos() 69 163 opacities = [] 164 om = opacitymodel(temperature, pressure, humidity) 70 165 for ino in inos: 71 166 sel.set_ifs(ino) … … 74 169 airms = [] 75 170 tsyss = [] 76 77 171 if plot: 78 xyplotter.cla()79 xyplotter.ioff()80 xyplotter.clf()81 xyplotter.xlabel("Airmass")82 xyplotter.ylabel(r"$T_{sys}$")172 pylab.cla() 173 pylab.ioff() 174 pylab.clf() 175 pylab.xlabel("Airmass") 176 pylab.ylabel(r"$T_{sys}$") 83 177 for pno in pnos: 84 178 sel.set_polarisations(pno) … … 102 196 if plot: 103 197 colors = ['b','g','k'] 104 for i in range(len(airms)): 105 xyplotter.plot(airms[i], tsyss[i], 'o', color=colors[i]) 106 xyplotter.plot(airms[i], fits[i], '-', color=colors[i]) 107 xyplotter.figtext(0.7,0.3-(i/30.0), 198 n = len(airms) 199 for i in range(n): 200 pylab.plot(airms[i], tsyss[i], 'o', color=colors[i]) 201 pylab.plot(airms[i], fits[i], '-', color=colors[i]) 202 pylab.figtext(0.7,0.3-(i/30.0), 108 203 r"$\tau_{fit}=%0.2f$" % opacity[i], 109 204 color=colors[i]) 110 205 if averagepol: 111 xyplotter.figtext(0.7,0.3-(len(airms)/30.0),112 r"$\tau =%0.2f$" % opacities[-1],206 pylab.figtext(0.7,0.3-(n/30.0), 207 r"$\tau_{avg}=%0.2f$" % opacities[-1], 113 208 color='r') 114 xyplotter.title("IF%d : %s" % (ino, freqstr)) 115 116 xyplotter.ion() 117 xyplotter.draw() 209 n +=1 210 pylab.figtext(0.7,0.3-(n/30.0), 211 r"$\tau_{model}=%0.2f$" % om.get_opacities(freq*1e9), 212 color='grey') 213 214 pylab.title("IF%d : %s" % (ino, freqstr)) 215 216 pylab.ion() 217 pylab.draw() 118 218 raw_input("Hit <return> for next fit...") 119 219 sel.reset() … … 122 222 rcParams['verbose'] = rcsave 123 223 if plot: 124 xyplotter.close()224 pylab.close() 125 225 return opacities -
trunk/python/scantable.py
r1697 r1725 1115 1115 1116 1116 @print_log_dec 1117 def opacity(self, tau , insitu=None):1117 def opacity(self, tau=None, insitu=None): 1118 1118 """ 1119 1119 Apply an opacity correction. The data … … 1126 1126 nIF*nPol or 1 and in order of IF/POL, e.g. 1127 1127 [opif0pol0, opif0pol1, opif1pol0 ...] 1128 if tau is `None` the opacities are determined from a 1129 model. 1128 1130 insitu: if False a new scantable is returned. 1129 1131 Otherwise, the scaling is done in-situ -
trunk/src/STFiller.cpp
r1586 r1725 241 241 if ( status != 0 ) break; 242 242 n += 1; 243 244 243 Regex filterrx(".*[SL|PA]$"); 245 244 Regex obsrx("^AT.+"); -
trunk/src/python_STAtmosphere.cpp
r1715 r1725 44 44 .def( init < double, double, double > () ) 45 45 .def("set_weather", &STAtmosphere::setWeather) 46 .def("set_observatory_elevation", &STAtmosphere::setObservatoryElevation) 46 .def("set_observatory_elevation", 47 &STAtmosphere::setObservatoryElevation) 47 48 .def("zenith_opacity", &STAtmosphere::zenithOpacity) 48 49 .def("zenith_opacities", &STAtmosphere::zenithOpacities) -
trunk/test/test_scantable.py
r1600 r1725 1 1 import unittest 2 2 import datetime 3 from asap import scantable, selector, rcParams 3 from asap import scantable, selector, rcParams, mask_not 4 4 rcParams["verbose"] = False 5 5 … … 8 8 9 9 self.st = scantable("data/MOPS.rpf", average=True) 10 restfreqs = [86.243] # 13CO-1/0, SiO the two IF 11 self.st.set_restfreqs(restfreqs,"GHz") 10 12 11 13 def test_init(self): … … 135 137 self.assertEqual(s1.getscannos(), (1,)) 136 138 139 def test_flag(self): 140 q = self.st.auto_quotient() 141 q.set_unit('km/s') 142 q0 = q.copy() 143 q1 = q.copy() 144 msk = q0.create_mask([-10,20]) 145 q0.flag(mask=mask_not(msk)) 146 self.assertAlmostEqual(q0.stats(stat='max')[0], 95.62171936) 147 q1.flag(mask=msk) 148 self.assertAlmostEqual(q1.stats(stat='max')[0], 2.66563416) 137 149 138 150 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.