Changeset 489
- Timestamp:
- 02/21/05 11:38:19 (20 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r481 r489 31 31 if kwargs.has_key('mask'): 32 32 mask = kwargs.get('mask') 33 varlist = vars() 33 34 lst = tuple(args) 35 del varlist["kwargs"] 36 varlist["args"] = "%d scantables" % len(lst) 37 # need special formatting her for history... 38 34 39 from asap._asap import average as _av 35 40 for s in lst: … … 37 42 print "Please give a list of scantables" 38 43 return 39 return scantable(_av(lst, mask, scanAv, weight)) 44 s = scantable(_av(lst, mask, scanAv, weight)) 45 s._add_history("average_time",varlist) 46 return s 40 47 41 48 def quotient(source, reference, preserve=True): … … 69 76 as well as the data 70 77 """ 78 varlist = vars() 71 79 if not isinstance(left,scantable) and not isinstance(right,scantable): 72 80 print "Please provide two scantables as input" 73 81 return 74 82 from asap._asap import b_operate as _bop 75 return scantable(_bop(left, right, op, tsys)) 83 s = scantable(_bop(left, right, op, tsys)) 84 s._add_history("simple_math", varlist) 85 return s 76 86 77 87 def scale(scan, factor, insitu=None, allaxes=None, tsys=True): … … 92 102 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 93 103 if insitu is None: insitu = rcParams['insitu'] 104 varlist = vars() 94 105 if not insitu: 95 106 from asap._asap import scale as _scale 96 return scantable(_scale(scan, factor, allaxes, tsys)) 107 s = scantable(_scale(scan, factor, allaxes, tsys)) 108 s._add_history("scale",varlist) 109 return s 97 110 else: 98 111 from asap._asap import scale_insitu as _scale 99 112 _scale(scan, factor, allaxes, tsys) 113 scan._add_history("scale",varlist) 100 114 return 101 115 102 103 116 def add(scan, offset, insitu=None, allaxes=None): 104 117 """ … … 124 137 return 125 138 126 def convert_flux(scan, jyperk=None, eta=None, d=None, insitu=None, allaxes=None): 139 def convert_flux(scan, jyperk=None, eta=None, d=None, insitu=None, 140 allaxes=None): 127 141 """ 128 142 Return a scan where all spectra are converted to either Jansky or Kelvin … … 146 160 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 147 161 if insitu is None: insitu = rcParams['insitu'] 162 varlist = vars() 148 163 if jyperk is None: jyperk = -1.0 149 164 if d is None: d = -1.0 … … 151 166 if not insitu: 152 167 from asap._asap import convertflux as _convert 153 return scantable(_convert(scan, d, eta, jyperk, allaxes)) 168 s = scantable(_convert(scan, d, eta, jyperk, allaxes)) 169 s._add_history("convert_flux", varlist) 170 return s 154 171 else: 155 172 from asap._asap import convertflux_insitu as _convert 156 173 _convert(scan, d, eta, jyperk, allaxes) 174 scan._add_history("convert_flux", varlist) 157 175 return 158 176 … … 200 218 """ 201 219 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 220 if insitu is None: insitu = rcParams['insitu'] 221 varlist = vars() 202 222 if poly is None: 203 223 poly = () 204 if insitu is None: insitu = rcParams['insitu']205 224 from os.path import expandvars 206 225 filename = expandvars(filename) 207 226 if not insitu: 208 227 from asap._asap import gainel as _gainEl 209 return scantable(_gainEl(scan, poly, filename, method, allaxes)) 228 s = scantable(_gainEl(scan, poly, filename, method, allaxes)) 229 s._add_history("gain_el", varlist) 230 return s 210 231 else: 211 232 from asap._asap import gainel_insitu as _gainEl 212 233 _gainEl(scan, poly, filename, method, allaxes) 234 scan._add_history("gain_el", varlist) 213 235 return 214 236 … … 229 251 The default is taken from .asaprc (False) 230 252 """ 253 if insitu is None: insitu = rcParams['insitu'] 254 varlist = vars() 231 255 if reftime is None: reftime = '' 232 if insitu is None: insitu = rcParams['insitu']233 256 perfreqid = not perif 234 257 if not insitu: 235 258 from asap._asap import freq_align as _align 236 return scantable(_align(scan, reftime, method, perfreqid)) 259 s = scantable(_align(scan, reftime, method, perfreqid)) 260 s._add_history("freq_align", varlist) 261 return s 237 262 else: 238 263 from asap._asap import freq_align_insitu as _align 239 264 _align(scan, reftime, method, perfreqid) 265 scan._add_history("freq_align", varlist) 240 266 return 241 267 … … 257 283 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 258 284 if insitu is None: insitu = rcParams['insitu'] 285 varlist = vars() 259 286 if not insitu: 260 287 from asap._asap import opacity as _opacity 261 return scantable(_opacity(scan, tau, allaxes)) 288 s = scantable(_opacity(scan, tau, allaxes)) 289 s._add_history("opacity", varlist) 290 return s 262 291 else: 263 292 from asap._asap import opacity_insitu as _opacity 264 293 _opacity(scan, tau, allaxes) 294 scan._add_history("opacity", varlist) 265 295 return 266 296 … … 274 304 """ 275 305 if insitu is None: insitu = rcParams['insitu'] 306 varlist = vars() 276 307 if not insitu: 277 308 from asap._asap import bin as _bin 278 return scantable(_bin(scan, width)) 309 s = scantable(_bin(scan, width)) 310 s._add_history("bin",varlist) 311 return s 279 312 else: 280 313 from asap._asap import bin_insitu as _bin 281 314 _bin(scan, width) 315 scan._add_history("bin",varlist) 282 316 return 283 317 … … 293 327 """ 294 328 if insitu is None: insitu = rcParams['insitu'] 329 varlist = vars() 295 330 if not insitu: 296 331 from asap._asap import resample as _resample 297 return scantable(_resample(scan, method, width)) 332 s = scantable(_resample(scan, method, width)) 333 s._add_history("resample",varlist) 334 return s 298 335 else: 299 336 from asap._asap import resample_insitu as _resample 300 337 _resample(scan, method, width) 338 scan._add_history("resample",varlist) 301 339 return 302 340 … … 318 356 polav = average_pols(myscan) 319 357 """ 358 if insitu is None: insitu = rcParams['insitu'] 359 varlist = vars() 360 320 361 if mask is None: 321 362 mask = () 322 if insitu is None: insitu = rcParams['insitu']323 363 if not insitu: 324 364 from asap._asap import averagepol as _avpol 325 return scantable(_avpol(scan, mask, weight)) 365 s = scantable(_avpol(scan, mask, weight)) 366 s._add_history("average_pol",varlist) 367 return s 326 368 else: 327 369 from asap._asap import averagepol_insitu as _avpol 328 370 _avpol(scan, mask, weight) 371 scan._add_history("average_pol",varlist) 329 372 return 330 373 … … 352 395 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 353 396 if insitu is None: insitu = rcParams['insitu'] 397 varlist = vars() 354 398 if not insitu: 355 399 from asap._asap import smooth as _smooth 356 return scantable(_smooth(scan,kernel,width,allaxes)) 400 s = scantable(_smooth(scan,kernel,width,allaxes)) 401 s._add_history("smooth", varlist) 402 return s 357 403 else: 358 404 from asap._asap import smooth_insitu as _smooth 359 405 _smooth(scan,kernel,width,allaxes) 406 scan._add_history("smooth", varlist) 360 407 return 361 408 … … 375 422 bscan = poly_baseline(scan, order=3) 376 423 """ 424 if insitu is None: insitu = rcParams['insitu'] 425 varlist = vars() 377 426 from asap.asapfitter import fitter 378 427 if mask is None: … … 384 433 f.set_function(poly=order) 385 434 sf = f.auto_fit(insitu) 435 sf._add_history("poly_baseline", varlist) 386 436 return sf 387 437 388 def rotate_xyphase 438 def rotate_xyphase(scan, angle, allaxes=None): 389 439 """ 390 440 Rotate the phase of the XY correlation. This is always done in situ … … 400 450 """ 401 451 if allaxes is None: allaxes = rcParams['scantable.allaxes'] 452 varlist = vars() 402 453 from asap._asap import rotate_xyphase as _rotate_xyphase 403 454 _rotate_xyphase(scan, angle, allaxes) 455 s._add_history("rotate_xyphase", varlist) 404 456 return 405 -
trunk/python/scantable.py
r484 r489 27 27 (input rpfits/sdfits/ms) or replaces the value 28 28 in existing scantables 29 """ 29 """ 30 if average is None or type(average) is not bool: 31 average = rcParams['scantable.autoaverage'] 32 30 33 varlist = vars() 31 34 self._vb = rcParams['verbose'] 32 35 self._p = None 33 34 if average is None or type(average) is not bool:35 autoav = rcParams['scantable.autoaverage']36 36 37 37 if isinstance(filename,sdtable): … … 64 64 if unit is not None: 65 65 tbl.set_fluxunit(unit) 66 if a utoav:67 from asap._asap import average 66 if average: 67 from asap._asap import average as _av 68 68 tmp = tuple([tbl]) 69 69 print 'Auto averaging integrations...' 70 tbl2 = average(tmp,(),True,'none')70 tbl2 = _av(tmp,(),True,'none') 71 71 sdtable.__init__(self,tbl2) 72 72 del r,tbl … … 81 81 Parameters: 82 82 name: the name of the outputfile. For format="FITS" this 83 is the directory file name into which all the files will84 be written (default is 'asap_FITS')83 is the directory file name into which all the files 84 will be written (default is 'asap_FITS') 85 85 format: an optional file format. Default is ASAP. 86 86 Allowed are - 'ASAP' (save as ASAP [aips++] Table), … … 90 90 'MS2' (saves as an aips++ 91 91 MeasurementSet V2) 92 stokes: Convert to Stokes parameters. Default is False. 92 stokes: Convert to Stokes parameters (only available 93 currently with FITS and ASCII formats. 94 Default is False. 93 95 overwrite: If the file should be overwritten if it exists. 94 96 The default False is to return with warning … … 711 713 print "-"*80 712 714 for h in hist: 713 items = h.split("##") 714 date = items[0] 715 func = items[1] 716 items = items[2:] 717 print date 718 print "Function: %s\n Parameters:" % (func) 719 for i in items: 720 s = i.split("=") 721 print " %s: %s" % (s[0],s[1]) 722 print "-"*80 715 if h.startswith("---"): 716 print h 717 else: 718 items = h.split("##") 719 date = items[0] 720 func = items[1] 721 items = items[2:] 722 print date 723 print "Function: %s\n Parameters:" % (func) 724 for i in items: 725 s = i.split("=") 726 print " %s = %s" % (s[0],s[1]) 727 print "-"*80 723 728 return 724 729
Note:
See TracChangeset
for help on using the changeset viewer.