Skip to content

Commit 141e723

Browse files
committed
use the Swifttools TOO()-supplied list of observation types
1 parent f9ea18b commit 141e723

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

tom_swift/swift.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
from tom_swift import __version__
1414
from tom_swift.swift_api import (SwiftAPI,
1515
SWIFT_INSTRUMENT_CHOICES,
16-
SWIFT_OBSERVATION_TYPE_CHOICES,
1716
SWIFT_TARGET_CLASSIFICATION_CHOICES,
1817
SWIFT_URGENCY_CHOICES,
19-
SWIFT_XRT_MODE_CHOICES)
18+
SWIFT_XRT_MODE_CHOICES,
19+
get_observation_type_choices,
2020
get_monitoring_unit_choices,)
2121

2222
logger = logging.getLogger(__name__)
@@ -91,9 +91,8 @@ class SwiftObservationForm(BaseObservationForm):
9191
obs_type = forms.ChoiceField(
9292
required=True,
9393
label='Observation Type',
94-
choices=SWIFT_OBSERVATION_TYPE_CHOICES,
95-
help_text='What is driving the exposure time?',
96-
initial=SWIFT_OBSERVATION_TYPE_CHOICES[0])
94+
choices=get_observation_type_choices(),
95+
help_text='What is driving the exposure time?')
9796

9897
#
9998
# Description of the source brightness for various instruments

tom_swift/swift_api.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,17 @@ def resolve_target(self, target: Target):
103103
# Note that:
104104
# >>> TOO().obs_types
105105
# ['Spectroscopy', 'Light Curve', 'Position', 'Timing']
106-
SWIFT_OBSERVATION_TYPE_CHOICES = [
107-
('Spectroscopy', 'Spectroscopy'),
108-
('Light Curve', 'Light Curve'),
109-
('Position', 'Position'),
110-
('Timing', 'Timing'),
111-
]
106+
107+
def get_observation_type_choices():
108+
"""Returns a list of tuples for the observation type choices.
109+
110+
Since the TOO() object has propperty describing the valid observation types,
111+
use that to create the choices list of tuples (e.g. [('Spectroscopy', 'Spectroscopy'), ('Light Curve', 'Light Curve'), ...]).
112+
"""
113+
observation_type_choices = []
114+
for obs_type in TOO().obs_types:
115+
observation_type_choices.append((obs_type, obs_type))
116+
return observation_type_choices
112117

113118
#
114119
# Instruments

0 commit comments

Comments
 (0)