示例#1
0
    def filein(self, filein, verbose=False, load=True):
        """ if no filein given, should pop up a GUI to select, but this is not supported yet
        """
        self._filein = filein
        self.mode = 1

        self._session = gbt.GBTSession(self._filein)
        if verbose: print(self._session)
        if load:
            nsrc = len(self._session.targets.keys())
            if nsrc == 1:
                src = list(self._session.targets.keys())[0]
                self._targets = self._session.load_target(src)
                print("Target: %s" % src)
            else:
                print('%d : too many targets for me now, not stored.' % nsrc)
        return self._session
示例#2
0
from __future__ import print_function
# grab the GBT reader from pyspeckit
from pyspeckit.spectrum.readers import gbt

# declare our session name and read the file
A029 = gbt.GBTSession('AGBT11B_029_01.raw.acs.fits')

# let's see what's in it
print(A029)

# reduce one of the targets
ob1 = A029.reduce_target('003918.9+402158.4')
# you can also access ob1 as A029.target['003918.9+402158.4'] or simply A029['003918.9+402158.4']

# now see what it contains
print(ob1.spectra.keys())

# Average polarizations & feeds for each IF
# (this may be poorly named)
ob1.average_IFs()
# again, check on the contents
print(ob1.spectra.keys())

# now plot IF0
ob1['if0'].plotter()

# convert to velocity units
ob1['if0'].xarr.convert_to_unit('km/s')
# and replot
ob1['if0'].plotter()
示例#3
0
from __future__ import print_function
try:
    from astropy.io import fits as pyfits
except ImportError:
    import pyfits
from pylab import *
import numpy, scipy, matplotlib
import pyspeckit
from pyspeckit.spectrum.readers import gbt

sdfitsfile = '/Users/adam/observations/gbt/h2co_pilot/AGBT09C_049_02.raw.acs.fits'
gbtdata = pyfits.open(sdfitsfile)
objectname = 'G32.80+0.19'
bintable = gbtdata[1]
A049 = gbt.GBTSession(bintable)
whobject = bintable.data['OBJECT'] == objectname
blocks = A049.load_target(objectname).blocks
onMoff1 = blocks['A9OFF1'] - blocks['A9OFF2']
onMoff1on = blocks['A9ON1'] - blocks['A9ON2']

onoffs = dict((name[:-1], blocks[name[:-1] + '1'] - blocks[name[:-1] + '2'])
              for name in blocks if name[-1] == '1')

av1 = onMoff1.average()
av1.plotter()
av2 = onMoff1on.average()
av2.plotter(axis=av1.plotter.axis, clear=False, color='b')

calonA9 = blocks['A9ON1'].average()
caloffA9 = blocks['A9OFF1'].average()
print("tsys: ", gbt.dcmeantsys(calonA9, caloffA9, calonA9.header['TCAL']))
示例#4
0
from __future__ import print_function
from pyspeckit.spectrum.readers import gbt
session = gbt.GBTSession('3C286.fits')
print(session)
session.load_target('3C286')
target = session['3C286']
sp = target.blocks['A13OFF2'][0] # there are 4 identical spectra
sp.xarr.convert_to_unit('km/s')
sp.plotter(xmin=207408,xmax=207598)
sp.plotter.label(verbose_label=True)
stats = sp.stats(statrange=(-20+207458,20+207458))
sp.error[:] = stats['std']
sp.specfit(fittype='gaussian')
sp.specfit.plotresiduals(drawstyle='line')
print("Gaussian chi^2: %g  chi^2/n: %g" % (sp.specfit.chi2, sp.specfit.chi2/sp.specfit.dof))
print("Optimal chi^2: %g  chi^2/n: %g" % (sp.specfit.optimal_chi2(reduced=False),sp.specfit.optimal_chi2()))
sp.specfit(fittype='voigt', clear=False, composite_fit_color='blue')
sp.specfit.plotresiduals(clear=False, color='blue', drawstyle='line')
print("Voigt   chi^2: %g  chi^2/n: %g" % (sp.specfit.chi2, sp.specfit.chi2/sp.specfit.dof))
print("Optimal chi^2: %g  chi^2/n: %g" % (sp.specfit.optimal_chi2(reduced=False),sp.specfit.optimal_chi2()))
sp.specfit.residualaxis.set_ylim(-0.2,0.2)

# this is usually unnecessary, but it's platform-dependent
import pylab
pylab.ion()
pylab.show()


import pyspeckit
sp1 = target.blocks['A13OFF2'][0]
sp2 = target.blocks['A13OFF2'][1]