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 Jul 9, 2024
1 parent 5fad06b commit 0c3fcd5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 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
4 changes: 2 additions & 2 deletions tests/unit/bufr_export/test_get_bufr.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_bufr_variables_gcnet(self):
heightOfStationGroundAboveMeanSeaLevel=2123.2,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=2.05,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=2.05,
heightOfBarometerAboveMeanSeaLevel=2125.25,
heightOfBarometerAboveMeanSeaLevel=2125.3,
)

def test_bufr_variables_promice_v2(self):
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_bufr_variables_promice_v2(self):
heightOfStationGroundAboveMeanSeaLevel=2123.8,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=2.2,
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=2.6,
heightOfBarometerAboveMeanSeaLevel=2124.45,
heightOfBarometerAboveMeanSeaLevel=2124.5,
)

def test_bufr_variables_promice_v3(self):
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 0c3fcd5

Please sign in to comment.