Skip to content

Commit 061d7a1

Browse files
committed
Increased the real_time_utilities rounding precisions
1 parent c6581ca commit 061d7a1

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/pypromice/postprocess/real_time_utilities.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_latest_data(
7272

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

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

151151
# Extrapolate recommended for altitude, optional for lat and lon.
152-
df_limited, lat_valid = linear_fit(df_limited, "gps_lat", 6)
153-
df_limited, lon_valid = linear_fit(df_limited, "gps_lon", 6)
154-
df_limited, alt_valid = linear_fit(df_limited, "gps_alt", 1)
152+
df_limited, lat_valid = linear_fit(df_limited, "gps_lat", 7)
153+
df_limited, lon_valid = linear_fit(df_limited, "gps_lon", 7)
154+
df_limited, alt_valid = linear_fit(df_limited, "gps_alt", 4)
155155

156156
# If we have no valid lat, lon or alt data in the df_limited window, then interpolate
157157
# using full tx dataset.
@@ -162,9 +162,9 @@ def find_positions(df, time_limit):
162162
logger.info(f"----> Using full history for linear extrapolation: {k}")
163163
logger.info(f"first transmission: {df.index.min()}")
164164
if k == "gps_alt":
165-
df, valid = linear_fit(df, k, 1)
165+
df, valid = linear_fit(df, k, 2)
166166
else:
167-
df, valid = linear_fit(df, k, 6)
167+
df, valid = linear_fit(df, k, 7)
168168
check_valid_again[k] = valid
169169
if check_valid_again[k] is True:
170170
df_limited[f"{k}_fit"] = df.loc[df_limited.index, f"{k}_fit"]

tests/unit/bufr_export/test_get_bufr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def test_bufr_variables_gcnet(self):
6161
latitude=66.482488,
6262
longitude=-46.294266,
6363
heightOfStationGroundAboveMeanSeaLevel=2123.2,
64-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.6,
65-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
66-
heightOfBarometerAboveMeanSeaLevel=2125.25,
64+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.59,
65+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
66+
heightOfBarometerAboveMeanSeaLevel=2125.3,
6767
)
6868

6969
def test_bufr_variables_promice_v2(self):
@@ -91,9 +91,9 @@ def test_bufr_variables_promice_v2(self):
9191
latitude=66.482488,
9292
longitude=-46.294266,
9393
heightOfStationGroundAboveMeanSeaLevel=2123.8,
94-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.2,
95-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
96-
heightOfBarometerAboveMeanSeaLevel=2124.45,
94+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.19,
95+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
96+
heightOfBarometerAboveMeanSeaLevel=2124.5,
9797
)
9898

9999
def test_bufr_variables_promice_v3(self):
@@ -121,8 +121,8 @@ def test_bufr_variables_promice_v3(self):
121121
latitude=66.482488,
122122
longitude=-46.294266,
123123
heightOfStationGroundAboveMeanSeaLevel=2123.8,
124-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.2,
125-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
124+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.19,
125+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
126126
heightOfBarometerAboveMeanSeaLevel=2126,
127127
)
128128

tests/unit/bufr_export/test_get_bufr_integration.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ def test_get_bufr_has_new_data(self):
149149
longitude=-46.29427,
150150
heightOfStationGroundAboveMeanSeaLevel=2123.7,
151151
heightOfBarometerAboveMeanSeaLevel=2124.7,
152-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
153-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
152+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
153+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
154154
)
155155
pd.testing.assert_series_equal(
156156
bufr_data.as_series(),
@@ -188,8 +188,8 @@ def test_get_bufr_has_new_data_dont_store_position(self):
188188
longitude=-46.29427,
189189
heightOfStationGroundAboveMeanSeaLevel=2123.7,
190190
heightOfBarometerAboveMeanSeaLevel=2124.7,
191-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
192-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
191+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
192+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
193193
)
194194
pd.testing.assert_series_equal(
195195
bufr_data.as_series(),
@@ -268,8 +268,8 @@ def test_get_bufr_includes_datasets_not_in_latests_timestamps(self):
268268
longitude=-46.29427,
269269
heightOfStationGroundAboveMeanSeaLevel=2123.7,
270270
heightOfBarometerAboveMeanSeaLevel=2124.7,
271-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
272-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
271+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
272+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
273273
)
274274
pd.testing.assert_series_equal(
275275
bufr_data.as_series(),
@@ -329,8 +329,8 @@ def test_invalid_value_at_last_index(self):
329329
longitude=-46.29427,
330330
heightOfStationGroundAboveMeanSeaLevel=2123.7,
331331
heightOfBarometerAboveMeanSeaLevel=2124.7,
332-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
333-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
332+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
333+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
334334
)
335335
pd.testing.assert_series_equal(
336336
bufr_data.as_series(),
@@ -467,8 +467,8 @@ def test_ignore_newer_data_than_now_input(self):
467467
longitude=-46.29426,
468468
heightOfStationGroundAboveMeanSeaLevel=2123.3,
469469
heightOfBarometerAboveMeanSeaLevel=2124.3,
470-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
471-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
470+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
471+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
472472
)
473473
pd.testing.assert_series_equal(
474474
bufr_data.as_series(),
@@ -508,8 +508,8 @@ def test_land_station_export(self):
508508
longitude=-46.29427,
509509
heightOfStationGroundAboveMeanSeaLevel=2123.7,
510510
heightOfBarometerAboveMeanSeaLevel=2124.7,
511-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.1,
512-
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.6,
511+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformTempRH=4.09,
512+
heightOfSensorAboveLocalGroundOrDeckOfMarinePlatformWSPD=4.59,
513513
)
514514
pd.testing.assert_series_equal(
515515
bufr_data.as_series(),

tests/unit/bufr_export/test_realtime_utilitites.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def test_1(self):
5050
"gps_lon": -46.294232,
5151
"gps_alt": 2116.0,
5252
"z_boom_u": 4.1901,
53-
"gps_lat_fit": 66.482479,
54-
"gps_lon_fit": -46.294269,
55-
"gps_alt_fit": 2121.4,
56-
"z_boom_u_smooth": 4.2,
53+
"gps_lat_fit": 66.4824788,
54+
"gps_lon_fit": -46.2942685,
55+
"gps_alt_fit": 2121.4118,
56+
"z_boom_u_smooth": 4.188,
5757
},
5858
name=datetime.datetime(2023, 12, 7, 6),
5959
)
@@ -94,10 +94,10 @@ def test_latest_data_row_is_invalid(self):
9494
"gps_lon": -46.294335,
9595
"gps_alt": 2125.0,
9696
"z_boom_u": 4.1844,
97-
"gps_lat_fit": 66.482483,
98-
"gps_lon_fit": -46.294275,
99-
"gps_alt_fit": 2123.3,
100-
"z_boom_u_smooth": 4.2,
97+
"gps_lat_fit": 66.4824828,
98+
"gps_lon_fit": -46.2942753,
99+
"gps_alt_fit": 2123.3088,
100+
"z_boom_u_smooth": 4.187,
101101
},
102102
name=expected_output_timestamp,
103103
)
@@ -127,10 +127,10 @@ def test_latest_data_has_some_invalid_values(self):
127127
"gps_lon": -46.294232,
128128
"gps_alt": 2116.0,
129129
"z_boom_u": 4.1901,
130-
"gps_lat_fit": 66.482479,
131-
"gps_lon_fit": -46.294269,
132-
"gps_alt_fit": 2121.4,
133-
"z_boom_u_smooth": 4.2,
130+
"gps_lat_fit": 66.4824788,
131+
"gps_lon_fit": -46.2942685,
132+
"gps_alt_fit": 2121.4118,
133+
"z_boom_u_smooth": 4.188,
134134
},
135135
name=datetime.datetime(2023, 12, 7, 6),
136136
)

0 commit comments

Comments
 (0)