-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from LSSTDESC/u/jchiang/add_proper_motion_for_…
…Gaia_stars add proper motion for gaia stars
- Loading branch information
Showing
14 changed files
with
2,291 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
datastore: | ||
cls: lsst.daf.butler.datastores.fileDatastore.FileDatastore | ||
records: | ||
table: file_datastore_records | ||
root: <butlerRoot> | ||
registry: | ||
db: sqlite:///<butlerRoot>/gen3.sqlite3 | ||
managers: | ||
attributes: lsst.daf.butler.registry.attributes.DefaultButlerAttributeManager | ||
collections: lsst.daf.butler.registry.collections.synthIntKey.SynthIntKeyCollectionManager | ||
datasets: lsst.daf.butler.registry.datasets.byDimensions.ByDimensionsDatasetRecordStorageManagerUUID | ||
datastores: lsst.daf.butler.registry.bridge.monolithic.MonolithicDatastoreRegistryBridgeManager | ||
dimensions: lsst.daf.butler.registry.dimensions.static.StaticDimensionRecordStorageManager | ||
opaque: lsst.daf.butler.registry.opaque.ByNameOpaqueTableStorageManager |
Binary file not shown.
290 changes: 290 additions & 0 deletions
290
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131072_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
239 changes: 239 additions & 0 deletions
239
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131073_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
256 changes: 256 additions & 0 deletions
256
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131074_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
224 changes: 224 additions & 0 deletions
224
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131075_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
292 changes: 292 additions & 0 deletions
292
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131076_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
261 changes: 261 additions & 0 deletions
261
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131077_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
285 changes: 285 additions & 0 deletions
285
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131078_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
294 changes: 294 additions & 0 deletions
294
data/ci_sample/repo/refcats/gaia_dr2_20200414/gaia_dr2_20200414_131079_refcats.fits
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import os | ||
from pathlib import Path | ||
import unittest | ||
import numpy as np | ||
import pandas as pd | ||
import lsst.daf.butler as daf_butler | ||
from desc.skycatalogs import skyCatalogs | ||
from desc.skycatalogs.objects import GaiaCollection | ||
|
||
|
||
PACKAGE_DIR = os.path.dirname(os.path.abspath(str(Path(__file__).parent))) | ||
SKYCATALOG_ROOT = os.path.join(PACKAGE_DIR, "data") | ||
CATALOG_DIR = os.path.join(PACKAGE_DIR, "data", "ci_sample") | ||
|
||
|
||
CONFIG = {'area_partition': None, | ||
'butler_parameters': | ||
{'collections': 'refcats', | ||
'dstype': 'gaia_dr2_20200414', | ||
'repo': os.path.join(CATALOG_DIR, 'repo')}, | ||
'data_file_type': 'butler_refcat'} | ||
|
||
|
||
def get_gaia_data(butler_params): | ||
butler = daf_butler.Butler(butler_params['repo'], | ||
collections=[butler_params['collections']]) | ||
refs = set(butler.registry.queryDatasets(butler_params['dstype'])) | ||
return pd.concat(butler.get(_).asAstropy().to_pandas() for _ in refs) | ||
|
||
|
||
class GaiaObjectTestCase(unittest.TestCase): | ||
"""TestCase class for GaiaObjects""" | ||
def setUp(self): | ||
self.df = get_gaia_data(CONFIG['butler_parameters']) | ||
GaiaCollection.set_config(CONFIG) | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_proper_motion(self): | ||
ra, dec = 0, 0 | ||
radius = 1 | ||
region = skyCatalogs.Disk(ra, dec, radius*3600.0) | ||
|
||
# Use start of proper motion epoch, so ra, dec values should | ||
# be unchanged from refcat values. | ||
epoch_a_values = set(self.df['epoch']) | ||
assert len(epoch_a_values) == 1 | ||
mjd0 = epoch_a_values.pop() | ||
object_list = GaiaCollection.load_collection(region, None, mjd=mjd0) | ||
for index in np.random.choice(range(len(object_list)), size=20): | ||
obj = object_list[index] | ||
gaia_id = obj.id.split('_')[-1] | ||
df = self.df.query(f"id=={gaia_id}") | ||
row = df.iloc[0] | ||
self.assertAlmostEqual(np.degrees(row.coord_ra), obj.ra, places=15) | ||
self.assertAlmostEqual(np.degrees(row.coord_dec), obj.dec, | ||
places=15) | ||
|
||
self.assertEqual(mjd0, object_list.mjd) | ||
|
||
# Use a plausible LSST observation date, and ensure that | ||
# calculated proper motion offsets are at least 10% larger | ||
# than the naive estimates. | ||
mjd = 60584. # 2024-10-01 00:00:00 | ||
object_list = GaiaCollection.load_collection(region, None, mjd=mjd) | ||
for index in np.random.choice(range(len(object_list)), size=20): | ||
obj = object_list[index] | ||
gaia_id = obj.id.split('_')[-1] | ||
df = self.df.query(f"id=={gaia_id}") | ||
row = df.iloc[0] | ||
self.assertGreaterEqual(abs(np.radians(obj.ra) - row.coord_ra), | ||
abs(row['pm_ra']*(mjd - mjd0)/365.)/1.1) | ||
self.assertGreaterEqual(abs(np.radians(obj.dec) - row.coord_dec), | ||
abs(row['pm_dec']*(mjd - mjd0)/365.)/1.1) | ||
|
||
self.assertEqual(mjd, object_list.mjd) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |