pypromice 1.4.1__py3-none-any.whl → 1.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pypromice might be problematic. Click here for more details.

@@ -32,15 +32,44 @@ def resample_dataset(ds_h, t):
32
32
  ds_d : xarray.Dataset
33
33
  L3 AWS dataset resampled to the frequency defined by t
34
34
  '''
35
- df_d = ds_h.to_dataframe().resample(t).mean()
35
+ # Convert dataset to DataFrame
36
+ df_d = ds_h.to_dataframe()
36
37
 
38
+ # Identify non-numeric columns
39
+ non_numeric_cols = df_d.select_dtypes(exclude=['number']).columns
40
+
41
+ # Log a warning and drop non-numeric columns
42
+ if len(non_numeric_cols) > 0:
43
+ for col in non_numeric_cols:
44
+ unique_values = df_d[col].unique()
45
+ logger.warning(f"Dropping column '{col}' because it is of type '{df_d[col].dtype}' and contains unique values: {unique_values}")
46
+
47
+ df_d = df_d.drop(columns=non_numeric_cols)
48
+ # Resample the DataFrame
49
+ df_d = df_d.resample(t).mean()
50
+
37
51
  # taking the 10 min data and using it as instantaneous values:
38
- if (t == '60min') and (ds_h.time.diff(dim='time').isel(time=0).dt.total_seconds() == 600):
52
+ is_10_minutes_timestamp = (ds_h.time.diff(dim='time') / np.timedelta64(1, 's') == 600)
53
+ if (t == '60min') and is_10_minutes_timestamp.any():
39
54
  cols_to_update = ['p_i', 't_i', 'rh_i', 'rh_i_cor', 'wspd_i', 'wdir_i','wspd_x_i','wspd_y_i']
55
+ timestamp_10min = ds_h.time.where(is_10_minutes_timestamp, drop=True).to_index()
56
+ timestamp_round_hour = df_d.index
57
+ timestamp_to_update = timestamp_round_hour.intersection(timestamp_10min)
58
+
40
59
  for col in cols_to_update:
41
- df_d[col] = ds_h.reindex(time=df_d.index)[col.replace('_i','_u')].values
60
+ if col not in df_d.columns:
61
+ df_d[col] = np.nan
62
+ else:
63
+ # if there are already instantaneous values in the dataset
64
+ # we want to keep them as they are
65
+ # removing timestamps where there is already t_i filled from a TX file
66
+ missing_instantaneous = ds_h.reindex(time=timestamp_to_update)[col].isnull()
67
+ timestamp_to_update = timestamp_to_update[missing_instantaneous]
68
+ df_d.loc[timestamp_to_update, col] = ds_h.reindex(
69
+ time= timestamp_to_update
70
+ )[col.replace('_i','_u')].values
42
71
  if col == 'p_i':
43
- df_d[col] = df_d[col].values-1000
72
+ df_d.loc[timestamp_to_update, col] = df_d.loc[timestamp_to_update, col].values-1000
44
73
 
45
74
 
46
75
  # recalculating wind direction from averaged directional wind speeds
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypromice
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: PROMICE/GC-Net data processing toolbox
5
5
  Home-page: https://github.com/GEUS-Glaciology-and-Climate/pypromice
6
6
  Author: GEUS Glaciology and Climate
@@ -21,7 +21,7 @@ pypromice/process/get_l2tol3.py,sha256=4Qu2d5rT25H2dObyCc70ivtJg3vw6WA-hzI-kRD6y
21
21
  pypromice/process/join_l2.py,sha256=ifjuhFR9scVvZt3xuy-ELp-iRchxV1dEK9qJ4UNh5bE,4567
22
22
  pypromice/process/join_l3.py,sha256=nLLQbX0vuuvHET8r33ZAt5g1dtIk3foUJ9RZkwkEwE4,20158
23
23
  pypromice/process/load.py,sha256=iaFvJeaDanAA60caVj4BWupZpqgQNj3CiNU4csz9FdU,4585
24
- pypromice/process/resample.py,sha256=caOqcO3AQQ6ejEbVd2AcCKycQps7U0y6GKjLYzWfZnI,5714
24
+ pypromice/process/resample.py,sha256=x0t9CE4YnwYMrn6wDRArhrQHqHOIJpYpTrgEcARUppo,7138
25
25
  pypromice/process/utilities.py,sha256=1pqSaF3bIbvRNtOjb25mbegHfuW9MY4KpCBDVXWyML8,1773
26
26
  pypromice/process/value_clipping.py,sha256=FkBiDT_HK_BDFiVjB7NdWH-_nab7vONG9LOd2PpEBI8,1573
27
27
  pypromice/process/write.py,sha256=fRCCK4g_W07M4EEsJErdTSN2Pldr9SLgqM2w_rsp2ZQ,16257
@@ -45,9 +45,9 @@ pypromice/tx/payload_types.csv,sha256=C1-xCmHytAqqAzgzPwBLWqabzWu6s6tKAd8AjVd935
45
45
  pypromice/tx/tx.py,sha256=TE5lKYMJF4hAhHrKjMyx1LZWpOHlwGJI9EdlPJrQITs,34251
46
46
  pypromice/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  pypromice/utilities/git.py,sha256=7EUGjDs_VZucrckakXKyZEclDAZ_mKIxhTWzhopCIxM,1785
48
- pypromice-1.4.1.dist-info/LICENSE.txt,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
49
- pypromice-1.4.1.dist-info/METADATA,sha256=znYJm-tDsyrWFwkvQ9xE2BEiN9ZofRxO5EtmBYeIhrQ,4762
50
- pypromice-1.4.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
51
- pypromice-1.4.1.dist-info/entry_points.txt,sha256=ufX1npmY3nqMPtSVRKVxn3MhG9IyFHD5FjPZQcELVXo,618
52
- pypromice-1.4.1.dist-info/top_level.txt,sha256=cBdfwgSbWDQq3a07nKRjrfmLC7jdaYXs98GG58HpTks,10
53
- pypromice-1.4.1.dist-info/RECORD,,
48
+ pypromice-1.4.2.dist-info/LICENSE.txt,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
49
+ pypromice-1.4.2.dist-info/METADATA,sha256=7Y55ySy-BVM0Tb1HoVShtxYqjpIMQWBjiIypPaGqMLE,4762
50
+ pypromice-1.4.2.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
51
+ pypromice-1.4.2.dist-info/entry_points.txt,sha256=ufX1npmY3nqMPtSVRKVxn3MhG9IyFHD5FjPZQcELVXo,618
52
+ pypromice-1.4.2.dist-info/top_level.txt,sha256=cBdfwgSbWDQq3a07nKRjrfmLC7jdaYXs98GG58HpTks,10
53
+ pypromice-1.4.2.dist-info/RECORD,,