-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtargetClass.py
More file actions
144 lines (108 loc) · 3.64 KB
/
Copy pathtargetClass.py
File metadata and controls
144 lines (108 loc) · 3.64 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import numpy
import datetime
import calendar
import pylab
import scipy.interpolate as spint
import astropy.coordinates as coord
import astropy.units as u
NOACTIONSET = 0
class Target():
"""
Individual targets
"""
def __init__(self, RA, Dec, reqObsTime, name="None", scienceGoal=-1, ObsPlan=False, idnumber=0):
"""
RA: float
Right Acension (J2000, decimal)
Dec: float
Declination (J2000, decimal)
reqObsTime : float
Total required observation time (s)
name : string
target name
scienceGoal : int or [int, int,...]
Science goal target(s) target applies to
ObsPlan : ObsPlan
The parent observation plan this target is within
"""
self.RA = RA
self.Dec = Dec
self.Coord = coord.SkyCoord(RA*u.deg, Dec*u.deg)
self.reqObsTime = reqObsTime
self.copmleteObsTime = 0
self.targetComplete=False
self.name = name
try:
tmp = iter(scieneGoal)
except:
scienceGoal = [scienceGoal]
self.scienceGoal = scienceGoal
self.ObsPlan = ObsPlan
self.idNumber=idnumber
self.restrictions=[]
def set_time_intervals(self, timeList):
# all the times go here
self.timeList = timeList
# this is for the hardwired, permanent, what can be seen
self.visibility = numpy.ones(len(timeList), dtype=bool)
# this is the visibilty, plus periods ruled out for other activities
self.startVisibility = numpy.ones(len(timeList), dtype=bool)
def calc_visibility(self, restrictions, startTimeIndex=0, firstCalc=False):
"""
Calculate the times on which the target is visible
restrictions : observatory_restrictions
The various restrictions which are enforced
startTimeIndex : int
Only calculate visibility after this time, all before is
set to False (used to ignore visibility in the past)
"""
# apply general restrictions
for r in restrictions:
if ((r.needsRecalculated != False) | (firstCalc==True)):
tmp = r.applyRestriction(self)
self.visibility[tmp==False] = False
# set the visibility to match the results
# self.visibility= isgood
# set the visibility to False for all the earlier observations
self.visibility[:startTimeIndex] = False
# now calculate target specific restrictions
# self.visibility[self.ObsPlan.observatoryActions != NOACTIONSET] = False
def calc_start_visibility(self, timeIndex):
"""
This updates the softVisibility based on the current observation plan
The idea is this reflects potential starting points of observations instead
of hardwired times
"""
self.startVisibility[:timeIndex]=False
for r in self.restrictions:
tmp = r.applyRestriction(self)
self.startVisibility[tmp==False] = False
# self.startVisibility = numpy.zeros(len(timelist), dtype=bool)
def add_restriction(self, restriction):
self.restrictions.append(restriction)
class TargetType():
"""
Class for groups of targets
"""
def __init__(self, name="None", scienceGoal=-1, ObsPlan=False):
"""
name : string
target name
scienceGoal : int or [int, int,...]
Science goal target(s) target applies to
ObsPlan : ObsPlan
The parent observation plan this target is within
"""
self.name=name
self.scienceGoal = scienceGoal
self.ObsPlan = ObsPlan
self.restrictions = []
seld.targets = []
def add_target(self, target):
self.targets.append(target)
def add_restriction(self, restriction):
self.restrictions.append(restrictions)
def apply_restrictions():
for r in self.restrictions:
for t in self.targets:
r.apply_restriction(t)