Package gavo :: Package protocols :: Module sdm
[frames] | no frames]

Module sdm

source code

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. There's an sdm2 module for version 2 support. Generic, version-independent code should go here.

Functions
 
getSDM1UtypeForSSA(utype)
returns a utype from the spectrum data model for a utype of the ssa data model.
source code
 
getSDM2UtypeForSSA(utype)
returns a utype from the spectral data model 2 for a utype of the ssa data model.
source code
 
getSDM2utypeForSDM1(utype)
returns a utype for the spectral data model 2 from a version 1 one.
source code
 
hackSDM1ToSDM2(data)
changes some utypes to make an SDM2 compliant spectrum from an SDM1 compliant one.
source code
 
makeSDMDataForSSARow(ssaRow, spectrumData, sdmVersion=u'1')
returns a rsc.Data instance containing an SDM compliant spectrum for the spectrum described by ssaRow.
source code
 
makeSDMDataForPUBDID(pubDID, ssaTD, spectrumData, sdmVersion=u'1')
returns a rsc.Data instance containing an SDM compliant spectrum for pubDID from ssaTable.
source code
 
getColIndForUtype(header, colUtype)
returns the fits field index that has colUtype as its utype within header.
source code
 
makeBasicSDMHeader(sdmData, header)
updates the fits header header with the params from sdmData.
source code
 
makeSDMFITS(sdmData)
returns sdmData in an SDM-compliant FITS.
source code
 
formatSDMData(sdmData, format, queryMeta={'direction': 'ASC', 'dbLimit': 100, 'format': 'HTML', 'verbos...)
returns a pair of mime-type and payload for a rendering of the SDM Data instance sdmData in format.
source code
 
getFluxColumn(sdmTable)
returns the column containing the flux in sdmTable.
source code
 
getSpectralColumn(sdmTable)
returns the column containing the spectral coordindate in sdmTable.
source code
 
mangle_cutout(sdmTable, low, high)
returns only those rows from sdmTable for which the spectral coordinate is between low and high.
source code
 
mangle_fluxcalib(sdmTable, newCalib)
returns sdmTable with a new calibration.
source code
Variables
  GETDATA_FORMATS = {'application/fits': None, 'application/x-vo...
  SDM1_TO_SDM2_IRREGULARS = {'Char.FluxAxis.Calibration': 'Char....
  __package__ = 'gavo.protocols'
Function Details

getSDM1UtypeForSSA(utype)

source code 

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.

getSDM2UtypeForSSA(utype)

source code 

returns a utype from the spectral data model 2 for a utype of the ssa data model.

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

hackSDM1ToSDM2(data)

source code 

changes some utypes to make an SDM2 compliant spectrum from an SDM1 compliant one.

All this is too horrible to even contemplate, but it's really pending sound DM support in both DaCHS and the VO. If we have that, I hope sick mess like this is going to disappear.

makeSDMDataForSSARow(ssaRow, spectrumData, sdmVersion=u'1')

source code 

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

makeSDMDataForPUBDID(pubDID, ssaTD, spectrumData, sdmVersion=u'1')

source code 

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

ssaTD is the definition of a table containg 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).

getColIndForUtype(header, colUtype)

source code 

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

If no such field exists, this raises a KeyError

makeSDMFITS(sdmData)

source code 

returns sdmData in an SDM-compliant FITS.

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

formatSDMData(sdmData, format, queryMeta={'direction': 'ASC', 'dbLimit': 100, 'format': 'HTML', 'verbos...)

source code 

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)

getFluxColumn(sdmTable)

source code 

returns the column containing the flux in sdmTable.

sdmTable can be in SDM1 or SDM2.

getSpectralColumn(sdmTable)

source code 

returns the column containing the spectral coordindate in sdmTable.

sdmTable can be in SDM1 or SDM2.

mangle_cutout(sdmTable, low, high)

source code 

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

mangle_fluxcalib(sdmTable, newCalib)

source code 

returns sdmTable with a new calibration.

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


Variables Details

GETDATA_FORMATS

Value:
{'application/fits': None,
 'application/x-votable+xml': 'votable',
 'application/x-votable+xml;content=spec2': None,
 'application/x-votable+xml;serialization=tabledata': 'votabletd',
 'application/x-votable+xml;version=1.4': 'vodml',
 'text/csv': 'csv',
 'text/plain': 'tsv'}

SDM1_TO_SDM2_IRREGULARS

Value:
{'Char.FluxAxis.Calibration': 'Char.FluxAxis.CalibrationStatus',
 'Char.SpatialAxis.Calibration': 'Char.SpatialAxis.CalibrationStatus',
 'Char.SpatialAxis.Resolution': 'Char.SpatialAxis.Resolution.refVal',
 'Char.SpectralAxis.Calibration': 'Char.SpectralAxis.CalibrationStatus\
',
 'Char.SpectralAxis.ResPower': 'Char.SpectralAxis.Resolution.ResolPowe\
r.refVal',
 'Char.SpectralAxis.Resolution': 'Char.SpectralAxis.Resolution.refVal'\
...