gavo.protocols.sdm module

Code dealing with spectra (the actual data), in particular in the spectral data model (sdm).

This assumes Spectral Data Model Version 1, but doesn’t use very much of it.

gavo.protocols.sdm.formatSDMData(sdmData, format, queryMeta={'accept': {}, 'additionalFields': [], 'columnSet': None, 'dbLimit': 100, 'dbSortKeys': [], 'direction': 'ASC', 'formal_data': {}, 'inputTable': None, 'password': None, 'tdEnc': False, 'timeout': 15, 'user': None, 'verbosity': 20})[source]

returns a pair of mime-type and payload for a rendering of the SDM Data instance sdmData in format.

(you’ll usually use this via //soda#sdm_format)

gavo.protocols.sdm.getColIndForUtype(header, colUtype)[source]

returns the fits field index that has colUtype as its utype within header.

If no such field exists, this raises a KeyError

gavo.protocols.sdm.getFluxColumn(sdmTable)[source]

returns the column containing the flux in sdmTable.

gavo.protocols.sdm.getSDM1UtypeForSSA(utype)[source]

returns a utype from the spectrum data model for a utype of the ssa data model.

For most utypes, this just removes a prefix and adds spec:Spectrum. Heaven knows why these are two different data models anyway. There are some (apparently random) differences, though.

For convenience, utype=None is allowed and returned as such.

gavo.protocols.sdm.getSpectralColumn(sdmTable)[source]

returns the column containing the spectral coordinate in sdmTable.

gavo.protocols.sdm.makeBasicSDMHeader(sdmData, header)[source]

updates the fits header header with the params from sdmData.

gavo.protocols.sdm.makeSDMDataForPUBDID(pubDID, ssaTD, spectrumData, sdmVersion='1')[source]

returns a rsc.Data instance containing an SDM compliant spectrum for pubDID from ssaTable.

ssaTD is the definition of a table containing the SSA metadata, spectrumData is a data element making a primary table containing the spectrum data from an SSA row (typically, this is going to be the tablesource property of an SSA service).

gavo.protocols.sdm.makeSDMDataForSSARow(ssaRow, spectrumData, sdmVersion='1')[source]

returns a rsc.Data instance containing an SDM compliant spectrum for the spectrum described by ssaRow.

spectrumData is a data element making a primary table containing the spectrum data from an SSA row (typically, this is going to be the tablesource property of an SSA service).

You’ll usually use this via //soda#sdm_genData

gavo.protocols.sdm.makeSDMFITS(sdmData)[source]

returns sdmData in an SDM-compliant FITS.

This only works for SDM version 1. Behaviour with version 2 SDM data is undefined.

gavo.protocols.sdm.mangle_cutout(sdmTable, low, high)[source]

returns only those rows from sdmTable for which the spectral coordinate is between low and high.

Both low and high must be given. If you actually want half-open intervals, do it in interface code (low=-1 and high=1e308 should do fine).

gavo.protocols.sdm.mangle_fluxcalib(sdmTable, newCalib)[source]

returns sdmTable with a new calibration.

Currently, we can only normalize the spectrum to the maximum value.