Skip to content

Commit

Permalink
Merge pull request #1012 from TOMToolkit/993-enable-user-to-deselect-…
Browse files Browse the repository at this point in the history
…guiding-in-lco-observations

add guiding to LCO imaging facility page
  • Loading branch information
jchate6 authored Aug 22, 2024
2 parents 1da554c + 582b26a commit 4a781c7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 24 deletions.
26 changes: 26 additions & 0 deletions tom_observations/facilities/lco.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ def get_final_accordion_items(self, instance):
)


class ImagingConfigurationLayout(LCOConfigurationLayout):
def _get_basic_config_layout(self, instance):
return super()._get_basic_config_layout(instance) + (
Div(
f'c_{instance}_guide_mode',
css_class='form-row'
),
)


class MuscatConfigurationLayout(LCOConfigurationLayout):
def _get_target_override(self, instance):
if instance == 1:
Expand Down Expand Up @@ -524,19 +534,35 @@ class LCOImagingObservationForm(LCOFullObservationForm):
Imagers and their details can be found here: https://lco.global/observatory/instruments/
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Need to add guiding
for j in range(self.facility_settings.get_setting('max_configurations')):
self.fields[f'c_{j+1}_guide_mode'] = forms.ChoiceField(
choices=self.mode_choices('guiding'), required=False, initial='ON', label='Guide Mode')

def get_instruments(self):
instruments = super().get_instruments()
return {
code: instrument for (code, instrument) in instruments.items() if (
'IMAGE' == instrument['type'] and 'MUSCAT' not in code and 'SOAR' not in code)
}

def configuration_layout_class(self):
return ImagingConfigurationLayout

def form_name(self):
return 'image'

def configuration_type_choices(self):
return [('EXPOSE', 'Exposure'), ('REPEAT_EXPOSE', 'Exposure Sequence')]

def _build_guiding_config(self, configuration_id=1):
guiding_config = super()._build_guiding_config()
guiding_config['mode'] = self.cleaned_data[f'c_{configuration_id}_guide_mode']
guiding_config['optional'] = True
return guiding_config


class LCOMuscatImagingObservationForm(LCOFullObservationForm):
"""
Expand Down
53 changes: 29 additions & 24 deletions tom_observations/facilities/ocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,30 +499,7 @@ def _get_config_tabs(self, oe_groups, num_tabs):

def _get_config_layout(self, instance, oe_groups):
return (
Alert(
content="""When using multiple configurations, ensure the instrument types are all
available on the same telescope class.
""",
css_class='alert-warning'
),
Div(
Div(
f'c_{instance}_instrument_type',
css_class='col'
),
Div(
f'c_{instance}_configuration_type',
css_class='col'
),
css_class='form-row'
),
Div(
Div(
f'c_{instance}_repeat_duration',
css_class='col'
),
css_class='form-row'
),
*self._get_basic_config_layout(instance),
*self._get_target_override(instance),
Accordion(
*self.get_initial_accordion_items(instance),
Expand Down Expand Up @@ -565,6 +542,34 @@ def get_final_accordion_items(self, instance):
"""
return ()

def _get_basic_config_layout(self, instance):
return (
Alert(
content="""When using multiple configurations, ensure the instrument types are all
available on the same telescope class.
""",
css_class='alert-warning'
),
Div(
Div(
f'c_{instance}_instrument_type',
css_class='col'
),
Div(
f'c_{instance}_configuration_type',
css_class='col'
),
css_class='form-row'
),
Div(
Div(
f'c_{instance}_repeat_duration',
css_class='col'
),
css_class='form-row'
),
)

def _get_target_override(self, instance):
if instance == 1:
return ()
Expand Down

0 comments on commit 4a781c7

Please sign in to comment.