from skyfield.data import hipparcos
s = hipparcos.get('25930')
from skyfield.units import Angle
def cross_index(catalog, name):
'''Uses the New Cross Index (`IV/27A <http://cdsarc.u-strasbg.fr/viz-bin/Cat?IV/27A>`_) to look up designations between catalogs. It also includes the visual magnitude, right ascension, magnitude and constellation abbreviation.
Designations:
Henry Draper Catalog Number ``HD`` (`III/135 <http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=III/135>`_),
Durchmusterung Identification from HD Catalog ``DM`` (see `IV/27A note 1 <http://cdsarc.u-strasbg.fr/viz-bin/Cat?IV/27A#sRM3.1>`_),
General Catalogue of 33342 stars ``GC`` (`I/113 <http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=I/113>`_),
Harvard Revised Number - BSC5 ``HR`` (`V/50 <http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=V/50>`_),
Hipparcos Catalog ``HIP`` (`I/196 <http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=I/196>`_)
You can look solely for the Bayer ``Bayer`` *or* Flamsteed number ``Fl``, or return either with ``BFD``.
`IV/27A note 2 <http://cdsarc.u-strasbg.fr/viz-bin/Cat?IV/27A#sRM3.2>`_ on HIP and CSI (`IV/9 <http://vizier.u-strasbg.fr/viz-bin/VizieR?-source=IV/9>`_) right ascensions and visual magnitude:
Right ascensions, declinations and visual magnitudes for all stars were taken from the Hipparcos catalog and from the CSI for the stars that has no number in catalog Hipparcos.
Here is an example of looking up a star in Orion's belt by using the Hipparcos number:
::
sn_dict = cross_index('HIP','25930')
print(sn_dict['Bayer'],sn_dict['Vmag'],sn_dict['Cst'])
The greek alphabet dictionary was appreciatively taken from Pystaratlas' `catalogues.py <https://code.google.com/p/pystaratlas/source/browse/catalogues.py>`_.
Excluding DE to Dec as a key abbreviation and the addition of epoch, the labels are the same as the New Cross Index.
'''
alphabet={'alf ':'α','alf01':'α¹','alf02':'α²',\
'bet ':'β','bet01':'β¹','bet02':'β²','bet03':'β³',\
'gam ':'γ','gam01':'γ¹','gam02':'γ²','gam03':'γ³',\
'del ':'δ','del01':'δ¹','del02':'δ²','del03':'δ³',\
'eps ':'ε','eps01':'ε¹','eps02':'ε²','eps03':'ε³',\
'zet ':'ζ','zet01':'ζ¹','zet02':'ζ²','zet03':'ζ³',\
'eta ':'η','eta01':'η¹','eta02':'η²','eta03':'η³',\
'the ':'θ','the01':'θ¹','the02':'θ²','the03':'θ³',\
'iot ':'ι','iot01':'ι¹','iot02':'ι²',\
'kap ':'κ','kap01':'κ¹','kap02':'κ²',\
'lam ':'λ','lam01':'λ¹','lam02':'λ²','lam03':'λ³',\
'mu. ':'μ','mu.01':'μ¹','mu.02':'μ²','mu.03':'μ³',\
'nu. ':'ν','nu.01':'ν¹','nu.02':'ν²','nu.03':'ν³',\
'ksi ':'ξ','ksi01':'ξ¹','ksi02':'ξ²','ksi03':'ξ³',\
'omi ':'ο','omi01':'ο¹','omi02':'ο²','omi03':'ο³',\
'pi. ':'π','pi.01':'π¹','pi.02':'π²','pi.03':'π³','pi.04':'π⁴','pi.05':'π⁵','pi.06':'π⁶',\
'rho ':'ρ','rho01':'ρ¹','rho02':'ρ²','rho03':'ρ³',\
'sig ':'σ','sig01':'σ¹','sig02':'σ²','sig03':'σ³',\
'tau ':'τ','tau01':'τ¹','tau02':'τ²','tau03':'τ³','tau04':'τ⁴','tau05':'τ⁵','tau06':'τ⁶','tau07':'τ⁷','tau08':'τ⁸','tau09':'τ⁹',\
'ups ':'υ','ups01':'υ¹','ups02':'υ²','ups03':'υ³',\
'phi ':'φ','phi01':'φ¹','phi02':'φ²','phi03':'φ³','phi04':'φ⁴',\
'chi ':'χ','chi01':'χ¹','chi02':'χ²','chi03':'χ³',\
'psi ':'ψ','psi01':'ψ¹','psi02':'ψ²','psi03':'ψ³','psi04':'ψ⁴','psi05':'ψ⁵','psi06':'ψ⁶','psi07':'ψ⁷','psi08':'ψ⁸','psi09':'ψ⁹',\
'ome ':'ω','ome01':'ω¹','ome02':'ω²','ome03':'ω³'}
cross_index_url = 'ftp://cdsarc.u-strasbg.fr/pub/cats/IV/27A/catalog.dat'
star_dict = {}
#TODO: if used in skyfield load/cache can be used instead of wget. https://github.com/brandon-rhodes/python-skyfield/blob/master/skyfield/data/hipparcos.py and https://github.com/brandon-rhodes/python-skyfield/blob/master/skyfield/io.py
try:
data = open('catalog.dat','r')
except:
import wget
wget.download(cross_index_url)
data = open('catalog.dat','r')
for l in data.readlines():
s = {}
s['HD'] = l[0:6]
s['DM'] = l[7:19]
s['GC'] = l[20:25]
s['HR'] = l[26:30]
if(s['HR'] == ' '): s['HR'] = None
s['HIP'] = l[31:37]
if(s['HIP'] == ' '): s['HIP'] = None
ra = float(l[38:40])+float(l[40:42])/60.+float(l[42:47])/3600.
s['RA'] = Angle(degrees=float(ra))
if(l[48]=='+'):
sign=1
else:
sign=-1
dec = sign*float(l[49:51])+float(l[51:53])/60.+float(l[53:57])/3600.
s['Dec'] = Angle(degrees=float(dec))
s['Vmag'] = l[58:63]
s['Fl'] = l[64:67]
s['Bayer']= l[68:73]
if(s['Bayer'] == ' '):
s['Bayer'] = None
else:
try:
s['Bayer'] = alphabet[s['Bayer']]
except:
pass
if(s['Bayer']):
s['BFD'] = s['Bayer']
elif(s['Fl']):
s['BFD'] = s['Fl']
else:
s['BFD'] = None
s['Cst'] = l[74:77]
s['epoch'] = 2000 # The New Cross Index (IV/27A) uses epoch 2000.
# This function could be modified to look at a range of magnitudes, positions, or by constellation.
if(s[catalog] is not None and s[catalog].lower().strip() == name.lower().strip()):
return s
return False
n = cross_index('HIP','25930')
print(n)
print(n['Bayer'])
{'HIP': ' 25930', 'DM': 'BD-00 983 ', 'Vmag': ' 2.25', 'HR': '1852', 'BFD': '\xce\xb4', 'epoch': 2000, 'GC': ' 6847', 'RA': <Angle 05deg 32' 00.4">, 'Cst': 'Ori', 'Bayer': '\xce\xb4', 'Dec': <Angle 00deg 17' 56.7">, 'Fl': ' 34', 'HD': ' 36486'}
δ
s.names = n
print(s.names)
print(s.names['Bayer'])
{'HIP': ' 25930', 'DM': 'BD-00 983 ', 'Vmag': ' 2.25', 'HR': '1852', 'BFD': '\xce\xb4', 'epoch': 2000, 'GC': ' 6847', 'RA': <Angle 05deg 32' 00.4">, 'Cst': 'Ori', 'Bayer': '\xce\xb4', 'Dec': <Angle 00deg 17' 56.7">, 'Fl': ' 34', 'HD': ' 36486'}
δ
My apologies for all the issues this week. I've just been integrating Skyfield into a project and it has been useful enough that I've read through the code a few times :).
If this fits in with what you want for Skyfield, let me know and I can make a pull request for it.