Skip to content

Commit

Permalink
Merge pull request #76 from altairgomes/gaiadr3
Browse files Browse the repository at this point in the history
Implement Gaia-DR3
  • Loading branch information
Bmorgado19 authored Jun 21, 2022
2 parents 3bdd1df + c6671b7 commit 02bab6b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 10 deletions.
11 changes: 11 additions & 0 deletions docs/releases/v0.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ New Features
sora.body
^^^^^^^^^

- Added `get_position()` in Body as a shortcut to `ephem.get_position()`. [:issue:`76`]

sora.config
^^^^^^^^^^^

Expand All @@ -30,6 +32,8 @@ sora.prediction

- Included the ``VizierCatalogue`` in the prediction function. [:issue:`71`]

- Defined Gaia-DR3 as the default in the `prediction()` function. [:issue:`76`]

sora.star
^^^^^^^^^

Expand All @@ -38,6 +42,10 @@ sora.star

- Included the ``VizierCatalogue`` in the Star class. [:issue:`71`]

- Included the Gaia-DR3 catalogue, released on June 13, 2022, in the catalogue list. [:issue:`76`]

- Defined Gaia-DR3 as the default in the Star class. [:issue:`76`]

API Changes
-----------

Expand All @@ -50,6 +58,9 @@ sora.config
sora.ephem
^^^^^^^^^^

- `id_type` for planets and satellites are passed as `None` instead of `major_body`,
following changes made in Horizons. [:issue:`76`]

sora.extra
^^^^^^^^^^

Expand Down
20 changes: 20 additions & 0 deletions sora/body/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,26 @@ def __from_local(self, name, spkid):
"Tholen": {"value": None, "reference": None, "notes": None}}
self.discovery = ""

def get_position(self, time, observer='geocenter'):
"""Returns the object geocentric position.
Parameters
----------
time : `str`, `astropy.time.Time`
Reference time to calculate the object position. It can be a string
in the ISO format (yyyy-mm-dd hh:mm:ss.s) or an astropy Time object.
observer : `str`, `sora.Observer`, `sora.Spacecraft`
IAU code of the observer (must be present in given list of kernels),
a SORA observer object or a string: ['geocenter', 'barycenter']
Returns
-------
coord : `astropy.coordinates.SkyCoord`
Astropy SkyCoord object with the object coordinates at the given time.
"""
return self.ephem.get_position(time=time, observer=observer)

def get_pole_position_angle(self, time, observer='geocenter'):
"""Returns the pole position angle and the aperture angle relative to
the geocenter.
Expand Down
1 change: 1 addition & 0 deletions sora/ephem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def ephem_horizons(time, target, observer, id_type='smallbody', output='ephemeri
if getattr(observer, 'ephem', None) not in ['horizons', None]:
warnings.warn('Ephemeris using kernel for the observer and Horizons for the target is under construction. '
'We will use only Horizons.')
id_type = None if id_type == 'majorbody' else id_type
ob = Horizons(id=target, id_type=id_type, location=location, epochs=time2)

if output == 'ephemeris':
Expand Down
4 changes: 2 additions & 2 deletions sora/prediction/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def calc_min(time0, time_interval, delta_t, n_recursions=5, max_tdiff=None):


@deprecated_alias(log='verbose') # remove this line in v1.0
def prediction(time_beg, time_end, body=None, ephem=None, mag_lim=None, catalogue='gaiaedr3', step=60, divs=1, sigma=1,
def prediction(time_beg, time_end, body=None, ephem=None, mag_lim=None, catalogue='gaiadr3', step=60, divs=1, sigma=1,
radius=None, verbose=True, reference_center='geocenter'):
"""Predicts stellar occultations.
Expand All @@ -141,7 +141,7 @@ def prediction(time_beg, time_end, body=None, ephem=None, mag_lim=None, catalogu
catalogue : `str`, `VizierCatalogue`
The catalogue to download data. It can be ``'gaiadr2'``, ``'gaiaedr3'``,
or a VizierCatalogue object. default='gaiaedr3'
``'gaiadr3'``, or a VizierCatalogue object. default='gaiadr3'
step : `int`, `float`, default=60
Step, in seconds, of ephem times for search
Expand Down
8 changes: 7 additions & 1 deletion sora/star/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,11 @@ def __str__(self):
pmra='pmRA', pmdec='pmDE', epoch='Epoch', parallax='Plx', rad_vel='RVDR2', band={'G': 'Gmag'},
errors=['e_RA_ICRS', 'e_DE_ICRS', 'e_pmRA', 'e_pmDE', 'e_Plx', 'e_RVDR2'])

epoch = Time('J2016.0', scale='tdb')
gaiadr3 = VizierCatalogue(name='GaiaDR3', cat_path='I/355/gaiadr3', code='Source', ra='RA_ICRS', dec='DE_ICRS',
pmra='pmRA', pmdec='pmDE', epoch=epoch, parallax='Plx', rad_vel='RV', band={'G': 'Gmag'},
errors=['e_RA_ICRS', 'e_DE_ICRS', 'e_pmRA', 'e_pmDE', 'e_Plx', 'e_RV'])


allowed_catalogues = SelectDefault(instance=VizierCatalogue, defaults={'gaiadr2': gaiadr2, 'gaiaedr3': gaiaedr3})
allowed_catalogues = SelectDefault(instance=VizierCatalogue,
defaults={'gaiadr2': gaiadr2, 'gaiaedr3': gaiaedr3, 'gaiadr3': gaiadr3})
12 changes: 6 additions & 6 deletions sora/star/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Star(MetaStar):
----------
catalogue : `str`, `VizierCatalogue`
The catalogue to download data. It can be ``'gaiadr2'``, ``'gaiaedr3'``,
or a VizierCatalogue object.. default='gaiaedr3'
``'gaiadr3'``, or a VizierCatalogue object.. default='gaiadr3'
code : `str`
Gaia Source code for searching in VizieR.
Expand Down Expand Up @@ -81,7 +81,7 @@ class Star(MetaStar):
"""

@deprecated_alias(log='verbose') # remove this line in v1.0
def __init__(self, catalogue='gaiaedr3', **kwargs):
def __init__(self, catalogue='gaiadr3', **kwargs):

self._attributes = {}
self.mag = {}
Expand Down Expand Up @@ -286,7 +286,7 @@ def __searchgaia(self, catalog):
Parameters
----------
catalog : `VizierCatalogue`
The catalogue to download data. It can be ``'gaiadr2'`` or ``'gaiaedr3'``.
The catalogue to download data. It can be ``'gaiadr2'``, ``'gaiaedr3'`` or ``'gaiadr3'``.
"""
if hasattr(self, 'code'):
catalogue = catalog.search_star(code=self.code)
Expand All @@ -307,7 +307,7 @@ def __searchgaia(self, catalog):
self.code = str(cat_data['code'][0])
self.epoch = cat_data['epoch'][0]
self.set_magnitude(**{band: value[0].value for band, value in cat_data['band'].items()})
if self.__cgaudin and catalog.name == 'GaiaEDR3':
if self.__cgaudin and catalog.name in ['GaiaEDR3', 'GaiaDR3']:
from sora.star.utils import edr3ToICRF
self.pmra, self.pmdec = edr3ToICRF(pmra = self.pmra, pmdec = self.pmdec,
ra = self.ra.deg, dec = self.dec.deg,
Expand Down Expand Up @@ -336,7 +336,7 @@ def __searchgaia(self, catalog):
x = cov[2, 2] * (self.rad_vel.value ** 2 + self.errors['rad_vel'].value ** 2) / (
A ** 2) + (self.parallax.to(u.rad).value * self.errors['rad_vel'].value / A) ** 2
cov[5, 5] = x
if catalog.name in ['GaiaDR2', 'GaiaEDR3']:
if catalog.name in ['GaiaDR2', 'GaiaEDR3', 'GaiaDR3']:
a = ['RA', 'DE', 'Plx', 'pmRA', 'pmDE']
for i in np.arange(5):
v1 = 'e_' + a[i]
Expand Down Expand Up @@ -541,7 +541,7 @@ def __str__(self):
out += 'User coordinates\n'
text_cgaudin = ''
if self.__cgaudin:
text_cgaudin = 'Gaia-EDR3 Proper motion corrected as suggested by Cantat-Gaudin & Brandt (2021) \n'
text_cgaudin = f'{self._catalogue} Proper motion corrected as suggested by Cantat-Gaudin & Brandt (2021) \n'
out += ('ICRS star coordinate at J{}:\n'
'RA={} +/- {:.4f}, DEC={} +/- {:.4f}\n'
'pmRA={:.3f} +/- {:.3f} mas/yr, pmDEC={:.3f} +/- {:.3f} mas/yr\n{}'
Expand Down
2 changes: 1 addition & 1 deletion sora/star/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def bjones(self, value):
@property
def diameter_gaia(self):
try:
rad = self.meta_gaia.get('Rad')
rad = self.meta_catalogue.get('Rad')
if rad is not None and not np.ma.core.is_masked(rad):
return 2*np.arctan((rad*u.solRad)/self.distance).to(u.mas)
except:
Expand Down

0 comments on commit 02bab6b

Please sign in to comment.