From c12d868da03b926004f0a29ed8364972986f4a19 Mon Sep 17 00:00:00 2001 From: JulienPeloton Date: Fri, 22 May 2026 10:43:36 +0200 Subject: [PATCH] [SSO] Add ephemerides for LSST --- apps/routes/v1/lsst/sso/utils.py | 27 ++++++++++++++------------- apps/routes/v1/ztf/sso/utils.py | 2 +- requirements.txt | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/routes/v1/lsst/sso/utils.py b/apps/routes/v1/lsst/sso/utils.py index 32acab6..ad43b9e 100644 --- a/apps/routes/v1/lsst/sso/utils.py +++ b/apps/routes/v1/lsst/sso/utils.py @@ -16,7 +16,8 @@ import requests from flask import Response -# from fink_utils.sso.miriade import get_miriade_data +from fink_utils.sso.miriade import get_miriade_data + # from fink_utils.sso.spins import func_hg1g2_with_spin, estimate_sso_params from line_profiler import profile @@ -86,6 +87,10 @@ def extract_sso_data(payload: dict) -> pd.DataFrame: # For name resolving, i:ssnamenr must be here # In case the user forgot, let's add it silently cols += ",r:packed_primary_provisional_designation" + if truncated and with_ephem and "r:midpointMjdTai" not in cols: + cols += ",r:midpointMjdTai" + if truncated and with_ephem and "r:psfFlux" not in cols: + cols += ",r:psfFlux" n_or_d = str(payload["n_or_d"]) @@ -164,18 +169,14 @@ def extract_sso_data(payload: dict) -> pd.DataFrame: lambda x: sso_names[x] ) - # if with_ephem: - # # TODO: In case truncated is True, check (before DB call) - # # the mandatory fields have been requested - # # TODO: We should probably add a timeout and try/except - # # in case of miriade shutdown - # pdf = get_miriade_data(pdf, sso_colname="sso_name") - # if "i:magpsf_red" not in pdf.columns: - # rep = { - # "status": "error", - # "text": "We could not obtain the ephemerides information. Check Miriade availabilities.", - # } - # return Response(str(rep), 400) + if with_ephem: + pdf = get_miriade_data(pdf, survey="lsst", observer="X05", shift=0.0) + if "i:magpsf_red" not in pdf.columns: + rep = { + "status": "error", + "text": "We could not obtain the ephemerides information. Check Miriade availabilities.", + } + return Response(str(rep), 400) # if with_residuals: # # TODO: In case truncated is True, check (before DB call) diff --git a/apps/routes/v1/ztf/sso/utils.py b/apps/routes/v1/ztf/sso/utils.py index 731586e..0ed66d4 100644 --- a/apps/routes/v1/ztf/sso/utils.py +++ b/apps/routes/v1/ztf/sso/utils.py @@ -202,7 +202,7 @@ def extract_sso_data(payload: dict) -> pd.DataFrame: # the mandatory fields have been requested # TODO: We should probably add a timeout and try/except # in case of miriade shutdown - pdf = get_miriade_data(pdf, sso_colname="sso_name") + pdf = get_miriade_data(pdf, survey="ztf", observer="I41", shift=15.0) if "i:magpsf_red" not in pdf.columns: rep = { "status": "error", diff --git a/requirements.txt b/requirements.txt index 5338ad5..0e78707 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,8 +4,8 @@ flask flask-restx pandas numpy -fink-filters==7.31 -fink-utils==0.59.0 +fink-filters==7.33 +fink-utils==0.64.0 line_profiler requests pyarrow