dysh for GBTIDL Users#
Some key differences#
No longer tied to a single input and output file, can load as many SDFITS files as RAM allows
No longer tied to a finite number of data containers, you can have as many ScanBlock/Spectrum objects as RAM allows
Python allows for well-trackable local and global variables
Rough equivalents#
In the tables below, it is assumed you have executed the following commands in Python:
from dysh.fits.gbtfitsload import GBTFITSLoad
File I/O and Metadata Operations#
GBTIDL
dysh
Notes
online
sdf = GBTOnline(); sdf = GBTOnline([projID])
Monitor the currently online project or a specific project
projID. Load the SDFITS intosdf.offline
sdf = GBTOffline([projID])
Load data from project/session
projIDintosdf.filein, [SDFITS file]
sdfits = GBTFITSLoad( [SDFITSfile] )
This will directly load a SDFITS file into python.
dirin, [SDFITS dir]
sdfits = GBTFITSLoad( [SDFITS dir] )
This will load each SDFITS file in a directory into python, in the case it is a project directory where each file is a different VEGAS bank. (A, B, C, etc.). The implementation is identical to the single SDFITS file load.
fileout
There is no direct translation; in dysh, simply specify a filename with the spectrum.write function
keep
spec.write( [SDFITSfile], format=[fmt] )
Write the spectrum
specto the outputSDFITS filespecified, using the formatfmtsummary
sdfits.summary()
In dysh, you can also input a list of scan numbers you would like to see.
list
sdfits.summary( verbose=True )
Using the “verbose=True” option returns similar results to GBTIDL’s “list”.
header, scan_info
spec.meta
Return meta information about the spectrum
spec. In GBTIDL, this returns a text printout. In dysh, this returns a dictionary with all SDFITS keywords and values.
Calibration and Data Retrieval#
GBTIDL
dysh
explanation
select
sdf.select( [col1]=[val1], [col2]=[val2] )
Select subsets of the GBTFITSLoad object
sdfbased on the constraints oncol1andcol2given byval1andval2flag
sdf.flag( [col1]=[val1], [col2]=[val2] )
Create flagging rules of the GBTFITSLoad object
sdfbased on the constraints oncol1andcol2given byval1andval2. See flagging examples given in the Recipes.gettp, [scan_num]
sdfits.gettp( scan=[scan_num] )
Returns a Scan Block. Get a total power scan, with the option in dysh to optionally calibrate it.
getps, [scan_num]
sdfits.getps( scan=[scan_num] )
Returns a Scan Block. Retrieve and calibrate position-switched data.
getfs, [scan_num]
sdfits.getfs( scan=[scan_num] )
Returns a Scan Block. Retrieve and calibrate frequency-switched data.
getnod, [scan_num]
sdfits.getnod( scan=[scan_num] )
Returns a Scan Block.
show
spec.plot()
Plot the spectrum
spec. Calibration routines in GBTIDL do this automatically.
Spectrum Operations#
GBTIDL
dysh
Notes
baseline, bshape, bsubtract, nfit
spec.baseline( [deg], exclude=[ex_reg],remove=True/False )
Compute and optionally remove a baseline with degree
degand exclusion regionsex_reggsmooth, [int]
spec.smooth( “gauss”, [int] )
Convolve spec with a Gaussian kernel. Default behavior is to decimate, which isn’t true in GBTIDL
hanning
spec.smooth( “hann” )
Convolve
specwith a Hanning window. Default behavior is to decimate, which isn’t true in GBTIDLboxcar, [int]
spec.smooth( “box”, [int] )
Convolve
specwith a boxcar window. This matches the GBTIDL results only when integerintis an odd number. Default behavior is to decimate, which isn’t true in GBTIDLadd/subtract/divide/scale
spec + other, spec - other, spec/other, spec*other
Perform element-wise math between spectrum
specand other vector/scalarother.bias, [bias]
spec + bias
Add scalar
biasto spectrumspec. The units ofbiasmust match those ofspec.flux.accum
average_spectra(list of spectra)
ave
scanblock.timeaverage(); scan.timeaverage()
Average a set of scans inside Scan Block
scanblockor Scanscan.stats
spec.stats()
Print statistics of spectrum
spec.fshift, vshift, xshift
spec.find_shift(other)
Find the shift between
specandother.gshift
spec.shift(shift) spec.align_to(other)
Shift
specbyshift. Find the shift betweenspecandotherand apply. Equivalent tospec.shift(spec.find_shift(other)).write_ascii, filename
spec.write(filename, format=”ascii.basic”)
Write the contents of spec to a text file in ascii format with minimum header information.