Skip to content

Commit

Permalink
format fix new version json Basetime
Browse files Browse the repository at this point in the history
  • Loading branch information
BasetimeBV committed Oct 10, 2024
1 parent ec81d5b commit afe3266
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/baec/measurements/io/basetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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"),
Expand Down Expand Up @@ -448,3 +455,4 @@ def convert_epsg_string_to_list_int(epsg_string: str) -> list:
return [num1]
else:
return []

0 comments on commit afe3266

Please sign in to comment.