diff --git a/geomagio/api/ws/algorithms.py b/geomagio/api/ws/algorithms.py index f2eeee314c9b0dd20b2deaad8fe969f87433f1a2..bcc42a3590b1804c87d95ada48679e2ba7584b4c 100644 --- a/geomagio/api/ws/algorithms.py +++ b/geomagio/api/ws/algorithms.py @@ -33,11 +33,7 @@ def get_dbdt( @router.post("/algorithms/residual", response_model=Reading) def calculate_residual(reading: Reading, adjust_reference: bool = True): - missing_types = reading.get_missing_measurement_types() - if len(missing_types) != 0: - missing_types = ", ".join(t.value for t in missing_types) - raise HTTPException( - status_code=400, - detail=f"Missing {missing_types} measurements in input reading", - ) - return calculate(reading=reading, adjust_reference=adjust_reference) + try: + return calculate(reading=reading, adjust_reference=adjust_reference) + except ValueError as e: + raise HTTPException(status_code=400, detail=str(e)) diff --git a/geomagio/residual/Reading.py b/geomagio/residual/Reading.py index 519245b697c393c6ae73364f425618d792d79a95..437da4992fd3bac827861ff3340c3743b530c143 100644 --- a/geomagio/residual/Reading.py +++ b/geomagio/residual/Reading.py @@ -8,10 +8,14 @@ from pydantic import BaseModel from .. import TimeseriesUtility from ..TimeseriesFactory import TimeseriesFactory from .Absolute import Absolute -from .Calculation import DECLINATION_TYPES, INCLINATION_TYPES, MARK_TYPES from .Measurement import Measurement, average_measurement from .Diagnostics import Diagnostics -from .MeasurementType import MeasurementType +from .MeasurementType import ( + MeasurementType, + DECLINATION_TYPES, + INCLINATION_TYPES, + MARK_TYPES, +) class Reading(BaseModel):