Skip to content

Commit

Permalink
Increased the real_time_utilities rounding precisions
Browse files Browse the repository at this point in the history
  • Loading branch information
ladsmund committed Aug 6, 2024
1 parent c6581ca commit 061d7a1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions src/pypromice/postprocess/real_time_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_latest_data(

# Apply smoothing to z_boom_u
# require at least 2 hourly obs? Sometimes seeing once/day data for z_boom_u
df_limited = rolling_window(df_limited, "z_boom_u", "72H", 2, 1)
df_limited = rolling_window(df_limited, "z_boom_u", "72H", 2, 3)

# limit to single most recent valid row (convert to series)
s_current = df_limited.loc[last_valid_index]
Expand Down Expand Up @@ -149,9 +149,9 @@ def find_positions(df, time_limit):
logger.info(f"last transmission: {df_limited.index.max()}")

# Extrapolate recommended for altitude, optional for lat and lon.
df_limited, lat_valid = linear_fit(df_limited, "gps_lat", 6)
df_limited, lon_valid = linear_fit(df_limited, "gps_lon", 6)
df_limited, alt_valid = linear_fit(df_limited, "gps_alt", 1)
df_limited, lat_valid = linear_fit(df_limited, "gps_lat", 7)
df_limited, lon_valid = linear_fit(df_limited, "gps_lon", 7)
df_limited, alt_valid = linear_fit(df_limited, "gps_alt", 4)

# If we have no valid lat, lon or alt data in the df_limited window, then interpolate
# using full tx dataset.
Expand All @@ -162,9 +162,9 @@ def find_positions(df, time_limit):
logger.info(f"----> Using full history for linear extrapolation: {k}")
logger.info(f"first transmission: {df.index.min()}")
if k == "gps_alt":
df, valid = linear_fit(df, k, 1)
df, valid = linear_fit(df, k, 2)
else:
df, valid = linear_fit(df, k, 6)
df, valid = linear_fit(df, k, 7)
check_valid_again[k] = valid
if check_valid_again[k] is True:
df_limited[f"{k}_fit"] = df.loc[df_limited.index, f"{k}_fit"]
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/bufr_export/test_get_bufr.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def test_bufr_variables_gcnet(self):
latitude=66.482488,
longitude=-46.294266,
heightOfStationGroundAboveMeanSeaLevel=2123.2,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfBarometerAboveMeanSeaLevel=2125.25,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.59,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
heightOfBarometerAboveMeanSeaLevel=2125.3,
)

def test_bufr_variables_promice_v2(self):
Expand Down Expand Up @@ -91,9 +91,9 @@ def test_bufr_variables_promice_v2(self):
latitude=66.482488,
longitude=-46.294266,
heightOfStationGroundAboveMeanSeaLevel=2123.8,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.2,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfBarometerAboveMeanSeaLevel=2124.45,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.19,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
heightOfBarometerAboveMeanSeaLevel=2124.5,
)

def test_bufr_variables_promice_v3(self):
Expand Down Expand Up @@ -121,8 +121,8 @@ def test_bufr_variables_promice_v3(self):
latitude=66.482488,
longitude=-46.294266,
heightOfStationGroundAboveMeanSeaLevel=2123.8,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.2,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.19,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
heightOfBarometerAboveMeanSeaLevel=2126,
)

Expand Down
24 changes: 12 additions & 12 deletions tests/unit/bufr_export/test_get_bufr_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def test_get_bufr_has_new_data(self):
longitude=-46.29427,
heightOfStationGroundAboveMeanSeaLevel=2123.7,
heightOfBarometerAboveMeanSeaLevel=2124.7,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down Expand Up @@ -188,8 +188,8 @@ def test_get_bufr_has_new_data_dont_store_position(self):
longitude=-46.29427,
heightOfStationGroundAboveMeanSeaLevel=2123.7,
heightOfBarometerAboveMeanSeaLevel=2124.7,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down Expand Up @@ -268,8 +268,8 @@ def test_get_bufr_includes_datasets_not_in_latests_timestamps(self):
longitude=-46.29427,
heightOfStationGroundAboveMeanSeaLevel=2123.7,
heightOfBarometerAboveMeanSeaLevel=2124.7,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down Expand Up @@ -329,8 +329,8 @@ def test_invalid_value_at_last_index(self):
longitude=-46.29427,
heightOfStationGroundAboveMeanSeaLevel=2123.7,
heightOfBarometerAboveMeanSeaLevel=2124.7,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down Expand Up @@ -467,8 +467,8 @@ def test_ignore_newer_data_than_now_input(self):
longitude=-46.29426,
heightOfStationGroundAboveMeanSeaLevel=2123.3,
heightOfBarometerAboveMeanSeaLevel=2124.3,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down Expand Up @@ -508,8 +508,8 @@ def test_land_station_export(self):
longitude=-46.29427,
heightOfStationGroundAboveMeanSeaLevel=2123.7,
heightOfBarometerAboveMeanSeaLevel=2124.7,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
)
pd.testing.assert_series_equal(
bufr_data.as_series(),
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/bufr_export/test_realtime_utilitites.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def test_1(self):
"gps_lon": -46.294232,
"gps_alt": 2116.0,
"z_boom_u": 4.1901,
"gps_lat_fit": 66.482479,
"gps_lon_fit": -46.294269,
"gps_alt_fit": 2121.4,
"z_boom_u_smooth": 4.2,
"gps_lat_fit": 66.4824788,
"gps_lon_fit": -46.2942685,
"gps_alt_fit": 2121.4118,
"z_boom_u_smooth": 4.188,
},
name=datetime.datetime(2023, 12, 7, 6),
)
Expand Down Expand Up @@ -94,10 +94,10 @@ def test_latest_data_row_is_invalid(self):
"gps_lon": -46.294335,
"gps_alt": 2125.0,
"z_boom_u": 4.1844,
"gps_lat_fit": 66.482483,
"gps_lon_fit": -46.294275,
"gps_alt_fit": 2123.3,
"z_boom_u_smooth": 4.2,
"gps_lat_fit": 66.4824828,
"gps_lon_fit": -46.2942753,
"gps_alt_fit": 2123.3088,
"z_boom_u_smooth": 4.187,
},
name=expected_output_timestamp,
)
Expand Down Expand Up @@ -127,10 +127,10 @@ def test_latest_data_has_some_invalid_values(self):
"gps_lon": -46.294232,
"gps_alt": 2116.0,
"z_boom_u": 4.1901,
"gps_lat_fit": 66.482479,
"gps_lon_fit": -46.294269,
"gps_alt_fit": 2121.4,
"z_boom_u_smooth": 4.2,
"gps_lat_fit": 66.4824788,
"gps_lon_fit": -46.2942685,
"gps_alt_fit": 2121.4118,
"z_boom_u_smooth": 4.188,
},
name=datetime.datetime(2023, 12, 7, 6),
)
Expand Down

0 comments on commit 061d7a1

Please sign in to comment.