Reading in and writing out observations

Contents

Reading in and writing out observations#

Loading SDFITS files#

Classes and functions for importing SDFITS files

class dysh.fits.ColDef(operation, type, name=None, scale=1, post=None)[source]#

Bases: object

Class to hold column definitions.

For every column this lists the operation to be performed on the column when aggregating it by scan number and project id. The data operation is stored in the operation attribute. For a description of the operations see `https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#built-in-aggregation-methods`_. The type attribute is the data type for the column. The name attribute is the name to be shown when using summary(verbose=False). The scale attribute is the factor by which to scale the column. The post attribute is any post operations to apply to the column after being aggregated.

class dysh.fits.Conf[source]#

Bases: ConfigNamespace

Configuration parameters for dysh.fits.

Attributes:
summary_max_rows

Maximum number of rows to be displayed by summary

Methods

help([name])

Print info about configuration items.

items()

Iterate over configuration item (name, value) pairs.

reload([attr])

Reload a configuration item from the configuration file.

reset([attr])

Reset a configuration item to its default.

set_temp(attr, value)

Temporarily set a configuration value.

summary_max_rows

Maximum number of rows to be displayed by summary

values()

Iterate over configuration item values.

keys

summary_max_rows#

Maximum number of rows to be displayed by summary

class dysh.fits.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, force_fits])

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

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.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan([bintable])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns 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

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

rawspectra(bintable[, setmask, rows, ...])

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

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]#
class dysh.fits.GBTBackend(value)[source]#

Bases: StrEnum

GBT spectrometer backends.

ACS = 'acs'#
DCR = 'dcr'#
SP = 'sp'#
VEGAS = 'vegas'#
ZPEC = 'zpec'#
classmethod from_string(s: str) GBTBackend | None[source]#

Parse backend from string (case-insensitive).

classmethod spectral_line_backends() set[GBTBackend][source]#

Return backends used for spectral line observations.

class dysh.fits.GBTFITSLoad(fileobj, source=None, hdu=None, skipflags=True, flag_vegas=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

skipflagsbool

If True, do not read any flag files associated with these data. If it exists, the FLAGS column of the binary table will always be read in regardless of skipflags value. Default: True

flag_vegasbool

If True, flag VEGAS spurs using the algorithm described in calc_vegas_spurs() and ignore VEGAS_SPUR flag rules in flag files. Note this parameter is independent of ‘skip_flags’, which controls only the reading of the flag file. If you want no flags at all, use skipflags=True, flag_vegas=False. Note: Since flagging VEGAS spurs requires reading certain SDFITS binary table(s), instantiation of GBTFITSLoad will take longer, commensurate with the number of rows in the binary table(s). It is more efficient to use flag_vegas=True in calibration routines. Default: False

skipflags

flag_vegas

behavior

False

False

Flags are created based on the flags file and the FLAGS column, but VEGAS spurs are not flagged.

True

False

No flags are read file the flag file. Flags are read in from the FLAGS column.

True

True

VEGAS flags are created based on the FITS header. Flags are read from the FLAGS column.

False

True

VEGAS flags are created based on the FITS header. Other flags are read from the flags file and FLAGS column.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(scan[, fdnum, ifnum, plnum, freq, ...])

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary([scan, verbose, columns, ...])

Create a summary of the input dataset as a DataFrame.

getfs(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate frequency-switched data.

getnod(ifnum, plnum[, fdnum, calibrate, ...])

Retrieve and calibrate nodding data.

getps(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(scan, ref, fdnum, ifnum, plnum[, ...])

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(scan, ifnum, plnum, zenith_opacity)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(fdnum, ifnum, plnum[, sig, cal, ...])

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(fdnum, ifnum, plnum[, method, ...])

Calibrate a SubBeamNod scan.

summary([scan, verbose, max_rows, ...])

Show a summary of the GBTFITSLoad object.

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

vanecal(scan[, ifnum, plnum, fdnum, mode, ...])

Compute the system temperature from a VANE/SKY calibration cycle.

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(flag_outer=True)[source]#

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

Parameters:
flag_outerbool

If the inner 80% of channels has been flagged, flag the rest. This defaults to True because the system temperature calculation uses the inner 80% of channels.

Returns:
None.
property backend: str#

Return the backend value or ‘unknown’ if it can’t be currently determined.

Note: Some SDFITS files do not have the BACKEND or INSTRUME keywords in the primary header. If the FITS metadata were loaded from an index file rather than the SDFITS binary table, the return string could be ‘unknown’ in this case even if the binary table properly reflects the BACKEND value.

binheader(fitsindex: int = 0) list[source]#

The list of bintable headers in a given underlying SDFITSLoad object

Parameters:
fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
binheader: list

A list of all the :class:`~astropy.io.fits.header.Header`s in the input fitsindex.

bintable(fitsindex: int = 0) list[source]#

The list of bintables in a given underlying SDFITSLoad object.

Parameters:
fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
bintable: list

A list of all the :class:`~astropy.io.fits.hdu.table.BinTableHDU`s in the input fitsindex.

calseq(scan, fdnum=0, ifnum=0, plnum=0, freq: Quantity | None = None, tcold: float | None = None, twarm: float | None = None, apply_flags: bool = True, flag_vegas: bool = True)[source]#

This routine returns the system temperature and gain for the selected W-band channel.

The W-band receiver uses a CALSEQ where during a scan three different observations are made: sky, cold1 and cold2, from which the system temperature is derived.

Parameters:
scanint or list of int

Scan number(s) where CALSEQ is expected. See sdf.summary() to find the scan number(s). If multiple scans are used, an average Tsys is computed.

fdnumint, optional

Feed to be used, 0 being the first. The default is 0.

ifnumint, optional

IF to be used, 0 being the first. The default is 0.

plnumint, optional

Polarization to be used, 0 being the first. The default is 0.

freqQuantity, optional

Set the frequency. By default the topocentric frequency of ifnum at scan will be used. It must have units of frequency.

tcoldfloat, optional

Set the cold temperature. By default it is computed as 54 K - 0.6 K/GHz * (freq - 77 GHz).

twarmfloat, optional

Set the warm temperature. By default it will use the value in the TWARM column of the SDFITS.

apply_flagsbool, optional

If True, apply flags before computing the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
tsysfloat

The system temperature, in K

gfloat

The gain in K/counts

Raises:
ValueError

If fdnum is not 0 or 1.

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:
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:
DataFrame

The final merged flags

property final_selection#

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

Returns:
DataFrame

The final merged selection

flag(tag=None, check=False, **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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

keystr

The key (SDFITS column name or other supported key)

valueany

The value to select

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

Flag channels and/or channel ranges. These will be used to create a mask for data when calibrating (see apply_flags()). 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
flag_channel(((1,10), [47,56], 75))

Note

If 80% of more of the inner channels in an integration are flagged, the rest of the channels will be flagged. This is because the system temperature calculation uses the inner 80% of channels.

For a further description of flagging, see Flag.

Parameters:
channelnumber, or array-like

The channels to flag

Returns:
None.
flag_range(tag=None, check=False, **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,).

For time values, Time, datetime64 and datetime are supported.

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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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_vegas_spurs(flag_central: bool = False, selection: Selection = None)[source]#

Flag VEGAS spur channels.

Note: It is generally more efficient, to use flag_vegas=True in calibration routines than to call this method directly without a Selection which will force a read of all the rows in the SDFITS file(s). Passing flag_vegas=True to calibration routines will only read the rows being calibrated.

Parameters:
flag_centralbool, optional

Whether to flag the central VEGAS spur location or not. The GBO SDFITS writer by default replaces the value at the central spur with the average of the two adjacent channels, and hence the central channel is not typically flagged.

selectionSelection, optional

A Selection object which will indicate which rows to flag. If None, then all rows are flagged.

Returns
——-
None.
flag_within(tag=None, check=False, **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,...

For time values, Time, datetime64 and datetime are supported.

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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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:
Flag

The Flag object

get_nod_beams(scan)[source]#

Find the FDNUM values for two nodding beams.

Parameters:
scanint

Scan for which to find the nodding beams.

Returns:
beamslist of two ints

Feed numbers representing the nodding beams. The first item is the first nodding beam.

Raises:
TypeError

If scan is not an integer.

ValueError

If there is no ‘SCAN’=`scan` in the index, or if it is not possible to determine the nodding beams.

get_summary(scan=None, verbose=False, columns=None, add_columns=None, col_defs=None, selected=False)[source]#

Create a summary of the input dataset as a DataFrame.

Parameters:
scanint or 2-tuple

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

verbosebool

If verbose=False (default), the records are grouped by scan number and project id and aggregated according to the column. For example, the records for columns RESTFREQ, AZIMUTH and ELEVATIO are averaged for every scan. For columns IFNUM, PLNUM and FDNUM it counts the unique number of records. For column OBJECT it shows the value of the first record for the scan. For more details and a full list of the supported columns see summary_column_definitions. If True, list every record.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, mul tiple column names must be comma separated.

col_defsdict

Dictionary with column definitions. See summary_column_definitions for the expected format.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

Returns
——-
summaryDataFrame

Summary of the data as a DataFrame.

Raises:
TypeError

If column is not a list.

ValueError

If one of the column names in column is not defined.

KeyError

If one of the column names in column is not part of the index.

getfs(fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, fold: bool = True, shift_method: str = 'fft', use_sig: bool = True, smoothref: int = 1, apply_flags: bool = True, units: str = 'ta', zenith_opacity: float | None = None, t_sys=None, t_cal=None, nocal: bool = False, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
fdnum: int

The feed number

ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

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

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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

Note: With certain choices of channel, folding the data with shift_method='fft' can result in a numpy array broadcast exception. If this occurs, either change shift_method to ‘interpolate’ or change the channel range by one channel to avoid the error.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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`~dysh.spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(ifnum: int, plnum: int, fdnum: None | int = None, calibrate: bool = True, smoothref: int = 1, apply_flags: bool = True, t_sys=None, t_cal=None, nocal=False, units='ta', zenith_opacity=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

fdnum2-tuple, optional

The feed numbers. A pair of feed numbers may be given to choose different nodding beams than were used to obtain the observations. Default: None which means use the beams found in the data.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

Smooth the reference spectra using a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference spectra.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

t_sysfloat or list or list of lists or dict, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. For example, t_sys = np.array([[30], [50]]) would use a system temperature of 30 K for the first feed and 50 K for the second feed. Another example, t_sys = {1: [[50, 60]], 2: [[45],[65]], 3: [[60],[70]]} would use a system temperature of 50 K for the first feed in scan 1, 60 K for the second feed in scan 1, 45 K for the first feed in scan 2, 65 K for the second feed in scan 2, 60 K for the first feed in scan 3, and 70 K for the second feed in scan 3. If passing a dict it should contain an item for every scan. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane calibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., intnum=1, plnum=2 etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly tagged 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(fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, smoothref: int = 1, apply_flags: str = True, units: str = 'ta', zenith_opacity: float | None = None, t_sys=None, nocal=False, t_cal=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs) ScanBlock[source]#

Retrieve and calibrate position-switched data.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, 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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `scan=[27,30], source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

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

Get a FITS_record from the input bintable

Parameters:
iint

The record (row) index to retrieve

bintableint

The index of the bintable attribute

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad.

Returns:
rowFITS_record

The i-th record of the input bintable and fitsindex

getsigref(scan: int | list | ndarray, ref: int | Spectrum, fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, smoothref: int = 1, apply_flags: str = True, units: str = 'ta', zenith_opacity: float | None = None, weights='tsys', t_sys=None, t_cal=None, nocal: bool = False, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs) ScanBlock[source]#

Retrieve and calibrate position-switched data using a custom reference scan. Also known as Flexible Off.

Note that the current version may not set the exposure time correctly. See issue #800 GreenBankObservatory/dysh#800

Parameters:
scanint or list or numpy.array

The signal scan numbers to calibrate

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. If channel is given, the reference spectrum will be trimmed to the channel range before calibration.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

If >1 smooth the reference with a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

t_sysfloat, optional

If given, this is the system temperature in Kelvin. It overrides the values calculated using the noise diodes. If not given, and signal and reference are scan numbers, the system temperature will be calculated from the reference scan and the noise diode. If not given, and the reference is a Spectrum, the reference system temperature as given in the metadata header will be used. The default is to use the noise diode or the metadata, as appropriate. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used. If t_sys is provided, t_cal will be ignored.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `source=’NGC123’, ` 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.

gettcal(scan: int, ifnum: int, plnum: int, zenith_opacity: float, ref: None | int | Spectrum = None, fdnum: None | int = None, apply_flags: bool = True, method=None, name=None, fluxscale=None, method_kwargs: None | dict = None, ap_eff=None, surface_error=None, **kwargs)[source]#

Derive the noise diode temperature from observations of a flux calibrator.

Parameters:
scanint

The scan number.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. This is only used if method=GBTFITSLoad.getsigref.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

zenith_opacityfloat

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

methodcallable

Method to use for calibrating the data. It can be one of GBTFITSLoad.getsigref, GBTFITSLoad.getps, GBTFITSLoad.getnod or GBTFITSLoad.subbeamnod. If None, the default, it will use GBTFITSLoad.getsigref for Track observations, GBTFITSLoad.getps for OnOff or OffOn observations, GBTFITSLoad.getnod for Nod observations, and GBTFITSLoad.subbeamnod for SubBeamNod observations.

namestr

Alternative name for the calibrator source. This will override the value found in the “OBJECT” column of the SDFITS. Useful when the “OBJECT” column contains a value not present in the calibrator catalog.

fluxscalestr

Name of the flux scale to use to compute the flux of the calibrator. “Perley-Butler 2017” and “Ott 1994” are known to dysh, although the user can provide other scales.

method_kwargsdict

Dictionary with additional keywords to pass to the calibration method.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_error: Quantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., object='NGC123'.

Returns:
tcalTCal

Object that contains the noise diode temperature in its flux attribute.

Raises:
TypeError

If more than one scan is provided.

TypeError

If method is not recognized.

gettp(fdnum: int, ifnum: int, plnum: int, sig: bool | None = None, cal: bool | None = None, calibrate: bool = True, apply_flags: bool = True, t_sys=None, t_cal=None, channel: list | None = None, vane=None, flag_vegas: bool = True, **kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

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

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

See apply_flags(). Default: True

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan] before any smoothing. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneNone

Used to suppress info message about use of TSYS column in case this is being used to make a VaneSpectrum.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., source="NGC132", intnum=range(20) etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

getvane(scan: int, fdnum: int, ifnum: int, plnum: int, t_cal: float | None = None, zenith_opacity: float | None = None, t_atm: float | None = None, t_warm: float | None = None, t_bkg: float = 2.725, apply_flags=True, flag_vegas: bool = True, **kwargs)[source]#

Return a VaneSpectrum used for calibrating observations with a vane. Uses the Equations provided in [1]. For the most accurate results zenith_opacity and tatm should be provided. Otherwise, it will try to fetch these values from the GBT weather forecast scripts (only available at GBO).

Parameters:
scanint

Scan number for either the VANE object.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

t_calfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1].

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

t_atmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

t_warmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

t_bkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool, optional

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
VaneSpectrum

A VaneSpectrum object which can be used to calibrate observations with a vane.

index(hdu=None, bintable: int | None = 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:
indexDataFrame

The index of this GBTFITSLoad

info()[source]#

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

is_vegas()[source]#

Check if these data appear to use the VEGAS backend

Returns:
True if FITS HEADER Keyword INSTRUME or BACKEND is present and equals ‘VEGAS’, False otherwise
load_all() None[source]#

Load all rows from FITS files if any required columns are missing.

naxis(naxis, bintable: int = 0, fitsindex: int = 0)[source]#

The NAXISn value of the input bintable.

Parameters:
naxisint

The NAXIS whose length is requested

bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
naxisthe length of the NAXIS
nchan(bintable: int = 0, fitsindex: int = 0) int[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

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns
——-
nchanint

Number channels in the first spectrum of the input bintable

ncolss(bintable: int = 0, fitsindex: int = 0) int[source]#

The number of columns an the underlying SDFITSLoad object.

Parameters:
bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
ncolsint

Number of columns, i.e., the width of the input bintable and fitsindex.

nrows(bintable: int = 0, fitsindex: int = 0) int[source]#

The number of rows an the underlying SDFITSLoad object.

Parameters:
bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
nrowsint

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

property projectID#

The project identification

Returns:
str

The project ID string

qd_check(threshold: float = 0.5) None[source]#

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

Parameters:
thresholdfloat

Fraction of the beam width used to check.

qd_correct(ignore_jump: bool = False) None[source]#

Apply quadrant detector (QD) corrections to sky coordinates. During an observation the QD records the motion of the GBT feed arm in the elevation and cross elevation directions. This movement results in pointing errors which are not automatically corrected for. This method allows users to correct for this movement, when possible. Typically, these corrections are of the order of a few arcseconds. More details about the QD and its use can be found in this reference: https://ui.adsabs.harvard.edu/abs/2011PASP..123..682R/abstract

Parameters:
ignore_jumpbool

Whether to ignore the prescence of jumps in the QD data. If set to True the corrections will be applied even if jumps are found. These jumps are also referred to as hysteresis events.

qd_flag(threshold: float = 0.5) None[source]#

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

Parameters:
thresholdfloat

Fraction of the beam width used to check.

rawspectra(bintable: int, fitsindex: int, setmask: bool = False, rows: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, fits_backend: FITSBackend | None = None) MaskedArray[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

rowsarray-like or None

If provided, load only these specific rows. If None, load all rows. This is an internal parameter used by Scan classes.

fits_backendFITSBackend or None

Backend to use for reading data. Options: - None (default): auto-select (fitsio when rows specified, astropy otherwise) - FITSBackend.ASTROPY: force astropy (memory-mapped, efficient for full loads) - FITSBackend.FITSIO: force fitsio (efficient for selective row loading)

Returns:
rawspectrandarray

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
——-
rawspectrumMaskedArray

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

property sdf#

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

select(tag=None, check=False, **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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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
select_channel(((1,10), [47,56], 75))

See Selection.

Parameters:
channelnumber, or array-like

The channels to select

Returns:
None.
select_range(tag=None, check=False, **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,).

For time values, Time, datetime64 and datetime are supported. 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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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, check=False, **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,...

For time values, Time, datetime64 and datetime are supported. 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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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:
Selection

The Selection object

stats(bintable=0)[source]#

Return some basic statistics of the GBTFITSLoad. Useful for performance testing. A dictionary with the following keys and values is returned:

nfiles : number of FITS files nrows : number of data rows fdnum : number of unique feeds ifnum : number of unique IFs plnum : number of unique polarizations sig : number of unique SIG integrations cal : number of unique CAL integrations

Parameters:
bintableint

The index of the bintable attribute to probe.

Returns:
statsdict

A dictionary with keys

subbeamnod(fdnum: int, ifnum: int, plnum: int, method='cycle', calibrate: bool = True, weights='tsys', smoothref: int = 1, apply_flags: bool = True, units='ta', zenith_opacity=None, t_sys=None, t_cal=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, nocal: bool = False, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Calibrate a SubBeamNod scan.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

methodstr

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ (default) treats each SUBREF_STATE independently, resulting in multiple signal and reference states per scan.. ‘scan’ averages the SUBREF_STATE rows resulting in one signal and reference state per scan.

calibratebool

Whether or not to calibrate the data.

weightsstr or None

Weights to use for the time averaging of the sub reflector states. None to indicate equal weighting or ‘tsys’ to indicate inverse variance weights.

smooth_refint, optional

The boxcar kernel width to smooth the reference spectra prior to calibration.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags().

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use to correct the data for atmospheric opacity.

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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(scan=None, verbose=False, max_rows=-1, show_index=False, columns=None, add_columns=None, selected=False)[source]#

Show a summary of the GBTFITSLoad object. To retrieve the underlying DataFrame use get_summary().

Parameters:
scanint or 2-tuple

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

verbosebool

If True, list every record, otherwise return a compact summary. The compact summary averages some of the columns over scan number (e.g., RESTFREQ, AZIMUTH, ELEVATIO), and lists the number of spectral windows (IFs), polarizations (# POL), feeds (# FEED), and integrations (# INT).

max_rowsint or None

Maximum number of rows to display. If less than the total number of rows, then the first max_rows/2 and last max_rows/2 rows will be shown, separated by ellipsis. If set to -1 (Default), the value found in the dysh configuration file for summary_max_rows will be used. Set to None for unlimited rows.

show_indexbool

Show index of the DataFrame.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist or str

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, multiple column names must be comma separated.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

property total_rows#

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

vanecal(scan, ifnum=0, plnum=0, fdnum=0, mode=2, tcal=None, zenith_opacity=None, tatm=None, twarm=None, tbkg=2.725, apply_flags=True, flag_vegas: bool = True, **kwargs)[source]#

Compute the system temperature from a VANE/SKY calibration cycle. Uses the Equations provided in [1]_. For the most accurate results zenith_opacity and tatm should be provided.

Parameters:
scanint

Scan number for either the SKY or VANE object. The pair will be found by the object name.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

fdnumint

The feed number.

modeint, optional

Mode of computing. See also mean_tsys() mode=0 Do the mean before the division mode=1 Do the mean after the division mode=2 Take a median of the inverse division The default is 2.

tcalfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]_. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1]_.

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

tatmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

twarmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

tbkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns
——-
tsysfloat

System temperature in K.

.. [1] `D. Frayer et al., “Calibration of Argus and the 4mm Receiver on the GBT” <https://ui.adsabs.harvard.edu/abs/2019nrao.reptE…1F/abstract>`_
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).

Uses fitsio with chunked row processing to keep memory bounded, even for very large files.

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.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, as in GBTIDL, one can use SDFITS_DATA instead of DYSH_DATA

Use dysh_data(‘?’) to display all filenames in the “sdfits” area.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(scan[, fdnum, ifnum, plnum, freq, ...])

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary([scan, verbose, columns, ...])

Create a summary of the input dataset as a DataFrame.

getfs(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate frequency-switched data.

getnod(ifnum, plnum[, fdnum, calibrate, ...])

Retrieve and calibrate nodding data.

getps(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(scan, ref, fdnum, ifnum, plnum[, ...])

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(scan, ifnum, plnum, zenith_opacity)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(fdnum, ifnum, plnum[, sig, cal, ...])

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(fdnum, ifnum, plnum[, method, ...])

Calibrate a SubBeamNod scan.

summary([scan, verbose, max_rows, ...])

Show a summary of the GBTFITSLoad object.

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

vanecal(scan[, ifnum, plnum, fdnum, mode, ...])

Compute the system temperature from a VANE/SKY calibration cycle.

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.GBTOnline(fileobj=None, *args, backend: GBTBackend | str | None = None, **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, as in GBTIDL, one can use SDFITS_DATA instead of DYSH_DATA

Use dysh_data(‘?’) to display all filenames in the “sdfits” area.

Parameters:
fileobjstr or None

Project name or path to monitor. If None, auto-discovers most recent observation.

backendGBTBackend, str, or None

Filter to specific backend (vegas, acs, sp). Only used in auto-discover mode.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(*args, **kwargs)

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary(*args, **kwargs)

Create a summary of the input dataset as a DataFrame.

getfs(*args, **kwargs)

Retrieve and calibrate frequency-switched data.

getnod(*args, **kwargs)

Retrieve and calibrate nodding data.

getps(*args, **kwargs)

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(*args, **kwargs)

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(*args, **kwargs)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(*args, **kwargs)

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(*args, **kwargs)

Calibrate a SubBeamNod scan.

summary(*args, **kwargs)

Show a summary of the GBTFITSLoad object.

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

vanecal(*args, **kwargs)

Compute the system temperature from a VANE/SKY calibration cycle.

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(*args, **kwargs)

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

Examples

>>> sdf = GBTOnline()                          # Auto-discover most recent
>>> sdf = GBTOnline(backend=GBTBackend.VEGAS)  # Most recent VEGAS
>>> sdf = GBTOnline(backend='vegas')           # Same, using string
>>> sdf = GBTOnline('AGBT21B_024_01')          # Monitor specific project
calseq(*args, **kwargs)[source]#

This routine returns the system temperature and gain for the selected W-band channel.

The W-band receiver uses a CALSEQ where during a scan three different observations are made: sky, cold1 and cold2, from which the system temperature is derived.

Parameters:
scanint or list of int

Scan number(s) where CALSEQ is expected. See sdf.summary() to find the scan number(s). If multiple scans are used, an average Tsys is computed.

fdnumint, optional

Feed to be used, 0 being the first. The default is 0.

ifnumint, optional

IF to be used, 0 being the first. The default is 0.

plnumint, optional

Polarization to be used, 0 being the first. The default is 0.

freqQuantity, optional

Set the frequency. By default the topocentric frequency of ifnum at scan will be used. It must have units of frequency.

tcoldfloat, optional

Set the cold temperature. By default it is computed as 54 K - 0.6 K/GHz * (freq - 77 GHz).

twarmfloat, optional

Set the warm temperature. By default it will use the value in the TWARM column of the SDFITS.

apply_flagsbool, optional

If True, apply flags before computing the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
tsysfloat

The system temperature, in K

gfloat

The gain in K/counts

Raises:
ValueError

If fdnum is not 0 or 1.

get_summary(*args, **kwargs)[source]#

Create a summary of the input dataset as a DataFrame.

Parameters:
scanint or 2-tuple

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

verbosebool

If verbose=False (default), the records are grouped by scan number and project id and aggregated according to the column. For example, the records for columns RESTFREQ, AZIMUTH and ELEVATIO are averaged for every scan. For columns IFNUM, PLNUM and FDNUM it counts the unique number of records. For column OBJECT it shows the value of the first record for the scan. For more details and a full list of the supported columns see summary_column_definitions. If True, list every record.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, mul tiple column names must be comma separated.

col_defsdict

Dictionary with column definitions. See summary_column_definitions for the expected format.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

Returns
——-
summaryDataFrame

Summary of the data as a DataFrame.

Raises:
TypeError

If column is not a list.

ValueError

If one of the column names in column is not defined.

KeyError

If one of the column names in column is not part of the index.

getfs(*args, **kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
fdnum: int

The feed number

ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

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

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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

Note: With certain choices of channel, folding the data with shift_method='fft' can result in a numpy array broadcast exception. If this occurs, either change shift_method to ‘interpolate’ or change the channel range by one channel to avoid the error.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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`~dysh.spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(*args, **kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

fdnum2-tuple, optional

The feed numbers. A pair of feed numbers may be given to choose different nodding beams than were used to obtain the observations. Default: None which means use the beams found in the data.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

Smooth the reference spectra using a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference spectra.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

t_sysfloat or list or list of lists or dict, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. For example, t_sys = np.array([[30], [50]]) would use a system temperature of 30 K for the first feed and 50 K for the second feed. Another example, t_sys = {1: [[50, 60]], 2: [[45],[65]], 3: [[60],[70]]} would use a system temperature of 50 K for the first feed in scan 1, 60 K for the second feed in scan 1, 45 K for the first feed in scan 2, 65 K for the second feed in scan 2, 60 K for the first feed in scan 3, and 70 K for the second feed in scan 3. If passing a dict it should contain an item for every scan. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane calibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., intnum=1, plnum=2 etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly tagged 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(*args, **kwargs)[source]#

Retrieve and calibrate position-switched data.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, 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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `scan=[27,30], source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

getsigref(*args, **kwargs)[source]#

Retrieve and calibrate position-switched data using a custom reference scan. Also known as Flexible Off.

Note that the current version may not set the exposure time correctly. See issue #800 GreenBankObservatory/dysh#800

Parameters:
scanint or list or numpy.array

The signal scan numbers to calibrate

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. If channel is given, the reference spectrum will be trimmed to the channel range before calibration.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

If >1 smooth the reference with a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

t_sysfloat, optional

If given, this is the system temperature in Kelvin. It overrides the values calculated using the noise diodes. If not given, and signal and reference are scan numbers, the system temperature will be calculated from the reference scan and the noise diode. If not given, and the reference is a Spectrum, the reference system temperature as given in the metadata header will be used. The default is to use the noise diode or the metadata, as appropriate. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used. If t_sys is provided, t_cal will be ignored.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

gettcal(*args, **kwargs)[source]#

Derive the noise diode temperature from observations of a flux calibrator.

Parameters:
scanint

The scan number.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. This is only used if method=GBTFITSLoad.getsigref.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

zenith_opacityfloat

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

methodcallable

Method to use for calibrating the data. It can be one of GBTFITSLoad.getsigref, GBTFITSLoad.getps, GBTFITSLoad.getnod or GBTFITSLoad.subbeamnod. If None, the default, it will use GBTFITSLoad.getsigref for Track observations, GBTFITSLoad.getps for OnOff or OffOn observations, GBTFITSLoad.getnod for Nod observations, and GBTFITSLoad.subbeamnod for SubBeamNod observations.

namestr

Alternative name for the calibrator source. This will override the value found in the “OBJECT” column of the SDFITS. Useful when the “OBJECT” column contains a value not present in the calibrator catalog.

fluxscalestr

Name of the flux scale to use to compute the flux of the calibrator. “Perley-Butler 2017” and “Ott 1994” are known to dysh, although the user can provide other scales.

method_kwargsdict

Dictionary with additional keywords to pass to the calibration method.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_error: Quantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., object='NGC123'.

Returns:
tcalTCal

Object that contains the noise diode temperature in its flux attribute.

Raises:
TypeError

If more than one scan is provided.

TypeError

If method is not recognized.

gettp(*args, **kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

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

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

See apply_flags(). Default: True

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan] before any smoothing. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneNone

Used to suppress info message about use of TSYS column in case this is being used to make a VaneSpectrum.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., source="NGC132", intnum=range(20) etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

subbeamnod(*args, **kwargs)[source]#

Calibrate a SubBeamNod scan.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

methodstr

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ (default) treats each SUBREF_STATE independently, resulting in multiple signal and reference states per scan.. ‘scan’ averages the SUBREF_STATE rows resulting in one signal and reference state per scan.

calibratebool

Whether or not to calibrate the data.

weightsstr or None

Weights to use for the time averaging of the sub reflector states. None to indicate equal weighting or ‘tsys’ to indicate inverse variance weights.

smooth_refint, optional

The boxcar kernel width to smooth the reference spectra prior to calibration.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags().

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use to correct the data for atmospheric opacity.

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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(*args, **kwargs)[source]#

Show a summary of the GBTFITSLoad object. To retrieve the underlying DataFrame use get_summary().

Parameters:
scanint or 2-tuple

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

verbosebool

If True, list every record, otherwise return a compact summary. The compact summary averages some of the columns over scan number (e.g., RESTFREQ, AZIMUTH, ELEVATIO), and lists the number of spectral windows (IFs), polarizations (# POL), feeds (# FEED), and integrations (# INT).

max_rowsint or None

Maximum number of rows to display. If less than the total number of rows, then the first max_rows/2 and last max_rows/2 rows will be shown, separated by ellipsis. If set to -1 (Default), the value found in the dysh configuration file for summary_max_rows will be used. Set to None for unlimited rows.

show_indexbool

Show index of the DataFrame.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist or str

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, multiple column names must be comma separated.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

vanecal(*args, **kwargs)[source]#

Compute the system temperature from a VANE/SKY calibration cycle. Uses the Equations provided in [1]_. For the most accurate results zenith_opacity and tatm should be provided.

Parameters:
scanint

Scan number for either the SKY or VANE object. The pair will be found by the object name.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

fdnumint

The feed number.

modeint, optional

Mode of computing. See also mean_tsys() mode=0 Do the mean before the division mode=1 Do the mean after the division mode=2 Take a median of the inverse division The default is 2.

tcalfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]_. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1]_.

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

tatmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

twarmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

tbkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns
——-
tsysfloat

System temperature in K.

.. [1] `D. Frayer et al., “Calibration of Argus and the 4mm Receiver on the GBT” <https://ui.adsabs.harvard.edu/abs/2019nrao.reptE…1F/abstract>`_
write(*args, **kwargs)[source]#

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

Uses fitsio with chunked row processing to keep memory bounded, even for very large files.

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.SDFITSLoad(filename: str, source: str | None = None, hdu: int | list[int] | None = 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, force_fits])

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

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.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan([bintable])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns 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

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

rawspectra(bintable[, setmask, rows, ...])

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

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: int | list[int] | None = None, skipindex=('DATA', 'FLAGS'), force_fits: bool = False)[source]#

Create the index of the SDFITS file.

This method will first attempt to load from a .index file (fast path). If no .index file is found, it falls back to reading from the FITS 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

force_fitsbool

If True, skip .index file and always load from FITS. Default: False. Used internally for lazy loading when .index columns are insufficient.

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

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

load_full_rows(rows: ndarray, bintable: int = 0, exclude_data: bool = True) DataFrame[source]#

Load full rows (all columns) for specific row indices from FITS file.

This enables lazy loading when row data is needed - loads the entire row once rather than column by column.

Parameters:
rowsnp.ndarray

Row indices to load

bintableint

The bintable index (default 0)

exclude_databool

If True (default), exclude the DATA column (it’s huge and loaded separately)

Returns:
pd.DataFrame

DataFrame with all columns for the requested rows

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: int = 0) int[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

ncols(bintable: int = 0) int[source]#

The number of columns of the input bintable

Parameters:
bintableint

The index of the bintable attribute

Returns:
ncolsint

Number of columns, i.e., the width 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: int = 0) int[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: int = 0) int[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

nscans(bintable: int = 0) int[source]#

The number of scans present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
nscans: int

Number of scans as given by SCAN FITS header keyword.

nsources(bintable: int = 0) int[source]#

The number of sources present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
nsources: int

Number of sources as given by OBJECT FITS header keyword.

rawspectra(bintable: int, setmask: bool = False, rows: ArrayLike | None = None, fits_backend: FITSBackend | None = None) MaskedArray[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.

rowsarray-like or None

If provided, load only these rows. If None, load all rows.

fits_backendFITSBackend or None

Backend to use for reading data. Options: - None (default): auto-select (fitsio when rows specified, astropy otherwise) - FITSBackend.ASTROPY: force astropy (memory-mapped, efficient for full loads) - FITSBackend.FITSIO: force fitsio (efficient for selective row loading)

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.
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.

dysh.fits.default_sdfits_columns()[source]#

The default column names for GBT SDFITS.

Returns:
colnameslist
A list of the GBT SDFITS column names
dysh.fits.summary_column_definitions()[source]#

Column definitions for the summary function of GBTFITSLoad.

Returns:
col_defsdict

Dictionary of column definitions (ColDef). See ColDef for details.

SDFITSLoad#

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

class dysh.fits.sdfitsload.FITSBackend(value)[source]#

Bases: Enum

Backend options for reading FITS data.

ASTROPY = 'astropy'#
FITSIO = 'fitsio'#
class dysh.fits.sdfitsload.SDFITSLoad(filename: str, source: str | None = None, hdu: int | list[int] | None = 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, force_fits])

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

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.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan([bintable])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns 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

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

rawspectra(bintable[, setmask, rows, ...])

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

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: int | list[int] | None = None, skipindex=('DATA', 'FLAGS'), force_fits: bool = False)[source]#

Create the index of the SDFITS file.

This method will first attempt to load from a .index file (fast path). If no .index file is found, it falls back to reading from the FITS 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

force_fitsbool

If True, skip .index file and always load from FITS. Default: False. Used internally for lazy loading when .index columns are insufficient.

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

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

load_full_rows(rows: ndarray, bintable: int = 0, exclude_data: bool = True) DataFrame[source]#

Load full rows (all columns) for specific row indices from FITS file.

This enables lazy loading when row data is needed - loads the entire row once rather than column by column.

Parameters:
rowsnp.ndarray

Row indices to load

bintableint

The bintable index (default 0)

exclude_databool

If True (default), exclude the DATA column (it’s huge and loaded separately)

Returns:
pd.DataFrame

DataFrame with all columns for the requested rows

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: int = 0) int[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

ncols(bintable: int = 0) int[source]#

The number of columns of the input bintable

Parameters:
bintableint

The index of the bintable attribute

Returns:
ncolsint

Number of columns, i.e., the width 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: int = 0) int[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: int = 0) int[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

nscans(bintable: int = 0) int[source]#

The number of scans present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
nscans: int

Number of scans as given by SCAN FITS header keyword.

nsources(bintable: int = 0) int[source]#

The number of sources present in the input bintable.

Parameters:
bintableint

The index of the bintable attribute

Returns:
nsources: int

Number of sources as given by OBJECT FITS header keyword.

rawspectra(bintable: int, setmask: bool = False, rows: ArrayLike | None = None, fits_backend: FITSBackend | None = None) MaskedArray[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.

rowsarray-like or None

If provided, load only these rows. If None, load all rows.

fits_backendFITSBackend or None

Backend to use for reading data. Options: - None (default): auto-select (fitsio when rows specified, astropy otherwise) - FITSBackend.ASTROPY: force astropy (memory-mapped, efficient for full loads) - FITSBackend.FITSIO: force fitsio (efficient for selective row loading)

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.
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.GBTBackend(value)[source]#

Bases: StrEnum

GBT spectrometer backends.

ACS = 'acs'#
DCR = 'dcr'#
SP = 'sp'#
VEGAS = 'vegas'#
ZPEC = 'zpec'#
classmethod from_string(s: str) GBTBackend | None[source]#

Parse backend from string (case-insensitive).

classmethod spectral_line_backends() set[GBTBackend][source]#

Return backends used for spectral line observations.

class dysh.fits.gbtfitsload.GBTFITSLoad(fileobj, source=None, hdu=None, skipflags=True, flag_vegas=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

skipflagsbool

If True, do not read any flag files associated with these data. If it exists, the FLAGS column of the binary table will always be read in regardless of skipflags value. Default: True

flag_vegasbool

If True, flag VEGAS spurs using the algorithm described in calc_vegas_spurs() and ignore VEGAS_SPUR flag rules in flag files. Note this parameter is independent of ‘skip_flags’, which controls only the reading of the flag file. If you want no flags at all, use skipflags=True, flag_vegas=False. Note: Since flagging VEGAS spurs requires reading certain SDFITS binary table(s), instantiation of GBTFITSLoad will take longer, commensurate with the number of rows in the binary table(s). It is more efficient to use flag_vegas=True in calibration routines. Default: False

skipflags

flag_vegas

behavior

False

False

Flags are created based on the flags file and the FLAGS column, but VEGAS spurs are not flagged.

True

False

No flags are read file the flag file. Flags are read in from the FLAGS column.

True

True

VEGAS flags are created based on the FITS header. Flags are read from the FLAGS column.

False

True

VEGAS flags are created based on the FITS header. Other flags are read from the flags file and FLAGS column.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(scan[, fdnum, ifnum, plnum, freq, ...])

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary([scan, verbose, columns, ...])

Create a summary of the input dataset as a DataFrame.

getfs(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate frequency-switched data.

getnod(ifnum, plnum[, fdnum, calibrate, ...])

Retrieve and calibrate nodding data.

getps(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(scan, ref, fdnum, ifnum, plnum[, ...])

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(scan, ifnum, plnum, zenith_opacity)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(fdnum, ifnum, plnum[, sig, cal, ...])

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(fdnum, ifnum, plnum[, method, ...])

Calibrate a SubBeamNod scan.

summary([scan, verbose, max_rows, ...])

Show a summary of the GBTFITSLoad object.

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

vanecal(scan[, ifnum, plnum, fdnum, mode, ...])

Compute the system temperature from a VANE/SKY calibration cycle.

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(flag_outer=True)[source]#

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

Parameters:
flag_outerbool

If the inner 80% of channels has been flagged, flag the rest. This defaults to True because the system temperature calculation uses the inner 80% of channels.

Returns:
None.
property backend: str#

Return the backend value or ‘unknown’ if it can’t be currently determined.

Note: Some SDFITS files do not have the BACKEND or INSTRUME keywords in the primary header. If the FITS metadata were loaded from an index file rather than the SDFITS binary table, the return string could be ‘unknown’ in this case even if the binary table properly reflects the BACKEND value.

binheader(fitsindex: int = 0) list[source]#

The list of bintable headers in a given underlying SDFITSLoad object

Parameters:
fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
binheader: list

A list of all the :class:`~astropy.io.fits.header.Header`s in the input fitsindex.

bintable(fitsindex: int = 0) list[source]#

The list of bintables in a given underlying SDFITSLoad object.

Parameters:
fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
bintable: list

A list of all the :class:`~astropy.io.fits.hdu.table.BinTableHDU`s in the input fitsindex.

calseq(scan, fdnum=0, ifnum=0, plnum=0, freq: Quantity | None = None, tcold: float | None = None, twarm: float | None = None, apply_flags: bool = True, flag_vegas: bool = True)[source]#

This routine returns the system temperature and gain for the selected W-band channel.

The W-band receiver uses a CALSEQ where during a scan three different observations are made: sky, cold1 and cold2, from which the system temperature is derived.

Parameters:
scanint or list of int

Scan number(s) where CALSEQ is expected. See sdf.summary() to find the scan number(s). If multiple scans are used, an average Tsys is computed.

fdnumint, optional

Feed to be used, 0 being the first. The default is 0.

ifnumint, optional

IF to be used, 0 being the first. The default is 0.

plnumint, optional

Polarization to be used, 0 being the first. The default is 0.

freqQuantity, optional

Set the frequency. By default the topocentric frequency of ifnum at scan will be used. It must have units of frequency.

tcoldfloat, optional

Set the cold temperature. By default it is computed as 54 K - 0.6 K/GHz * (freq - 77 GHz).

twarmfloat, optional

Set the warm temperature. By default it will use the value in the TWARM column of the SDFITS.

apply_flagsbool, optional

If True, apply flags before computing the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
tsysfloat

The system temperature, in K

gfloat

The gain in K/counts

Raises:
ValueError

If fdnum is not 0 or 1.

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:
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:
DataFrame

The final merged flags

property final_selection#

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

Returns:
DataFrame

The final merged selection

flag(tag=None, check=False, **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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

keystr

The key (SDFITS column name or other supported key)

valueany

The value to select

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

Flag channels and/or channel ranges. These will be used to create a mask for data when calibrating (see apply_flags()). 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
flag_channel(((1,10), [47,56], 75))

Note

If 80% of more of the inner channels in an integration are flagged, the rest of the channels will be flagged. This is because the system temperature calculation uses the inner 80% of channels.

For a further description of flagging, see Flag.

Parameters:
channelnumber, or array-like

The channels to flag

Returns:
None.
flag_range(tag=None, check=False, **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,).

For time values, Time, datetime64 and datetime are supported.

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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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_vegas_spurs(flag_central: bool = False, selection: Selection = None)[source]#

Flag VEGAS spur channels.

Note: It is generally more efficient, to use flag_vegas=True in calibration routines than to call this method directly without a Selection which will force a read of all the rows in the SDFITS file(s). Passing flag_vegas=True to calibration routines will only read the rows being calibrated.

Parameters:
flag_centralbool, optional

Whether to flag the central VEGAS spur location or not. The GBO SDFITS writer by default replaces the value at the central spur with the average of the two adjacent channels, and hence the central channel is not typically flagged.

selectionSelection, optional

A Selection object which will indicate which rows to flag. If None, then all rows are flagged.

Returns
——-
None.
flag_within(tag=None, check=False, **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,...

For time values, Time, datetime64 and datetime are supported.

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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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:
Flag

The Flag object

get_nod_beams(scan)[source]#

Find the FDNUM values for two nodding beams.

Parameters:
scanint

Scan for which to find the nodding beams.

Returns:
beamslist of two ints

Feed numbers representing the nodding beams. The first item is the first nodding beam.

Raises:
TypeError

If scan is not an integer.

ValueError

If there is no ‘SCAN’=`scan` in the index, or if it is not possible to determine the nodding beams.

get_summary(scan=None, verbose=False, columns=None, add_columns=None, col_defs=None, selected=False)[source]#

Create a summary of the input dataset as a DataFrame.

Parameters:
scanint or 2-tuple

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

verbosebool

If verbose=False (default), the records are grouped by scan number and project id and aggregated according to the column. For example, the records for columns RESTFREQ, AZIMUTH and ELEVATIO are averaged for every scan. For columns IFNUM, PLNUM and FDNUM it counts the unique number of records. For column OBJECT it shows the value of the first record for the scan. For more details and a full list of the supported columns see summary_column_definitions. If True, list every record.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, mul tiple column names must be comma separated.

col_defsdict

Dictionary with column definitions. See summary_column_definitions for the expected format.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

Returns
——-
summaryDataFrame

Summary of the data as a DataFrame.

Raises:
TypeError

If column is not a list.

ValueError

If one of the column names in column is not defined.

KeyError

If one of the column names in column is not part of the index.

getfs(fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, fold: bool = True, shift_method: str = 'fft', use_sig: bool = True, smoothref: int = 1, apply_flags: bool = True, units: str = 'ta', zenith_opacity: float | None = None, t_sys=None, t_cal=None, nocal: bool = False, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
fdnum: int

The feed number

ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

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

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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

Note: With certain choices of channel, folding the data with shift_method='fft' can result in a numpy array broadcast exception. If this occurs, either change shift_method to ‘interpolate’ or change the channel range by one channel to avoid the error.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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`~dysh.spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(ifnum: int, plnum: int, fdnum: None | int = None, calibrate: bool = True, smoothref: int = 1, apply_flags: bool = True, t_sys=None, t_cal=None, nocal=False, units='ta', zenith_opacity=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

fdnum2-tuple, optional

The feed numbers. A pair of feed numbers may be given to choose different nodding beams than were used to obtain the observations. Default: None which means use the beams found in the data.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

Smooth the reference spectra using a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference spectra.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

t_sysfloat or list or list of lists or dict, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. For example, t_sys = np.array([[30], [50]]) would use a system temperature of 30 K for the first feed and 50 K for the second feed. Another example, t_sys = {1: [[50, 60]], 2: [[45],[65]], 3: [[60],[70]]} would use a system temperature of 50 K for the first feed in scan 1, 60 K for the second feed in scan 1, 45 K for the first feed in scan 2, 65 K for the second feed in scan 2, 60 K for the first feed in scan 3, and 70 K for the second feed in scan 3. If passing a dict it should contain an item for every scan. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane calibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., intnum=1, plnum=2 etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly tagged 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(fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, smoothref: int = 1, apply_flags: str = True, units: str = 'ta', zenith_opacity: float | None = None, t_sys=None, nocal=False, t_cal=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs) ScanBlock[source]#

Retrieve and calibrate position-switched data.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, 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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `scan=[27,30], source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

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

Get a FITS_record from the input bintable

Parameters:
iint

The record (row) index to retrieve

bintableint

The index of the bintable attribute

fitsindex: int

the index of the FITS file contained in this GBTFITSLoad.

Returns:
rowFITS_record

The i-th record of the input bintable and fitsindex

getsigref(scan: int | list | ndarray, ref: int | Spectrum, fdnum: int, ifnum: int, plnum: int, calibrate: bool = True, smoothref: int = 1, apply_flags: str = True, units: str = 'ta', zenith_opacity: float | None = None, weights='tsys', t_sys=None, t_cal=None, nocal: bool = False, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs) ScanBlock[source]#

Retrieve and calibrate position-switched data using a custom reference scan. Also known as Flexible Off.

Note that the current version may not set the exposure time correctly. See issue #800 GreenBankObservatory/dysh#800

Parameters:
scanint or list or numpy.array

The signal scan numbers to calibrate

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. If channel is given, the reference spectrum will be trimmed to the channel range before calibration.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

If >1 smooth the reference with a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

t_sysfloat, optional

If given, this is the system temperature in Kelvin. It overrides the values calculated using the noise diodes. If not given, and signal and reference are scan numbers, the system temperature will be calculated from the reference scan and the noise diode. If not given, and the reference is a Spectrum, the reference system temperature as given in the metadata header will be used. The default is to use the noise diode or the metadata, as appropriate. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used. If t_sys is provided, t_cal will be ignored.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `source=’NGC123’, ` 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.

gettcal(scan: int, ifnum: int, plnum: int, zenith_opacity: float, ref: None | int | Spectrum = None, fdnum: None | int = None, apply_flags: bool = True, method=None, name=None, fluxscale=None, method_kwargs: None | dict = None, ap_eff=None, surface_error=None, **kwargs)[source]#

Derive the noise diode temperature from observations of a flux calibrator.

Parameters:
scanint

The scan number.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. This is only used if method=GBTFITSLoad.getsigref.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

zenith_opacityfloat

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

methodcallable

Method to use for calibrating the data. It can be one of GBTFITSLoad.getsigref, GBTFITSLoad.getps, GBTFITSLoad.getnod or GBTFITSLoad.subbeamnod. If None, the default, it will use GBTFITSLoad.getsigref for Track observations, GBTFITSLoad.getps for OnOff or OffOn observations, GBTFITSLoad.getnod for Nod observations, and GBTFITSLoad.subbeamnod for SubBeamNod observations.

namestr

Alternative name for the calibrator source. This will override the value found in the “OBJECT” column of the SDFITS. Useful when the “OBJECT” column contains a value not present in the calibrator catalog.

fluxscalestr

Name of the flux scale to use to compute the flux of the calibrator. “Perley-Butler 2017” and “Ott 1994” are known to dysh, although the user can provide other scales.

method_kwargsdict

Dictionary with additional keywords to pass to the calibration method.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_error: Quantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., object='NGC123'.

Returns:
tcalTCal

Object that contains the noise diode temperature in its flux attribute.

Raises:
TypeError

If more than one scan is provided.

TypeError

If method is not recognized.

gettp(fdnum: int, ifnum: int, plnum: int, sig: bool | None = None, cal: bool | None = None, calibrate: bool = True, apply_flags: bool = True, t_sys=None, t_cal=None, channel: list | None = None, vane=None, flag_vegas: bool = True, **kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

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

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

See apply_flags(). Default: True

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan] before any smoothing. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneNone

Used to suppress info message about use of TSYS column in case this is being used to make a VaneSpectrum.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., source="NGC132", intnum=range(20) etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

getvane(scan: int, fdnum: int, ifnum: int, plnum: int, t_cal: float | None = None, zenith_opacity: float | None = None, t_atm: float | None = None, t_warm: float | None = None, t_bkg: float = 2.725, apply_flags=True, flag_vegas: bool = True, **kwargs)[source]#

Return a VaneSpectrum used for calibrating observations with a vane. Uses the Equations provided in [1]. For the most accurate results zenith_opacity and tatm should be provided. Otherwise, it will try to fetch these values from the GBT weather forecast scripts (only available at GBO).

Parameters:
scanint

Scan number for either the VANE object.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

t_calfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1].

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

t_atmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

t_warmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

t_bkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool, optional

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
VaneSpectrum

A VaneSpectrum object which can be used to calibrate observations with a vane.

index(hdu=None, bintable: int | None = 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:
indexDataFrame

The index of this GBTFITSLoad

info()[source]#

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

is_vegas()[source]#

Check if these data appear to use the VEGAS backend

Returns:
True if FITS HEADER Keyword INSTRUME or BACKEND is present and equals ‘VEGAS’, False otherwise
load_all() None[source]#

Load all rows from FITS files if any required columns are missing.

naxis(naxis, bintable: int = 0, fitsindex: int = 0)[source]#

The NAXISn value of the input bintable.

Parameters:
naxisint

The NAXIS whose length is requested

bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
naxisthe length of the NAXIS
nchan(bintable: int = 0, fitsindex: int = 0) int[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

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns
——-
nchanint

Number channels in the first spectrum of the input bintable

ncolss(bintable: int = 0, fitsindex: int = 0) int[source]#

The number of columns an the underlying SDFITSLoad object.

Parameters:
bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
ncolsint

Number of columns, i.e., the width of the input bintable and fitsindex.

nrows(bintable: int = 0, fitsindex: int = 0) int[source]#

The number of rows an the underlying SDFITSLoad object.

Parameters:
bintableint

The index of the bintable attribute

fitsindex: int

The index of the FITS file contained in this GBTFITSLoad.

Returns:
nrowsint

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

property projectID#

The project identification

Returns:
str

The project ID string

qd_check(threshold: float = 0.5) None[source]#

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

Parameters:
thresholdfloat

Fraction of the beam width used to check.

qd_correct(ignore_jump: bool = False) None[source]#

Apply quadrant detector (QD) corrections to sky coordinates. During an observation the QD records the motion of the GBT feed arm in the elevation and cross elevation directions. This movement results in pointing errors which are not automatically corrected for. This method allows users to correct for this movement, when possible. Typically, these corrections are of the order of a few arcseconds. More details about the QD and its use can be found in this reference: https://ui.adsabs.harvard.edu/abs/2011PASP..123..682R/abstract

Parameters:
ignore_jumpbool

Whether to ignore the prescence of jumps in the QD data. If set to True the corrections will be applied even if jumps are found. These jumps are also referred to as hysteresis events.

qd_flag(threshold: float = 0.5) None[source]#

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

Parameters:
thresholdfloat

Fraction of the beam width used to check.

rawspectra(bintable: int, fitsindex: int, setmask: bool = False, rows: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, fits_backend: FITSBackend | None = None) MaskedArray[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

rowsarray-like or None

If provided, load only these specific rows. If None, load all rows. This is an internal parameter used by Scan classes.

fits_backendFITSBackend or None

Backend to use for reading data. Options: - None (default): auto-select (fitsio when rows specified, astropy otherwise) - FITSBackend.ASTROPY: force astropy (memory-mapped, efficient for full loads) - FITSBackend.FITSIO: force fitsio (efficient for selective row loading)

Returns:
rawspectrandarray

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
——-
rawspectrumMaskedArray

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

property sdf#

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

select(tag=None, check=False, **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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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
select_channel(((1,10), [47,56], 75))

See Selection.

Parameters:
channelnumber, or array-like

The channels to select

Returns:
None.
select_range(tag=None, check=False, **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,).

For time values, Time, datetime64 and datetime are supported. 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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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, check=False, **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,...

For time values, Time, datetime64 and datetime are supported. 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.

checkbool

If True, check that a previous selection does not give an identical result as this one.

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:
Selection

The Selection object

stats(bintable=0)[source]#

Return some basic statistics of the GBTFITSLoad. Useful for performance testing. A dictionary with the following keys and values is returned:

nfiles : number of FITS files nrows : number of data rows fdnum : number of unique feeds ifnum : number of unique IFs plnum : number of unique polarizations sig : number of unique SIG integrations cal : number of unique CAL integrations

Parameters:
bintableint

The index of the bintable attribute to probe.

Returns:
statsdict

A dictionary with keys

subbeamnod(fdnum: int, ifnum: int, plnum: int, method='cycle', calibrate: bool = True, weights='tsys', smoothref: int = 1, apply_flags: bool = True, units='ta', zenith_opacity=None, t_sys=None, t_cal=None, ap_eff: float | None = None, surface_error: Quantity | None = None, channel: list | None = None, nocal: bool = False, vane: int | VaneSpectrum | None = None, t_atm: float | None = None, t_bkg: float | None = None, t_warm: float | None = None, flag_vegas: bool = True, **kwargs)[source]#

Calibrate a SubBeamNod scan.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

methodstr

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ (default) treats each SUBREF_STATE independently, resulting in multiple signal and reference states per scan.. ‘scan’ averages the SUBREF_STATE rows resulting in one signal and reference state per scan.

calibratebool

Whether or not to calibrate the data.

weightsstr or None

Weights to use for the time averaging of the sub reflector states. None to indicate equal weighting or ‘tsys’ to indicate inverse variance weights.

smooth_refint, optional

The boxcar kernel width to smooth the reference spectra prior to calibration.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags().

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use to correct the data for atmospheric opacity.

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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(scan=None, verbose=False, max_rows=-1, show_index=False, columns=None, add_columns=None, selected=False)[source]#

Show a summary of the GBTFITSLoad object. To retrieve the underlying DataFrame use get_summary().

Parameters:
scanint or 2-tuple

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

verbosebool

If True, list every record, otherwise return a compact summary. The compact summary averages some of the columns over scan number (e.g., RESTFREQ, AZIMUTH, ELEVATIO), and lists the number of spectral windows (IFs), polarizations (# POL), feeds (# FEED), and integrations (# INT).

max_rowsint or None

Maximum number of rows to display. If less than the total number of rows, then the first max_rows/2 and last max_rows/2 rows will be shown, separated by ellipsis. If set to -1 (Default), the value found in the dysh configuration file for summary_max_rows will be used. Set to None for unlimited rows.

show_indexbool

Show index of the DataFrame.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist or str

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, multiple column names must be comma separated.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

property total_rows#

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

vanecal(scan, ifnum=0, plnum=0, fdnum=0, mode=2, tcal=None, zenith_opacity=None, tatm=None, twarm=None, tbkg=2.725, apply_flags=True, flag_vegas: bool = True, **kwargs)[source]#

Compute the system temperature from a VANE/SKY calibration cycle. Uses the Equations provided in [1]_. For the most accurate results zenith_opacity and tatm should be provided.

Parameters:
scanint

Scan number for either the SKY or VANE object. The pair will be found by the object name.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

fdnumint

The feed number.

modeint, optional

Mode of computing. See also mean_tsys() mode=0 Do the mean before the division mode=1 Do the mean after the division mode=2 Take a median of the inverse division The default is 2.

tcalfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]_. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1]_.

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

tatmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

twarmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

tbkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns
——-
tsysfloat

System temperature in K.

.. [1] `D. Frayer et al., “Calibration of Argus and the 4mm Receiver on the GBT” <https://ui.adsabs.harvard.edu/abs/2019nrao.reptE…1F/abstract>`_
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).

Uses fitsio with chunked row processing to keep memory bounded, even for very large files.

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, as in GBTIDL, one can use SDFITS_DATA instead of DYSH_DATA

Use dysh_data(‘?’) to display all filenames in the “sdfits” area.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(scan[, fdnum, ifnum, plnum, freq, ...])

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary([scan, verbose, columns, ...])

Create a summary of the input dataset as a DataFrame.

getfs(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate frequency-switched data.

getnod(ifnum, plnum[, fdnum, calibrate, ...])

Retrieve and calibrate nodding data.

getps(fdnum, ifnum, plnum[, calibrate, ...])

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(scan, ref, fdnum, ifnum, plnum[, ...])

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(scan, ifnum, plnum, zenith_opacity)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(fdnum, ifnum, plnum[, sig, cal, ...])

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(fdnum, ifnum, plnum[, method, ...])

Calibrate a SubBeamNod scan.

summary([scan, verbose, max_rows, ...])

Show a summary of the GBTFITSLoad object.

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

vanecal(scan[, ifnum, plnum, fdnum, mode, ...])

Compute the system temperature from a VANE/SKY calibration cycle.

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, backend: GBTBackend | str | None = None, **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, as in GBTIDL, one can use SDFITS_DATA instead of DYSH_DATA

Use dysh_data(‘?’) to display all filenames in the “sdfits” area.

Parameters:
fileobjstr or None

Project name or path to monitor. If None, auto-discovers most recent observation.

backendGBTBackend, str, or None

Filter to specific backend (vegas, acs, sp). Only used in auto-discover mode.

Attributes:
backend

Return the backend value or ‘unknown’ if it can’t be currently determined.

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

sdf

The list of SDFITSLoad objects (one per SDFITS file) inside this GBTFITSLoad.

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([flag_outer])

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

binheader([fitsindex])

The list of bintable headers in a given underlying SDFITSLoad object

bintable([fitsindex])

The list of bintables in a given underlying SDFITSLoad object.

calseq(*args, **kwargs)

This routine returns the system temperature and gain for the selected W-band channel.

clear_flags()

Clear all flags for these data

clear_selection()

Clear all selections for these data

create_index([hdu, skipindex, force_fits])

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

flag([tag, check])

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])

Flag channels and/or channel ranges.

flag_range([tag, check])

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

flag_vegas_spurs([flag_central, selection])

Flag VEGAS spur channels.

flag_within([tag, check])

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

get_nod_beams(scan)

Find the FDNUM values for two nodding beams.

get_summary(*args, **kwargs)

Create a summary of the input dataset as a DataFrame.

getfs(*args, **kwargs)

Retrieve and calibrate frequency-switched data.

getnod(*args, **kwargs)

Retrieve and calibrate nodding data.

getps(*args, **kwargs)

Retrieve and calibrate position-switched data.

getrow(i[, bintable, fitsindex])

Get a FITS_record from the input bintable

getsigref(*args, **kwargs)

Retrieve and calibrate position-switched data using a custom reference scan.

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

Get a row (record) as a Spectrum

gettcal(*args, **kwargs)

Derive the noise diode temperature from observations of a flux calibrator.

gettp(*args, **kwargs)

Get a total power scan, optionally calibrating it.

getvane(scan, fdnum, ifnum, plnum[, t_cal, ...])

Return a VaneSpectrum used for calibrating observations with a vane.

index([hdu, bintable, fitsindex])

Return The index table

info()

Return information on the HDUs contained in this object.

is_vegas()

Check if these data appear to use the VEGAS backend

load([hdu])

Load the bintable for given hdu.

load_all()

Load all rows from FITS files if any required columns are missing.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

merge_commentary(other)

Merge the history and comments from another HistoricalBase instance.

naxis(naxis[, bintable, fitsindex])

The NAXISn value of the input bintable.

nchan([bintable, fitsindex])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns of the input bintable

ncolss([bintable, fitsindex])

The number of columns an the underlying SDFITSLoad object.

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, fitsindex])

The number of rows an the underlying SDFITSLoad object.

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

qd_check([threshold])

Check that the pointing errors registered by the quadrant detector (QD) are less than threshold times the beam width.

qd_correct([ignore_jump])

Apply quadrant detector (QD) corrections to sky coordinates.

qd_flag([threshold])

Flag rows where the pointing errors registered by the quadrant detector (QD) are more than threshold times the half power beam width.

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

select([tag, check])

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, check])

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

select_within([tag, check])

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

stats([bintable])

Return some basic statistics of the GBTFITSLoad.

subbeamnod(*args, **kwargs)

Calibrate a SubBeamNod scan.

summary(*args, **kwargs)

Show a summary of the GBTFITSLoad object.

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

vanecal(*args, **kwargs)

Compute the system temperature from a VANE/SKY calibration cycle.

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(*args, **kwargs)

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

Examples

>>> sdf = GBTOnline()                          # Auto-discover most recent
>>> sdf = GBTOnline(backend=GBTBackend.VEGAS)  # Most recent VEGAS
>>> sdf = GBTOnline(backend='vegas')           # Same, using string
>>> sdf = GBTOnline('AGBT21B_024_01')          # Monitor specific project
calseq(*args, **kwargs)[source]#

This routine returns the system temperature and gain for the selected W-band channel.

The W-band receiver uses a CALSEQ where during a scan three different observations are made: sky, cold1 and cold2, from which the system temperature is derived.

Parameters:
scanint or list of int

Scan number(s) where CALSEQ is expected. See sdf.summary() to find the scan number(s). If multiple scans are used, an average Tsys is computed.

fdnumint, optional

Feed to be used, 0 being the first. The default is 0.

ifnumint, optional

IF to be used, 0 being the first. The default is 0.

plnumint, optional

Polarization to be used, 0 being the first. The default is 0.

freqQuantity, optional

Set the frequency. By default the topocentric frequency of ifnum at scan will be used. It must have units of frequency.

tcoldfloat, optional

Set the cold temperature. By default it is computed as 54 K - 0.6 K/GHz * (freq - 77 GHz).

twarmfloat, optional

Set the warm temperature. By default it will use the value in the TWARM column of the SDFITS.

apply_flagsbool, optional

If True, apply flags before computing the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns:
tsysfloat

The system temperature, in K

gfloat

The gain in K/counts

Raises:
ValueError

If fdnum is not 0 or 1.

get_summary(*args, **kwargs)[source]#

Create a summary of the input dataset as a DataFrame.

Parameters:
scanint or 2-tuple

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

verbosebool

If verbose=False (default), the records are grouped by scan number and project id and aggregated according to the column. For example, the records for columns RESTFREQ, AZIMUTH and ELEVATIO are averaged for every scan. For columns IFNUM, PLNUM and FDNUM it counts the unique number of records. For column OBJECT it shows the value of the first record for the scan. For more details and a full list of the supported columns see summary_column_definitions. If True, list every record.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, mul tiple column names must be comma separated.

col_defsdict

Dictionary with column definitions. See summary_column_definitions for the expected format.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

Returns
——-
summaryDataFrame

Summary of the data as a DataFrame.

Raises:
TypeError

If column is not a list.

ValueError

If one of the column names in column is not defined.

KeyError

If one of the column names in column is not part of the index.

getfs(*args, **kwargs)[source]#

Retrieve and calibrate frequency-switched data.

Parameters:
fdnum: int

The feed number

ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

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

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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

Note: With certain choices of channel, folding the data with shift_method='fft' can result in a numpy array broadcast exception. If this occurs, either change shift_method to ‘interpolate’ or change the channel range by one channel to avoid the error.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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`~dysh.spectra.scan.FSScan`.

Raises:
Exception

If no scans matching the selection criteria are found.

getnod(*args, **kwargs)[source]#

Retrieve and calibrate nodding data.

Parameters:
ifnumint

The intermediate frequency (IF) number

plnumint

The polarization number

fdnum2-tuple, optional

The feed numbers. A pair of feed numbers may be given to choose different nodding beams than were used to obtain the observations. Default: None which means use the beams found in the data.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

Smooth the reference spectra using a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference spectra.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

t_sysfloat or list or list of lists or dict, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. For example, t_sys = np.array([[30], [50]]) would use a system temperature of 30 K for the first feed and 50 K for the second feed. Another example, t_sys = {1: [[50, 60]], 2: [[45],[65]], 3: [[60],[70]]} would use a system temperature of 50 K for the first feed in scan 1, 60 K for the second feed in scan 1, 45 K for the first feed in scan 2, 65 K for the second feed in scan 2, 60 K for the first feed in scan 3, and 70 K for the second feed in scan 3. If passing a dict it should contain an item for every scan. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane calibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., intnum=1, plnum=2 etc. For multi-beam with more than 2 beams, fdnum=[BEAM1,BEAM2] must be selected, unless the data have been properly tagged 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(*args, **kwargs)[source]#

Retrieve and calibrate position-switched data.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, 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

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacity: float, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default:None

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this. Default: False

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `scan=[27,30], source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

getsigref(*args, **kwargs)[source]#

Retrieve and calibrate position-switched data using a custom reference scan. Also known as Flexible Off.

Note that the current version may not set the exposure time correctly. See issue #800 GreenBankObservatory/dysh#800

Parameters:
scanint or list or numpy.array

The signal scan numbers to calibrate

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. If channel is given, the reference spectrum will be trimmed to the channel range before calibration.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

calibrateboolean, optional

Calibrate the scans. The default is True.

smooth_refint, optional

If >1 smooth the reference with a boxcar kernel with a width of smooth_ref channels. The default is to not smooth the reference.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

t_sysfloat, optional

If given, this is the system temperature in Kelvin. It overrides the values calculated using the noise diodes. If not given, and signal and reference are scan numbers, the system temperature will be calculated from the reference scan and the noise diode. If not given, and the reference is a Spectrum, the reference system temperature as given in the metadata header will be used. The default is to use the noise diode or the metadata, as appropriate. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used. If t_sys is provided, t_cal will be ignored.

nocalbool, optional

Is the noise diode being fired? False means the noise diode was firing. By default it will figure this out by looking at the “CAL” column. It can be set to True to override this.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., `source=’NGC123’, ` etc.

Returns:
scanblockScanBlock

ScanBlock containing one or more PSScan.

Raises:
Exception

If scans matching the selection criteria are not found.

gettcal(*args, **kwargs)[source]#

Derive the noise diode temperature from observations of a flux calibrator.

Parameters:
scanint

The scan number.

fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

refint or Spectrum

The reference scan number or a Spectrum object. If an integer is given, the reference spectrum will be the total power time-averaged spectrum using the weights given. This is only used if method=GBTFITSLoad.getsigref.

apply_flagsboolean, optional

If True, apply flags before calibration. See apply_flags(). Default: True

zenith_opacityfloat

The zenith opacity to use in calculating the scale factors for the integrations. Default: None

methodcallable

Method to use for calibrating the data. It can be one of GBTFITSLoad.getsigref, GBTFITSLoad.getps, GBTFITSLoad.getnod or GBTFITSLoad.subbeamnod. If None, the default, it will use GBTFITSLoad.getsigref for Track observations, GBTFITSLoad.getps for OnOff or OffOn observations, GBTFITSLoad.getnod for Nod observations, and GBTFITSLoad.subbeamnod for SubBeamNod observations.

namestr

Alternative name for the calibrator source. This will override the value found in the “OBJECT” column of the SDFITS. Useful when the “OBJECT” column contains a value not present in the calibrator catalog.

fluxscalestr

Name of the flux scale to use to compute the flux of the calibrator. “Perley-Butler 2017” and “Ott 1994” are known to dysh, although the user can provide other scales.

method_kwargsdict

Dictionary with additional keywords to pass to the calibration method.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_error: Quantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., object='NGC123'.

Returns:
tcalTCal

Object that contains the noise diode temperature in its flux attribute.

Raises:
TypeError

If more than one scan is provided.

TypeError

If method is not recognized.

gettp(*args, **kwargs)[source]#

Get a total power scan, optionally calibrating it.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

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

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

See apply_flags(). Default: True

t_sysfloat

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan] before any smoothing. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

vaneNone

Used to suppress info message about use of TSYS column in case this is being used to make a VaneSpectrum.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**kwargsdict

Optional additional selection keyword arguments, typically given as key=value, though a dictionary works too. e.g., source="NGC132", intnum=range(20) etc.

Returns:
dataScanBlock

A ScanBlock containing one or more TPScan

subbeamnod(*args, **kwargs)[source]#

Calibrate a SubBeamNod scan.

Parameters:
fdnumint

The feed number.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

methodstr

Method to use when processing. One of ‘cycle’ or ‘scan’. ‘cycle’ (default) treats each SUBREF_STATE independently, resulting in multiple signal and reference states per scan.. ‘scan’ averages the SUBREF_STATE rows resulting in one signal and reference state per scan.

calibratebool

Whether or not to calibrate the data.

weightsstr or None

Weights to use for the time averaging of the sub reflector states. None to indicate equal weighting or ‘tsys’ to indicate inverse variance weights.

smooth_refint, optional

The boxcar kernel width to smooth the reference spectra prior to calibration.

apply_flagsboolean, optional.

If True, apply flags before calibration. See apply_flags().

unitsstr, optional
The brightness scale unit for the output scan, must be one of (case-insensitive)
  • ‘ta’ : Antenna Temperature

  • ‘ta*’ : Antenna temperature corrected to above the atmosphere

  • ‘flux’ : flux density in Jansky

If ‘ta*’ or ‘flux’ the zenith opacity must also be given. Default: ‘ta’

zenith_opacityfloat, optional

The zenith opacity to use to correct the data for atmospheric opacity.

t_sysfloat, optional

System temperature. If provided, it overrides the value computed using the noise diode. If no noise diode is fired, and t_sys=None, then the column “TSYS” will be used instead. If vane is provided, then t_sys will be ignored and vane will be used to derive the system temperature.

t_calNone or float

Noise diode temperature. If provided, this value is used instead of the value found in the TCAL column of the SDFITS file. If no value is provided, default, then the TCAL column is used.

channellist or None

An inclusive list of [firstchan, lastchan] to use in the calibration. The channel list is zero-based. If provided, only data channels in the inclusive range [firstchan,lastchan] will be used. If a reference spectrum has been given, it will also be trimmed to [firstchan,lastchan]. System temperature calculation will use 80% of the trimmed channel range. If channels have already been selected through GBTFITSLoad.select_channel(), a ValueError will be raised.

ap_efffloat or None

Aperture efficiency o be used when scaling data to brightness temperature of flux. The provided aperture efficiency must be a number between 0 and 1. If None, dysh will calculate it as described in aperture_efficiency(). Only one of ap_eff or surface_error can be provided.

surface_errorQuantity or None

Surface rms error, in units of length (typically microns), to be used in the Ruze formula when calculating the aperture efficiency. If None, dysh will use the known GBT surface error model. Only one of ap_eff or surface_error can be provided.

vaneint or VaneSpectrum or None

Vane scalibration scan. This will be used to derive the system temperature. If provided, t_sys will be ignored.

t_atmfloat or None

Atmospheric temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the atmospheric temperature. If not provided and vane is an int, VaneSpectrum will try to fetch a value from the GBO weather forecast script (only available at GBO).

t_bkgfloat or None

Background temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the background temperature. If not provided, it will take a default value of 2.725 K, i.e., the CMB at 3 mm.

t_warmfloat or None

Vane temperature in K. If vane is a VaneSpectrum it won’t be used. If vane is an int, then the resulting VaneSpectrum will use this value for the vane temperature. If not provided and vane is an int, it will take the value found in the “TWARM” column of the SDFITS.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

**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(*args, **kwargs)[source]#

Show a summary of the GBTFITSLoad object. To retrieve the underlying DataFrame use get_summary().

Parameters:
scanint or 2-tuple

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

verbosebool

If True, list every record, otherwise return a compact summary. The compact summary averages some of the columns over scan number (e.g., RESTFREQ, AZIMUTH, ELEVATIO), and lists the number of spectral windows (IFs), polarizations (# POL), feeds (# FEED), and integrations (# INT).

max_rowsint or None

Maximum number of rows to display. If less than the total number of rows, then the first max_rows/2 and last max_rows/2 rows will be shown, separated by ellipsis. If set to -1 (Default), the value found in the dysh configuration file for summary_max_rows will be used. Set to None for unlimited rows.

show_indexbool

Show index of the DataFrame.

columnslist or str

List of columns for the output summary. If not set and verbose=False, the default list will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM (# IF), PLNUM (# POL), INTNUM (# INT), FDNUM (# FEED), AZIMUTH, and ELEVATIO (ELEVATION). If not set and verbose=True, it will contain SCAN, OBJECT, VELOCITY, PROC, PROCSEQN, RESTFREQ, DOPFREQ, IFNUM, FEED, AZIMUTH, ELEVATIO, FDNUM, INTNUM, PLNUM, SIG, CAL, and DATE-OBS. If a string, multiple column names must be comma separated.

add_columnslist or str

List of columns to be added to the default columns. If columns is not None, then this will be ignored. If a string, multiple column names must be comma separated.

selected: bool

Show only those rows that are selected by the final selection (AND of all selection rules). Note if no selection rules have been set, this will display an empty summary.

vanecal(*args, **kwargs)[source]#

Compute the system temperature from a VANE/SKY calibration cycle. Uses the Equations provided in [1]_. For the most accurate results zenith_opacity and tatm should be provided.

Parameters:
scanint

Scan number for either the SKY or VANE object. The pair will be found by the object name.

ifnumint

The intermediate frequency (IF) number.

plnumint

The polarization number.

fdnumint

The feed number.

modeint, optional

Mode of computing. See also mean_tsys() mode=0 Do the mean before the division mode=1 Do the mean after the division mode=2 Take a median of the inverse division The default is 2.

tcalfloat, optional

Calibration temperature. If no value is provided, but zenith_opacity and tatm are provided, then it will use Eq. (22) of [1]_. If zenith_opacity and tatm are not provided, it will first try to retrieve them using the weather forecasts (only available at GBO), if that fails it will use the ambient temperature, Eq. (23) of [1]_.

zenith_opacityfloat, optional

Zenith opacity. If not provided it will try to fetch “Opacity” from the weather forecasts (only available at GBO).

tatmfloat, optional

Atmospheric temperature in K. If not provided it will try to fetch “Tatm” from the weather forecasts (only available at GBO).

twarmfloat, optional

Temperature of the VANE in K. If not provided it will use the value found in the “TWARM” column of the SDFITS for scan.

tbkgfloat, optional

Background temperature in K.

apply_flagsbool, optional

If True, apply flags before deriving the system temperature.

flag_vegasbool

If True, VEGAS spurs will be flagged for the row(s) being calibrated.

Returns
——-
tsysfloat

System temperature in K.

.. [1] `D. Frayer et al., “Calibration of Argus and the 4mm Receiver on the GBT” <https://ui.adsabs.harvard.edu/abs/2019nrao.reptE…1F/abstract>`_
write(*args, **kwargs)[source]#

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

Uses fitsio with chunked row processing to keep memory bounded, even for very large files.

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.

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, force_fits])

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

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.

load_full_rows(rows[, bintable, exclude_data])

Load full rows (all columns) for specific row indices from FITS file.

naxis(naxis, bintable)

The NAXISn value of the input bintable.

nchan([bintable])

The number of channels per row of the input bintable.

ncols([bintable])

The number of columns 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

nscans([bintable])

The number of scans present in the input bintable.

nsources([bintable])

The number of sources present in the input bintable.

rawspectra(bintable[, setmask, rows, ...])

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

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]#

Core Functions and Classes#

Core functions for FITS/SDFITS

class dysh.fits.core.ColDef(operation, type, name=None, scale=1, post=None)[source]#

Bases: object

Class to hold column definitions.

For every column this lists the operation to be performed on the column when aggregating it by scan number and project id. The data operation is stored in the operation attribute. For a description of the operations see `https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#built-in-aggregation-methods`_. The type attribute is the data type for the column. The name attribute is the name to be shown when using summary(verbose=False). The scale attribute is the factor by which to scale the column. The post attribute is any post operations to apply to the column after being aggregated.

dysh.fits.core.default_sdfits_columns()[source]#

The default column names for GBT SDFITS.

Returns:
colnameslist
A list of the GBT SDFITS column names
dysh.fits.core.summary_column_definitions()[source]#

Column definitions for the summary function of GBTFITSLoad.

Returns:
col_defsdict

Dictionary of column definitions (ColDef). See ColDef for details.