diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 31dd939..6dfd2d0 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -21,4 +21,4 @@ jobs: pip install --editable ".[dev]" - name: Analysing the code with pylint run: | - pylint winterapi --fail-under=10.00 + pylint winterapi --fail-under=9.9 diff --git a/example.env b/example.env new file mode 100644 index 0000000..9d808df --- /dev/null +++ b/example.env @@ -0,0 +1,2 @@ +WINTER_API_LOCAL="False" +WINTER_API_PROGRAM= \ No newline at end of file diff --git a/notebooks/Example_1_Setting_Up_Credentials.ipynb b/notebooks/Example_1_Setting_Up_Credentials.ipynb index 1c9b031..1859188 100644 --- a/notebooks/Example_1_Setting_Up_Credentials.ipynb +++ b/notebooks/Example_1_Setting_Up_Credentials.ipynb @@ -52,7 +52,7 @@ } ], "source": [ - "print(f\"Using server {BASE_URL}\") # Should show the URL of the API\n", + "print(f\"Using server {BASE_URL}\") # Should show the URL of the API\n", "print(f\"Pinging server: {winter.ping()}\")" ] }, diff --git a/notebooks/Example_2_Submitting_a_ToO.ipynb b/notebooks/Example_2_Submitting_a_ToO.ipynb index 782e5a5..2330eca 100644 --- a/notebooks/Example_2_Submitting_a_ToO.ipynb +++ b/notebooks/Example_2_Submitting_a_ToO.ipynb @@ -9,7 +9,7 @@ "source": [ "import logging\n", "from winterapi import WinterAPI\n", - "from wintertoo.models import WinterRaDecToO" + "from wintertoo.models import WinterRaDecToO, SpringRaDecToO" ] }, { @@ -51,11 +51,11 @@ "outputs": [], "source": [ "# Target details\n", - "ra_deg = 48.3986122\n", - "dec_deg = -2.1517241\n", + "ra_deg = 144.419513\n", + "dec_deg = 20.037579\n", "# Target name is a useful field for querying data, so put something useful!\n", "# If you use Skyportal, we strongly advise you to use that name\n", - "target_name = \"ZTF20abwtifz\"" + "target_name = \"ZTF25aclckzl\"" ] }, { @@ -67,7 +67,7 @@ { "data": { "text/plain": [ - "WinterRaDecToO(ra_deg=48.3986122, dec_deg=-2.1517241, use_field_grid=False, filters=['J'], target_priority=50.0, target_name='ZTF20abwtifz', total_exposure_time=960.0, n_dither=8, n_repetitions=1, dither_distance=30.0, start_time_mjd=60367.85786201929, end_time_mjd=60368.84786202299, max_airmass=2.0, use_best_detector=True, single_exposure_time=120.0)" + "WinterRaDecToO(ra_deg=144.419513, dec_deg=20.037579, use_field_grid=False, filters=['Y', 'J'], target_priority=50.0, target_name='ZTF25aclckzl', total_exposure_time=960.0, n_dither=8, n_repetitions=1, dither_distance=90.0, start_time_mjd=np.float64(61061.94537127345), end_time_mjd=np.float64(61068.94537128066), max_airmass=2.0, use_best_detector=True, camera='winter', single_exposure_time=120.0)" ] }, "execution_count": 6, @@ -77,9 +77,16 @@ ], "source": [ "# A ToO with the same dither combo for Y/J\n", - "# Note that you can specify the TOTAL exposure time in seconds! This will be divided across dithers. \n", + "# Note that you can specify the TOTAL exposure time in seconds! This will be divided across dithers.\n", "# You can see the duration of each individual exposure below.\n", - "too_1 = WinterRaDecToO(ra_deg=ra_deg, dec_deg=dec_deg, n_dither=8, total_exposure_time=960., filters=['J'], target_name=target_name)\n", + "too_1 = WinterRaDecToO(\n", + " ra_deg=ra_deg,\n", + " dec_deg=dec_deg,\n", + " n_dither=8,\n", + " total_exposure_time=960.0,\n", + " filters=[\"Y\", \"J\"],\n", + " target_name=target_name,\n", + ")\n", "too_1" ] }, @@ -92,7 +99,7 @@ { "data": { "text/plain": [ - "WinterRaDecToO(ra_deg=48.3986122, dec_deg=-2.1517241, use_field_grid=False, filters=['Hs'], target_priority=50.0, target_name='ZTF20abwtifz', total_exposure_time=960.0, n_dither=15, n_repetitions=1, dither_distance=30.0, start_time_mjd=60367.85786201929, end_time_mjd=60368.84786202299, max_airmass=2.0, use_best_detector=True, single_exposure_time=64.0)" + "WinterRaDecToO(ra_deg=144.419513, dec_deg=20.037579, use_field_grid=False, filters=['Hs'], target_priority=50.0, target_name='ZTF25aclckzl', total_exposure_time=960.0, n_dither=15, n_repetitions=1, dither_distance=90.0, start_time_mjd=np.float64(61061.94537137891), end_time_mjd=np.float64(61068.94537138248), max_airmass=2.0, use_best_detector=True, camera='winter', single_exposure_time=64.0)" ] }, "execution_count": 7, @@ -102,7 +109,14 @@ ], "source": [ "# A second ToO, with a different dither number for Hs\n", - "too_2 = WinterRaDecToO(ra_deg=ra_deg, dec_deg=dec_deg, n_dither=15, total_exposure_time=960., filters=[\"Hs\"], target_name=target_name)\n", + "too_2 = WinterRaDecToO(\n", + " ra_deg=ra_deg,\n", + " dec_deg=dec_deg,\n", + " n_dither=15,\n", + " total_exposure_time=960.0,\n", + " filters=[\"Hs\"],\n", + " target_name=target_name,\n", + ")\n", "too_2" ] }, @@ -126,7 +140,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Available programs: ['2023A000', '2023A001', '2023A002', '2023A004', '2023A999', '2024A000', '2024A001', '2024A006']\n" + "Available programs: ['2023A001', '2024A000', '2024A001', '2024A004']\n" ] } ], @@ -183,37 +197,62 @@ " ditherNumber\n", " ditherStepSize\n", " bestDetector\n", + " camera\n", " obsHistID\n", " \n", " \n", " \n", " \n", " 0\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", - " J\n", + " Y\n", " 960.0\n", " 120.0\n", " 50.0\n", " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 8\n", - " 30.0\n", + " 90.0\n", " True\n", + " winter\n", " 0\n", " \n", " \n", " 1\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", + " 999999999\n", + " J\n", + " 960.0\n", + " 120.0\n", + " 50.0\n", + " MKasliwal\n", + " 2024A000\n", + " 3\n", + " 61061.945371\n", + " 61068.945371\n", + " False\n", + " 2.0\n", + " 8\n", + " 90.0\n", + " True\n", + " winter\n", + " 1\n", + " \n", + " \n", + " 2\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", " Hs\n", " 960.0\n", @@ -222,35 +261,40 @@ " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 15\n", - " 30.0\n", + " 90.0\n", " True\n", - " 1\n", + " winter\n", + " 2\n", " \n", " \n", "\n", "" ], "text/plain": [ - " targName raDeg decDeg fieldID filter visitExpTime \\\n", - "0 ZTF20abwtifz 48.398612 -2.151724 999999999 J 960.0 \n", - "1 ZTF20abwtifz 48.398612 -2.151724 999999999 Hs 960.0 \n", + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 Y 960.0 \n", + "1 ZTF25aclckzl 144.419513 20.037579 999999999 J 960.0 \n", + "2 ZTF25aclckzl 144.419513 20.037579 999999999 Hs 960.0 \n", "\n", " singleExpTime priority progPI progName progID validStart \\\n", - "0 120.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", - "1 64.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", + "0 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "1 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "2 64.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", "\n", " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", - "0 60368.847862 False 2.0 8 30.0 \n", - "1 60368.847862 False 2.0 15 30.0 \n", + "0 61068.945371 False 2.0 8 90.0 \n", + "1 61068.945371 False 2.0 8 90.0 \n", + "2 61068.945371 False 2.0 15 90.0 \n", "\n", - " bestDetector obsHistID \n", - "0 True 0 \n", - "1 True 1 " + " bestDetector camera obsHistID \n", + "0 True winter 0 \n", + "1 True winter 1 \n", + "2 True winter 2 " ] }, "execution_count": 10, @@ -260,10 +304,7 @@ ], "source": [ "# Schedule has three observations in total\n", - "local_schedule = winter.build_schedule_locally(\n", - " program_name=program,\n", - " data=too_list\n", - ")\n", + "local_schedule = winter.build_schedule_locally(program_name=program, data=too_list)\n", "local_schedule" ] }, @@ -277,9 +318,7 @@ "# If submit_trigger is False, the API will just check the schedule but not put in a ToO\n", "# Set this to True to actually trigger!\n", "api_res, api_schedule = winter.submit_too(\n", - " program_name=program,\n", - " data=too_list,\n", - " submit_trigger=False\n", + " program_name=program, data=too_list, submit_trigger=False\n", ")" ] }, @@ -350,37 +389,62 @@ " ditherNumber\n", " ditherStepSize\n", " bestDetector\n", + " camera\n", " obsHistID\n", " \n", " \n", " \n", " \n", " 0\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", - " J\n", + " Y\n", " 960.0\n", " 120.0\n", " 50.0\n", " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 8\n", - " 30.0\n", + " 90.0\n", " True\n", + " winter\n", " 0\n", " \n", " \n", " 1\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", + " 999999999\n", + " J\n", + " 960.0\n", + " 120.0\n", + " 50.0\n", + " MKasliwal\n", + " 2024A000\n", + " 3\n", + " 61061.945371\n", + " 61068.945371\n", + " False\n", + " 2.0\n", + " 8\n", + " 90.0\n", + " True\n", + " winter\n", + " 1\n", + " \n", + " \n", + " 2\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", " Hs\n", " 960.0\n", @@ -389,35 +453,40 @@ " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 15\n", - " 30.0\n", + " 90.0\n", " True\n", - " 1\n", + " winter\n", + " 2\n", " \n", " \n", "\n", "" ], "text/plain": [ - " targName raDeg decDeg fieldID filter visitExpTime \\\n", - "0 ZTF20abwtifz 48.398612 -2.151724 999999999 J 960.0 \n", - "1 ZTF20abwtifz 48.398612 -2.151724 999999999 Hs 960.0 \n", + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 Y 960.0 \n", + "1 ZTF25aclckzl 144.419513 20.037579 999999999 J 960.0 \n", + "2 ZTF25aclckzl 144.419513 20.037579 999999999 Hs 960.0 \n", "\n", " singleExpTime priority progPI progName progID validStart \\\n", - "0 120.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", - "1 64.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", + "0 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "1 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "2 64.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", "\n", " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", - "0 60368.847862 False 2.0 8 30.0 \n", - "1 60368.847862 False 2.0 15 30.0 \n", + "0 61068.945371 False 2.0 8 90.0 \n", + "1 61068.945371 False 2.0 8 90.0 \n", + "2 61068.945371 False 2.0 15 90.0 \n", "\n", - " bestDetector obsHistID \n", - "0 True 0 \n", - "1 True 1 " + " bestDetector camera obsHistID \n", + "0 True winter 0 \n", + "1 True winter 1 \n", + "2 True winter 2 " ] }, "execution_count": 13, @@ -439,7 +508,7 @@ { "data": { "text/plain": [ - "\"Request passed validation! Triggering was set to True. Schedule name is 'request_2024A000_2024_02_27_12_23_18' .\"" + "\"Request passed validation! Triggering was set to True. Schedule name is 'request_2024A000_2026_01_21_14_42_19' .\"" ] }, "execution_count": 14, @@ -450,9 +519,7 @@ "source": [ "# Uncomment to trigger for real\n", "api_res, api_schedule = winter.submit_too(\n", - " program_name=program,\n", - " data=too_list,\n", - " submit_trigger=True\n", + " program_name=program, data=too_list, submit_trigger=True\n", ")\n", "api_res.json()[\"msg\"]" ] @@ -502,37 +569,62 @@ " ditherNumber\n", " ditherStepSize\n", " bestDetector\n", + " camera\n", " obsHistID\n", " \n", " \n", " \n", " \n", " 0\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", - " J\n", + " Y\n", " 960.0\n", " 120.0\n", " 50.0\n", " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 8\n", - " 30.0\n", + " 90.0\n", " True\n", + " winter\n", " 0\n", " \n", " \n", " 1\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", + " 999999999\n", + " J\n", + " 960.0\n", + " 120.0\n", + " 50.0\n", + " MKasliwal\n", + " 2024A000\n", + " 3\n", + " 61061.945371\n", + " 61068.945371\n", + " False\n", + " 2.0\n", + " 8\n", + " 90.0\n", + " True\n", + " winter\n", + " 1\n", + " \n", + " \n", + " 2\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", " Hs\n", " 960.0\n", @@ -541,35 +633,40 @@ " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.945371\n", + " 61068.945371\n", " False\n", " 2.0\n", " 15\n", - " 30.0\n", + " 90.0\n", " True\n", - " 1\n", + " winter\n", + " 2\n", " \n", " \n", "\n", "" ], "text/plain": [ - " targName raDeg decDeg fieldID filter visitExpTime \\\n", - "0 ZTF20abwtifz 48.398612 -2.151724 999999999 J 960.0 \n", - "1 ZTF20abwtifz 48.398612 -2.151724 999999999 Hs 960.0 \n", + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 Y 960.0 \n", + "1 ZTF25aclckzl 144.419513 20.037579 999999999 J 960.0 \n", + "2 ZTF25aclckzl 144.419513 20.037579 999999999 Hs 960.0 \n", "\n", " singleExpTime priority progPI progName progID validStart \\\n", - "0 120.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", - "1 64.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", + "0 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "1 120.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", + "2 64.0 50.0 MKasliwal 2024A000 3 61061.945371 \n", "\n", " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", - "0 60368.847862 False 2.0 8 30.0 \n", - "1 60368.847862 False 2.0 15 30.0 \n", + "0 61068.945371 False 2.0 8 90.0 \n", + "1 61068.945371 False 2.0 8 90.0 \n", + "2 61068.945371 False 2.0 15 90.0 \n", "\n", - " bestDetector obsHistID \n", - "0 True 0 \n", - "1 True 1 " + " bestDetector camera obsHistID \n", + "0 True winter 0 \n", + "1 True winter 1 \n", + "2 True winter 2 " ] }, "execution_count": 15, @@ -582,13 +679,481 @@ "api_schedule" ] }, + { + "cell_type": "markdown", + "id": "bec2317e-923f-467e-ac90-f27d454ccb1e", + "metadata": {}, + "source": [ + "# Submitting SPRING ToO requests" + ] + }, + { + "cell_type": "markdown", + "id": "bf09e185-709a-4d7b-9122-2d16219c3f7d", + "metadata": {}, + "source": [ + "You can also submit ToOs to SPRING. The procedure is the same, though there is no field grid so the only requests are RA/Dec ones. The default exposure times / number of dithers are different for SPRING, but you can still customise these if you like as you can for WINTER." + ] + }, { "cell_type": "code", - "execution_count": null, - "id": "ba9f510f", + "execution_count": 16, + "id": "6f1828a0-86eb-4edd-8d02-e46c2cc0ea4e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SpringRaDecToO(ra_deg=144.419513, dec_deg=20.037579, use_field_grid=False, filters=['J'], target_priority=50.0, target_name='ZTF25aclckzl', total_exposure_time=900.0, n_dither=30, n_repetitions=1, dither_distance=60.0, start_time_mjd=np.float64(61061.9460627211), end_time_mjd=np.float64(61068.94606272622), max_airmass=2.0, use_best_detector=True, camera='spring', single_exposure_time=30.0)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "too_1 = SpringRaDecToO(\n", + " ra_deg=ra_deg, dec_deg=dec_deg, filters=[\"J\"], target_name=target_name\n", + ")\n", + "too_1" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "f236e07a-c24b-4a1a-9e42-d529dca6e9c4", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "too_list = [too_1]" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "3996e934-b23b-4567-bd5f-f21a3336b1c0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
targNameraDegdecDegfieldIDfiltervisitExpTimesingleExpTimepriorityprogPIprogNameprogIDvalidStartvalidStopobservedmaxAirmassditherNumberditherStepSizebestDetectorcameraobsHistID
0ZTF25aclckzl144.41951320.037579999999999J900.030.050.0MKasliwal2024A000361061.94606361068.946063False2.03060.0Truespring0
\n", + "
" + ], + "text/plain": [ + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 J 900.0 \n", + "\n", + " singleExpTime priority progPI progName progID validStart \\\n", + "0 30.0 50.0 MKasliwal 2024A000 3 61061.946063 \n", + "\n", + " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", + "0 61068.946063 False 2.0 30 60.0 \n", + "\n", + " bestDetector camera obsHistID \n", + "0 True spring 0 " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Schedule has three observations in total\n", + "local_schedule = winter.build_schedule_locally(program_name=program, data=too_list)\n", + "local_schedule" + ] + }, + { + "cell_type": "markdown", + "id": "6247b091-5845-4cf8-9241-a8351d0b009f", + "metadata": {}, + "source": [ + "**Be careful to use the different submit function for SPRING ToOs!**" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "637a5399-e7e3-4068-8922-24a31463aa2e", + "metadata": {}, + "outputs": [], + "source": [ + "# If submit_trigger is False, the API will just check the schedule but not put in a ToO\n", + "# Set this to True to actually trigger!\n", + "api_res, api_schedule = winter.submit_too_spring(\n", + " program_name=program, data=too_list, submit_trigger=False\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "884e2186-47b2-43b8-a25d-7e6a7f85df17", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Request passed validation! Triggering was set to False. Schedule was not saved to disk and has no assigned name.'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Let's see what message the API sent back\n", + "api_res.json()[\"msg\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "1daa3e88-07cb-4314-b5b2-5fe4ec58f0d4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
targNameraDegdecDegfieldIDfiltervisitExpTimesingleExpTimepriorityprogPIprogNameprogIDvalidStartvalidStopobservedmaxAirmassditherNumberditherStepSizebestDetectorcameraobsHistID
0ZTF25aclckzl144.41951320.037579999999999J900.030.050.0MKasliwal2024A000361061.94606361068.946063False2.03060.0Truespring0
\n", + "
" + ], + "text/plain": [ + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 J 900.0 \n", + "\n", + " singleExpTime priority progPI progName progID validStart \\\n", + "0 30.0 50.0 MKasliwal 2024A000 3 61061.946063 \n", + "\n", + " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", + "0 61068.946063 False 2.0 30 60.0 \n", + "\n", + " bestDetector camera obsHistID \n", + "0 True spring 0 " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the schedule sent back by the API. Reassuringly, it matches the local one\n", + "api_schedule" + ] + }, + { + "cell_type": "markdown", + "id": "0fda9516-6103-4774-aaf3-928ac93b92ca", + "metadata": {}, + "source": [ + "# Non-standard exposure times" + ] + }, + { + "cell_type": "markdown", + "id": "bb8d36a5-2383-4f6b-beb8-e42c334786a4", + "metadata": {}, + "source": [ + "If you submit a non-default exposure time for a target, whether via WINTER or SPRING, you must also request darks with the same exposure time. You do this by including the dark filter in your request." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "fc5a10ad-335f-4ed3-852c-587b6ee7f44e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SpringRaDecToO(ra_deg=144.419513, dec_deg=20.037579, use_field_grid=False, filters=['J', 'dark'], target_priority=50.0, target_name='ZTF25aclckzl', total_exposure_time=900.0, n_dither=60, n_repetitions=1, dither_distance=60.0, start_time_mjd=np.float64(61061.946349995094), end_time_mjd=np.float64(61068.9463499981), max_airmass=2.0, use_best_detector=True, camera='spring', single_exposure_time=15.0)" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "too_1 = SpringRaDecToO(\n", + " ra_deg=ra_deg,\n", + " dec_deg=dec_deg,\n", + " filters=[\"J\", \"dark\"],\n", + " target_name=target_name,\n", + " n_dither=60,\n", + ")\n", + "too_1" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "d31a61be-45a5-41f2-9342-ec27ca9bce76", + "metadata": {}, + "outputs": [], + "source": [ + "api_res, api_schedule = winter.submit_too_spring(\n", + " program_name=program, data=too_list, submit_trigger=False\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "fa100f7e-c360-4fdb-9ba2-cf8935eff698", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Request passed validation! Triggering was set to False. Schedule was not saved to disk and has no assigned name.'" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Let's see what message the API sent back\n", + "api_res.json()[\"msg\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "4a8d1758-9732-4bdc-81e5-8751f9d0d908", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
targNameraDegdecDegfieldIDfiltervisitExpTimesingleExpTimepriorityprogPIprogNameprogIDvalidStartvalidStopobservedmaxAirmassditherNumberditherStepSizebestDetectorcameraobsHistID
0ZTF25aclckzl144.41951320.037579999999999J900.030.050.0MKasliwal2024A000361061.94606361068.946063False2.03060.0Truespring0
\n", + "
" + ], + "text/plain": [ + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 J 900.0 \n", + "\n", + " singleExpTime priority progPI progName progID validStart \\\n", + "0 30.0 50.0 MKasliwal 2024A000 3 61061.946063 \n", + "\n", + " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", + "0 61068.946063 False 2.0 30 60.0 \n", + "\n", + " bestDetector camera obsHistID \n", + "0 True spring 0 " + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# This is the schedule sent back by the API. Reassuringly, it matches the local one\n", + "api_schedule" + ] } ], "metadata": { @@ -607,7 +1172,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.14.2" } }, "nbformat": 4, diff --git a/notebooks/Example_3_Interacting_with_Observatory_Queue.ipynb b/notebooks/Example_3_Interacting_with_Observatory_Queue.ipynb index e114db5..74d3068 100644 --- a/notebooks/Example_3_Interacting_with_Observatory_Queue.ipynb +++ b/notebooks/Example_3_Interacting_with_Observatory_Queue.ipynb @@ -8,8 +8,7 @@ "outputs": [], "source": [ "import logging\n", - "from winterapi import WinterAPI\n", - "from wintertoo.models import WinterRaDecToO" + "from winterapi import WinterAPI" ] }, { @@ -62,7 +61,9 @@ "cell_type": "code", "execution_count": 5, "id": "03095da8", - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "res, queue = winter.get_observatory_queue(program_name=program_name)" @@ -126,89 +127,275 @@ " total_time_hours\n", " window_start\n", " window_end\n", + " archived\n", " \n", " \n", " \n", " \n", + " 0\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_16_14_27_33\n", + " [ZTF25acipkui]\n", + " 1\n", + " 0.266667\n", + " 2026-01-16 22:27:07.000\n", + " 2026-01-23 22:27:07.000\n", + " False\n", + " \n", + " \n", + " 1\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_19_14_01_36\n", + " [ZTF25acfxvcu]\n", + " 1\n", + " 0.266667\n", + " 2026-01-19 22:01:11.000\n", + " 2026-01-26 22:01:11.000\n", + " False\n", + " \n", + " \n", " 2\n", " 2024A000\n", - " 0.333333\n", - " request_2024A000_2024_02_11_10_11_56\n", - " [ZTF24aaecooj]\n", - " 3\n", - " 0.800000\n", - " 2024-02-11 18:11:25.995\n", - " 2024-04-18 18:11:25.996\n", + " 1.0\n", + " request_2024A000_2026_01_20_08_55_05\n", + " [ZTF25aclckzl]\n", + " 2\n", + " 0.533333\n", + " 2026-01-20 16:54:07.413\n", + " 2026-01-27 16:54:09.181\n", + " False\n", " \n", " \n", " 3\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_08_34\n", - " [ZTF24aaetnsm]\n", + " 1.0\n", + " request_2024A000_2026_01_20_09_37_54\n", + " [ZTF26aaaqczz]\n", " 1\n", " 0.266667\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 2026-01-20 17:37:27.000\n", + " 2026-01-27 17:37:27.000\n", + " False\n", " \n", " \n", " 4\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_09_22\n", - " [ZTF24aaetnsm]\n", + " 1.0\n", + " request_2024A000_2026_01_20_09_39_11\n", + " [ZTF26aabwols]\n", " 1\n", " 0.266667\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 2026-01-20 17:38:46.000\n", + " 2026-01-27 17:38:46.000\n", + " False\n", " \n", " \n", " 5\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_09_55\n", - " [ZTF24aaetnsm]\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_36_29\n", + " [ZTF25acinfdh]\n", " 1\n", - " 0.250000\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 0.266667\n", + " 2026-01-24 17:35:59.000\n", + " 2026-01-28 17:35:59.000\n", + " False\n", " \n", " \n", " 6\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_27_12_23_18\n", - " [ZTF20abwtifz]\n", - " 2\n", - " 0.533333\n", - " 2024-02-27 20:35:19.278\n", - " 2024-02-28 20:20:55.279\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_37_38\n", + " [ZTF25acdheca]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 17:37:08.000\n", + " 2026-01-28 17:37:08.000\n", + " False\n", + " \n", + " \n", + " 7\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_42_44\n", + " [ZTF25acfojmo]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 17:42:13.000\n", + " 2026-01-28 17:42:13.000\n", + " False\n", + " \n", + " \n", + " 8\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_36_26\n", + " [ZTF25ackyfnb]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:35:57.000\n", + " 2026-01-28 18:35:57.000\n", + " False\n", + " \n", + " \n", + " 9\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_37_12\n", + " [ZTF25achapja]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:36:44.000\n", + " 2026-01-28 18:36:44.000\n", + " False\n", + " \n", + " \n", + " 10\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_37_47\n", + " [ZTF25acglosh]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:37:20.000\n", + " 2026-01-28 18:37:20.000\n", + " False\n", + " \n", + " \n", + " 11\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_38_31\n", + " [ZTF21aasyjxq]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:38:04.000\n", + " 2026-01-28 18:38:04.000\n", + " False\n", + " \n", + " \n", + " 12\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_39_03\n", + " [ZTF25abyevmr]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:38:35.000\n", + " 2026-01-28 18:38:35.000\n", + " False\n", + " \n", + " \n", + " 13\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_42_30\n", + " [ZTF25abwjtwc]\n", + " 1\n", + " 0.266667\n", + " 2026-01-21 18:42:04.000\n", + " 2026-01-28 18:42:04.000\n", + " False\n", + " \n", + " \n", + " 14\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_43_33\n", + " [ZTF25abjlnnh]\n", + " 1\n", + " 0.266667\n", + " 2026-01-21 18:43:07.000\n", + " 2026-01-28 18:43:07.000\n", + " False\n", + " \n", + " \n", + " 15\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_47_45\n", + " [ZTF25acfxvcu]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:47:12.000\n", + " 2026-01-28 18:47:12.000\n", + " False\n", + " \n", + " \n", + " 16\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_51_05\n", + " [ZTF25aclckzl]\n", + " 3\n", + " 0.800000\n", + " 2026-01-21 18:50:17.593\n", + " 2026-01-28 18:50:18.123\n", + " False\n", " \n", " \n", "\n", "" ], "text/plain": [ - " prog_name attempted_frac too_schedule_name \\\n", - "2 2024A000 0.333333 request_2024A000_2024_02_11_10_11_56 \n", - "3 2024A000 0.000000 request_2024A000_2024_02_26_11_08_34 \n", - "4 2024A000 0.000000 request_2024A000_2024_02_26_11_09_22 \n", - "5 2024A000 0.000000 request_2024A000_2024_02_26_11_09_55 \n", - "6 2024A000 0.000000 request_2024A000_2024_02_27_12_23_18 \n", + " prog_name attempted_frac too_schedule_name \\\n", + "0 2024A000 0.0 request_2024A000_2026_01_16_14_27_33 \n", + "1 2024A000 0.0 request_2024A000_2026_01_19_14_01_36 \n", + "2 2024A000 1.0 request_2024A000_2026_01_20_08_55_05 \n", + "3 2024A000 1.0 request_2024A000_2026_01_20_09_37_54 \n", + "4 2024A000 1.0 request_2024A000_2026_01_20_09_39_11 \n", + "5 2024A000 0.0 request_2024A000_2026_01_21_09_36_29 \n", + "6 2024A000 0.0 request_2024A000_2026_01_21_09_37_38 \n", + "7 2024A000 0.0 request_2024A000_2026_01_21_09_42_44 \n", + "8 2024A000 0.0 request_2024A000_2026_01_21_10_36_26 \n", + "9 2024A000 0.0 request_2024A000_2026_01_21_10_37_12 \n", + "10 2024A000 0.0 request_2024A000_2026_01_21_10_37_47 \n", + "11 2024A000 0.0 request_2024A000_2026_01_21_10_38_31 \n", + "12 2024A000 0.0 request_2024A000_2026_01_21_10_39_03 \n", + "13 2024A000 0.0 request_2024A000_2026_01_21_10_42_30 \n", + "14 2024A000 0.0 request_2024A000_2026_01_21_10_43_33 \n", + "15 2024A000 0.0 request_2024A000_2026_01_21_10_47_45 \n", + "16 2024A000 0.0 request_2024A000_2026_01_21_10_51_05 \n", "\n", - " target_names n_entries total_time_hours window_start \\\n", - "2 [ZTF24aaecooj] 3 0.800000 2024-02-11 18:11:25.995 \n", - "3 [ZTF24aaetnsm] 1 0.266667 2024-02-26 00:00:00.000 \n", - "4 [ZTF24aaetnsm] 1 0.266667 2024-02-26 00:00:00.000 \n", - "5 [ZTF24aaetnsm] 1 0.250000 2024-02-26 00:00:00.000 \n", - "6 [ZTF20abwtifz] 2 0.533333 2024-02-27 20:35:19.278 \n", + " target_names n_entries total_time_hours window_start \\\n", + "0 [ZTF25acipkui] 1 0.266667 2026-01-16 22:27:07.000 \n", + "1 [ZTF25acfxvcu] 1 0.266667 2026-01-19 22:01:11.000 \n", + "2 [ZTF25aclckzl] 2 0.533333 2026-01-20 16:54:07.413 \n", + "3 [ZTF26aaaqczz] 1 0.266667 2026-01-20 17:37:27.000 \n", + "4 [ZTF26aabwols] 1 0.266667 2026-01-20 17:38:46.000 \n", + "5 [ZTF25acinfdh] 1 0.266667 2026-01-24 17:35:59.000 \n", + "6 [ZTF25acdheca] 1 0.266667 2026-01-24 17:37:08.000 \n", + "7 [ZTF25acfojmo] 1 0.266667 2026-01-24 17:42:13.000 \n", + "8 [ZTF25ackyfnb] 1 0.266667 2026-01-24 18:35:57.000 \n", + "9 [ZTF25achapja] 1 0.266667 2026-01-24 18:36:44.000 \n", + "10 [ZTF25acglosh] 1 0.266667 2026-01-24 18:37:20.000 \n", + "11 [ZTF21aasyjxq] 1 0.266667 2026-01-24 18:38:04.000 \n", + "12 [ZTF25abyevmr] 1 0.266667 2026-01-24 18:38:35.000 \n", + "13 [ZTF25abwjtwc] 1 0.266667 2026-01-21 18:42:04.000 \n", + "14 [ZTF25abjlnnh] 1 0.266667 2026-01-21 18:43:07.000 \n", + "15 [ZTF25acfxvcu] 1 0.266667 2026-01-24 18:47:12.000 \n", + "16 [ZTF25aclckzl] 3 0.800000 2026-01-21 18:50:17.593 \n", "\n", - " window_end \n", - "2 2024-04-18 18:11:25.996 \n", - "3 2024-03-06 00:00:00.000 \n", - "4 2024-03-06 00:00:00.000 \n", - "5 2024-03-06 00:00:00.000 \n", - "6 2024-02-28 20:20:55.279 " + " window_end archived \n", + "0 2026-01-23 22:27:07.000 False \n", + "1 2026-01-26 22:01:11.000 False \n", + "2 2026-01-27 16:54:09.181 False \n", + "3 2026-01-27 17:37:27.000 False \n", + "4 2026-01-27 17:38:46.000 False \n", + "5 2026-01-28 17:35:59.000 False \n", + "6 2026-01-28 17:37:08.000 False \n", + "7 2026-01-28 17:42:13.000 False \n", + "8 2026-01-28 18:35:57.000 False \n", + "9 2026-01-28 18:36:44.000 False \n", + "10 2026-01-28 18:37:20.000 False \n", + "11 2026-01-28 18:38:04.000 False \n", + "12 2026-01-28 18:38:35.000 False \n", + "13 2026-01-28 18:42:04.000 False \n", + "14 2026-01-28 18:43:07.000 False \n", + "15 2026-01-28 18:47:12.000 False \n", + "16 2026-01-28 18:50:18.123 False " ] }, "execution_count": 7, @@ -220,6 +407,152 @@ "queue" ] }, + { + "cell_type": "markdown", + "id": "fed40cb0-1d76-4a12-8218-f6b94c1b4c28", + "metadata": {}, + "source": [ + "You can also include archived (i.e. expired) schedules and/or specify a target name to narrow down the list" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "a2a30438-59e8-4c0b-9d82-2eb97f854e1c", + "metadata": {}, + "outputs": [], + "source": [ + "res, queue = winter.get_observatory_queue(\n", + " program_name=program_name, include_archived=True, target_name=\"ZTF18acecugr\"\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "7f8cbcfa-9612-416e-90e4-75a7fc9443e8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Returning schedule summary for 2024A000'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "res.json()[\"msg\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ee0b9637-bc82-4a30-9b23-763f0a9747ee", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
prog_nameattempted_fractoo_schedule_nametarget_namesn_entriestotal_time_hourswindow_startwindow_endarchived
13492024A0001.0request_2024A000_2025_10_30_18_55_52[ZTF18acecugr]10.2666672025-10-31 01:55:21.0002025-11-07 02:55:21.000True
13502024A0001.0request_2024A000_2025_10_31_11_33_34[ZTF18acecugr]10.2500002025-10-31 18:32:56.0002025-11-07 19:32:56.000True
13562024A0000.5request_2024A000_2025_11_03_15_15_32[ZTF18acecugr]307.8333332025-11-03 23:14:06.8522025-12-03 23:14:06.852True
\n", + "
" + ], + "text/plain": [ + " prog_name attempted_frac too_schedule_name \\\n", + "1349 2024A000 1.0 request_2024A000_2025_10_30_18_55_52 \n", + "1350 2024A000 1.0 request_2024A000_2025_10_31_11_33_34 \n", + "1356 2024A000 0.5 request_2024A000_2025_11_03_15_15_32 \n", + "\n", + " target_names n_entries total_time_hours window_start \\\n", + "1349 [ZTF18acecugr] 1 0.266667 2025-10-31 01:55:21.000 \n", + "1350 [ZTF18acecugr] 1 0.250000 2025-10-31 18:32:56.000 \n", + "1356 [ZTF18acecugr] 30 7.833333 2025-11-03 23:14:06.852 \n", + "\n", + " window_end archived \n", + "1349 2025-11-07 02:55:21.000 True \n", + "1350 2025-11-07 19:32:56.000 True \n", + "1356 2025-12-03 23:14:06.852 True " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "queue" + ] + }, { "cell_type": "markdown", "id": "e6e88fea", @@ -238,42 +571,41 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "id": "877ed48e", "metadata": {}, "outputs": [], "source": [ - "schedule_name = \"request_2024A000_2024_02_27_12_23_18\"" + "schedule_name = \"request_2024A000_2026_01_21_10_51_05\"" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "id": "463289d3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'Returning details of schedule request_2024A000_2024_02_27_12_23_18'" + "'Returning details of schedule request_2024A000_2026_01_21_10_51_05'" ] }, - "execution_count": 9, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res, too_request = winter.get_too_details(\n", - " too_schedule_name=schedule_name,\n", - " program_name=program_name\n", + " too_schedule_name=schedule_name, program_name=program_name\n", ")\n", "res.json()[\"msg\"]" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "id": "48b9dd11", "metadata": {}, "outputs": [ @@ -316,37 +648,62 @@ " ditherNumber\n", " ditherStepSize\n", " bestDetector\n", + " camera\n", " obsHistID\n", " \n", " \n", " \n", " \n", " 0\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", - " J\n", + " Y\n", " 960.0\n", " 120.0\n", " 50.0\n", " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.784926\n", + " 61068.784926\n", " 0\n", " 2.0\n", " 8\n", - " 30.0\n", + " 90.0\n", " 1\n", + " winter\n", " 0\n", " \n", " \n", " 1\n", - " ZTF20abwtifz\n", - " 48.398612\n", - " -2.151724\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", + " 999999999\n", + " J\n", + " 960.0\n", + " 120.0\n", + " 50.0\n", + " MKasliwal\n", + " 2024A000\n", + " 3\n", + " 61061.784926\n", + " 61068.784926\n", + " 0\n", + " 2.0\n", + " 8\n", + " 90.0\n", + " 1\n", + " winter\n", + " 1\n", + " \n", + " \n", + " 2\n", + " ZTF25aclckzl\n", + " 144.419513\n", + " 20.037579\n", " 999999999\n", " Hs\n", " 960.0\n", @@ -355,38 +712,43 @@ " MKasliwal\n", " 2024A000\n", " 3\n", - " 60367.857862\n", - " 60368.847862\n", + " 61061.784932\n", + " 61068.784932\n", " 0\n", " 2.0\n", " 15\n", - " 30.0\n", - " 1\n", + " 90.0\n", " 1\n", + " winter\n", + " 2\n", " \n", " \n", "\n", "" ], "text/plain": [ - " targName raDeg decDeg fieldID filter visitExpTime \\\n", - "0 ZTF20abwtifz 48.398612 -2.151724 999999999 J 960.0 \n", - "1 ZTF20abwtifz 48.398612 -2.151724 999999999 Hs 960.0 \n", + " targName raDeg decDeg fieldID filter visitExpTime \\\n", + "0 ZTF25aclckzl 144.419513 20.037579 999999999 Y 960.0 \n", + "1 ZTF25aclckzl 144.419513 20.037579 999999999 J 960.0 \n", + "2 ZTF25aclckzl 144.419513 20.037579 999999999 Hs 960.0 \n", "\n", " singleExpTime priority progPI progName progID validStart \\\n", - "0 120.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", - "1 64.0 50.0 MKasliwal 2024A000 3 60367.857862 \n", + "0 120.0 50.0 MKasliwal 2024A000 3 61061.784926 \n", + "1 120.0 50.0 MKasliwal 2024A000 3 61061.784926 \n", + "2 64.0 50.0 MKasliwal 2024A000 3 61061.784932 \n", "\n", " validStop observed maxAirmass ditherNumber ditherStepSize \\\n", - "0 60368.847862 0 2.0 8 30.0 \n", - "1 60368.847862 0 2.0 15 30.0 \n", + "0 61068.784926 0 2.0 8 90.0 \n", + "1 61068.784926 0 2.0 8 90.0 \n", + "2 61068.784932 0 2.0 15 90.0 \n", "\n", - " bestDetector obsHistID \n", - "0 1 0 \n", - "1 1 1 " + " bestDetector camera obsHistID \n", + "0 1 winter 0 \n", + "1 1 winter 1 \n", + "2 1 winter 2 " ] }, - "execution_count": 10, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -416,27 +778,24 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "id": "14666fd9", - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'Deleted request_2024A000_2024_02_27_12_23_18'" + "'Deleted request_2024A000_2026_01_21_10_51_05'" ] }, - "execution_count": 11, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = winter.delete_too_request(\n", - " too_schedule_name=schedule_name,\n", - " program_name=program_name\n", + " too_schedule_name=schedule_name, program_name=program_name\n", ")\n", "res.json()[\"msg\"]" ] @@ -451,7 +810,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "id": "525f3d16", "metadata": {}, "outputs": [ @@ -491,78 +850,278 @@ " total_time_hours\n", " window_start\n", " window_end\n", + " archived\n", " \n", " \n", " \n", " \n", + " 0\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_16_14_27_33\n", + " [ZTF25acipkui]\n", + " 1\n", + " 0.266667\n", + " 2026-01-16 22:27:07.000\n", + " 2026-01-23 22:27:07.000\n", + " False\n", + " \n", + " \n", + " 1\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_19_14_01_36\n", + " [ZTF25acfxvcu]\n", + " 1\n", + " 0.266667\n", + " 2026-01-19 22:01:11.000\n", + " 2026-01-26 22:01:11.000\n", + " False\n", + " \n", + " \n", " 2\n", " 2024A000\n", - " 0.333333\n", - " request_2024A000_2024_02_11_10_11_56\n", - " [ZTF24aaecooj]\n", - " 3\n", - " 0.800000\n", - " 2024-02-11 18:11:25.995\n", - " 2024-04-18 18:11:25.996\n", + " 1.0\n", + " request_2024A000_2026_01_20_08_55_05\n", + " [ZTF25aclckzl]\n", + " 2\n", + " 0.533333\n", + " 2026-01-20 16:54:07.413\n", + " 2026-01-27 16:54:09.181\n", + " False\n", " \n", " \n", " 3\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_08_34\n", - " [ZTF24aaetnsm]\n", + " 1.0\n", + " request_2024A000_2026_01_20_09_37_54\n", + " [ZTF26aaaqczz]\n", " 1\n", " 0.266667\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 2026-01-20 17:37:27.000\n", + " 2026-01-27 17:37:27.000\n", + " False\n", " \n", " \n", " 4\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_09_22\n", - " [ZTF24aaetnsm]\n", + " 1.0\n", + " request_2024A000_2026_01_20_09_39_11\n", + " [ZTF26aabwols]\n", " 1\n", " 0.266667\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 2026-01-20 17:38:46.000\n", + " 2026-01-27 17:38:46.000\n", + " False\n", " \n", " \n", " 5\n", " 2024A000\n", - " 0.000000\n", - " request_2024A000_2024_02_26_11_09_55\n", - " [ZTF24aaetnsm]\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_36_29\n", + " [ZTF25acinfdh]\n", " 1\n", - " 0.250000\n", - " 2024-02-26 00:00:00.000\n", - " 2024-03-06 00:00:00.000\n", + " 0.266667\n", + " 2026-01-24 17:35:59.000\n", + " 2026-01-28 17:35:59.000\n", + " False\n", + " \n", + " \n", + " 6\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_37_38\n", + " [ZTF25acdheca]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 17:37:08.000\n", + " 2026-01-28 17:37:08.000\n", + " False\n", + " \n", + " \n", + " 7\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_09_42_44\n", + " [ZTF25acfojmo]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 17:42:13.000\n", + " 2026-01-28 17:42:13.000\n", + " False\n", + " \n", + " \n", + " 8\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_36_26\n", + " [ZTF25ackyfnb]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:35:57.000\n", + " 2026-01-28 18:35:57.000\n", + " False\n", + " \n", + " \n", + " 9\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_37_12\n", + " [ZTF25achapja]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:36:44.000\n", + " 2026-01-28 18:36:44.000\n", + " False\n", + " \n", + " \n", + " 10\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_37_47\n", + " [ZTF25acglosh]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:37:20.000\n", + " 2026-01-28 18:37:20.000\n", + " False\n", + " \n", + " \n", + " 11\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_38_31\n", + " [ZTF21aasyjxq]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:38:04.000\n", + " 2026-01-28 18:38:04.000\n", + " False\n", + " \n", + " \n", + " 12\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_39_03\n", + " [ZTF25abyevmr]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:38:35.000\n", + " 2026-01-28 18:38:35.000\n", + " False\n", + " \n", + " \n", + " 13\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_42_30\n", + " [ZTF25abwjtwc]\n", + " 1\n", + " 0.266667\n", + " 2026-01-21 18:42:04.000\n", + " 2026-01-28 18:42:04.000\n", + " False\n", + " \n", + " \n", + " 14\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_43_33\n", + " [ZTF25abjlnnh]\n", + " 1\n", + " 0.266667\n", + " 2026-01-21 18:43:07.000\n", + " 2026-01-28 18:43:07.000\n", + " False\n", + " \n", + " \n", + " 15\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_47_45\n", + " [ZTF25acfxvcu]\n", + " 1\n", + " 0.266667\n", + " 2026-01-24 18:47:12.000\n", + " 2026-01-28 18:47:12.000\n", + " False\n", + " \n", + " \n", + " 16\n", + " 2024A000\n", + " 0.0\n", + " request_2024A000_2026_01_21_10_51_05\n", + " [ZTF25aclckzl]\n", + " 3\n", + " 0.800000\n", + " 2026-01-21 18:50:17.593\n", + " 2026-01-28 18:50:18.123\n", + " False\n", " \n", " \n", "\n", "" ], "text/plain": [ - " prog_name attempted_frac too_schedule_name \\\n", - "2 2024A000 0.333333 request_2024A000_2024_02_11_10_11_56 \n", - "3 2024A000 0.000000 request_2024A000_2024_02_26_11_08_34 \n", - "4 2024A000 0.000000 request_2024A000_2024_02_26_11_09_22 \n", - "5 2024A000 0.000000 request_2024A000_2024_02_26_11_09_55 \n", + " prog_name attempted_frac too_schedule_name \\\n", + "0 2024A000 0.0 request_2024A000_2026_01_16_14_27_33 \n", + "1 2024A000 0.0 request_2024A000_2026_01_19_14_01_36 \n", + "2 2024A000 1.0 request_2024A000_2026_01_20_08_55_05 \n", + "3 2024A000 1.0 request_2024A000_2026_01_20_09_37_54 \n", + "4 2024A000 1.0 request_2024A000_2026_01_20_09_39_11 \n", + "5 2024A000 0.0 request_2024A000_2026_01_21_09_36_29 \n", + "6 2024A000 0.0 request_2024A000_2026_01_21_09_37_38 \n", + "7 2024A000 0.0 request_2024A000_2026_01_21_09_42_44 \n", + "8 2024A000 0.0 request_2024A000_2026_01_21_10_36_26 \n", + "9 2024A000 0.0 request_2024A000_2026_01_21_10_37_12 \n", + "10 2024A000 0.0 request_2024A000_2026_01_21_10_37_47 \n", + "11 2024A000 0.0 request_2024A000_2026_01_21_10_38_31 \n", + "12 2024A000 0.0 request_2024A000_2026_01_21_10_39_03 \n", + "13 2024A000 0.0 request_2024A000_2026_01_21_10_42_30 \n", + "14 2024A000 0.0 request_2024A000_2026_01_21_10_43_33 \n", + "15 2024A000 0.0 request_2024A000_2026_01_21_10_47_45 \n", + "16 2024A000 0.0 request_2024A000_2026_01_21_10_51_05 \n", "\n", - " target_names n_entries total_time_hours window_start \\\n", - "2 [ZTF24aaecooj] 3 0.800000 2024-02-11 18:11:25.995 \n", - "3 [ZTF24aaetnsm] 1 0.266667 2024-02-26 00:00:00.000 \n", - "4 [ZTF24aaetnsm] 1 0.266667 2024-02-26 00:00:00.000 \n", - "5 [ZTF24aaetnsm] 1 0.250000 2024-02-26 00:00:00.000 \n", + " target_names n_entries total_time_hours window_start \\\n", + "0 [ZTF25acipkui] 1 0.266667 2026-01-16 22:27:07.000 \n", + "1 [ZTF25acfxvcu] 1 0.266667 2026-01-19 22:01:11.000 \n", + "2 [ZTF25aclckzl] 2 0.533333 2026-01-20 16:54:07.413 \n", + "3 [ZTF26aaaqczz] 1 0.266667 2026-01-20 17:37:27.000 \n", + "4 [ZTF26aabwols] 1 0.266667 2026-01-20 17:38:46.000 \n", + "5 [ZTF25acinfdh] 1 0.266667 2026-01-24 17:35:59.000 \n", + "6 [ZTF25acdheca] 1 0.266667 2026-01-24 17:37:08.000 \n", + "7 [ZTF25acfojmo] 1 0.266667 2026-01-24 17:42:13.000 \n", + "8 [ZTF25ackyfnb] 1 0.266667 2026-01-24 18:35:57.000 \n", + "9 [ZTF25achapja] 1 0.266667 2026-01-24 18:36:44.000 \n", + "10 [ZTF25acglosh] 1 0.266667 2026-01-24 18:37:20.000 \n", + "11 [ZTF21aasyjxq] 1 0.266667 2026-01-24 18:38:04.000 \n", + "12 [ZTF25abyevmr] 1 0.266667 2026-01-24 18:38:35.000 \n", + "13 [ZTF25abwjtwc] 1 0.266667 2026-01-21 18:42:04.000 \n", + "14 [ZTF25abjlnnh] 1 0.266667 2026-01-21 18:43:07.000 \n", + "15 [ZTF25acfxvcu] 1 0.266667 2026-01-24 18:47:12.000 \n", + "16 [ZTF25aclckzl] 3 0.800000 2026-01-21 18:50:17.593 \n", "\n", - " window_end \n", - "2 2024-04-18 18:11:25.996 \n", - "3 2024-03-06 00:00:00.000 \n", - "4 2024-03-06 00:00:00.000 \n", - "5 2024-03-06 00:00:00.000 " + " window_end archived \n", + "0 2026-01-23 22:27:07.000 False \n", + "1 2026-01-26 22:01:11.000 False \n", + "2 2026-01-27 16:54:09.181 False \n", + "3 2026-01-27 17:37:27.000 False \n", + "4 2026-01-27 17:38:46.000 False \n", + "5 2026-01-28 17:35:59.000 False \n", + "6 2026-01-28 17:37:08.000 False \n", + "7 2026-01-28 17:42:13.000 False \n", + "8 2026-01-28 18:35:57.000 False \n", + "9 2026-01-28 18:36:44.000 False \n", + "10 2026-01-28 18:37:20.000 False \n", + "11 2026-01-28 18:38:04.000 False \n", + "12 2026-01-28 18:38:35.000 False \n", + "13 2026-01-28 18:42:04.000 False \n", + "14 2026-01-28 18:43:07.000 False \n", + "15 2026-01-28 18:47:12.000 False \n", + "16 2026-01-28 18:50:18.123 False " ] }, - "execution_count": 12, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -588,6 +1147,14 @@ "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd6e113c-fc32-48b1-9e02-c800a629f4ee", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -606,7 +1173,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.14.2" } }, "nbformat": 4, diff --git a/notebooks/Example_4_Finding_Observatory_Data.ipynb b/notebooks/Example_4_Finding_Observatory_Data.ipynb index 01ed58a..403bfbf 100644 --- a/notebooks/Example_4_Finding_Observatory_Data.ipynb +++ b/notebooks/Example_4_Finding_Observatory_Data.ipynb @@ -67,7 +67,9 @@ } ], "source": [ - "res, images = winter.query_images_by_program(program_name, image_type=\"exposure\", start_date=start_date, end_date=end_date)" + "res, images = winter.query_images_by_program(\n", + " program_name, image_type=\"exposure\", start_date=start_date, end_date=end_date\n", + ")" ] }, { @@ -415,7 +417,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"exposure\", target_name=target_name, start_date=start_date, end_date=end_date)" + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"exposure\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")" ] }, { @@ -679,7 +687,14 @@ } ], "source": [ - "res, images = winter.query_images_by_cone(program_name, image_type=\"exposure\", ra_deg=150.959309, dec_deg=17.825813, start_date=start_date, end_date=end_date)" + "res, images = winter.query_images_by_cone(\n", + " program_name,\n", + " image_type=\"exposure\",\n", + " ra_deg=150.959309,\n", + " dec_deg=17.825813,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")" ] }, { @@ -950,10 +965,14 @@ ], "source": [ "res, images = winter.query_images_by_rectangle(\n", - " program_name, start_date=start_date, end_date=end_date,\n", - " ra_min_deg = 146., ra_max_deg=147.,\n", - " dec_min_deg = -5., dec_max_deg = -4.,\n", - " image_type=\"stack\"\n", + " program_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + " ra_min_deg=146.0,\n", + " ra_max_deg=147.0,\n", + " dec_min_deg=-5.0,\n", + " dec_max_deg=-4.0,\n", + " image_type=\"stack\",\n", ")" ] }, @@ -1302,7 +1321,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"exposure\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"exposure\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] }, @@ -2253,7 +2278,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"raw\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"raw\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] }, @@ -2414,7 +2445,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"science\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"science\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] }, @@ -2520,7 +2557,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"stack\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"stack\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] }, @@ -2625,7 +2668,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"diff\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"diff\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] }, @@ -2732,7 +2781,13 @@ } ], "source": [ - "res, images = winter.query_images_by_target_name(program_name, image_type=\"avro\", target_name=target_name, start_date=start_date, end_date=end_date)\n", + "res, images = winter.query_images_by_target_name(\n", + " program_name,\n", + " image_type=\"avro\",\n", + " target_name=target_name,\n", + " start_date=start_date,\n", + " end_date=end_date,\n", + ")\n", "images" ] } diff --git a/notebooks/Example_5_Downloading_Observatory_Data.ipynb b/notebooks/Example_5_Downloading_Observatory_Data.ipynb index c451b95..47d1846 100644 --- a/notebooks/Example_5_Downloading_Observatory_Data.ipynb +++ b/notebooks/Example_5_Downloading_Observatory_Data.ipynb @@ -207,7 +207,9 @@ ], "source": [ "# Let's start by doing an image query\n", - "res, images = winter.query_images_by_program(program_name, image_type=image_type, start_date=\"20240129\")\n", + "res, images = winter.query_images_by_program(\n", + " program_name, image_type=image_type, start_date=\"20240129\"\n", + ")\n", "images" ] }, @@ -278,7 +280,9 @@ } ], "source": [ - "res, output_path = winter.download_image_list(program_name, image_type=image_type, paths=savepaths)\n", + "res, output_path = winter.download_image_list(\n", + " program_name, image_type=image_type, paths=savepaths\n", + ")\n", "print(f\"Saved images to {output_path}\")\n", "print(res.headers)\n", "res.raise_for_status()" diff --git a/notebooks/Info_2a_ToO_Parameters.ipynb b/notebooks/Info_2a_ToO_Parameters.ipynb index 106571f..ad541c2 100644 --- a/notebooks/Info_2a_ToO_Parameters.ipynb +++ b/notebooks/Info_2a_ToO_Parameters.ipynb @@ -11,7 +11,12 @@ "from IPython.display import JSON\n", "import json\n", "from winterapi import WinterAPI\n", - "from wintertoo.models import SummerFieldToO, SummerRaDecToO, WinterFieldToO, WinterRaDecToO" + "from wintertoo.models import (\n", + " SummerFieldToO,\n", + " SummerRaDecToO,\n", + " WinterFieldToO,\n", + " WinterRaDecToO,\n", + ")" ] }, { @@ -320,7 +325,7 @@ ], "source": [ "# end time in the past\n", - "too = WinterFieldToO(field_id=55, end_time_mjd=58000.)\n", + "too = WinterFieldToO(field_id=55, end_time_mjd=58000.0)\n", "too" ] }, @@ -531,7 +536,7 @@ } ], "source": [ - "too = WinterRaDecToO(ra_deg=300., dec_deg=51.)\n", + "too = WinterRaDecToO(ra_deg=300.0, dec_deg=51.0)\n", "too" ] }, @@ -563,7 +568,7 @@ } ], "source": [ - "too = WinterRaDecToO(ra_deg=300., dec_deg=51., use_field_grid=False)\n", + "too = WinterRaDecToO(ra_deg=300.0, dec_deg=51.0, use_field_grid=False)\n", "too" ] }, diff --git a/notebooks/Info_2b_Submitting_ToOs.ipynb b/notebooks/Info_2b_Submitting_ToOs.ipynb index 4bccffd..216e3b8 100644 --- a/notebooks/Info_2b_Submitting_ToOs.ipynb +++ b/notebooks/Info_2b_Submitting_ToOs.ipynb @@ -333,10 +333,7 @@ } ], "source": [ - "local_schedule = winter.build_schedule_locally(\n", - " program_name=\"202XA000\",\n", - " data=too_list\n", - ")\n", + "local_schedule = winter.build_schedule_locally(program_name=\"202XA000\", data=too_list)\n", "local_schedule" ] }, @@ -362,9 +359,7 @@ "outputs": [], "source": [ "api_res, api_schedule = winter.submit_too(\n", - " program_name=\"202XA000\",\n", - " data=too_list,\n", - " submit_trigger=False\n", + " program_name=\"202XA000\", data=too_list, submit_trigger=False\n", ")" ] }, diff --git a/pyproject.toml b/pyproject.toml index 3ced6b4..5270f7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "winterapi" -version = "1.5.0" +version = "1.6.0" description = "" authors = [ {name = "Robert Stein", email = "rdstein@caltech.edu"} @@ -36,13 +36,14 @@ dependencies = [ "jupyter", "backoff", "pydantic", - "wintertoo>=1.8.0" + "wintertoo>=1.9.1", + "python-dotenv" ] [project.optional-dependencies] dev = [ - "black == 24.4.2", - "isort == 5.13.2", - "pylint == 3.2.2", + "black >= 26.1.0", + "isort == 7.0.0", + "pylint == 4.0.4", "coveralls", ] diff --git a/tests/testdata/test_schedule.csv b/tests/testdata/test_schedule.csv index 3d0b7c0..6923afb 100644 --- a/tests/testdata/test_schedule.csv +++ b/tests/testdata/test_schedule.csv @@ -1,7 +1,7 @@ -targName,raDeg,decDeg,fieldID,filter,visitExpTime,singleExpTime,priority,progPI,progName,progID,validStart,validStop,observed,maxAirmass,ditherNumber,ditherStepSize,bestDetector,obsHistID -test_field,211.56398,54.0,3944,Y,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,0 -test_field,211.56398,54.0,3944,J,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,1 -test_field,211.56398,54.0,3944,Hs,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,2 -test_radec,210.910674637,54.3116510708,999999999,Y,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,3 -test_radec,210.910674637,54.3116510708,999999999,J,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,4 -test_radec,210.910674637,54.3116510708,999999999,Hs,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,5 +targName,raDeg,decDeg,fieldID,filter,visitExpTime,singleExpTime,priority,progPI,progName,progID,validStart,validStop,observed,maxAirmass,ditherNumber,ditherStepSize,bestDetector,camera,obsHistID +test_field,211.56398,54.0,3944,Y,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,winter,0 +test_field,211.56398,54.0,3944,J,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,winter,1 +test_field,211.56398,54.0,3944,Hs,300.0,33.333333333333336,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,9,90.0,True,winter,2 +test_radec,210.910674637,54.3116510708,999999999,Y,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,winter,3 +test_radec,210.910674637,54.3116510708,999999999,J,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,winter,4 +test_radec,210.910674637,54.3116510708,999999999,Hs,300.0,37.5,50.0,Stein,2023A999,0,62721.1894969287,62722.1894969452,False,2.0,8,90.0,True,winter,5 diff --git a/winterapi/base_api.py b/winterapi/base_api.py index 920dd4b..cab5e05 100644 --- a/winterapi/base_api.py +++ b/winterapi/base_api.py @@ -41,13 +41,17 @@ def clean_data(data): if isinstance(data, list): convert = json.dumps( [ - x.model_dump(exclude=set(x.model_computed_fields.keys())) + x.model_dump(exclude=set(x.__class__.model_computed_fields.keys())) for x in data ] ) elif isinstance(data, BaseModel): convert = json.dumps( - [data.model_dump(exclude=set(data.model_computed_fields.keys()))] + [ + data.model_dump( + exclude=set(data.__class__.model_computed_fields.keys()) + ) + ] ) else: err = f"Unrecognised data type {type(data)}" diff --git a/winterapi/configure_tests.py b/winterapi/configure_tests.py index b0f885c..76cecd4 100644 --- a/winterapi/configure_tests.py +++ b/winterapi/configure_tests.py @@ -4,8 +4,12 @@ import os +from dotenv import load_dotenv + from winterapi import WinterAPI +load_dotenv() + winter = WinterAPI() diff --git a/winterapi/endpoints.py b/winterapi/endpoints.py index 3472459..96dfd2c 100644 --- a/winterapi/endpoints.py +++ b/winterapi/endpoints.py @@ -4,6 +4,10 @@ import os +from dotenv import load_dotenv + +load_dotenv() + run_local = os.getenv("WINTER_API_LOCAL", "0") in ["True", "true", "1"] BASE_URL = "http://127.0.0.1:7000" if run_local else "http://winter.caltech.edu:82" PING_URL = BASE_URL + "/ping" @@ -11,6 +15,7 @@ USER_URL = BASE_URL + "/validation/user" PROGRAM_URL = BASE_URL + "/validation/program" WINTER_TOO_URL = BASE_URL + "/too/winter" +SPRING_TOO_URL = BASE_URL + "/too/spring" SUMMER_TOO_URL = BASE_URL + "/too/summer" SCHEDULE_SUMMARY_URL = BASE_URL + "/too/summary" SCHEDULE_DETAILS_URL = BASE_URL + "/too/details" diff --git a/winterapi/messenger.py b/winterapi/messenger.py index 50c9a54..5a032a9 100644 --- a/winterapi/messenger.py +++ b/winterapi/messenger.py @@ -24,6 +24,8 @@ ) from wintertoo.models.too import ( AllTooClasses, + Spring, + SpringRaDecToO, Summer, SummerFieldToO, SummerRaDecToO, @@ -43,6 +45,7 @@ SCHEDULE_DELETE_URL, SCHEDULE_DETAILS_URL, SCHEDULE_SUMMARY_URL, + SPRING_TOO_URL, SUMMER_TOO_URL, USER_URL, VERSION_URL, @@ -282,6 +285,31 @@ def submit_too( submit_trigger=submit_trigger, ) + def submit_too_spring( + self, + program_name: str, + data: list[SpringRaDecToO] | SpringRaDecToO, + submit_trigger: bool = False, + ) -> tuple[requests.Response, pd.DataFrame]: + """ + Function to submit TOO requests for SPRING + + :param program_name: Name of the program under which to submit the TOO + :param data: List of SPRING TOO requests + :param submit_trigger: boolean whether to really submit the TOO + :return: API response and TOO schedule + """ + if not isinstance(data, list): + data = [data] + for entry in data: + assert isinstance(entry, Spring), f"Entry {entry} is not a Spring ToO" + return self._submit_too( + program_name=program_name, + url=SPRING_TOO_URL, + data=data, + submit_trigger=submit_trigger, + ) + def submit_too_summer( self, program_name: str, @@ -323,11 +351,15 @@ def build_schedule_locally( def get_observatory_queue( self, program_name: str, + include_archived: bool = False, + target_name: Optional[str] = None, ) -> tuple[requests.Response, pd.DataFrame]: """ Function to get the observatory queue :param program_name: Name of the program under which to check ToOs + :param include_archived: Whether to include archived schedules` + :param target_name: Name of the target to filter by :return: API response and TOO schedule """ @@ -337,9 +369,15 @@ def get_observatory_queue( SCHEDULE_SUMMARY_URL, program_name=program_name, program_api_key=program.prog_key, + include_archived=include_archived, ) observatory_queue = pd.DataFrame(res.json()["body"]) + + if target_name is not None: + mask = [target_name in x for x in observatory_queue["target_names"]] + observatory_queue = observatory_queue[mask] + return res, observatory_queue def get_too_details(