Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tribeiro committed Nov 22, 2024
2 parents 83bba15 + 5a2d4c4 commit 4c2d755
Show file tree
Hide file tree
Showing 11 changed files with 723 additions and 4 deletions.
2 changes: 2 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build:
test:
requires:
- ts-conda-build =0.4
- ts-utils
- rubin-scheduler =3
- {{ pin_compatible('rubin-scheduler', min_pin='x') }}
source_files:
Expand Down Expand Up @@ -42,3 +43,4 @@ requirements:
run:
- python {{ python }}
- {{ pin_compatible('rubin-scheduler', min_pin='x') }}
- ts-utils
5 changes: 5 additions & 0 deletions doc/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Version History
===============

v0.14.0
-------

* Update ``MakeFieldSurveyScheduler`` with ``add_field_altaz_surveys`` method, that will add ``FieldAltAzSurvey`` to the list of surveys.

v0.13.1
-------

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ version = { attr = "setuptools_scm.get_version" }

[tool.setuptools.packages.find]
where = [ "python" ]

[project.scripts]
make_pointing_model_grid = "lsst.ts.fbs.utils.maintel.pointing_model.__main__:main"

[tool.setuptools_scm]
write_to = "python/lsst/ts/fbs/utils/version.py"
Expand Down
35 changes: 35 additions & 0 deletions python/lsst/ts/fbs/utils/data/pointing-tiles-block-324.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Name Alt Az
BLOCK-324_001 45.14 -162.81
BLOCK-324_002 61.08 -160.35
BLOCK-324_003 74.54 -149.90
BLOCK-324_004 45.38 -141.73
BLOCK-324_005 61.22 -125.84
BLOCK-324_006 45.47 -122.61
BLOCK-324_007 45.57 -103.32
BLOCK-324_008 58.20 -98.91
BLOCK-324_009 70.98 -94.50
BLOCK-324_010 45.62 -82.92
BLOCK-324_011 64.90 -62.15
BLOCK-324_012 45.48 -60.03
BLOCK-324_013 57.76 -36.59
BLOCK-324_014 45.25 -28.70
BLOCK-324_015 48.52 -14.78
BLOCK-324_016 49.62 0.48
BLOCK-324_017 62.95 0.71
BLOCK-324_018 76.28 1.33
BLOCK-324_019 48.37 15.69
BLOCK-324_020 44.97 29.49
BLOCK-324_021 57.41 37.60
BLOCK-324_022 44.98 60.59
BLOCK-324_023 64.38 62.99
BLOCK-324_024 45.04 83.27
BLOCK-324_025 70.40 94.64
BLOCK-324_026 57.62 99.05
BLOCK-324_027 45.01 103.47
BLOCK-324_028 44.98 122.57
BLOCK-324_029 60.75 125.51
BLOCK-324_030 45.02 141.55
BLOCK-324_031 74.25 148.39
BLOCK-324_032 60.88 159.64
BLOCK-324_033 44.97 162.53
BLOCK-324_034 50.38 179.79
35 changes: 35 additions & 0 deletions python/lsst/ts/fbs/utils/data/pointing-tiles-block-328.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Name Alt Az
BLOCK-328_001 45.13 -162.87
BLOCK-328_002 61.07 -160.44
BLOCK-328_003 74.56 -150.11
BLOCK-328_004 45.38 -141.80
BLOCK-328_005 61.30 -125.97
BLOCK-328_006 45.61 -122.67
BLOCK-328_007 45.59 -103.39
BLOCK-328_008 58.22 -98.99
BLOCK-328_009 70.99 -94.59
BLOCK-328_010 45.64 -82.98
BLOCK-328_011 64.92 -62.20
BLOCK-328_012 45.64 -59.90
BLOCK-328_013 57.83 -36.48
BLOCK-328_014 45.28 -28.73
BLOCK-328_015 48.54 -14.80
BLOCK-328_016 49.63 0.47
BLOCK-328_017 62.97 0.71
BLOCK-328_018 76.30 1.38
BLOCK-328_019 48.38 15.68
BLOCK-328_020 44.98 29.47
BLOCK-328_021 57.46 37.47
BLOCK-328_022 45.10 60.42
BLOCK-328_023 64.37 63.00
BLOCK-328_024 45.02 83.25
BLOCK-328_025 70.37 94.65
BLOCK-328_026 57.60 99.03
BLOCK-328_027 44.98 103.44
BLOCK-328_028 45.08 122.53
BLOCK-328_029 60.79 125.51
BLOCK-328_030 44.99 141.50
BLOCK-328_031 74.24 148.40
BLOCK-328_032 60.85 159.58
BLOCK-328_033 44.95 162.48
BLOCK-328_034 50.36 179.72
64 changes: 61 additions & 3 deletions python/lsst/ts/fbs/utils/maintel/make_fieldsurvey_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import typing

import yaml
from lsst.ts.fbs.utils import get_data_dir
from rubin_scheduler.scheduler.basis_functions import BaseBasisFunction
from lsst.ts.fbs.utils import get_data_dir, get_pointing_model_grid_data
from rubin_scheduler.scheduler.basis_functions import BaseBasisFunction, VisitGap
from rubin_scheduler.scheduler.detailers import BaseDetailer
from rubin_scheduler.scheduler.schedulers import CoreScheduler
from rubin_scheduler.scheduler.surveys import BaseSurvey, FieldSurvey
from rubin_scheduler.scheduler.surveys import BaseSurvey, FieldAltAzSurvey, FieldSurvey


class MakeFieldSurveyScheduler:
Expand Down Expand Up @@ -113,6 +113,64 @@ def add_field_surveys(
)
)

def add_field_altaz_surveys(
self,
tier: int,
observation_reason: str,
science_program: str,
survey_name: str | None = None,
basis_functions: typing.List[BaseBasisFunction] = [],
sequence: str = "ugrizy",
nvisits: dict | None = None,
exptimes: dict | None = None,
nexps: dict | None = None,
detailers: typing.List[BaseDetailer] = [],
**kwargs: typing.Any,
) -> None:
"""Add a list of field surveys to the scheduler configuration.
Parameters
----------
tier: `int`
Tier index used to control prioritization of surveys.
json_block: `str`
JSON BLOCK used to perform the observations.
observation_reason: `str`
Purpose of the observation, e.g., "science"
science_program: `str`
Name of the science program.
basis_functions: `list` of `BaseBasisFunction`
Basis functions provided to each field survey.
"""

targets = get_pointing_model_grid_data(science_program=science_program)

for target_name, alt, az in targets:

self.surveys[tier].append(
FieldAltAzSurvey(
basis_functions=[VisitGap(note=target_name, gap_min=420)]
+ basis_functions,
alt=alt,
az=az,
sequence=sequence,
nvisits=nvisits,
exptimes=exptimes,
nexps=nexps,
ignore_obs=None,
survey_name=survey_name,
target_name=target_name,
science_program=science_program,
observation_reason=observation_reason,
scheduler_note=target_name,
readtime=2.4,
filter_change_time=120.0,
nside=self.nside,
flush_pad=30.0,
detailers=detailers,
)
)

def add_cwfs_survey(self) -> None:
"""Add curvature wavefront sensing survey."""
pass
Expand Down
22 changes: 22 additions & 0 deletions python/lsst/ts/fbs/utils/maintel/pointing_model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is part of ts_fbs_utils.
#
# Developed for the Vera Rubin Observatory Telescope and Site System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from .pointing_model import *
114 changes: 114 additions & 0 deletions python/lsst/ts/fbs/utils/maintel/pointing_model/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# This file is part of ts_fbs_utils.
#
# Developed for the Vera Rubin Observatory Telescope and Site System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import argparse

import numpy as np
from astropy import units
from astropy.coordinates import Angle

from ... import get_data_dir
from .pointing_model import AltAzLimits, make_pointing_grid_hadec


def main() -> None:
parser = argparse.ArgumentParser("make_pointing_model_grid")

parser.add_argument(
"--min_altitude",
type=float,
help="Minimum altitude, in degrees.",
default=45.0,
)
parser.add_argument(
"--max_altitude",
type=float,
help="Maximum altitude, in degrees.",
default=80.0,
)
parser.add_argument(
"--min_azimuth",
type=float,
help="Minimum azimuth, in degrees.",
default=-180.0,
)
parser.add_argument(
"--max_azimuth",
type=float,
help="Maximum azimuth, in degrees.",
default=180,
)
parser.add_argument(
"--dec_min",
type=float,
help="Minimum declination, in degrees.",
default=-70,
)
parser.add_argument(
"--dec_max",
type=float,
help="Maximum declination, in degrees.",
default=10,
)
parser.add_argument(
"--hour_angle_n_grid",
type=int,
nargs="+",
help="A sequence of numbers that specify the number of poitings in RA for each declination.",
default=[3, 4, 6, 8, 5, 5, 5],
)
parser.add_argument(
"--block",
type=str,
help="Block name.",
required=True,
)

args = parser.parse_args()

altaz_limits = AltAzLimits(
min_altitude=Angle(args.min_altitude, units.deg),
max_altitude=Angle(args.max_altitude, units.deg),
min_azimuth=Angle(args.min_azimuth, units.deg),
max_azimuth=Angle(args.max_azimuth, units.deg),
)

altaz_grid = make_pointing_grid_hadec(
altaz_limit=altaz_limits,
dec_min=Angle(args.dec_min, units.deg),
dec_max=Angle(args.dec_max, units.deg),
hour_angle_n_grid=args.hour_angle_n_grid,
)

sort_data = np.argsort([az.value for (_, az) in altaz_grid])
filename = get_data_dir() / f"pointing-tiles-{args.block.lower()}.txt"

print(f"Writing pointing grid data to {filename}.")

with open(filename, "w") as fp:
fp.write("Name Alt Az\n")
for i, index in enumerate(sort_data):
(alt, az) = altaz_grid[index]
fp.write(f"{args.block}_{i+1:03d} {alt.deg:6.2f} {az.deg:7.2f}\n")


if __name__ == "__main__":
main()
Loading

0 comments on commit 4c2d755

Please sign in to comment.