Changeset 1798
- Timestamp:
- 08/02/10 10:51:45 (14 years ago)
- Location:
- branches/newfiller
- Files:
-
- 1 deleted
- 8 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/newfiller
- Property svn:mergeinfo changed
/branches/alma (added) merged: 1781-1783
- Property svn:mergeinfo changed
-
branches/newfiller/python/asapfitter.py
r1757 r1798 127 127 return 128 128 129 #@print_log_dec129 @print_log_dec 130 130 def fit(self, row=0, estimate=False): 131 131 """ … … 222 222 self.data._addfit(fit,self._fittedrow) 223 223 224 #@print_log_dec224 @print_log_dec 225 225 def set_parameters(self,*args,**kwargs): 226 226 """ … … 544 544 return self.fitter.getfit() 545 545 546 #@print_log_dec546 @print_log_dec 547 547 def commit(self): 548 548 """ … … 573 573 return scan 574 574 575 #@print_log_dec575 @print_log_dec 576 576 def plot(self, residual=False, components=None, plotparms=False, 577 577 filename=None): … … 674 674 print_log() 675 675 676 #@print_log_dec676 @print_log_dec 677 677 def auto_fit(self, insitu=None, plot=False): 678 678 """ -
branches/newfiller/python/asaplotbase.py
r1766 r1798 282 282 283 283 284 #def get_region(self):285 #pos = []286 #print "Please select the bottom/left point"287 #pos.append(self.figure.ginput(n=1, show_clicks=False)[0])288 #print "Please select the top/right point"289 #pos.append(self.figure.ginput(n=1, show_clicks=False)[0])290 #return pos291 292 #def get_point(self):293 #print "Please select the point"294 #pt = self.figure.ginput(n=1, show_clicks=False)295 #if pt:296 #return pt[0]297 #else:298 #return None284 def get_region(self): 285 pos = [] 286 print "Please select the bottom/left point" 287 pos.append(self.figure.ginput(n=1, show_clicks=False)[0]) 288 print "Please select the top/right point" 289 pos.append(self.figure.ginput(n=1, show_clicks=False)[0]) 290 return pos 291 292 def get_point(self): 293 print "Please select the point" 294 pt = self.figure.ginput(n=1, show_clicks=False) 295 if pt: 296 return pt[0] 297 else: 298 return None 299 299 300 300 def region(self): -
branches/newfiller/python/asapmath.py
r1757 r1798 6 6 from asap import asaplotgui 7 7 8 #@print_log_dec8 @print_log_dec 9 9 def average_time(*args, **kwargs): 10 10 """ … … 123 123 return s 124 124 125 #@print_log_dec125 @print_log_dec 126 126 def dototalpower(calon, caloff, tcalval=0.0): 127 127 """ … … 142 142 return s 143 143 144 #@print_log_dec144 @print_log_dec 145 145 def dosigref(sig, ref, smooth, tsysval=0.0, tauval=0.0): 146 146 """ … … 163 163 return s 164 164 165 #@print_log_dec165 @print_log_dec 166 166 def calps(scantab, scannos, smooth=1, tsysval=0.0, tauval=0.0, tcalval=0.0, verify=False): 167 167 """ … … 446 446 return ress 447 447 448 #@print_log_dec448 @print_log_dec 449 449 def calnod(scantab, scannos=[], smooth=1, tsysval=0.0, tauval=0.0, tcalval=0.0, verify=False): 450 450 """ … … 687 687 return resspec 688 688 689 #@print_log_dec689 @print_log_dec 690 690 def calfs(scantab, scannos=[], smooth=1, tsysval=0.0, tauval=0.0, tcalval=0.0, verify=False): 691 691 """ … … 895 895 return resspec 896 896 897 #@print_log_dec897 @print_log_dec 898 898 def merge(*args): 899 899 """ -
branches/newfiller/python/asapplotter.py
r1765 r1798 77 77 else: return None 78 78 79 #@print_log_dec79 @print_log_dec 80 80 def plot(self, scan=None): 81 81 """ … … 180 180 def text(self, *args, **kwargs): 181 181 if kwargs.has_key("interactive"): 182 #if kwargs.pop("interactive"): 183 # pos = self._plotter.get_point() 184 # args = tuple(pos)+args 185 kwargs.pop("interactive") 182 if kwargs.pop("interactive"): 183 pos = self._plotter.get_point() 184 args = tuple(pos)+args 186 185 self._axes_callback("text", *args, **kwargs) 187 186 … … 190 189 def arrow(self, *args, **kwargs): 191 190 if kwargs.has_key("interactive"): 192 #if kwargs.pop("interactive"): 193 # pos = self._plotter.get_region() 194 # dpos = (pos[0][0], pos[0][1], 195 # pos[1][0]-pos[0][0], 196 # pos[1][1] - pos[0][1]) 197 # args = dpos + args 198 kwargs.pop("interactive") 191 if kwargs.pop("interactive"): 192 pos = self._plotter.get_region() 193 dpos = (pos[0][0], pos[0][1], 194 pos[1][0]-pos[0][0], 195 pos[1][1] - pos[0][1]) 196 args = dpos + args 199 197 self._axes_callback("arrow", *args, **kwargs) 200 198 … … 203 201 def annotate(self, text, xy=None, xytext=None, **kwargs): 204 202 if kwargs.has_key("interactive"): 205 #if kwargs.pop("interactive"): 206 # xy = self._plotter.get_point() 207 # xytext = self._plotter.get_point() 208 kwargs.pop("interactive") 203 if kwargs.pop("interactive"): 204 xy = self._plotter.get_point() 205 xytext = self._plotter.get_point() 209 206 if not kwargs.has_key("arrowprops"): 210 207 kwargs["arrowprops"] = dict(arrowstyle="->") … … 215 212 def axvline(self, *args, **kwargs): 216 213 if kwargs.has_key("interactive"): 217 #if kwargs.pop("interactive"): 218 # pos = self._plotter.get_point() 219 # args = (pos[0],)+args 220 kwargs.pop("interactive") 214 if kwargs.pop("interactive"): 215 pos = self._plotter.get_point() 216 args = (pos[0],)+args 221 217 self._axes_callback("axvline", *args, **kwargs) 222 218 … … 225 221 def axhline(self, *args, **kwargs): 226 222 if kwargs.has_key("interactive"): 227 #if kwargs.pop("interactive"): 228 # pos = self._plotter.get_point() 229 # args = (pos[1],)+args 230 kwargs.pop("interactive") 223 if kwargs.pop("interactive"): 224 pos = self._plotter.get_point() 225 args = (pos[1],)+args 231 226 self._axes_callback("axhline", *args, **kwargs) 232 227 … … 235 230 def axvspan(self, *args, **kwargs): 236 231 if kwargs.has_key("interactive"): 237 #if kwargs.pop("interactive"): 238 # pos = self._plotter.get_region() 239 # dpos = (pos[0][0], pos[1][0]) 240 # args = dpos + args 241 kwargs.pop("interactive") 232 if kwargs.pop("interactive"): 233 pos = self._plotter.get_region() 234 dpos = (pos[0][0], pos[1][0]) 235 args = dpos + args 242 236 self._axes_callback("axvspan", *args, **kwargs) 243 237 # hack to preventy mpl from redrawing the patch … … 250 244 def axhspan(self, *args, **kwargs): 251 245 if kwargs.has_key("interactive"): 252 #if kwargs.pop("interactive"): 253 # pos = self._plotter.get_region() 254 # dpos = (pos[0][1], pos[1][1]) 255 # args = dpos + args 256 kwargs.pop("interactive") 246 if kwargs.pop("interactive"): 247 pos = self._plotter.get_region() 248 dpos = (pos[0][1], pos[1][1]) 249 args = dpos + args 257 250 self._axes_callback("axhspan", *args, **kwargs) 258 251 # hack to preventy mpl from redrawing the patch … … 1220 1213 private method for plotting total power data 1221 1214 """ 1222 from matplotlib.numeriximport ma, array, arange, logical_not1215 from numpy import ma, array, arange, logical_not 1223 1216 r=0 1224 1217 nr = scan.nrow() -
branches/newfiller/python/asapreader.py
r1757 r1798 25 25 rpfits ONLY. 26 26 """ 27 #@print_log_dec27 @print_log_dec 28 28 def __init__(self, filename, unit=None, theif=None, thebeam=None): 29 29 self.unit = unit … … 48 48 print_log() 49 49 50 #@print_log_dec50 @print_log_dec 51 51 def read(self): 52 52 """ -
branches/newfiller/python/scantable.py
r1757 r1798 36 36 """ 37 37 38 #@print_log_dec38 @print_log_dec 39 39 def __init__(self, filename, average=None, unit=None, getpt=None, antenna=None, parallactify=None): 40 40 """ … … 75 75 tmpstr = '' 76 76 for i in range( len(antenna) ): 77 if type(antenna[i]) == int: 78 tmpstr = tmpstr + ('%s,'%(antenna[i])) 77 if type(antenna[i]) == int: 78 tmpstr = tmpstr + ('%s,'%(antenna[i])) 79 79 elif type(antenna[i]) == str: 80 80 tmpstr=tmpstr+antenna[i]+',' … … 82 82 asaplog.push('Bad antenna selection.') 83 83 print_log('ERROR') 84 return 84 return 85 85 antenna = tmpstr.rstrip(',') 86 86 parallactify = parallactify or rcParams['scantable.parallactify'] … … 128 128 print_log() 129 129 130 #@print_log_dec130 @print_log_dec 131 131 def save(self, name=None, format=None, overwrite=False): 132 132 """ … … 485 485 if stat.lower().endswith('_abc'): rtnabc = True 486 486 getchan = False 487 if stat.lower().startswith('min') or stat.lower().startswith('max'): 487 if stat.lower().startswith('min') or stat.lower().startswith('max'): 488 488 chan = self._math._minmaxchan(self, mask, stat) 489 489 getchan = True … … 522 522 if self.npol(-1) > 1: out += ' Pol[%d] ' % (self.getpol(i)) 523 523 #outvec.append(callback(i)) 524 #out += ('= %'+form) % (outvec[i]) +' '+refstr+'\n' 525 out += ('= %'+form) % (statvals[i]) +' '+refstr+'\n' 524 #out += ('= %'+form) % (outvec[i]) +' '+refstr+'\n' 525 out += ('= %'+form) % (statvals[i]) +' '+refstr+'\n' 526 526 out += sep+"\n" 527 527 … … 752 752 return self._get_column(self._getdirectionvec, row) 753 753 754 #@print_log_dec754 @print_log_dec 755 755 def set_unit(self, unit='channel'): 756 756 """ … … 768 768 self._add_history("set_unit", varlist) 769 769 770 #@print_log_dec770 @print_log_dec 771 771 def set_instrument(self, instr): 772 772 """ … … 780 780 print_log() 781 781 782 #@print_log_dec782 @print_log_dec 783 783 def set_feedtype(self, feedtype): 784 784 """ … … 791 791 print_log() 792 792 793 #@print_log_dec793 @print_log_dec 794 794 def set_doppler(self, doppler='RADIO'): 795 795 """ … … 805 805 print_log() 806 806 807 #@print_log_dec807 @print_log_dec 808 808 def set_freqframe(self, frame=None): 809 809 """ … … 927 927 else: raise 928 928 self._add_history("flag_row", varlist) 929 929 930 930 def clip(self, uthres=None, dthres=None, clipoutside=True, unflag=False): 931 931 """ … … 950 950 self._add_history("clip", varlist) 951 951 952 #@print_log_dec952 @print_log_dec 953 953 def lag_flag(self, start, end, unit="MHz", insitu=None): 954 954 #def lag_flag(self, frequency, width=0.0, unit="GHz", insitu=None): … … 994 994 return s 995 995 996 #@print_log_dec996 @print_log_dec 997 997 def create_mask(self, *args, **kwargs): 998 998 """ … … 1221 1221 # list values are scalars 1222 1222 if isinstance(freqs[-1], int) or isinstance(freqs[-1], float): 1223 self._setrestfreqs(freqs, [""], unit)1223 self._setrestfreqs(freqs, [""], unit) 1224 1224 # list values are tuples, (value, name) 1225 1225 elif isinstance(freqs[-1], dict): … … 1233 1233 #self._setselection(savesel) 1234 1234 self._setrestfreqs(freqs["value"], 1235 freqs["name"], "MHz")1235 freqs["name"], unit) 1236 1236 elif isinstance(freqs[-1], list) or isinstance(freqs[-1], tuple): 1237 1237 sel = selector() … … 1243 1243 sel.set_ifs(iflist[i]) 1244 1244 self._setselection(sel) 1245 self._setrestfreqs(freqs[i]["value"], 1246 freqs[i]["name"], "MHz") 1245 self._setrestfreqs(freqs[i], [""], unit) 1247 1246 self._setselection(savesel) 1248 1247 # freqs are to be taken from a linecatalog … … 1324 1323 # Maths business 1325 1324 # 1326 #@print_log_dec1325 @print_log_dec 1327 1326 def average_time(self, mask=None, scanav=False, weight='tint', align=False): 1328 1327 """ … … 1376 1375 return s 1377 1376 1378 #@print_log_dec1377 @print_log_dec 1379 1378 def convert_flux(self, jyperk=None, eta=None, d=None, insitu=None): 1380 1379 """ … … 1405 1404 else: return s 1406 1405 1407 #@print_log_dec1406 @print_log_dec 1408 1407 def gain_el(self, poly=None, filename="", method="linear", insitu=None): 1409 1408 """ … … 1460 1459 return s 1461 1460 1462 #@print_log_dec1461 @print_log_dec 1463 1462 def freq_align(self, reftime=None, method='cubic', insitu=None): 1464 1463 """ … … 1486 1485 else: return s 1487 1486 1488 #@print_log_dec1487 @print_log_dec 1489 1488 def opacity(self, tau=None, insitu=None): 1490 1489 """ … … 1515 1514 else: return s 1516 1515 1517 #@print_log_dec1516 @print_log_dec 1518 1517 def bin(self, width=5, insitu=None): 1519 1518 """ … … 1536 1535 return s 1537 1536 1538 #@print_log_dec1537 @print_log_dec 1539 1538 def resample(self, width=5, method='cubic', insitu=None): 1540 1539 """ 1541 1540 Return a scan where all spectra have been binned up. 1542 1541 1543 1542 Parameters: 1544 1543 width: The bin width (default=5) in pixels … … 1559 1558 else: return s 1560 1559 1561 #@print_log_dec1560 @print_log_dec 1562 1561 def average_pol(self, mask=None, weight='none'): 1563 1562 """ … … 1577 1576 return s 1578 1577 1579 #@print_log_dec1578 @print_log_dec 1580 1579 def average_beam(self, mask=None, weight='none'): 1581 1580 """ … … 1607 1606 self._add_history("parallactify", varlist) 1608 1607 1609 #@print_log_dec1608 @print_log_dec 1610 1609 def convert_pol(self, poltype=None): 1611 1610 """ … … 1632 1631 return s 1633 1632 1634 #@print_log_dec1633 @print_log_dec 1635 1634 def smooth(self, kernel="hanning", width=5.0, order=2, plot=False, insitu=None): 1636 1635 """ … … 1706 1705 else: return s 1707 1706 1708 #@print_log_dec1707 @print_log_dec 1709 1708 def poly_baseline(self, mask=None, order=0, plot=False, uselin=False, 1710 1709 insitu=None): … … 1734 1733 if mask is None: 1735 1734 mask = [True for i in xrange(self.nchan(-1))] 1736 1735 1737 1736 from asap.asapfitter import fitter 1738 1737 try: … … 1746 1745 if len(rows) > 0: 1747 1746 self.blpars = [] 1748 1747 1749 1748 for r in rows: 1750 1749 # take into account flagtra info (CAS-1434) … … 1779 1778 print_log() 1780 1779 if insitu: self._assign(workscan) 1781 else: return workscan 1780 else: return workscan 1782 1781 except RuntimeError: 1783 1782 msg = "The fit failed, possibly because it didn't converge." … … 1913 1912 f.data = None 1914 1913 f.fit() 1915 1914 1916 1915 # Show mask list 1917 1916 masklist=workscan.get_masklist(fl.get_mask(),row=r) … … 1939 1938 return workscan 1940 1939 1941 #@print_log_dec1940 @print_log_dec 1942 1941 def rotate_linpolphase(self, angle): 1943 1942 """ … … 1956 1955 return 1957 1956 1958 #@print_log_dec1957 @print_log_dec 1959 1958 def rotate_xyphase(self, angle): 1960 1959 """ … … 1973 1972 return 1974 1973 1975 #@print_log_dec1974 @print_log_dec 1976 1975 def swap_linears(self): 1977 1976 """ … … 1985 1984 return 1986 1985 1987 #@print_log_dec1986 @print_log_dec 1988 1987 def invert_phase(self): 1989 1988 """ … … 1996 1995 return 1997 1996 1998 #@print_log_dec1997 @print_log_dec 1999 1998 def add(self, offset, insitu=None): 2000 1999 """ … … 2017 2016 return s 2018 2017 2019 #@print_log_dec2018 @print_log_dec 2020 2019 def scale(self, factor, tsys=True, insitu=None): 2021 2020 """ … … 2085 2084 self._add_history("set_sourcetype", varlist) 2086 2085 2087 #@print_log_dec2086 @print_log_dec 2088 2087 def auto_quotient(self, preserve=True, mode='paired', verify=False): 2089 2088 """ … … 2129 2128 return s 2130 2129 2131 #@print_log_dec2130 @print_log_dec 2132 2131 def mx_quotient(self, mask = None, weight='median', preserve=True): 2133 2132 """ … … 2152 2151 return q 2153 2152 2154 #@print_log_dec2153 @print_log_dec 2155 2154 def freq_switch(self, insitu=None): 2156 2155 """ … … 2172 2171 else: return s 2173 2172 2174 #@print_log_dec2173 @print_log_dec 2175 2174 def recalc_azel(self): 2176 2175 """ … … 2186 2185 return 2187 2186 2188 #@print_log_dec2187 @print_log_dec 2189 2188 def __add__(self, other): 2189 varlist = vars() 2190 s = None 2191 if isinstance(other, scantable): 2192 s = scantable(self._math._binaryop(self, other, "ADD")) 2193 elif isinstance(other, float): 2194 s = scantable(self._math._unaryop(self, other, "ADD", False)) 2195 else: 2196 raise TypeError("Other input is not a scantable or float value") 2197 s._add_history("operator +", varlist) 2198 return s 2199 2200 @print_log_dec 2201 def __sub__(self, other): 2190 2202 """ 2191 2203 implicit on all axes and on Tsys 2192 2204 """ 2193 return self._operation( other, "ADD" ) 2194 2195 #@print_log_dec 2196 def __sub__(self, other): 2205 varlist = vars() 2206 s = None 2207 if isinstance(other, scantable): 2208 s = scantable(self._math._binaryop(self, other, "SUB")) 2209 elif isinstance(other, float): 2210 s = scantable(self._math._unaryop(self, other, "SUB", False)) 2211 else: 2212 raise TypeError("Other input is not a scantable or float value") 2213 s._add_history("operator -", varlist) 2214 return s 2215 2216 @print_log_dec 2217 def __mul__(self, other): 2197 2218 """ 2198 2219 implicit on all axes and on Tsys 2199 2220 """ 2200 return self._operation( other, 'SUB' ) 2201 2202 #@print_log_dec 2203 def __mul__(self, other): 2221 varlist = vars() 2222 s = None 2223 if isinstance(other, scantable): 2224 s = scantable(self._math._binaryop(self, other, "MUL")) 2225 elif isinstance(other, float): 2226 s = scantable(self._math._unaryop(self, other, "MUL", False)) 2227 else: 2228 raise TypeError("Other input is not a scantable or float value") 2229 s._add_history("operator *", varlist) 2230 return s 2231 2232 2233 @print_log_dec 2234 def __div__(self, other): 2204 2235 """ 2205 2236 implicit on all axes and on Tsys 2206 2237 """ 2207 return self._operation( other, 'MUL' ) 2208 2209 #@print_log_dec 2210 def __div__(self, other): 2211 """ 2212 implicit on all axes and on Tsys 2213 """ 2214 return self._operation( other, 'DIV' ) 2238 varlist = vars() 2239 s = None 2240 if isinstance(other, scantable): 2241 s = scantable(self._math._binaryop(self, other, "DIV")) 2242 elif isinstance(other, float): 2243 if other == 0.0: 2244 raise ZeroDivisionError("Dividing by zero is not recommended") 2245 s = scantable(self._math._unaryop(self, other, "DIV", False)) 2246 else: 2247 raise TypeError("Other input is not a scantable or float value") 2248 s._add_history("operator /", varlist) 2249 return s 2215 2250 2216 2251 def get_fit(self, row=0): … … 2389 2424 for i in range(len(self)): 2390 2425 yield self[i] 2391 2392 def _operation(self, other, opmode):2393 varlist = vars()2394 s = None2395 import numpy2396 if isinstance(other, scantable):2397 s = scantable(self._math._binaryop(self.copy(), other, opmode))2398 elif isinstance(other, float) or isinstance(other, int):2399 if opmode == 'DIV' and float(other) == 0.0:2400 raise ZeroDivisionError("Dividing by zero is not recommended")2401 s = scantable(self._math._unaryop(self.copy(), other, opmode, False))2402 elif isinstance(other, list) or isinstance(other, numpy.ndarray):2403 if isinstance(other[0], list) or isinstance(other[0], numpy.ndarray):2404 from asapmath import _array2dOp2405 s = _array2dOp( self.copy(), other, opmode, False )2406 else:2407 s = scantable(self._math._arrayop(self.copy(), other, opmode, False))2408 else:2409 raise TypeError("Other input is not a scantable or float value or float list")2410 opdic = {}2411 opdic['ADD'] = '+'2412 opdic['SUB'] = '-'2413 opdic['MUL'] = '*'2414 opdic['DIV'] = '/'2415 s._add_history("operator %s" % opdic[opmode], varlist)2416 print_log()2417 return s2418 2419 -
branches/newfiller/src/SConscript
-
Property svn:mergeinfo
set to
/branches/alma/src/SConscript merged eligible /branches/asap-3.x/src/SConscript merged eligible /trunk/src/SConscript merged eligible
r1328 r1798 3 3 # import root environment 4 4 Import( "env") 5 myenv = env.C opy()5 myenv = env.Clone() 6 6 7 7 # gather cpp files -
Property svn:mergeinfo
set to
Note:
See TracChangeset
for help on using the changeset viewer.