From f04c502fc270fd166a54c6f71af0b450ece499e1 Mon Sep 17 00:00:00 2001 From: Spandan Bhattacharya Date: Sun, 24 May 2026 19:00:19 +0530 Subject: [PATCH 1/2] Fix #1369 --- exotic/api/colab.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exotic/api/colab.py b/exotic/api/colab.py index c7662d0f..c84a50f1 100644 --- a/exotic/api/colab.py +++ b/exotic/api/colab.py @@ -220,7 +220,7 @@ def convert_Mobs_to_utc(datestamp, latitude, longitude, height): def find (hdr, ks, obs): # Special stuff for MObs and Boyce-Astro Observatories boyce = {"FILTER": "ip", "LATITUDE": "+32.6135", "LONGITUD": "-116.3334", "HEIGHT": 1405 } - mobs = {"FILTER": "V", "LATITUDE": "+37.04", "LONGITUD": "-110.73", "HEIGHT": 2606 } + mobs = {"FILTER": "CV", "LATITUDE": "+31.675467", "LONGITUD": "-110.951376", "HEIGHT": 1268} if "OBSERVAT" in hdr.keys() and hdr["OBSERVAT"] == 'Whipple Observatory': obs = "MObs" @@ -365,7 +365,7 @@ def make_inits_file(planetary_params, image_dir, output_dir, first_image, targ_c "Obs. Longitude": "%s", "Obs. Elevation (meters)": %d, "Camera Type (CCD or DSLR)": "CCD", - "Pixel Binning": "1x1", + "Pixel Binning": "2x2", "Filter Name (aavso.org/filters)": "%s", "Observing Notes": "%s", From 995cea48511a4f9d3bdcb6ca4198e9d9e501e8c7 Mon Sep 17 00:00:00 2001 From: Spandan Bhattacharya Date: Sun, 24 May 2026 19:21:12 +0530 Subject: [PATCH 2/2] Add regression test for #1369 --- tests/test_colab.py | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/test_colab.py diff --git a/tests/test_colab.py b/tests/test_colab.py new file mode 100644 index 00000000..e78c5b84 --- /dev/null +++ b/tests/test_colab.py @@ -0,0 +1,71 @@ +import importlib +import json +import sys +import types + +import numpy as np +from astropy.io import fits + + +def import_colab(monkeypatch): + fake_barycorrpy = types.ModuleType("barycorrpy") + fake_barycorrpy.utc_tdb = object() + fake_ipython = types.ModuleType("IPython") + fake_display = types.ModuleType("IPython.display") + fake_display.display = lambda *args, **kwargs: None + fake_display.HTML = lambda value: value + + monkeypatch.setitem(sys.modules, "barycorrpy", fake_barycorrpy) + monkeypatch.setitem(sys.modules, "IPython", fake_ipython) + monkeypatch.setitem(sys.modules, "IPython.display", fake_display) + + return importlib.import_module("exotic.api.colab") + + +def test_mobs_defaults_match_exotic_metadata(monkeypatch, tmp_path): + colab = import_colab(monkeypatch) + fits_path = tmp_path / "mobs.fits" + fits.PrimaryHDU(data=np.zeros((2, 2))).writeto(fits_path) + + with fits.open(fits_path, mode="update") as hdul: + hdr = hdul[0].header + hdr["OBSERVAT"] = "Whipple Observatory" + hdr["DATE"] = "2017-12-20T01:33:43.000" + hdr["WEATHER"] = 80 + hdr["TELTEMP"] = 20.0 + hdr["CAMTEMP"] = 10.0 + + hdr = fits.getheader(fits_path) + assert colab.find(hdr, ["FILTER", "FILT"], "MObs") == "CV" + assert colab.find(hdr, ["LATITUDE", "LAT", "SITELAT"], "MObs") == "+31.675467" + assert colab.find(hdr, ["LONGITUD", "LONG", "LONGITUDE", "SITELONG"], "MObs") == "-110.951376" + assert colab.find(hdr, ["HEIGHT", "ELEVATION", "ELE", "EL", "OBSGEO-H", "ALT-OBS", "SITEELEV"], "MObs") == 1268 + + image_dir = tmp_path.as_posix() + output_dir = f"{tmp_path.as_posix()}/" + inits_path = colab.make_inits_file( + '"planetary_parameters": {}', + image_dir, + output_dir, + fits_path.as_posix(), + "[424, 286]", + "[[465, 183], [512, 263]]", + "MObs", + "RTZ", + "", + False, + ) + inits = json_loads(inits_path) + user_info = inits["user_info"] + + assert user_info["Filter Name (aavso.org/filters)"] == "CV" + assert user_info["Obs. Latitude"] == "+31.675467" + assert user_info["Obs. Longitude"] == "-110.951376" + assert user_info["Obs. Elevation (meters)"] == 1268 + assert user_info["Pixel Binning"] == "2x2" + assert user_info["Secondary Observer Codes (N/A if none)"] == "MOBS" + + +def json_loads(path): + with open(path) as inits_file: + return json.load(inits_file)