Reading in and writing out observations

Contents

Reading in and writing out observations#

Loading SDFITS files#

Classes and functions for importing SDFITS files

SDFITSLoad#

Load generic SDFITS files - Not typically used directly. Sub-class for specific telescope SDFITS flavors.

class dysh.fits.sdfitsload.SDFITSLoad(filename, source=None, hdu=None, **kwargs)[source]#

Bases: object

Generic Container for a bintable(s) from selected HDU(s) for a single SDFITS file. For multiple SDFITS files, see GBTFITSLoad.

Parameters:
filenamestr

input file name

sourcestr

target source to select from input file. Default: all sources

hduint or list

Header Data Unit to select from input file. Default: all HDUs

Attributes:
binheader

The list of bintable headers

bintable

The list of bintables

columns

The column names in the binary table, minus the DATA column

filename

The input SDFITS filename

total_rows

Returns the total number of rows summed over all binary table HDUs

Methods

create_index([hdu, skipindex])

Create the index of the SDFITS file.

delete_column(column)

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

fix_meta(meta)

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place.

getrow(i[, bintable])

Get a FITS_record from the input bintable

getspec(i[, bintable, observer_location, ...])

Get a row (record) as a Spectrum

index([hdu, bintable])

Return The index table.

info()

Return the HDUList info()

load([hdu])

Load the bintable for given hdu.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan(bintable)

The number of channels per row of the input bintable.

nintegrations(bintable[, source])

The number of integrations on a given source divided by the number of polarizations

npol(bintable)

The number of polarizations present in the input bintable.

nrows(bintable)

The number of rows of the input bintable

rawspectra(bintable[, setmask])

Get the raw (unprocessed) spectra from the input bintable.

rawspectrum(i[, bintable, setmask])

Get a single raw (unprocessed) spectrum from the input bintable.

rename_column(oldname, newname)

Rename a column in both index table and any binary tables in this SDFITSLoad

scans(bintable)

The number of scans present in the input bintable.

sources(bintable)

The number of sources present in the input bintable.

summary()

Print a summary of each record of the data

udata(key[, bintable])

The unique list of values of a given header keyword

ushow(key[, bintable])

Print the unique list of values of a given header keyword

velocity_convention(veldef, velframe)

Compute the velocity convention string use for velocity conversions, given the VELDEF and VELFRAME values.

write(fileobj[, rows, bintable, flags, ...])

Write the SDFITSLoad to a new file, potentially sub-selecting rows or bintables.

property binheader#

The list of bintable headers

property bintable#

The list of bintables

property columns#

The column names in the binary table, minus the DATA column

Returns:
~pandas.Index

The column names as a DataFrame Index

create_index(hdu=None, skipindex=['DATA', 'FLAGS'])[source]#

Create the index of the SDFITS file.

Parameters:
hduint or list

Header Data Unit to select from input file. Default: all HDUs

skipindexlist

List of str column names to not put in the index. The default are the multidimensional columns DATA and FLAGS

delete_column(column)[source]#

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

Parameters:
columnstr or list-like

The column name(s) to delete.

Returns:
None.
property filename#

The input SDFITS filename

fix_meta(meta)[source]#

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place. At minimum this method must populate meta[‘VELDEF’] and meta[‘VELFRAME’]

Parameters:
metadict

The header of the Spectrum to be fixed, corresponding to the meta attribute of the Spectrum.

getrow(i, bintable=0)[source]#

Get a FITS_record from the input bintable

Parameters:
iint

The record (row) index to retrieve

bintableint

The index of the bintable attribute

Returns:
rowFITS_record

The i-th record of the input bintable

getspec(i, bintable=0, observer_location=None, setmask=False)[source]#

Get a row (record) as a Spectrum

Parameters:
iint

The record (row) index to retrieve

bintableint, optional

The index of the bintable attribute. default is 0.

observer_locationEarthLocation

Location of the observatory. See Observatory. This will be transformed to ITRS using the time of observation DATE-OBS or MJD-OBS in the SDFITS header. The default is None.

setmaskbool

If True, set the data mask according to the current flags in the _flagmask attribute.

Returns:
sSpectrum

The Spectrum object representing the data row.

index(hdu=None, bintable=None)[source]#

Return The index table.

Parameters:
hduint or list

Header Data Unit to select from the index. Default: all HDUs

bintableint

The index of the bintable attribute, None means all bintables

Returns:
index~pandas.DataFrame

The index of this SDFITS file

info()[source]#

Return the HDUList info()

load(hdu=None, **kwargs)[source]#

Load the bintable for given hdu. Note mmHg and UTC are unrecognized units. mmHg is in astropy.units.cds but UTC is just wrong.

Parameters:
hduint or list

Header Data Unit to select from input file. Default: all HDUs

naxis(naxis, bintable)[source]#

The NAXISn value of the input bintable.

Parameters:
naxisint

The NAXIS whose length is requested

bintableint

The index of the bintable attribute

Returns:
naxisthe length of the NAXIS
nchan(bintable)[source]#

The number of channels per row of the input bintable. Assumes all rows have same length.

Parameters:
bintableint

The index of the bintable attribute

Returns:
nchanint

Number channels in the first spectrum of the input bintable

nintegrations(bintable, source=None)[source]#

The number of integrations on a given source divided by the number of polarizations

Parameters:
bintableint

The index of the bintable attribute

source: str

The source name (OBJECT keyword) or None for all sources. Default: None

Returns:
nintegrationsthe number of integrations
npol(bintable)[source]#

The number of polarizations present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
npol: int

Number of polarizations as given by CRVAL4 FITS header keyword.

nrows(bintable)[source]#

The number of rows of the input bintable

Parameters:
bintableint

The index of the bintable attribute

Returns:
nrowsint

Number of rows, i.e., the length of the input bintable

rawspectra(bintable, setmask=False)[source]#

Get the raw (unprocessed) spectra from the input bintable.

Parameters:
bintableint

The index of the bintable attribute

setmaskbool

If True, set the data mask according to the current flags in the _flagmask attribute. If False, set the data mask to False.

Returns:
rawspectra~numpy.ma.MaskedArray

The DATA column of the input bintable, masked according to setmask

rawspectrum(i, bintable=0, setmask=False)[source]#

Get a single raw (unprocessed) spectrum from the input bintable.

Parameters:
iint

The row index to retrieve.

bintableint or None

The index of the bintable attribute. If None, the underlying bintable is computed from i

setmaskbool

If True, set the data mask according to the current flags in the _flagmask attribute.

Returns
——-
rawspectrum~numpy.ma.MaskedArray

The i-th row of DATA column of the input bintable, masked according to setmask

rename_column(oldname, newname)[source]#

Rename a column in both index table and any binary tables in this SDFITSLoad

Parameters:
oldnamestr

The SDFITS binary table column to rename, e.g. ‘SITELAT’, case insensitive

newnamestr

The new name for the SDFITS binary table column, case insensitive

All names will be uppercased before rename.
Returns:
None.
scans(bintable)[source]#

The number of scans present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
scans: int

Number of scans as given by SCAN FITS header keyword.

sources(bintable)[source]#

The number of sources present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
sources: int

Number of sources as given by OBJECT FITS header keyword.

summary()[source]#

Print a summary of each record of the data

property total_rows#

Returns the total number of rows summed over all binary table HDUs

udata(key, bintable=None)[source]#

The unique list of values of a given header keyword

Parameters:
keystr

The keyword to retrieve

bintableint

The index of the bintable attribute, None means all bintables

Returns:
udatalist

The unique set of values for the input keyword.

ushow(key, bintable=None)[source]#

Print the unique list of values of a given header keyword

Parameters:
keystr

The keyword to retrieve

bintableint

The index of the bintable attribute, None means all bintables

velocity_convention(veldef, velframe)[source]#

Compute the velocity convention string use for velocity conversions, given the VELDEF and VELFRAME values. Return value must be a recognized string of Spectrum1D, one of {“doppler_relativistic”, “doppler_optical”, “doppler_radio”} Sub-classes should implement, because different observatories use VELDEF and VELFRAME inconsistently. This base class method hard-coded to return “doppler_radio.”

Parameters:
veldefstr

The velocity definition string (VELDEF FITS keyword)

velframestr

The velocity frame string (VELFRAME FITS keyword)

write(fileobj, rows=None, bintable=None, flags=True, output_verify='exception', overwrite=False, checksum=False)[source]#

Write the SDFITSLoad to a new file, potentially sub-selecting rows or bintables.

Parameters:
fileobjstr, file-like or pathlib.Path

File to write to. If a file object, must be opened in a writeable mode.

rows: int or list-like

Range of rows in the bintable(s) to write out. e.g. 0, [14,25,32]. Default: None, meaning all rows Note: Currently rows, if given, must be contained in a single bintable and bintable must be given

bintableint

The index of the bintable attribute or None for all bintables. Default: None

flags: bool, optional

If True, write the applied flags to a FLAGS column in the binary table

output_verifystr

Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". May also be any combination of "fix" or "silentfix" with "+ignore", +warn, or +exception" (e.g. ``"fix+warn"). See https://docs.astropy.org/en/latest/io/fits/api/verification.html for more info

overwritebool, optional

If True, overwrite the output file if it exists. Raises an OSError if False and the output file exists. Default is False.

checksumbool

When True adds both DATASUM and CHECKSUM cards to the headers of all HDU’s written to the file.

GBTFITSLoad#

Load SDFITS files produced by the Green Bank Telescope

class dysh.fits.gbtfitsload.GBTFITSLoad(fileobj, source=None, hdu=None, skipflags=False, **kwargs)[source]#

Bases: SDFITSLoad, HistoricalBase

GBT-specific container to represent one or more SDFITS files

Parameters:
fileobjstr or pathlib.Path

File to read or directory path. If a directory, all FITS files within will be read in.

sourcestr

target source to select from input file(s). Default: all sources

hduint or list

Header Data Unit to select from input file. Default: all HDUs

skipflags: bool

If True, do not read any flag files associated with these data. Default:False

Attributes:
binheader

The list of bintable headers

bintable

The list of bintables

columns

The column names in the binary table, minus the DATA column

comments

Get the comment strings.

filename

The input SDFITS filename

files

The list of SDFITS file(s) that make up this GBTFITSLoad object

final_flags

The merged flag rules in the Flag object.

final_selection

The merged selection rules in the Selection object.

flags

The data flag object

history

Get the history strings.

projectID

The project identification

selection

The data selection object

total_rows

Returns the total number of rows summed over all files and binary table HDUs

Methods

add_comment(comment[, add_time])

Add one or more comments to the class metadata.

add_history(history[, add_time])

Add one or more history entries to the class metadata

apply_flags()

Set the channel flags according to the rules specified in the flags attribute.

calonoff_rows([scans, bintable, fitsindex])

Get individual scan row numbers sorted by whether the calibration (diode) was on or off, and selected by ifnum,plnum, fdnum,subref,bintable.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex])

Create the index of the SDFITS file.

delete_column(column)

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

filenames()

The list of SDFITS filenames(s) that make up this GBTFITSLoad object

fix_meta(meta)

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place.

flag([tag])

Add one or more exact flag rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be flagged.

flag_channel(channel[, tag])

Select channels and/or channel ranges.

flag_range([tag])

Flag a range of inclusive values for a given key(s).

flag_within([tag])

Flag a value within a plus or minus for a given key(s).

getfs([calibrate, fold, shift_method, ...])

Retrieve and calibrate frequency-switched data.

getnod([calibrate, timeaverage, polaverage, ...])

Retrieve and calibrate nodding data.

getps([calibrate, timeaverage, polaverage, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable])

Get a FITS_record from the input bintable

getspec(i[, bintable, observer_location, ...])

Get a row (record) as a Spectrum

gettp([sig, cal, calibrate, timeaverage, ...])

Get a total power scan, optionally calibrating it.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

load([hdu])

Load the bintable for given hdu.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan(bintable)

The number of channels per row of the input bintable.

nintegrations(bintable[, source])

The number of integrations on a given source divided by the number of polarizations

npol(bintable)

The number of polarizations present in the input bintable.

nrows(bintable)

The number of rows of the input bintable

onoff_rows([scans, ifnum, plnum, bintable, ...])

Get individual ON/OFF (position switch) scan row numbers selected by ifnum,plnum, bintable.

onoff_scan_list([scans, ifnum, plnum, ...])

Get the scans for position-switch data sorted

rawspectra(bintable, fitsindex[, setmask])

Get the raw (unprocessed) spectra from the input bintable.

rawspectrum(i[, bintable, fitsindex, setmask])

Get a single raw (unprocessed) spectrum from the input bintable.

rename_column(oldname, newname)

Rename a column in both index table and any binary tables in this SDFITSLoad

scan_rows(scans[, ifnum, plnum, bintable, ...])

Get scan rows selected by ifnum,plnum, bintable.

scans(bintable)

The number of scans present in the input bintable.

select([tag])

Add one or more exact selection rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be selected.

select_channel(channel[, tag])

Select channels and/or channel ranges.

select_range([tag])

Select a range of inclusive values for a given key(s).

select_within([tag])

Select a value within a plus or minus for a given key(s).

sources(bintable)

The number of sources present in the input bintable.

subbeamnod([method, sig, cal, calibrate, ...])

Get a subbeam nod power scan, optionally calibrating it.

summary([scans, verbose, show_index])

Create a summary list of the input dataset.

udata(key[, bintable])

The unique list of values of a given header keyword

ushow(key[, bintable])

Print the unique list of values of a given header keyword

velocity_convention(veldef)

Given the GBT VELDEF FITS string return the specutils velocity convention, e.g., "doppler_radio"

velocity_frame(veldef)

Given the GBT VELDEF FITS string return the velocity frame, e.g., "heliocentric".

write(fileobj[, multifile, flags, verbose, ...])

Write all or a subset of the GBTFITSLoad data to a new SDFITS file(s).

apply_flags()[source]#

Set the channel flags according to the rules specified in the flags attribute. This sets numpy masks in the underlying SDFITSLoad objects.

Returns:
None.
calonoff_rows(scans=None, bintable=None, fitsindex=0, **kwargs)[source]#

Get individual scan row numbers sorted by whether the calibration (diode) was on or off, and selected by ifnum,plnum, fdnum,subref,bintable.

Parameters:
scansint or list-like

The scan numbers to find the rows of

ifnumint

the IF index

plnumint

the polarization index

fdnumint

the feed index

subrefint

the subreflector state (-1,0,1)

bintableint

the index for BINTABLE containing the scans

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

Returns:
rowsdict

A dictionary with keys ‘ON’ and ‘OFF’ giving the row indices of CALON and CALOFF data for the input scan(s)

clear_flags()[source]#

Clear all flags for these data

clear_selection()[source]#

Clear all selections for these data

property columns#

The column names in the binary table, minus the DATA column

Returns:
~pandas.Index

The column names as a DataFrame Index

filenames()[source]#

The list of SDFITS filenames(s) that make up this GBTFITSLoad object

Returns:
filenameslist

list of str filenames

property files#

The list of SDFITS file(s) that make up this GBTFITSLoad object

Returns:
fileslist

list of PosixPath objects

property final_flags#

The merged flag rules in the Flag object. See final()

Returns:
~pandas.DataFrame

The final merged flags

property final_selection#

The merged selection rules in the Selection object. See final()

Returns:
~pandas.DataFrame

The final merged selection

flag(tag=None, **kwargs)[source]#

Add one or more exact flag rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be flagged. For instance flag(object=['3C273', 'NGC1234']) will select data for either of those objects and flag(ifnum=[0,2]) will flag IF number 0 or IF number 2. Channels for selected data can be flagged using keyword channel, e.g., flag(object='MBM12',channel=[0,23]) will flag channels 0 through 23 inclusive for object MBM12. See Flag.

Parameters:
tagstr

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valueany

The value to select

flag_channel(channel, tag=None)[source]#

Select channels and/or channel ranges. These are NOT used in final() but rather will be used to create a mask for flagging. Single arrays/tuples will be treated as channel lists; nested arrays will be treated as ranges, for instance

`` # flag channel 128 flag_channel(128) # flags channels 1 and 10 flag_channel([1,10]) # flags channels 1 thru 10 inclusive flag_channel([[1,10]]) # flags channel ranges 1 thru 10 and 47 thru 56 inclusive, and channel 75 flag_channel([[1,10], [47,56], 75)]) # tuples also work, though can be harder for a human to read flag_channel(((1,10), [47,56], 75)) ``

See Flag.

Parameters:
channelnumber, or array-like

The channels to flag

Returns:
None.
flag_range(tag=None, **kwargs)[source]#

Flag a range of inclusive values for a given key(s). e.g., key1 = (v1,v2), key2 = (v3,v4), ... will select data v1 <= data1 <= v2, v3 <= data2 <= v4, ... ` Upper and lower limits may be given by setting one of the tuple values to None. e.g., `key1 = (None,v1) for an upper limit data1 <= v1 and key1 = (v1,None) for a lower limit data >=v1. Lower limits may also be specified by a one-element tuple key1 = (v1,). See Flag.

Parameters:
tagstr, optional

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valuearray-like

Tuple or list giving the lower and upper limits of the range.

Returns:
None.
flag_within(tag=None, **kwargs)[source]#

Flag a value within a plus or minus for a given key(s). e.g. key1 = [value1,epsilon1], key2 = [value2,epsilon2], ... Will select data value1-epsilon1 <= data1 <= value1+epsilon1, value2-epsilon2 <= data2 <= value2+epsilon2,...

See Flag.

Parameters:
tagstr, optional

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valuearray-like

Tuple or list giving the value and epsilon

Returns:
None.
property flags#

The data flag object

Returns:
~dysh.util.Flag

The Flag object

getfs(calibrate=True, fold=True, shift_method='fft', use_sig=True, timeaverage=True, polaverage=False, weights='tsys', bintable=None, smoothref=1, apply_flags=True, observer_location=<EarthLocation (882593.9465029, -4924896.36541728, 3943748.74743984) m>, **kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

foldboolean, optional

Fold the sig and ref scans. The default is True.

shift_methodstr

Method to use when shifting the spectra for folding. One of ‘fft’ or ‘interpolate’. ‘fft’ uses a phase shift in the time domain. ‘interpolate’ interpolates the signal. Default: ‘fft’.

use_sigboolean, optional

Return the sig or ref based spectrum. This applies to both the folded and unfolded option. The default is True. NOT IMPLEMENTED YET

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

observer_locationEarthLocation

Location of the observatory. See Observatory. This will be transformed to ITRS using the time of observation DATE-OBS or MJD-OBS in the SDFITS header. The default is the location of the GBT.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more`~spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(calibrate=True, timeaverage=True, polaverage=False, weights='tsys', bintable=None, smoothref=1, apply_flags=True, **kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables. (This keyword should eventually go away)

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly taggeed using PROCSCAN which BEAM1 and BEAM2 are.

Returns:
scanblockScanBlock

ScanBlock containing one or more NodScan.

Raises:
Exception

If scans matching the selection criteria are not found.

getps(calibrate=True, timeaverage=True, polaverage=False, weights='tsys', bintable=None, smoothref=1, apply_flags=True, **kwargs)[source]#

Retrieve and calibrate position-switched data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables. (This keyword should eventually go away)

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

getspec(i, bintable=0, observer_location=<EarthLocation (882593.9465029, -4924896.36541728, 3943748.74743984) m>, fitsindex=0, setmask=False)[source]#

Get a row (record) as a Spectrum

Parameters:
iint

The record (row) index to retrieve

bintableint, optional

The index of the bintable attribute. default is 0.

observer_locationEarthLocation

Location of the observatory. See Observatory. This will be transformed to ITRS using the time of observation DATE-OBS or MJD-OBS in the SDFITS header. The default is the location of the GBT.

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

setmaskbool

If True, set the data mask according to the current flags. Default:False Note: if apply_flags() has not been called, flags will not yet be set.

Returns
——-
sSpectrum

The Spectrum object representing the data row.

gettp(sig=None, cal=None, calibrate=True, timeaverage=True, polaverage=False, weights='tsys', bintable=None, smoothref=1, apply_flags=True, **kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
sigbool or None

True to use only integrations where signal state is True, False to use reference state (signal state is False). None to use all integrations.

cal: bool or None

True to use only integrations where calibration (diode) is on, False if off. None to use all integrations regardless calibration state. The system temperature will be calculated from both states regardless of the value of this variable.

calibrate: bool

whether or not to calibrate the data. If True, the data will be (calon - caloff)*0.5, otherwise it will be SDFITS row data. Default:True

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weights: str or None

None or ‘tsys’ to indicate equal weighting or tsys weighting to use in time averaging. Default: ‘tsys’

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

index(hdu=None, bintable=None, fitsindex=None)[source]#

Return The index table

Parameters:
hduint or list

Header Data Unit to select from the index. Default: all HDUs

bintableint

The index of the bintable attribute, None means all bintables

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad. Default:None meaning return one index over all files.

Returns:
index~pandas.DataFrame

The index of this GBTFITSLoad

info()[source]#

Return information on the HDUs contained in this object. See HDUList/info()

onoff_rows(scans=None, ifnum=0, plnum=0, bintable=None, fitsindex=0)[source]#

Get individual ON/OFF (position switch) scan row numbers selected by ifnum,plnum, bintable.

Parameters:
scansint or list-like

The scan numbers to find the rows of

ifnumint

the IF index

plnumint

the polarization index

bintableint

the index for BINTABLE in sdfits containing the scans

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

Returns:
rowsdict

A dictionary with keys ‘ON’ and ‘OFF’ giving the row indices of the ON and OFF data for the input scan(s)

onoff_scan_list(scans=None, ifnum=0, plnum=0, bintable=None, fitsindex=0)[source]#
Get the scans for position-switch data sorted

by ON and OFF state

Parameters:
scansint or list-like

The scan numbers to find the rows of

ifnumint

the IF index

plnumint

the polarization index

Returns:
rowsdict

A dictionary with keys ‘ON’ and ‘OFF’ giving the scan numbers of ON and OFF data for the input scan(s)

property projectID#

The project identification

Returns:
str

The project ID string

rawspectra(bintable, fitsindex, setmask=False)[source]#

Get the raw (unprocessed) spectra from the input bintable.

Parameters:
bintableint

The index of the bintable attribute

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

setmaskboolean

If True, set the mask according to the current flags. Default:False

Returns:
rawspectra~numpy.ndarray

The DATA column of the input bintable, masked according to setmask

rawspectrum(i, bintable=0, fitsindex=0, setmask=False)[source]#

Get a single raw (unprocessed) spectrum from the input bintable.

Parameters:
iint

The row index to retrieve.

bintableint or None

The index of the bintable attribute. If None, the underlying bintable is computed from i

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

setmaskbool

If True, set the data mask according to the current flags. Default:False Note: if apply_flags() has not been called, flags will not yet be set.

Returns
——-
rawspectrum~numpy.ma.MaskedArray

The i-th row of DATA column of the input bintable, masked according to setmask

scan_rows(scans, ifnum=0, plnum=0, bintable=None, fitsindex=0)[source]#

Get scan rows selected by ifnum,plnum, bintable.

Parameters:
scansint or list-like

The scan numbers to find the rows of

ifnumint

the IF index

plnumint

the polarization index

bintableint

the index for BINTABLE in sdfits containing the scans. Default:None

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad. Default:0

Returns:
rowslist

Lists of the rows in each bintable that contain the scans. Index of rows is the bintable index number

select(tag=None, **kwargs)[source]#

Add one or more exact selection rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be selected. For instance select(object=['3C273', 'NGC1234']) will select data for either of those objects and select(ifnum=[0,2]) will select IF number 0 or IF number 2. See Selection.

Parameters:
tagstr

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valueany

The value to select

select_channel(channel, tag=None)[source]#

Select channels and/or channel ranges. These are NOT used in final() but rather will be used to create a mask for calibration or flagging. Single arrays/tuples will be treated as channel lists; nested arrays will be treated as ranges, for instance

`` # selects channels 1 and 10 select_channel([1,10]) # selects channels 1 thru 10 inclusive select_channel([[1,10]]) # select channel ranges 1 thru 10 and 47 thru 56 inclusive, and channel 75 select_channel([[1,10], [47,56], 75)]) # tuples also work, though can be harder for a human to read select_channel(((1,10), [47,56], 75)) ``

See Selection.

Parameters:
channelnumber, or array-like

The channels to select

Returns:
None.
select_range(tag=None, **kwargs)[source]#

Select a range of inclusive values for a given key(s). e.g., key1 = (v1,v2), key2 = (v3,v4), ... will select data v1 <= data1 <= v2, v3 <= data2 <= v4, ... ` Upper and lower limits may be given by setting one of the tuple values to None. e.g., `key1 = (None,v1) for an upper limit data1 <= v1 and key1 = (v1,None) for a lower limit data >=v1. Lower limits may also be specified by a one-element tuple key1 = (v1,). See Selection.

Parameters:
tagstr, optional

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valuearray-like

Tuple or list giving the lower and upper limits of the range.

Returns:
None.
select_within(tag=None, **kwargs)[source]#

Select a value within a plus or minus for a given key(s). e.g. key1 = [value1,epsilon1], key2 = [value2,epsilon2], ... Will select data value1-epsilon1 <= data1 <= value1+epsilon1, value2-epsilon2 <= data2 <= value2+epsilon2,...

See Selection.

Parameters:
tagstr, optional

An identifying tag by which the rule may be referred to later. If None, a randomly generated tag will be created.

keystr

The key (SDFITS column name or other supported key)

valuearray-like

Tuple or list giving the value and epsilon

Returns:
None.
property selection#

The data selection object

Returns:
~dysh.util.Selection

The Selection object

subbeamnod(method='cycle', sig=None, cal=None, calibrate=True, timeaverage=True, polaverage=False, weights='tsys', bintable=None, smoothref=1, apply_flags=True, **kwargs)[source]#

Get a subbeam nod power scan, optionally calibrating it.

Parameters:
method: str

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ is more accurate and averages data in each SUBREF_STATE cycle. ‘scan’ reproduces GBTIDL’s snodka function which has been shown to be less accurate. Default:’cycle’

sigbool

True to indicate if this is the signal scan, False if reference

cal: bool

True if calibration (diode) is on, False if off.

calibrate: bool

whether or not to calibrate the data. If True, the data will be (calon - caloff)*0.5, otherwise it will be SDFITS row data. Default:True

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weights: str or None

None to indicate equal weighting or ‘tsys’ to indicate tsys weighting to use in time averaging. Default: ‘tsys’

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
dataScanBlock

A ScanBlock containing one or more SubBeamNodScan

summary(scans=None, verbose=False, show_index=True)[source]#

Create a summary list of the input dataset. If verbose=False (default), some numeric data (e.g., RESTFREQ, AZIMUTH, ELEVATIO) are averaged over the records with the same scan number.

Parameters:
scansint or 2-tuple

The scan(s) to use. A 2-tuple represents (beginning, ending) scans. Default: show all scans

verbose: bool

If True, list every record, otherwise return a compact summary

show_index: bool

If True, show the DataFrame index column. Default: False

Returns:
summary - DataFrame

Summary of the data as a DataFrame.

property total_rows#

Returns the total number of rows summed over all files and binary table HDUs

velocity_convention(veldef)[source]#

Given the GBT VELDEF FITS string return the specutils velocity convention, e.g., “doppler_radio”

Parameters:
veldefstr

The FITS header VELDEF string

Returns:
conventionstr

The velocity convention

velocity_frame(veldef)[source]#

Given the GBT VELDEF FITS string return the velocity frame, e.g., “heliocentric”.

Parameters:
veldefstr

The FITS header VELDEF string

Returns:
frame: str

The velocity frame

write(fileobj, multifile=True, flags=True, verbose=False, output_verify='exception', overwrite=False, checksum=False, **kwargs)[source]#

Write all or a subset of the GBTFITSLoad data to a new SDFITS file(s).

Parameters:
fileobjstr, file-like or pathlib.Path

File to write to. If a file object, must be opened in a writeable mode.

multifile: bool, optional

If True, write to multiple files if and only if there are multiple SDFITS files in this GBTFITSLoad. Otherwise, write to a single SDFITS file.

flags: bool, optional

If True, write the applied flags to a FLAGS column in the binary table.

verbose: bool, optional

If True, print out some information about number of rows written per file

output_verifystr

Output verification option. Must be one of "fix", "silentfix", "ignore", "warn", or "exception". May also be any combination of "fix" or "silentfix" with "+ignore", +warn, or +exception" (e.g. ``"fix+warn"). See https://docs.astropy.org/en/latest/io/fits/api/verification.html for more info

overwritebool, optional

If True, overwrite the output file if it exists. Raises an OSError if False and the output file exists. Default is False.

checksumbool

When True adds both DATASUM and CHECKSUM cards to the headers of all HDU’s written to the file.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

class dysh.fits.gbtfitsload.GBTOffline(fileobj, *args, **kwargs)[source]#

Bases: GBTFITSLoad

GBTOffline(‘foo’) connects to a GBT project ‘foo’ using GBTFITSLoad

Note project directories are assumed to exist in /home/sdfits or whereever dysh_data thinks your /home/sdfits lives.

Also note in GBTIDL one can use SDFITS_DATA instead of DYSH_DATA

Attributes:
binheader

The list of bintable headers

bintable

The list of bintables

columns

The column names in the binary table, minus the DATA column

comments

Get the comment strings.

filename

The input SDFITS filename

files

The list of SDFITS file(s) that make up this GBTFITSLoad object

final_flags

The merged flag rules in the Flag object.

final_selection

The merged selection rules in the Selection object.

flags

The data flag object

history

Get the history strings.

projectID

The project identification

selection

The data selection object

total_rows

Returns the total number of rows summed over all files and binary table HDUs

Methods

add_comment(comment[, add_time])

Add one or more comments to the class metadata.

add_history(history[, add_time])

Add one or more history entries to the class metadata

apply_flags()

Set the channel flags according to the rules specified in the flags attribute.

calonoff_rows([scans, bintable, fitsindex])

Get individual scan row numbers sorted by whether the calibration (diode) was on or off, and selected by ifnum,plnum, fdnum,subref,bintable.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex])

Create the index of the SDFITS file.

delete_column(column)

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

filenames()

The list of SDFITS filenames(s) that make up this GBTFITSLoad object

fix_meta(meta)

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place.

flag([tag])

Add one or more exact flag rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be flagged.

flag_channel(channel[, tag])

Select channels and/or channel ranges.

flag_range([tag])

Flag a range of inclusive values for a given key(s).

flag_within([tag])

Flag a value within a plus or minus for a given key(s).

getfs([calibrate, fold, shift_method, ...])

Retrieve and calibrate frequency-switched data.

getnod([calibrate, timeaverage, polaverage, ...])

Retrieve and calibrate nodding data.

getps([calibrate, timeaverage, polaverage, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable])

Get a FITS_record from the input bintable

getspec(i[, bintable, observer_location, ...])

Get a row (record) as a Spectrum

gettp([sig, cal, calibrate, timeaverage, ...])

Get a total power scan, optionally calibrating it.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

load([hdu])

Load the bintable for given hdu.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan(bintable)

The number of channels per row of the input bintable.

nintegrations(bintable[, source])

The number of integrations on a given source divided by the number of polarizations

npol(bintable)

The number of polarizations present in the input bintable.

nrows(bintable)

The number of rows of the input bintable

onoff_rows([scans, ifnum, plnum, bintable, ...])

Get individual ON/OFF (position switch) scan row numbers selected by ifnum,plnum, bintable.

onoff_scan_list([scans, ifnum, plnum, ...])

Get the scans for position-switch data sorted

rawspectra(bintable, fitsindex[, setmask])

Get the raw (unprocessed) spectra from the input bintable.

rawspectrum(i[, bintable, fitsindex, setmask])

Get a single raw (unprocessed) spectrum from the input bintable.

rename_column(oldname, newname)

Rename a column in both index table and any binary tables in this SDFITSLoad

scan_rows(scans[, ifnum, plnum, bintable, ...])

Get scan rows selected by ifnum,plnum, bintable.

scans(bintable)

The number of scans present in the input bintable.

select([tag])

Add one or more exact selection rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be selected.

select_channel(channel[, tag])

Select channels and/or channel ranges.

select_range([tag])

Select a range of inclusive values for a given key(s).

select_within([tag])

Select a value within a plus or minus for a given key(s).

sources(bintable)

The number of sources present in the input bintable.

subbeamnod([method, sig, cal, calibrate, ...])

Get a subbeam nod power scan, optionally calibrating it.

summary([scans, verbose, show_index])

Create a summary list of the input dataset.

udata(key[, bintable])

The unique list of values of a given header keyword

ushow(key[, bintable])

Print the unique list of values of a given header keyword

velocity_convention(veldef)

Given the GBT VELDEF FITS string return the specutils velocity convention, e.g., "doppler_radio"

velocity_frame(veldef)

Given the GBT VELDEF FITS string return the velocity frame, e.g., "heliocentric".

write(fileobj[, multifile, flags, verbose, ...])

Write all or a subset of the GBTFITSLoad data to a new SDFITS file(s).

class dysh.fits.gbtfitsload.GBTOnline(fileobj=None, *args, **kwargs)[source]#

Bases: GBTFITSLoad

GBTOnline(‘foo’) monitors project ‘foo’ as if it could be online GBTOnline() monitors for new projects and connects, and refreshes when updated

Note project directories are assumed to exist in /home/sdfits or whereever dysh_data thinks your /home/sdfits lives.

Also note in GBTIDL one can use SDFITS_DATA instead of DYSH_DATA

Use dysh_data(‘?’) as a method to get all filenames in SDFITS_DATA

GBTIDL says: Connecting to file: …..

File has not been updated in xxx.xx minutes.

Attributes:
binheader

The list of bintable headers

bintable

The list of bintables

columns

The column names in the binary table, minus the DATA column

comments

Get the comment strings.

filename

The input SDFITS filename

files

The list of SDFITS file(s) that make up this GBTFITSLoad object

final_flags

The merged flag rules in the Flag object.

final_selection

The merged selection rules in the Selection object.

flags

The data flag object

history

Get the history strings.

projectID

The project identification

selection

The data selection object

total_rows

Returns the total number of rows summed over all files and binary table HDUs

Methods

add_comment(comment[, add_time])

Add one or more comments to the class metadata.

add_history(history[, add_time])

Add one or more history entries to the class metadata

apply_flags()

Set the channel flags according to the rules specified in the flags attribute.

calonoff_rows([scans, bintable, fitsindex])

Get individual scan row numbers sorted by whether the calibration (diode) was on or off, and selected by ifnum,plnum, fdnum,subref,bintable.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex])

Create the index of the SDFITS file.

delete_column(column)

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

filenames()

The list of SDFITS filenames(s) that make up this GBTFITSLoad object

fix_meta(meta)

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place.

flag([tag])

Add one or more exact flag rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be flagged.

flag_channel(channel[, tag])

Select channels and/or channel ranges.

flag_range([tag])

Flag a range of inclusive values for a given key(s).

flag_within([tag])

Flag a value within a plus or minus for a given key(s).

getfs(**kwargs)

Retrieve and calibrate frequency-switched data.

getnod(**kwargs)

Retrieve and calibrate nodding data.

getps(**kwargs)

Retrieve and calibrate position-switched data.

getrow(i[, bintable])

Get a FITS_record from the input bintable

getspec(i[, bintable, observer_location, ...])

Get a row (record) as a Spectrum

gettp(**kwargs)

Get a total power scan, optionally calibrating it.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

load([hdu])

Load the bintable for given hdu.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan(bintable)

The number of channels per row of the input bintable.

nintegrations(bintable[, source])

The number of integrations on a given source divided by the number of polarizations

npol(bintable)

The number of polarizations present in the input bintable.

nrows(bintable)

The number of rows of the input bintable

onoff_rows([scans, ifnum, plnum, bintable, ...])

Get individual ON/OFF (position switch) scan row numbers selected by ifnum,plnum, bintable.

onoff_scan_list([scans, ifnum, plnum, ...])

Get the scans for position-switch data sorted

rawspectra(bintable, fitsindex[, setmask])

Get the raw (unprocessed) spectra from the input bintable.

rawspectrum(i[, bintable, fitsindex, setmask])

Get a single raw (unprocessed) spectrum from the input bintable.

rename_column(oldname, newname)

Rename a column in both index table and any binary tables in this SDFITSLoad

scan_rows(scans[, ifnum, plnum, bintable, ...])

Get scan rows selected by ifnum,plnum, bintable.

scans(bintable)

The number of scans present in the input bintable.

select([tag])

Add one or more exact selection rules, e.g., key1 = value1, key2 = value2, ... If value is array-like then a match to any of the array members will be selected.

select_channel(channel[, tag])

Select channels and/or channel ranges.

select_range([tag])

Select a range of inclusive values for a given key(s).

select_within([tag])

Select a value within a plus or minus for a given key(s).

sources(bintable)

The number of sources present in the input bintable.

subbeamnod(**kwargs)

Get a subbeam nod power scan, optionally calibrating it.

summary(**kwargs)

reload, if need be

udata(key[, bintable])

The unique list of values of a given header keyword

ushow(key[, bintable])

Print the unique list of values of a given header keyword

velocity_convention(veldef)

Given the GBT VELDEF FITS string return the specutils velocity convention, e.g., "doppler_radio"

velocity_frame(veldef)

Given the GBT VELDEF FITS string return the velocity frame, e.g., "heliocentric".

write(fileobj[, multifile, flags, verbose, ...])

Write all or a subset of the GBTFITSLoad data to a new SDFITS file(s).

getfs(**kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

foldboolean, optional

Fold the sig and ref scans. The default is True.

shift_methodstr

Method to use when shifting the spectra for folding. One of ‘fft’ or ‘interpolate’. ‘fft’ uses a phase shift in the time domain. ‘interpolate’ interpolates the signal. Default: ‘fft’.

use_sigboolean, optional

Return the sig or ref based spectrum. This applies to both the folded and unfolded option. The default is True. NOT IMPLEMENTED YET

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

observer_locationEarthLocation

Location of the observatory. See Observatory. This will be transformed to ITRS using the time of observation DATE-OBS or MJD-OBS in the SDFITS header. The default is the location of the GBT.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more`~spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(**kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables. (This keyword should eventually go away)

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly taggeed using PROCSCAN which BEAM1 and BEAM2 are.

Returns:
scanblockScanBlock

ScanBlock containing one or more NodScan.

Raises:
Exception

If scans matching the selection criteria are not found.

getps(**kwargs)[source]#

Retrieve and calibrate position-switched data.

Parameters:
calibrateboolean, optional

Calibrate the scans. The default is True.

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weightsstr or None, optional

How to weight the spectral data when averaging. ‘tsys’ means use system temperature weighting (see e.g., timeaverage()); None means uniform weighting. The default is ‘tsys’.

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables. (This keyword should eventually go away)

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

gettp(**kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
sigbool or None

True to use only integrations where signal state is True, False to use reference state (signal state is False). None to use all integrations.

cal: bool or None

True to use only integrations where calibration (diode) is on, False if off. None to use all integrations regardless calibration state. The system temperature will be calculated from both states regardless of the value of this variable.

calibrate: bool

whether or not to calibrate the data. If True, the data will be (calon - caloff)*0.5, otherwise it will be SDFITS row data. Default:True

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weights: str or None

None or ‘tsys’ to indicate equal weighting or tsys weighting to use in time averaging. Default: ‘tsys’

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

subbeamnod(**kwargs)[source]#

Get a subbeam nod power scan, optionally calibrating it.

Parameters:
method: str

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ is more accurate and averages data in each SUBREF_STATE cycle. ‘scan’ reproduces GBTIDL’s snodka function which has been shown to be less accurate. Default:’cycle’

sigbool

True to indicate if this is the signal scan, False if reference

cal: bool

True if calibration (diode) is on, False if off.

calibrate: bool

whether or not to calibrate the data. If True, the data will be (calon - caloff)*0.5, otherwise it will be SDFITS row data. Default:True

timeaverageboolean, optional

Average the scans in time. The default is True.

polaverageboolean, optional

Average the scans in polarization. The default is False.

weights: str or None

None to indicate equal weighting or ‘tsys’ to indicate tsys weighting to use in time averaging. Default: ‘tsys’

bintableint, optional

Limit to the input binary table index. The default is None which means use all binary tables.

smooth_ref: int, optional

the number of channels in the reference to boxcar smooth prior to calibration

apply_flagsboolean, optional. If True, apply flags before calibration.

See apply_flags(). Default: True

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., ifnum=1, plnum=[2,3] etc.

Returns:
dataScanBlock

A ScanBlock containing one or more SubBeamNodScan

summary(**kwargs)[source]#

reload, if need be

GB20MFITSLoad#

Load SDFITS files produced for GBO’s 20m telescope

class dysh.fits.gb20mfitsload.GB20MFITSLoad(filename, source=None, hdu=None, **kwargs)[source]#

Bases: SDFITSLoad

Attributes:
binheader

The list of bintable headers

bintable

The list of bintables

columns

The column names in the binary table, minus the DATA column

filename

The input SDFITS filename

total_rows

Returns the total number of rows summed over all binary table HDUs

Methods

create_index([hdu, skipindex])

Create the index of the SDFITS file.

delete_column(column)

Delete one or more columns from both the index table and any binary tables in this SDFITSLoad Warning: cannot be undone

fix_meta(meta)

Do any repair to the meta/header for peculariaties in definitions from a particular observatory The passed-in dictionary will be repaired in place.

getps([ifnum, plnum])

Calibrate position switched observations.

getrow(i[, bintable])

Get a FITS_record from the input bintable

getspec(i[, bintable, observer_location, ...])

Get a row (record) as a Spectrum

index([hdu, bintable])

Return The index table.

info()

Return the HDUList info()

load([hdu])

Load the bintable for given hdu.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan(bintable)

The number of channels per row of the input bintable.

nintegrations(bintable[, source])

The number of integrations on a given source divided by the number of polarizations

npol(bintable)

The number of polarizations present in the input bintable.

nrows(bintable)

The number of rows of the input bintable

rawspectra(bintable[, setmask])

Get the raw (unprocessed) spectra from the input bintable.

rawspectrum(i[, bintable, setmask])

Get a single raw (unprocessed) spectrum from the input bintable.

rename_column(oldname, newname)

Rename a column in both index table and any binary tables in this SDFITSLoad

scans(bintable)

The number of scans present in the input bintable.

sources(bintable)

The number of sources present in the input bintable.

summary()

Print a summary of each record of the data

udata(key[, bintable])

The unique list of values of a given header keyword

ushow(key[, bintable])

Print the unique list of values of a given header keyword

velocity_convention(veldef, velframe)

Compute the velocity convention string use for velocity conversions, given the VELDEF and VELFRAME values.

write(fileobj[, rows, bintable, flags, ...])

Write the SDFITSLoad to a new file, potentially sub-selecting rows or bintables.

do_sigref

make_meta_ps

select

do_sigref(sig, ref, tsys)[source]#
getps(ifnum=0, plnum=0)[source]#

Calibrate position switched observations. It time averages the signal and reference spectra and then calibrates using:

\(T_{\rm{sys}}\frac{\mathrm{SIG}}{\mathrm{SIG}-\mathrm{REF}}\)

Parameters:
ifnumint

Spectral window to calibrate.

plnumint

Polarization to calibrate.

Returns:
calSpectrum

Calibrated spectrum.

make_meta_ps(tsys)[source]#
select(**kwargs)[source]#