LSST Applications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-10-gbfb87ad6+3307648ee3,21.0.0-15-gedb9d5423+47cba9fc36,21.0.0-2-g103fe59+fdf0863a2a,21.0.0-2-g1367e85+d38a93257c,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g5242d73+d38a93257c,21.0.0-2-g7f82c8f+e682ffb718,21.0.0-2-g8dde007+d179fbfa6a,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+e682ffb718,21.0.0-2-ga63a54e+08647d4b1b,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0445ed2f95,21.0.0-2-gfc62afb+d38a93257c,21.0.0-27-gbbd0d29+ae871e0f33,21.0.0-28-g5fc5e037+feb0e9397b,21.0.0-3-g21c7a62+f4b9c0ff5c,21.0.0-3-g357aad2+57b0bddf0b,21.0.0-3-g4be5c26+d38a93257c,21.0.0-3-g65f322c+3f454acf5d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+9e4ef6332c,21.0.0-3-ge02ed75+4b120a55c4,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-g591bb35+4b120a55c4,21.0.0-4-gc004bbf+4911b9cd27,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-ge8fba5a+2b3a696ff9,21.0.0-5-gb155db7+2c5429117a,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g00874e7+c9fd7f7160,21.0.0-6-g4e60332+4b120a55c4,21.0.0-7-gc8ca178+40eb9cf840,21.0.0-8-gfbe0b4b+9e4ef6332c,21.0.0-9-g2fd488a+d83b7cd606,w.2021.05
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo Class Reference
Inheritance diagram for lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo:
lsst.obs.decam.makeDecamRawVisitInfo.MakeDecamRawVisitInfo

Public Member Functions

def __init__ (self, log=None, doStripHeader=False)
 
def __call__ (self, md, exposureId=None)
 

Static Public Member Functions

def observationInfo2visitInfo (obsInfo, log=None)
 

Public Attributes

 log
 
 doStripHeader
 

Static Public Attributes

 metadataTranslator = None
 

Detailed Description

Base class functor to make a VisitInfo from the FITS header of a
raw image using `~astro_metadata_translator.ObservationInfo` translators.

Subclasses can be used if a specific
`~astro_metadata_translator.MetadataTranslator` translator should be used.

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.

Parameters
----------
log : `lsst.log.Log` or None
    Logger to use for messages.
    (None to use ``Log.getLogger("MakeRawVisitInfoViaObsInfo")``).
doStripHeader : `bool`, optional
    Strip header keywords from the metadata as they are used?

Definition at line 47 of file makeRawVisitInfoViaObsInfo.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.__init__ (   self,
  log = None,
  doStripHeader = False 
)

Definition at line 72 of file makeRawVisitInfoViaObsInfo.py.

72  def __init__(self, log=None, doStripHeader=False):
73  if log is None:
74  log = Log.getLogger("MakeRawVisitInfoViaObsInfo")
75  self.log = log
76  self.doStripHeader = doStripHeader
77 

Member Function Documentation

◆ __call__()

def lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.__call__ (   self,
  md,
  exposureId = None 
)
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.
    May be modified if ``stripHeader`` is ``True``.
exposureId : `int`, optional
    Ignored.  Here for compatibility with `MakeRawVisitInfo`.

Returns
-------
visitInfo : `lsst.afw.image.VisitInfo`
    `~lsst.afw.image.VisitInfo` derived from the header using
    a `~astro_metadata_translator.MetadataTranslator`.

Definition at line 78 of file makeRawVisitInfoViaObsInfo.py.

78  def __call__(self, md, exposureId=None):
79  """Construct a VisitInfo and strip associated data from the metadata.
80 
81  Parameters
82  ----------
83  md : `lsst.daf.base.PropertyList` or `lsst.daf.base.PropertySet`
84  Metadata to pull from.
85  May be modified if ``stripHeader`` is ``True``.
86  exposureId : `int`, optional
87  Ignored. Here for compatibility with `MakeRawVisitInfo`.
88 
89  Returns
90  -------
91  visitInfo : `lsst.afw.image.VisitInfo`
92  `~lsst.afw.image.VisitInfo` derived from the header using
93  a `~astro_metadata_translator.MetadataTranslator`.
94  """
95 
96  obsInfo = ObservationInfo(md, translator_class=self.metadataTranslator)
97 
98  if self.doStripHeader:
99  # Strip all the cards out that were used
100  for c in obsInfo.cards_used:
101  del md[c]
102 
103  return self.observationInfo2visitInfo(obsInfo, log=self.log)
104 

◆ observationInfo2visitInfo()

def lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo (   obsInfo,
  log = None 
)
static
Construct a `~lsst.afw.image.VisitInfo` from an
`~astro_metadata_translator.ObservationInfo`

Parameters
----------
obsInfo : `astro_metadata_translator.ObservationInfo`
    Information gathered from the observation metadata.
log : `logging.Logger` or `lsst.log.Log`, optional
    Logger to use for logging informational messages.
    If `None` logging will be disabled.

Returns
-------
visitInfo : `lsst.afw.image.VisitInfo`
    `~lsst.afw.image.VisitInfo` derived from the supplied
    `~astro_metadata_translator.ObservationInfo`.

Definition at line 106 of file makeRawVisitInfoViaObsInfo.py.

106  def observationInfo2visitInfo(obsInfo, log=None):
107  """Construct a `~lsst.afw.image.VisitInfo` from an
108  `~astro_metadata_translator.ObservationInfo`
109 
110  Parameters
111  ----------
112  obsInfo : `astro_metadata_translator.ObservationInfo`
113  Information gathered from the observation metadata.
114  log : `logging.Logger` or `lsst.log.Log`, optional
115  Logger to use for logging informational messages.
116  If `None` logging will be disabled.
117 
118  Returns
119  -------
120  visitInfo : `lsst.afw.image.VisitInfo`
121  `~lsst.afw.image.VisitInfo` derived from the supplied
122  `~astro_metadata_translator.ObservationInfo`.
123  """
124  argDict = dict()
125 
126  # Map the translated information into a form suitable for VisitInfo
127  if obsInfo.exposure_time is not None:
128  argDict["exposureTime"] = obsInfo.exposure_time.to_value("s")
129  if obsInfo.dark_time is not None:
130  argDict["darkTime"] = obsInfo.dark_time.to_value("s")
131  argDict["exposureId"] = obsInfo.detector_exposure_id
132  argDict["instrumentLabel"] = obsInfo.instrument
133 
134  # VisitInfo uses the middle of the observation for the date
135  if obsInfo.datetime_begin is not None and obsInfo.datetime_end is not None:
136  tdelta = obsInfo.datetime_end - obsInfo.datetime_begin
137  middle = obsInfo.datetime_begin + 0.5*tdelta
138 
139  # DateTime uses nanosecond resolution, regardless of the resolution
140  # of the original date
141  middle.precision = 9
142  # isot is ISO8601 format with "T" separating date and time and no
143  # time zone
144  argDict["date"] = DateTime(middle.tai.isot, DateTime.TAI)
145 
146  # Derive earth rotation angle from UT1 (being out by a second is
147  # not a big deal given the uncertainty over exactly what part of
148  # the observation we are needing it for).
149  # ERFA needs a UT1 time split into two floats
150  # We ignore any problems with DUT1 not being defined for now.
151  try:
152  # Catch any warnings about the time being in the future
153  # since there is nothing we can do about that for simulated
154  # data and it tells us nothing for data from the past.
155  with warnings.catch_warnings():
156  # If we are using the real erfa it is not an AstropyWarning
157  # During transition period filter both
158  warnings.simplefilter("ignore", category=astropy.utils.exceptions.AstropyWarning)
159  if ErfaWarning is not None:
160  warnings.simplefilter("ignore", category=ErfaWarning)
161  ut1time = middle.ut1
162  except iers.IERSRangeError:
163  ut1time = middle
164 
165  era = erfa.era00(ut1time.jd1, ut1time.jd2)
166  argDict["era"] = era * radians
167  else:
168  argDict["date"] = DateTime()
169 
170  # Coordinates
171  if obsInfo.tracking_radec is not None:
172  icrs = obsInfo.tracking_radec.transform_to("icrs")
173  argDict["boresightRaDec"] = SpherePoint(icrs.ra.degree,
174  icrs.dec.degree, units=degrees)
175 
176  altaz = obsInfo.altaz_begin
177  if altaz is not None:
178  argDict["boresightAzAlt"] = SpherePoint(altaz.az.degree,
179  altaz.alt.degree, units=degrees)
180 
181  argDict["boresightAirmass"] = obsInfo.boresight_airmass
182 
183  if obsInfo.boresight_rotation_angle is not None:
184  argDict["boresightRotAngle"] = obsInfo.boresight_rotation_angle.degree*degrees
185 
186  if obsInfo.boresight_rotation_coord is not None:
187  rotType = RotType.UNKNOWN
188  if obsInfo.boresight_rotation_coord == "sky":
189  rotType = RotType.SKY
190  argDict["rotType"] = rotType
191 
192  # Weather and Observatory Location
193  temperature = float("nan")
194  if obsInfo.temperature is not None:
195  temperature = obsInfo.temperature.to_value("deg_C", astropy.units.temperature())
196  pressure = float("nan")
197  if obsInfo.pressure is not None:
198  pressure = obsInfo.pressure.to_value("Pa")
199  relative_humidity = float("nan")
200  if obsInfo.relative_humidity is not None:
201  relative_humidity = obsInfo.relative_humidity
202  argDict["weather"] = Weather(temperature, pressure, relative_humidity)
203 
204  if obsInfo.location is not None:
205  geolocation = obsInfo.location.to_geodetic()
206  argDict["observatory"] = Observatory(geolocation.lon.degree*degrees,
207  geolocation.lat.degree*degrees,
208  geolocation.height.to_value("m"))
209 
210  for key in list(argDict.keys()): # use a copy because we may delete items
211  if argDict[key] is None:
212  if log is not None:
213  log.warn("argDict[%s] is None; stripping", key)
214  del argDict[key]
215 
216  return VisitInfo(**argDict)
lsst::geom::SpherePoint SpherePoint
Definition: misc.h:35
daf::base::PropertyList * list
Definition: fits.cc:913

Member Data Documentation

◆ doStripHeader

lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.doStripHeader

Definition at line 76 of file makeRawVisitInfoViaObsInfo.py.

◆ log

lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.log

Definition at line 75 of file makeRawVisitInfoViaObsInfo.py.

◆ metadataTranslator

lsst.obs.base.makeRawVisitInfoViaObsInfo.MakeRawVisitInfoViaObsInfo.metadataTranslator = None
static

Definition at line 68 of file makeRawVisitInfoViaObsInfo.py.


The documentation for this class was generated from the following file: