Skip to content

Commit 33247c1

Browse files
authored
Merge pull request #840 from TOMToolkit/feature/facility_target_selection
Added view to enable target selection for manual observing runs
2 parents 8b27449 + a76bd8e commit 33247c1

16 files changed

Lines changed: 469 additions & 35 deletions

File tree

226 KB
Loading

docs/observing/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Observing Facilities and Observations
99
../common/scripts
1010
strategies
1111
observation_module
12+
selecting_targets_for_facility
1213
../api/tom_observations/models
1314
../api/tom_observations/facilities
1415
../api/tom_observations/views
@@ -26,6 +27,8 @@ the result of prior observations, as well as how to leverage observing templates
2627
:doc:`Building a TOM Observation Facility Module <observation_module>` - Learn to build a module which will
2728
allow your TOM to submit observation requests to observatories.
2829

30+
:doc:`Selecting Targets <selecting_targets_for_facility>` - Display a selection of targets for a specific observing facility.
31+
2932
:doc:`Observation Models <../api/tom_observations/models>` - Learn about the models used to store observation data.
3033

3134
:doc:`Facility Modules <../api/tom_observations/facilities>` - Take a look at the supported facilities.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Selecting Targets for an Observing Facility
2+
===========================================
3+
4+
During observing runs, particularly at manually- or remotely-operated telescope
5+
facilities, it can often be very useful to display a selection of targets to be
6+
observed on a particular night. This needs to take into account target visibility from
7+
the telescope site, as well as any prioritization of targets that the team have made.
8+
9+
TOMs provide support for this through the Target Selection option under the Target menu
10+
in the main navigation bar.
11+
12+
.. image:: target_selection_menu_option.png
13+
:alt: Menu option for Target Selection view
14+
15+
Observers can select the telescope facility that they are observing from using the form
16+
provided, indicating the date of the observing run. The selected targets will be draw
17+
from a predefined Target Grouping, which users can chose from the pulldown menu.
18+
19+
The TOM will evaluate the visibility of the selected sidereal targets for the telescope on the
20+
night in question, and the resulting table will include all objects with a minimum
21+
airmass less than 2.0. Since this is computationally expensive, the visibility is calculated at intervals
22+
of 10min for a 24hr period from the given start time.
23+
24+
.. image:: target_selection_table_default.png
25+
:alt: Default table output for target selection
26+
27+
Customizing the Selected Targets Table
28+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29+
30+
By default, this table will include the essential parameters necessary to point a
31+
telescope at the target, but it can be easily extended to add further information
32+
from a customized target model.
33+
34+
The columns of the table can be configured by editing the TOM's ``settings.py`` file,
35+
and adding a list called ``SELECTION_EXTRA_FIELDS``, as shown in the example below. The entries
36+
in this list can be one or more of the exact names of attributes on your custom Target model.
37+
``SELECTION_EXTRA_FIELDS`` can also include the names of methods on the custom Target model,
38+
provided that they return output that can be rendered as a string entry in the table.
39+
The list can be left empty if no additional fields should be added to the table.
40+
41+
.. code-block:: python
42+
43+
# settings.py
44+
SELECTION_EXTRA_FIELDS = [
45+
'mag_now',
46+
'priority1',
47+
'priority2',
48+
]
49+
50+
In this example, the custom Target model has fields named ``priority1``
51+
and ``priority2`` and a method called ``mag_now``. Adding those fields names to
52+
the ``SELECTION_EXTRA_FIELDS`` list will cause three columns of the same names to appear
53+
in the selected targets table output, containing the priority values and the calculated output of
54+
the ``mag_now`` method.
55+
56+
Adding Facilities to the Observing Facilities Table
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
59+
If you would like to record a telescope facility for the purposes of observation planning, but don't want to
60+
add code for a new facility module, you can add it to the TOM's table of observing facilities.
61+
62+
Currently, this can be done by the TOM's administrator, by navigating to the TOM's built-in admin interface.
63+
This page can be reached by adding ``/admin/`` to the end of the TOM's root URL in your browser's navigation bar, e.g.:
64+
65+
.. code-block:: html
66+
67+
> https://demo.lco.global/admin/
68+
69+
Scrolling down the list of database tables, you will find ``Facilities`` under the tables from the ``tom_observations`` app.
70+
Clicking on this link will take you to a list of telescopes recorded in the TOM's database. Note that this list
71+
is distinct (and does not include) telescopes already known to the TOM through installed facility modules.
72+
73+
You can record new telescopes to this table using the admin interface's ``Add Facility`` button; this will present you
74+
with the following form:
75+
76+
.. image:: add_facility_form_admin.png
77+
:alt: Form to add a new telescope facility
78+
79+
Fill in the form and click ``save``. Now if you return to your TOM's usual interface, and navigate to the ``Target Selection``
80+
page, the facility you added will appear in the list of facilities for which visibilities can be calculated.
81.3 KB
Loading
285 KB
Loading

tom_common/templates/tom_common/navbar_content.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<div class="dropdown-menu">
1313
<a class="dropdown-item" href="{% url 'targets:list' %}">Targets</a>
1414
<a class="dropdown-item" href="{% url 'targets:targetgrouping' %}">Target Grouping</a>
15+
<a class="dropdown-item" href="{% url 'targets:target-selection' %}">Target Selection</a>
1516
</div>
1617
</li>
1718
<li class="nav-item dropdown">
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.26 on 2026-01-15 01:52
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('tom_observations', '0015_remove_facility_mpc_site_code_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AlterModelOptions(
14+
name='facility',
15+
options={'verbose_name_plural': 'facilities'},
16+
),
17+
]

tom_observations/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,8 @@ class Facility(models.Model):
328328
help_text="Root URL of the facilities API endpoints"
329329
)
330330

331+
class Meta:
332+
verbose_name_plural = "facilities"
333+
331334
def __str__(self):
332335
return self.short_name

tom_observations/templatetags/observation_extras.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ def observation_plan(target, facility=None, length=2, interval=60, airmass_limit
108108
start_time = datetime.now()
109109
end_time = start_time + timedelta(days=length)
110110

111-
visibility_data = get_sidereal_visibility(target, start_time, end_time, interval, airmass_limit, facility)
111+
visibility_data = get_sidereal_visibility(
112+
target,
113+
start_time,
114+
end_time,
115+
interval,
116+
airmass_limit,
117+
facility_name=facility
118+
)
112119
i = 0
113120
plot_data = []
114121
for site, data in visibility_data.items():

tom_observations/tests/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ def test_get_visibility_sidereal(self, mock_facility):
460460
mock_facility.return_value = {'Fake Robotic Facility': FakeRoboticFacility}
461461
end = self.start + timedelta(minutes=60)
462462
airmass = get_sidereal_visibility(self.target, self.start, end, self.interval, self.airmass_limit)
463-
airmass_data = airmass['(Fake Robotic Facility) Siding Spring'][1]
463+
464+
airmass_data = airmass['(FakeRoboticFacility) Siding Spring'][1]
464465
expected_airmass = [
465466
1.2619096566629477, 1.2648181328558852, 1.2703522349950636, 1.2785703053923894,
466467
1.2895601364316183, 1.3034413026227516, 1.3203684217446099

0 commit comments

Comments
 (0)