Skip to content

Commit

Permalink
Add option to use best detector
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Feb 13, 2024
1 parent 502b229 commit bd47403
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "wintertoo"
version = "1.2.0"
version = "1.3.0"
description = ""
authors = [
{name = "Robert Stein", email = "[email protected]"},
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/test_schedule.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"targName":{"0":null,"1":null,"2":null,"3":null},"raDeg":{"0":173.7056754,"1":173.7056754,"2":173.7056754,"3":173.7056754},"decDeg":{"0":11.253441,"1":11.253441,"2":11.253441,"3":11.253441},"fieldID":{"0":999999999,"1":999999999,"2":999999999,"3":999999999},"filter":{"0":"u","1":"g","2":"r","3":"i"},"visitExpTime":{"0":30.0,"1":30.0,"2":30.0,"3":30.0},"priority":{"0":50.0,"1":50.0,"2":50.0,"3":50.0},"progPI":{"0":"Stein","1":"Stein","2":"Stein","3":"Stein"},"progName":{"0":"2021A000","1":"2021A000","2":"2021A000","3":"2021A000"},"progID":{"0":1,"1":1,"2":1,"3":1},"validStart":{"0":62721.1894969287,"1":62721.1894969287,"2":62721.1894969287,"3":62721.1894969287},"validStop":{"0":62722.1894969452,"1":62722.1894969452,"2":62722.1894969452,"3":62722.1894969452},"observed":{"0":false,"1":false,"2":false,"3":false},"maxAirmass":{"0":2.0,"1":2.0,"2":2.0,"3":2.0},"ditherNumber":{"0":1,"1":1,"2":1,"3":1},"ditherStepSize":{"0":30.0,"1":30.0,"2":30.0,"3":30.0},"obsHistID":{"0":0,"1":1,"2":2,"3":3}}
{"targName":{"0":null,"1":null,"2":null,"3":null},"raDeg":{"0":173.7056754,"1":173.7056754,"2":173.7056754,"3":173.7056754},"decDeg":{"0":11.253441,"1":11.253441,"2":11.253441,"3":11.253441},"fieldID":{"0":999999999,"1":999999999,"2":999999999,"3":999999999},"filter":{"0":"u","1":"g","2":"r","3":"i"},"visitExpTime":{"0":30.0,"1":30.0,"2":30.0,"3":30.0},"priority":{"0":50.0,"1":50.0,"2":50.0,"3":50.0},"progPI":{"0":"Stein","1":"Stein","2":"Stein","3":"Stein"},"progName":{"0":"2021A000","1":"2021A000","2":"2021A000","3":"2021A000"},"progID":{"0":1,"1":1,"2":1,"3":1},"validStart":{"0":62721.1894969287,"1":62721.1894969287,"2":62721.1894969287,"3":62721.1894969287},"validStop":{"0":62722.1894969452,"1":62722.1894969452,"2":62722.1894969452,"3":62722.1894969452},"observed":{"0":false,"1":false,"2":false,"3":false},"maxAirmass":{"0":2.0,"1":2.0,"2":2.0,"3":2.0},"ditherNumber":{"0":1,"1":1,"2":1,"3":1},"ditherStepSize":{"0":30.0,"1":30.0,"2":30.0,"3":30.0},"bestDetector":{"0":true,"1":true,"2":true,"3":true},"obsHistID":{"0":0,"1":1,"2":2,"3":3}}
3 changes: 2 additions & 1 deletion wintertoo/data/observing_request_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"ditherNumber": {"type": "integer", "default": 1},
"ditherStepSize": {"type": "number", "comment": "arcsec", "default": 30.0},
"fieldID": {"type": "integer", "default": 999999999},
"targName": {"type": ["string", "null"], "comment": "Target name e.g. GW170817", "default": null}
"targName": {"type": ["string", "null"], "comment": "Target name e.g. GW170817", "default": null},
"bestDetector": {"type": "boolean", "comment": "Center Ra/Dec of target on best detector", "default": true}
},
"required": [
"obsHistID",
Expand Down
17 changes: 17 additions & 0 deletions wintertoo/models/too.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class ToORequest(BaseModel):
le=5,
title="Allowed airmass range",
)
use_best_detector: bool = Field(
default=get_default_value("bestDetector"),
title="Place ra/dec at the center of the best detector",
)

@model_validator(mode="after")
def validate_end_time(self):
Expand Down Expand Up @@ -127,6 +131,19 @@ class ObsWithRaDec(BaseModel):
default=False,
)

@model_validator(mode="after")
def validate_field_best_detector(self):
"""
Field validator to ensure that the end time is greater than the start time
:return: validated field value
"""
if self.use_best_detector & self.use_field_grid:
raise WinterValidationError(
"Cannot use both use_best_detector and use_field_grid"
)
return self


class ObsWithField(BaseModel):
"""
Expand Down
1 change: 1 addition & 0 deletions wintertoo/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def make_schedule(
"maxAirmass": too.max_airmass,
"ditherNumber": too.n_dither,
"ditherStepSize": too.dither_distance,
"bestDetector": too.use_best_detector,
}
all_entries.append(new)

Expand Down

0 comments on commit bd47403

Please sign in to comment.