コード例 #1
0
    def makeDummyVisitInfo(self,
                           azimuth,
                           elevation,
                           exposureId=12345,
                           randomizeTime=False):
        """Make a self-consistent visitInfo object for testing.

        Parameters
        ----------
        azimuth : `lsst.geom.Angle`
            Azimuth angle of the simulated observation.
        elevation : `lsst.geom.Angle`
            Elevation angle of the simulated observation.
        exposureId : `int`, optional
            Unique integer identifier for this observation.
        randomizeTime : `bool`, optional
            Add a random offset to the observation time.

        Returns
        -------
        `lsst.afw.image.VisitInfo`
            VisitInfo for the exposure.
        """
        lsstLat = -30.244639 * u.degree
        lsstLon = -70.749417 * u.degree
        lsstAlt = 2663. * u.m
        lsstTemperature = 20. * u.Celsius
        lsstHumidity = 40.  # in percent
        lsstPressure = 73892. * u.pascal
        loc = EarthLocation(lat=lsstLat, lon=lsstLon, height=lsstAlt)
        airmass = 1.0 / np.sin(elevation.asDegrees())

        time = Time(2000.0, format="jyear", scale="tt")
        if randomizeTime:
            # Pick a random date and time within a 20-year span
            time += 20 * u.year * self.rng.rand()
        altaz = SkyCoord(alt=elevation.asDegrees(),
                         az=azimuth.asDegrees(),
                         unit='deg',
                         obstime=time,
                         frame='altaz',
                         location=loc)
        obsInfo = makeObservationInfo(
            location=loc,
            detector_exposure_id=exposureId,
            datetime_begin=time,
            datetime_end=time,
            boresight_airmass=airmass,
            boresight_rotation_angle=Angle(0. * u.degree),
            boresight_rotation_coord='sky',
            temperature=lsstTemperature,
            pressure=lsstPressure,
            relative_humidity=lsstHumidity,
            tracking_radec=altaz.icrs,
            altaz_begin=altaz,
            observation_type='science',
        )
        visitInfo = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(
            obsInfo)
        return visitInfo
コード例 #2
0
    def makeVisitInfo(self):
        """Construct a VisitInfo from metadata.

        Returns
        -------
        visitInfo : `~lsst.afw.image.VisitInfo`
            Structured metadata about the observation.
        """
        return MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(
            self.observationInfo)
コード例 #3
0
    def makeDummyVisitInfo(self, exposureId, randomizeTime=False):
        """Make a self-consistent visitInfo object for testing.

        Parameters
        ----------
        exposureId : `int`, optional
            Unique integer identifier for this observation.
        randomizeTime : `bool`, optional
            Add a random offset within a 6 hour window to the observation time.

        Returns
        -------
        visitInfo : `lsst.afw.image.VisitInfo`
            VisitInfo for the exposure.
        """
        lsstLat = -30.244639 * u.degree
        lsstLon = -70.749417 * u.degree
        lsstAlt = 2663. * u.m
        lsstTemperature = 20. * u.Celsius
        lsstHumidity = 40.  # in percent
        lsstPressure = 73892. * u.pascal
        loc = EarthLocation(lat=lsstLat, lon=lsstLon, height=lsstAlt)

        time = Time(2000.0, format="jyear", scale="tt")
        if randomizeTime:
            # Pick a random time within a 6 hour window
            time += 6 * u.hour * (self.rngMods.random() - 0.5)
        radec = SkyCoord(dec=self.dec.asDegrees(),
                         ra=self.ra.asDegrees(),
                         unit='deg',
                         obstime=time,
                         frame='icrs',
                         location=loc)
        airmass = float(1.0 / np.sin(radec.altaz.alt))
        obsInfo = makeObservationInfo(
            location=loc,
            detector_exposure_id=exposureId,
            datetime_begin=time,
            datetime_end=time,
            boresight_airmass=airmass,
            boresight_rotation_angle=Angle(0. * u.degree),
            boresight_rotation_coord='sky',
            temperature=lsstTemperature,
            pressure=lsstPressure,
            relative_humidity=lsstHumidity,
            tracking_radec=radec,
            altaz_begin=radec.altaz,
            observation_type='science',
        )
        visitInfo = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(
            obsInfo)
        return visitInfo
コード例 #4
0
    def testObservationInfo2VisitInfo(self):

        with self.assertWarns(UserWarning):
            obsInfo = ObservationInfo(self.header,
                                      translator_class=NewTranslator)

        # No log specified so no log message should appear
        visitInfo = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(
            obsInfo)
        self.assertIsInstance(visitInfo, lsst.afw.image.VisitInfo)
        self.assertAlmostEqual(visitInfo.getExposureTime(),
                               self.exposure_time.to_value("s"))
        self.assertEqual(visitInfo.getExposureId(), self.exposure_id)
        self.assertEqual(
            visitInfo.getDate(),
            DateTime("2001-01-02T03:04:06.123456789Z", DateTime.UTC))
コード例 #5
0
ファイル: assembly.py プロジェクト: gcmshadow/obs_lsst
def attachRawWcsFromBoresight(exposure, dataIdForErrMsg=None):
    """Attach a WCS by extracting boresight, rotation, and camera geometry from
    an Exposure.

    Parameters
    ----------
    exposure : `lsst.afw.image.Exposure`
        Image object with attached metadata and detector components.

    Return
    ------
    attached : `bool`
        If True, a WCS component was successfully created and attached to
        ``exposure``.
    """
    md = exposure.getMetadata()
    # Use the generic version since we do not have a mapper available to
    # tell us a specific translator to use.
    obsInfo = ObservationInfo(md)
    visitInfo = MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(
        obsInfo, log=logger)
    exposure.getInfo().setVisitInfo(visitInfo)

    # LATISS (and likely others) need flipping, DC2 etc do not
    flipX = False
    if obsInfo.instrument in ("LATISS", ):
        flipX = True

    if visitInfo.getBoresightRaDec().isFinite():
        exposure.setWcs(
            createInitialSkyWcs(visitInfo, exposure.getDetector(),
                                flipX=flipX))
        return True

    if obsInfo.observation_type == "science":
        logger.warn(
            "Unable to set WCS from header as RA/Dec/Angle are unavailable%s",
            ("" if dataIdForErrMsg is None else " for dataId %s" %
             dataIdForErrMsg))
    return False