@@ -72,6 +72,20 @@ def extract_sso_data(payload: dict) -> pd.DataFrame:
7272 ):
7373 with_cutouts = True
7474
75+ if with_cutouts and truncated :
76+ # Check mandatory fields
77+ if "i:objectId" not in cols or "i:candid" not in cols :
78+ rep = {
79+ "status" : "error" ,
80+ "text" : "You need to add 'i:objectId,i:candid' to the columns.\n " ,
81+ }
82+ return Response (str (rep ), 400 )
83+
84+ if truncated and "i:ssnamenr" not in cols :
85+ # For name resolving, i:ssnamenr must be here
86+ # In case the user forgot, let's add it silently
87+ cols += ",i:ssnamenr"
88+
7589 n_or_d = str (payload ["n_or_d" ])
7690
7791 if "," in n_or_d :
@@ -187,14 +201,12 @@ def extract_sso_data(payload: dict) -> pd.DataFrame:
187201 download_cutout (row ["i:objectId" ], row ["i:candid" ], cutout_kind )
188202 )
189203 pdf [colname ] = cutouts
190- # pdf[colname] = pdf[["i:objectId", "i:candid"]].apply(
191- # lambda x: pd.Series([download_cutout(x.iloc[0], x.iloc[1], cutout_kind)]),
192- # axis=1,
193- # )
194204
195205 if with_ephem :
196- # We should probably add a timeout
197- # and try/except in case of miriade shutdown
206+ # TODO: In case truncated is True, check (before DB call)
207+ # the mandatory fields have been requested
208+ # TODO: We should probably add a timeout and try/except
209+ # in case of miriade shutdown
198210 pdf = get_miriade_data (pdf , sso_colname = "sso_name" )
199211 if "i:magpsf_red" not in pdf .columns :
200212 rep = {
@@ -204,13 +216,11 @@ def extract_sso_data(payload: dict) -> pd.DataFrame:
204216 return Response (str (rep ), 400 )
205217
206218 if with_residuals :
207- # get phase curve parameters using
208- # the sHG1G2 model
219+ # TODO: In case truncated is True, check (before DB call)
220+ # the mandatory fields have been requested
209221
210- # Phase angle, in radians
222+ # Get phase curve parameters using the sHG1G2 model
211223 phase = np .deg2rad (pdf ["Phase" ].values )
212-
213- # Required for sHG1G2
214224 ra = np .deg2rad (pdf ["i:ra" ].values )
215225 dec = np .deg2rad (pdf ["i:dec" ].values )
216226
0 commit comments