# How should one efficiently get the MJD for a source catalog?

**URL:** <https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733>\
**Category:** Support\
**Tags:** visitinfo, mjd\
**Created:** [June 13, 2019, 4:13pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733 "2019-06-13T16:13:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [June 13, 2019, 4:13pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/1 "2019-06-13T16:13:12Z")

</div>

What’s the right/easy/best way (from Python) to get the MJD for a source catalog for particular `visit`?

1. For the full calexp, I can

```auto
dt = calexp.getInfo().getVisitInfo().getDate().toPython()
from astropy.time import Time
mjd = Time(dt).mjd

```

1. But if I have just the src catalog, the following doesn’t work:

```auto
In [51]: src.getMetadata().getDateTime()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-51-23e838d19621> in <module>
----> 1 src.getMetadata().getDateTime()

TypeError: getDateTime(): incompatible function arguments. The following argument types are supported:
    1. (self: lsst.daf.base.propertyContainer.propertyList.PropertyList, name: str) -> lsst.daf.base.dateTime.dateTime.DateTime
    2. (self: lsst.daf.base.propertyContainer.propertyList.PropertyList, name: str, defaultValue: lsst.daf.base.dateTime.dateTime.DateTime) -> lsst.daf.base.dateTime.dateTime.DateTime

Invoked with: <lsst.daf.base.propertyContainer.propertyList.PropertyList object at 0x2aaaaf4024c8>

```

1. Should I instead query directly the `registry.sqlite3` file, or is there a light-weight way of pulling out the date from a `calexp` without triggering a read of the full image?

---

<div class="post-metadata">

**Author:** ![timj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/timj/32/10_2.png) [@timj](https://www.rubin.community/u/timj)\
**Post date:** [June 13, 2019, 4:18pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/2 "2019-06-13T16:18:07Z")

</div>

> [@mwv](#):
>
> src.getMetadata

That returns a PropertyList and not something that inherently knows about date and time. I don’t know what keywords are defined in the PropertyList of catalogs though.

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [June 13, 2019, 4:52pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/3 "2019-06-13T16:52:12Z")

</div>

Nothing interesting:

```auto
In [5]: src.getMetadata().names()
Out[5]:
['NOISE_SOURCE',
 'NOISE_SEED_MULTIPLIER',
 'NOISE_EXPOSURE_ID',
 'ext_photometryKron_KronFlux_nRadiusForFlux',
 'NOISE_OFFSET',
 'base_CircularApertureFlux_radii']

```

---

<div class="post-metadata">

**Author:** ![parejkoj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/parejkoj/32/138_2.png) [@parejkoj](https://www.rubin.community/u/parejkoj)\
**Post date:** [June 13, 2019, 5:25pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/4 "2019-06-13T17:25:54Z")

</div>

The metadata associated with the `Exposure` is the metadata of the `SourceCatalog`, so the answer is your (1), after `butler.get('calexp_visitInfo', dataId)`, which only reads the header.

---

<div class="post-metadata">

**Author:** ![ktl](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/ktl/32/1373_2.png) [@ktl](https://www.rubin.community/u/ktl)\
**Post date:** [June 13, 2019, 5:44pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/5 "2019-06-13T17:44:09Z")

</div>

Also note that rather than going through Python and Astropy you can retrieve an MJD directly as `calexp.getInfo().getVisitInfo().getDate().get(lsst.daf.base.DateTime.MJD)` for TAI timescale or `...get(lsst.daf.base.DateTime.MJD, lsst.daf.base.DateTime.UTC)` for UTC timescale.

---

<div class="post-metadata">

**Author:** ![mwv](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mwv](https://www.rubin.community/u/mwv)\
**Post date:** [June 13, 2019, 7:42pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/6 "2019-06-13T19:42:49Z")

</div>

Thank you both, @parejkoj and @ktl! That was exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![rseaman](https://avatars.discourse-cdn.com/v4/letter/r/b5a626/32.png) [@rseaman](https://www.rubin.community/u/rseaman)\
**Post date:** [June 14, 2019, 1:39am UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/7 "2019-06-14T01:39:19Z")

</div>

To be pedantic, the MJD of mid-exposure varies from one side of the field to the other (by 1s according to the key numbers, or 0.98s from the youtube shutter video). For rapidly varying or moving objects this effect may be significant. Whether or not normal processing corrects for this, does the metadata include the traverse direction for the double-bladed shutter such that users can later correct for location in the focal plane? Otherwise successive exposures will see opposite edges leading and then trailing the mid-array mid-exposure MJD by 0.49s. Will MOPS include such a correction in astrometry submitted to MPC? How accurately will the mid-array mid-exposure MJD be measured aside from this mechanical constraint?

---

<div class="post-metadata">

**Author:** ![ebellm](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/ebellm/32/771_2.png) [@ebellm](https://www.rubin.community/u/ebellm)\
**Post date:** [April 27, 2023, 9:23pm UTC](https://www.rubin.community/t/how-should-one-efficiently-get-the-mjd-for-a-source-catalog/3733/8 "2023-04-27T21:23:43Z")

</div>

@rseaman Per the [DPDD](https://ls.st/dpdd), each individual catalog measurement will have its own `midPointTai` time that corrects for the motion of the shutter. That time will be what’s used in reporting to the MPC, and users won’t need to apply the correction themselves. OSS-REQ-0087 gives the requirements on timing precision (1 ms) and accuracy (10 ms).
