diff --git a/src/pypromice/postprocess/create_bufr_files.py b/src/pypromice/postprocess/create_bufr_files.py index a6cb7842..33178deb 100644 --- a/src/pypromice/postprocess/create_bufr_files.py +++ b/src/pypromice/postprocess/create_bufr_files.py @@ -47,7 +47,7 @@ def create_bufr_files( Suffix for the compiled output file """ - periods = pd.date_range(period_start, period_end, freq="H") + periods = pd.date_range(period_start, period_end, freq="h") output_individual_root = output_root / "individual" output_compiled_root = output_root / "compiled" output_individual_root.mkdir(parents=True, exist_ok=True) diff --git a/src/pypromice/postprocess/real_time_utilities.py b/src/pypromice/postprocess/real_time_utilities.py index 2ee3dec4..dd058286 100644 --- a/src/pypromice/postprocess/real_time_utilities.py +++ b/src/pypromice/postprocess/real_time_utilities.py @@ -73,8 +73,8 @@ 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] diff --git a/src/pypromice/process/L2toL3.py b/src/pypromice/process/L2toL3.py index e9d9fb1d..004cd615 100755 --- a/src/pypromice/process/L2toL3.py +++ b/src/pypromice/process/L2toL3.py @@ -102,6 +102,7 @@ def toL3(L2, station_config={}, T_0=273.15): if len(station_config)==0: logger.warning('\n***\nThe station configuration file is missing or improperly passed to pypromice. Some processing steps might fail.\n***\n') + # Smoothing and inter/extrapolation of GPS coordinates for var in ['gps_lat', 'gps_lon', 'gps_alt']: ds[var.replace('gps_','')] = ('time', gps_coordinate_postprocessing(ds, var, station_config)) @@ -193,7 +194,7 @@ def process_surface_height(ds, station_config={}): ts_interpolated = np.minimum( xr.where(ds.z_ice_surf.notnull(), ds.z_ice_surf,ds.z_surf_combined), - ds.z_surf_combined).to_series().resample('H').interpolate(limit=72) + ds.z_surf_combined).to_series().resample('h').interpolate(limit=72) if len(ts_interpolated)>24*7: # Apply the rolling window with median calculation @@ -337,7 +338,7 @@ def combine_surface_height(df, site_type, threshold_ablation = -0.0002): # meaning when smoothed_z_pt.diff() < threshold_ablation # first smoothing smoothed_PT = (df['z_ice_surf'] - .resample('H') + .resample('h') .interpolate(limit=72) .rolling('14D',center=True, min_periods=1) .mean()) diff --git a/src/pypromice/process/write.py b/src/pypromice/process/write.py index db513f23..58b87278 100644 --- a/src/pypromice/process/write.py +++ b/src/pypromice/process/write.py @@ -283,7 +283,7 @@ def addMeta(ds, meta): time_diff = pd.Timedelta((ds['time'][1] - ds['time'][0]).values) if time_diff == pd.Timedelta('10min'): sample_rate = "10min" - elif time_diff == pd.Timedelta('1H'): + elif time_diff == pd.Timedelta('1h'): sample_rate = "hourly" elif time_diff == pd.Timedelta('1D'): sample_rate = "daily" diff --git a/tests/data/test_config1.toml b/tests/data/test_config1.toml index 09392c08..6b9e2e95 100644 --- a/tests/data/test_config1.toml +++ b/tests/data/test_config1.toml @@ -2,6 +2,7 @@ station_id = 'TEST1' logger_type = 'CR1000X' nodata = ['-999', 'NAN'] # if one is a string, all must be strings number_of_booms = 1 #1-boom = promice, 2-boom = gc-net +site_type = 'ablation' latitude = 79.91 longitude = 24.09 diff --git a/tests/data/test_config2.toml b/tests/data/test_config2.toml index 8213d955..2c632abe 100644 --- a/tests/data/test_config2.toml +++ b/tests/data/test_config2.toml @@ -2,6 +2,7 @@ station_id = 'TEST2' logger_type = 'CR1000X' nodata = ['-999', 'NAN'] # if one is a string, all must be strings number_of_booms = 2 +site_type = 'accumulation' ['test_raw_transmitted2.txt'] format = 'TX' diff --git a/tests/unit/qc/test_persistence.py b/tests/unit/qc/test_persistence.py index 0707a9dd..8f4d813a 100644 --- a/tests/unit/qc/test_persistence.py +++ b/tests/unit/qc/test_persistence.py @@ -64,7 +64,7 @@ def test_persistent_period_longer_than_period_threshold(self): input_series = pd.Series(index=time_range, data=np.arange(0, len(time_range))) input_series.iloc[index_start:index_end] = input_series.iloc[index_start] expected_output = input_series.map(lambda _: False) - expected_output[expected_filter_start:expected_filter_end] = True + expected_output.iloc[expected_filter_start:expected_filter_end] = True persistent_mask = find_persistent_regions( input_series, min_repeats=min_repeats, max_diff=0.001 @@ -175,19 +175,19 @@ def test_get_duration_consecutive_true(self): np.isnan(duration_consecutive_true[0]), "The first index should be ignored" ) np.testing.assert_almost_equal( - duration_consecutive_true[1], + duration_consecutive_true.iloc[1], delta_time_hours[1], ) np.testing.assert_almost_equal( - duration_consecutive_true[6], + duration_consecutive_true.iloc[6], delta_time_hours[6], ) np.testing.assert_almost_equal( - duration_consecutive_true[10:14], + duration_consecutive_true.iloc[10:14], delta_time_hours[10:14].cumsum(), ) np.testing.assert_almost_equal( - duration_consecutive_true[-3:], + duration_consecutive_true.iloc[-3:], delta_time_hours[-3:].cumsum(), )