From 5c207953c318a094ae0ada143602de773c5ce138 Mon Sep 17 00:00:00 2001 From: Shane Elipot Date: Fri, 26 Jan 2024 17:07:23 -0500 Subject: [PATCH 1/2] subset docstring edit --- clouddrift/ragged.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clouddrift/ragged.py b/clouddrift/ragged.py index d5dc7be6..bc2d4a57 100644 --- a/clouddrift/ragged.py +++ b/clouddrift/ragged.py @@ -558,17 +558,17 @@ def subset( Parameters ---------- ds : xr.Dataset - Dataset stored as ragged arrays + Dataset stored as ragged arrays. criteria : dict - dictionary containing the variables (as keys) and the ranges/values/functions (as values) to subset + Dictionary containing the variables (as keys) and the ranges/values/functions (as values) to subset. id_var_name : str, optional - Name of the variable containing the ID of the trajectories (default is "id") + Name of the variable with dimension `traj_dim_name` containing the ID of the trajectories (default is "id"). rowsize_var_name : str, optional - Name of the variable containing the number of observations per trajectory (default is "rowsize") + Name of the variable containing the number of observations per trajectory (default is "rowsize"). traj_dim_name : str, optional - Name of the trajectory dimension (default is "traj") + Name of the trajectory dimension (default is "traj"). obs_dim_name : str, optional - Name of the observation dimension (default is "obs") + Name of the observation dimension (default is "obs"). full_trajectories : bool, optional If True, it returns the complete trajectories (rows) where at least one observation matches the criteria, rather than just the segments where the criteria are satisfied. From 803118e9e9085349467513070c0acc88536fee06 Mon Sep 17 00:00:00 2001 From: Philippe Miron Date: Sat, 27 Jan 2024 13:55:19 -0500 Subject: [PATCH 2/2] black v24 --- clouddrift/adapters/gdp1h.py | 12 ++++++------ clouddrift/adapters/gdp6h.py | 12 ++++++------ clouddrift/adapters/glad.py | 1 + clouddrift/adapters/mosaic.py | 1 + clouddrift/datasets.py | 1 + clouddrift/pairs.py | 1 + clouddrift/raggedarray.py | 1 + clouddrift/wavelet.py | 9 ++------- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/clouddrift/adapters/gdp1h.py b/clouddrift/adapters/gdp1h.py index acd85e17..cd2f32fd 100644 --- a/clouddrift/adapters/gdp1h.py +++ b/clouddrift/adapters/gdp1h.py @@ -601,11 +601,11 @@ def to_raggedarray( ) # set dynamic global attributes - ra.attrs_global[ - "time_coverage_start" - ] = f"{datetime(1970,1,1) + timedelta(seconds=int(np.min(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" - ra.attrs_global[ - "time_coverage_end" - ] = f"{datetime(1970,1,1) + timedelta(seconds=int(np.max(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ra.attrs_global["time_coverage_start"] = ( + f"{datetime(1970,1,1) + timedelta(seconds=int(np.min(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ) + ra.attrs_global["time_coverage_end"] = ( + f"{datetime(1970,1,1) + timedelta(seconds=int(np.max(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ) return ra diff --git a/clouddrift/adapters/gdp6h.py b/clouddrift/adapters/gdp6h.py index 941deae3..cf442cd3 100644 --- a/clouddrift/adapters/gdp6h.py +++ b/clouddrift/adapters/gdp6h.py @@ -488,11 +488,11 @@ def to_raggedarray( ) # update dynamic global attributes - ra.attrs_global[ - "time_coverage_start" - ] = f"{datetime(1970,1,1) + timedelta(seconds=int(np.min(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" - ra.attrs_global[ - "time_coverage_end" - ] = f"{datetime(1970,1,1) + timedelta(seconds=int(np.max(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ra.attrs_global["time_coverage_start"] = ( + f"{datetime(1970,1,1) + timedelta(seconds=int(np.min(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ) + ra.attrs_global["time_coverage_end"] = ( + f"{datetime(1970,1,1) + timedelta(seconds=int(np.max(ra.coords['time']))):%Y-%m-%d:%H:%M:%SZ}" + ) return ra diff --git a/clouddrift/adapters/glad.py b/clouddrift/adapters/glad.py index 2fe5cc78..c61d169c 100644 --- a/clouddrift/adapters/glad.py +++ b/clouddrift/adapters/glad.py @@ -13,6 +13,7 @@ --------- Özgökmen, Tamay. 2013. GLAD experiment CODE-style drifter trajectories (low-pass filtered, 15 minute interval records), northern Gulf of Mexico near DeSoto Canyon, July-October 2012. Distributed by: Gulf of Mexico Research Initiative Information and Data Cooperative (GRIIDC), Harte Research Institute, Texas A&M University–Corpus Christi. doi:10.7266/N7VD6WC8 """ + from clouddrift.adapters.utils import download_with_progress from io import BytesIO import numpy as np diff --git a/clouddrift/adapters/mosaic.py b/clouddrift/adapters/mosaic.py index 0f28cfb2..e3601298 100644 --- a/clouddrift/adapters/mosaic.py +++ b/clouddrift/adapters/mosaic.py @@ -18,6 +18,7 @@ >>> from clouddrift.adapters import mosaic >>> ds = mosaic.to_xarray() """ + from datetime import datetime from io import BytesIO import numpy as np diff --git a/clouddrift/datasets.py b/clouddrift/datasets.py index c64e59fa..741f4952 100644 --- a/clouddrift/datasets.py +++ b/clouddrift/datasets.py @@ -4,6 +4,7 @@ they will be downloaded from their upstream repositories and stored for later access (~/.clouddrift for UNIX-based systems). """ + from io import BufferedReader, BytesIO from clouddrift import adapters import os diff --git a/clouddrift/pairs.py b/clouddrift/pairs.py index 782f4bd8..3c65ca99 100644 --- a/clouddrift/pairs.py +++ b/clouddrift/pairs.py @@ -1,6 +1,7 @@ """ Functions to analyze pairs of contiguous data segments. """ + from clouddrift import ragged, sphere from concurrent.futures import as_completed, ThreadPoolExecutor import itertools diff --git a/clouddrift/raggedarray.py b/clouddrift/raggedarray.py index 5ad3d49c..4e3b1039 100644 --- a/clouddrift/raggedarray.py +++ b/clouddrift/raggedarray.py @@ -3,6 +3,7 @@ structure used by CloudDrift to process custom Lagrangian datasets to Xarray Datasets and Awkward Arrays. """ + import awkward as ak from clouddrift.ragged import rowsize_to_index import xarray as xr diff --git a/clouddrift/wavelet.py b/clouddrift/wavelet.py index 4edb8040..34f1f598 100644 --- a/clouddrift/wavelet.py +++ b/clouddrift/wavelet.py @@ -429,8 +429,7 @@ def morse_wavelet( if normalization == "energy": with np.errstate(divide="ignore"): waveletzero = np.exp( - beta * np.log(norm_radian_frequency) - - norm_radian_frequency**gamma + beta * np.log(norm_radian_frequency) - norm_radian_frequency**gamma ) elif normalization == "bandpass": if beta == 0: @@ -800,11 +799,7 @@ def morse_amplitude( if normalization == "energy": r = (2 * beta + 1) / gamma amp = ( - 2 - * np.pi - * gamma - * (2**r) - * np.exp(_lgamma(order) - _lgamma(order + r - 1)) + 2 * np.pi * gamma * (2**r) * np.exp(_lgamma(order) - _lgamma(order + r - 1)) ) ** 0.5 elif normalization == "bandpass": fm, _, _ = morse_freq(gamma, beta)