From 55e8f2427dbe1eee14acbce623a5095d8b1e4351 Mon Sep 17 00:00:00 2001 From: Robert David Stein Date: Mon, 20 May 2024 13:45:58 -0700 Subject: [PATCH] Require targname (#70) --- pyproject.toml | 2 +- tests/test_schedule.py | 10 +++++++++- tests/testdata/test_schedule.json | 2 +- wintertoo/data/observing_request_schema.json | 2 +- wintertoo/models/too.py | 3 +-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e85b029..5982643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "wintertoo" -version = "1.6.0" +version = "1.6.1" description = "" authors = [ {name = "Robert Stein", email = "rdstein@caltech.edu"}, diff --git a/tests/test_schedule.py b/tests/test_schedule.py index d8b80be..7e9d0ef 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -63,6 +63,7 @@ def test_generate_schedule(self): dec_deg=11.253441, start_time_mjd=62721.1894969287, end_time_mjd=62722.1894969452, + target_name="test_radec", ), program=program, ) @@ -81,6 +82,7 @@ def test_generate_schedule(self): dec_deg=11.253441, total_exposure_time=100.0, n_dither=1, + target_name="test_radec", ), program=program, ) @@ -100,6 +102,7 @@ def test_schedule_utils(self): field_too = SummerFieldToO( field_id=1, + target_name="test_field", ) schedule_field( @@ -109,6 +112,11 @@ def test_schedule_utils(self): ) concat_toos( - [field_too, SummerRaDecToO(ra_deg=173.7056754, dec_deg=11.253441)], + [ + field_too, + SummerRaDecToO( + ra_deg=173.7056754, dec_deg=11.253441, target_name="test_radec" + ), + ], program=program, ) diff --git a/tests/testdata/test_schedule.json b/tests/testdata/test_schedule.json index fa15188..d8ecca4 100644 --- a/tests/testdata/test_schedule.json +++ b/tests/testdata/test_schedule.json @@ -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":960.0,"1":960.0,"2":960.0,"3":960.0},"singleExpTime":{"0":120.0,"1":120.0,"2":120.0,"3":120.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":8,"1":8,"2":8,"3":8},"ditherStepSize":{"0":90.0,"1":90.0,"2":90.0,"3":90.0},"bestDetector":{"0":true,"1":true,"2":true,"3":true},"obsHistID":{"0":0,"1":1,"2":2,"3":3}} +{"targName":{"0":"test_radec","1":"test_radec","2":"test_radec","3":"test_radec"},"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":960.0,"1":960.0,"2":960.0,"3":960.0},"singleExpTime":{"0":120.0,"1":120.0,"2":120.0,"3":120.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":8,"1":8,"2":8,"3":8},"ditherStepSize":{"0":90.0,"1":90.0,"2":90.0,"3":90.0},"bestDetector":{"0":true,"1":true,"2":true,"3":true},"obsHistID":{"0":0,"1":1,"2":2,"3":3}} diff --git a/wintertoo/data/observing_request_schema.json b/wintertoo/data/observing_request_schema.json index f1328f6..bc2207d 100644 --- a/wintertoo/data/observing_request_schema.json +++ b/wintertoo/data/observing_request_schema.json @@ -17,7 +17,7 @@ "ditherNumber": {"type": "integer", "default": 8}, "ditherStepSize": {"type": "number", "comment": "arcsec", "default": 90.0}, "fieldID": {"type": "integer", "default": 999999999}, - "targName": {"type": ["string", "null"], "comment": "Target name e.g. GW170817", "default": null}, + "targName": {"type": ["string"], "comment": "Target name e.g. GW170817"}, "bestDetector": {"type": "boolean", "comment": "Center Ra/Dec of target on best detector", "default": true} }, "required": [ diff --git a/wintertoo/models/too.py b/wintertoo/models/too.py index afa7ce2..76e5c49 100644 --- a/wintertoo/models/too.py +++ b/wintertoo/models/too.py @@ -39,12 +39,11 @@ class ToORequest(BaseModel): title="Priority for target", ge=0.0, ) - target_name: Optional[str] = Field( + target_name: str = Field( title="Name of the target", min_length=1, max_length=MAX_TARGNAME_LEN, examples=["SN2021abc", "ZTF19aapreis"], - default=get_default_value("targName"), ) total_exposure_time: float = Field( default=get_default_value("visitExpTime"),