forked from zkbt/zachopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatalogs.py
More file actions
87 lines (71 loc) · 3.54 KB
/
Copy pathcatalogs.py
File metadata and controls
87 lines (71 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from collections import OrderedDict
import numpy as np
class CatalogEntry(object):
pass
class Magellan(CatalogEntry):
def __init__(self, star):
'''initialize a basic Magellan catalog entry, from a star object'''
self.colnames = [ 'number', # a reference number
'name', # the name of the target, no spaces
'ra', # right ascension
'dec', # declination
'equinox', # equinox of coordinates
'pmra', # in seconds of time per year (s.ss)
'pmdec', # in arcseconds per year (s.ss)
'rotatorangle', # rotator offset angle (dd.d)
'rotatormode', # rotator offset mode
'guide1_ra', # for guide star, leave 00:00:00
'guide1_dec', # for guide star, leave 00:00:00
'guide1_equinox', # for guide star, leave 2000.0
'guide2_ra', # for guide star, leave 00:00:00
'guide2_dec', # for guide star, leave 00:00:00
'guide2_equinox', # for guide star, leave 2000.0
'epoch'] # the epoch of the ra and dec, for PM
self.columns = OrderedDict()
for col in self.colnames:
self.columns[col] = None
self.star = star
self.populate()
def populate(self, epoch=2016.3):
self.columns['name'] = self.star.name.replace(' ', '')
self.columns['ra'], self.columns['dec'] = self.star.posstring(epoch, delimiter=':').split()[0:2]
self.columns['equinox'] = 2000.0
magpmra = self.star.pmra/1000.0/np.cos(self.star.icrs.dec.rad)/15.0
self.columns['pmra'] = magpmra
magpmdec = self.star.pmdec/1000.0
self.columns['pmdec'] = magpmdec
for k in ['pmra', 'pmdec']:
try:
assert(self.self.columns[k].mask == False)
except (AssertionError,AttributeError):
self.columns[k] = 0.0
print "replaced masked {0} with 0".format(k
)
# set the rotator mode to offset nothing from last position
self.columns['rotatorangle'] = 0.0
self.columns['rotatormode'] = 'OFF'
# deal with non-existant guide stars
self.columns['guide1_ra'] = '00:00:00'
self.columns['guide1_dec'] = '+00:00:00'
self.columns['guide1_equinox'] = '2000.0'
self.columns['guide2_ra'] = '00:00:00'
self.columns['guide2_dec'] = '+00:00:00'
self.columns['guide2_equinox'] = '2000.0'
self.columns['epoch'] = self.star.icrs.obstime.value
for k,v in self.star.attributes.iteritems():
self.columns[k] = v
try:
self.columns['comment']
except KeyError:
self.columns['comment'] = ''
def machine(self):
f = 'M{number:03.0f} {name:25s} {ra:10s} {dec:9s} {equinox:6.1f} {pmra:>5.2f} {pmdec:>5.2f} {rotatorangle:>6.1f} {rotatormode:3s} {guide1_ra} {guide1_dec} {guide1_equinox} {guide2_ra} {guide2_dec} {guide2_equinox} {epoch:6.1f}'
return f.format(**self.columns)
def human(self):
f = 'M{number:03.0f} {name:25s} {ra:10s} {dec:9s} # V={V:4.1f}, {comment}'
return f.format(**self.columns)
class MIKE(Magellan):
def populate(self, *args, **kwargs):
Magellan.populate(self, *args, **kwargs)
self.columns['rotatorangle'] = 0.0
self.columns['rotatormode'] = 'GRV'