MakeRawVisitInfo

class lsst.obs.base.MakeRawVisitInfo(log=None)[source]

Bases: object

Base class functor to make a VisitInfo from the FITS header of a raw image.

A subclass will be wanted for each camera. Subclasses should override:

  • setArgDict, The override can call the base implementation,
    which simply sets exposure time and date of observation
  • getDateAvg

The design philosophy is to make a best effort and log warnings of problems, rather than raising exceptions, in order to extract as much VisitInfo information as possible from a messy FITS header without the user needing to add a lot of error handling.

However, the methods that transform units are less forgiving; they assume the user provides proper data types, since type errors in arguments to those are almost certainly due to coding mistakes.

Parameters:

log : lsst.log.Log or None

Logger to use for messages. (None to use Log.getLogger("MakeRawVisitInfo")).

Methods Summary

__call__(md, exposureId) Construct a VisitInfo and strip associated data from the metadata.
altitudeFromZenithDistance(zd) Convert zenith distance to altitude (lsst.afw.geom.Angle)
centigradeFromKelvin(tempK) Convert temperature from Kelvin to Centigrade
defaultMetadata(value, defaultValue[, ...]) Return the value if it is not NaN and within min/max, otherwise return defaultValue.
eraFromLstAndLongitude(lst, longitude) Return an approximate Earth Rotation Angle (afw:Angle) computed from local sidereal time and longitude (both as afw:Angle; Longitude shares the afw:Observatory covention: positive values are E of Greenwich).
getDarkTime(argDict) Get the darkTime from the DARKTIME keyword, else expTime, else NaN,
getDateAvg(md, exposureTime) Return date at the middle of the exposure.
offsetDate(date, offsetSec) Return a date offset by a specified number of seconds.
pascalFromMBar(mbar) Convert pressure from millibars to Pascals
pascalFromMmHg(mmHg) Convert pressure from mm Hg to Pascals
pascalFromTorr(torr) Convert pressure from torr to Pascals
popAngle(md, key[, units]) Pop an lsst.afw.geom.Angle, whose metadata is in the specified units, with a default of Nan
popFloat(md, key) Pop a float with a default of NaN.
popIsoDate(md, key[, timesys]) Pop a FITS ISO date as an lsst.daf.base.DateTime
popItem(md, key[, default]) Remove an item of metadata and return the value.
popMjdDate(md, key[, timesys]) Get a FITS MJD date as an lsst.daf.base.DateTime.
setArgDict(md, argDict) Fill an argument dict with arguments for VisitInfo and pop associated metadata

Methods Documentation

__call__(md, exposureId)[source]

Construct a VisitInfo and strip associated data from the metadata.

Parameters:

md : lsst.daf.base.PropertyList or lsst.daf.base.PropertySet

Metadata to pull from. Items that are used are stripped from the metadata (except TIMESYS, because it may apply to other keywords).

exposureId : int

exposure ID

Notes

The basic implementation sets date and exposureTime using typical values found in FITS files and logs a warning if neither can be set.

static altitudeFromZenithDistance(zd)[source]

Convert zenith distance to altitude (lsst.afw.geom.Angle)

static centigradeFromKelvin(tempK)[source]

Convert temperature from Kelvin to Centigrade

static defaultMetadata(value, defaultValue, minimum=None, maximum=None)[source]

Return the value if it is not NaN and within min/max, otherwise return defaultValue.

Parameters:

value : float

metadata value returned by popItem, popFloat, or popAngle

defaultValue : float`

default value to use if the metadata value is invalid

minimum : float

Minimum possible valid value, optional

maximum : float

Maximum possible valid value, optional

Returns:

float

The “validated” value.

static eraFromLstAndLongitude(lst, longitude)[source]

Return an approximate Earth Rotation Angle (afw:Angle) computed from local sidereal time and longitude (both as afw:Angle; Longitude shares the afw:Observatory covention: positive values are E of Greenwich).

NOTE: if we properly compute ERA via UT1 a la DM-8053, we should remove this method.

getDarkTime(argDict)[source]

Get the darkTime from the DARKTIME keyword, else expTime, else NaN,

If dark time is available then subclasses should call this method by putting the following in their __init__ method:

argDict['darkTime'] = self.getDarkTime(argDict)
Parameters:

argdict : dict

Dict of arguments.

Returns:

float

Dark time, as inferred from the metadata.

getDateAvg(md, exposureTime)[source]

Return date at the middle of the exposure.

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull from. Items that are used are stripped from the metadata (except TIMESYS, because it may apply to other keywords).

exposureTime : float

Exposure time (sec)

Notes

Subclasses must override. Here is a typical implementation:

dateObs = self.popIsoDate(md, "DATE-OBS")
return self.offsetDate(dateObs, 0.5*exposureTime)
offsetDate(date, offsetSec)[source]

Return a date offset by a specified number of seconds.

date : lsst.daf.base.DateTime
Date baseline to offset from.
offsetSec : float
Offset, in seconds.
Returns:

lsst.daf.base.DateTime

The offset date.

static pascalFromMBar(mbar)[source]

Convert pressure from millibars to Pascals

static pascalFromMmHg(mmHg)[source]

Convert pressure from mm Hg to Pascals

Notes

Could use the following, but astropy.units.cds is not fully compatible with Python 2 as of astropy 1.2.1 (see https://github.com/astropy/astropy/issues/5350#issuecomment-248612824): astropy.units.cds.mmHg.to(astropy.units.pascal, mmHg)

static pascalFromTorr(torr)[source]

Convert pressure from torr to Pascals

popAngle(md, key, units=Unit("deg"))[source]

Pop an lsst.afw.geom.Angle, whose metadata is in the specified units, with a default of Nan

The angle may be specified as a float or sexagesimal string with 1-3 fields.

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull key from and remove.

key : str

Key to read and remove from md.

Returns:

lsst.afw.geom.Angle

Value of the requested key as an angle; Angle(NaN) if the key is not found.

popFloat(md, key)[source]

Pop a float with a default of NaN.

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull key from and remove.

key : str

Key to read and remove from md.

Returns:

float

Value of the requested key as a float; float(“nan”) if the key is not found.

popIsoDate(md, key, timesys=None)[source]

Pop a FITS ISO date as an lsst.daf.base.DateTime

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull key from and remove.

key : str

Date key to read and remove from md.

timesys : str

Time system as a string (not case sensitive), e.g. “UTC” or None; if None then look for TIMESYS (but do NOT pop it, since it may be used for more than one date) and if not found, use UTC.

Returns:

lsst.daf.base.DateTime

Value of the requested date; DateTime() if the key is not found.

popItem(md, key, default=None)[source]

Remove an item of metadata and return the value.

Log a warning if the key is not found.

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull key from and remove.

key : str

Metadata key to extract.

default : object

Value to return if key not found.

Returns:

object

The value of the specified key, using whatever type md.getScalar(key) returns.

popMjdDate(md, key, timesys=None)[source]

Get a FITS MJD date as an lsst.daf.base.DateTime.

Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull key from and remove.

key : str

Date key to read and remove from md.

timesys : str

Time system as a string (not case sensitive), e.g. “UTC” or None; if None then look for TIMESYS (but do NOT pop it, since it may be used for more than one date) and if not found, use UTC.

Returns:

lsst.daf.base.DateTime

Value of the requested date; DateTime() if the key is not found.

setArgDict(md, argDict)[source]

Fill an argument dict with arguments for VisitInfo and pop associated metadata

Subclasses are expected to override this method, though the override may wish to call this default implementation, which:

  • sets exposureTime from “EXPTIME”
  • sets date by calling getDateAvg
Parameters:

md : lsst.daf.base.PropertyList or PropertySet

Metadata to pull from. Items that are used are stripped from the metadata (except TIMESYS, because it may apply to other keywords).

argdict : dict

dict of arguments

Notes

Subclasses should expand this or replace it.