def specrate(parlist): """Return the countrate of the spectrum as observed through the obsmode, based on the binned wavelength set; and write the resulting spectrum to a file, returning the filename.""" d=getparms(parlist) sp=parse_spec(d['spectrum']) bp=ObsBandpass(d['instrument']) #Check overlap status & proceed accordingly ostat=bp.check_overlap(sp) try: obs=Observation(sp,bp,force=odict[ostat]) except KeyError: obs=Observation(sp,bp,bp.wave,force=odict[ostat]) obs.convert('counts') try: obs.writefits(d['output'],binned=True) except KeyError: d['output']=None if ostat == 'full': return "%g;%s"%(obs.countrate(),d['output']) else: return "%g;%s;%s"%(obs.countrate(),d['output'],owarn[ostat])
def etccalc(obsmode, spectrum, filename=None): bp=ObsBandpass(obsmode) sp=parse_spec(spectrum) try: obs=Observation(sp,bp) except KeyError: obs=Observation(sp,bp,bp.wave) obs.convert('counts') if (filename is not None): if not filename.endswith('.fits'): filename=filename+'.fits' obs.writefits(filename) sp.writefits(filename.replace('.fits','_sp.fits')) bp.writefits(filename.replace('.fits','_bp.fits')) return obs.countrate(), obs.efflam(), obs.pivot()
def calcphot(parlist): """Calculate either effstim or efflam, depending on the input argument""" d=getparms(parlist) sp=parse_spec(d['spectrum']) bp=ObsBandpass(d['obsmode']) # obs=bp.observe(sp) ostat=bp.check_overlap(sp) try: obs=Observation(sp,bp,force=odict[ostat]) except KeyError: obs=Observation(sp,bp,bp.wave,force=odict[ostat]) obs.convert('counts') ans=obs.efflam() if ostat == 'full': return ans else: return ans, owarn[ostat]
def countrate(parlist): """Return the pivot wavelength and countrate of the spectrum as observed through the obsmode, but based on the native waveset""" d=getparms(parlist) sp=parse_spec(d['spectrum']) bp=ObsBandpass(d['instrument']) #Check overlap status & proceed accordingly ostat=bp.check_overlap(sp) try: obs=Observation(sp,bp,force=odict[ostat]) except KeyError: obs=Observation(sp,bp,bp.wave,force=odict[ostat]) obs.convert('counts') efflam=obs.efflam() ans=obs.countrate(binned=False) if ostat == 'full': return ans,efflam else: return ans, efflam, owarn[ostat]