From afe3266e073f5400389ff42494e6545455cd688d Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 10 Oct 2024 09:15:55 +0200 Subject: [PATCH] format fix new version json Basetime --- src/baec/measurements/io/basetime.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/baec/measurements/io/basetime.py b/src/baec/measurements/io/basetime.py index 70be5bc..fccf9f7 100644 --- a/src/baec/measurements/io/basetime.py +++ b/src/baec/measurements/io/basetime.py @@ -342,7 +342,7 @@ def make_settlement_rod_measurement_series( for date_measurement in measurement_serie["Measurements"]: measurement = measurement_serie["Measurements"][date_measurement] - if measurement["Error Codes"] == " ": + if measurement["Error Codes"] in [" ", "[]"]: status_messages = [ StatusMessage( code=7000, @@ -351,9 +351,11 @@ def make_settlement_rod_measurement_series( ) ] else: - error_string_list = measurement["Error Codes"][1:-1].split(",") - error_integer_list = [int(num) for num in error_string_list] - + try: + error_string_list = measurement["Error Codes"][1:-1].split(",") + error_integer_list = [int(num) for num in error_string_list] + except ValueError: + error_integer_list = [7000] status_messages = [ StatusMessage( code=error_code, @@ -374,9 +376,16 @@ def make_settlement_rod_measurement_series( ) for error_code in error_integer_list if self.dict_errors[error_code]["status message level"] - in ["INFO", "WARNING", "ERROR"] + in ["OK", "INFO", "WARNING", "ERROR"] ] + if measurement_serie['Project type'] == 'SettlementRods': + rod_bottom_z = measurement["Coordinates Soil"]["Height groundplate"] + ground_surface_z = measurement["Coordinates Soil"]["Height Soil"] + else: + rod_bottom_z = float("nan") + ground_surface_z = float("nan") + test_measurement = SettlementRodMeasurement( project=baec_project, device=MeasurementDevice( @@ -393,10 +402,8 @@ def make_settlement_rod_measurement_series( rod_top_z=measurement["Coordinates Local"]["Height"] or float("nan"), rod_length=measurement["Vertical offset (meters)"] or float("nan"), - rod_bottom_z=measurement["Coordinates Soil"]["Height groundplate"] - or float("nan"), - ground_surface_z=measurement["Coordinates Soil"]["Height Soil"] - or float("nan"), + rod_bottom_z=rod_bottom_z or float("nan"), + ground_surface_z=ground_surface_z or float("nan"), status_messages=status_messages, temperature=measurement["Temperature (Celsius)"] or float("nan"), voltage=measurement["Voltage Locator One (mV)"] or float("nan"), @@ -448,3 +455,4 @@ def convert_epsg_string_to_list_int(epsg_string: str) -> list: return [num1] else: return [] +