You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.
As discussed with @andersy005 and @bonnland, it would be nice to have a more general resample capability that enable fluid translation between data at different temporal intervals.
Here's two functions that, if generalized, might be helpful.
The first by @klindsay28 finds the overlap between any two intervals on a number line.
definterval_overlap(interval_1, interval_2):
"""Compute the overlap between two intervals."""overlap= (np.min([np.max(interval_1), np.max(interval_2)]) -np.max([np.min(interval_1), np.min(interval_2)]))
returnmax([0.0, overlap])
The second computes averaging weights for a single coord_interval, given coord_bounds.
defcompute_vertical_weights(coord_interval, coord_bounds):
"""Compute averaging weights for remapping a peicewise-constant field on a 1D coordinate to a single interval. Example: [1]: weights = compute_vertical_weights(coord_interval=np.array([0, 20]), coord_bounds=np.array([[0, 10], [10, 20], [20, 30]])) [2]: weights array([0.5, 0.5, 0. ]) Parameters --------- coord_interval : numpy.array A two-element vector with the coordinate values over which to compute weights. For example coord_bounds : numpy.array A N x 2 element vector with the coordinate bounds. """weights=np.zeros(coord_bounds.shape[0])
foriinrange(coord_bounds.shape[0]):
weights[i] =interval_overlap(coord_interval, coord_bounds[i, :])
returnweights/weights.sum()
A more general resample functionality would have coord_bounds = time_bound_in and coord_interval = time_bound_out[i, :] for every time-level in the destination time coordinate.
We need a method to generate the new time-coordinate.
The text was updated successfully, but these errors were encountered:
As discussed with @andersy005 and @bonnland, it would be nice to have a more general
resample
capability that enable fluid translation between data at different temporal intervals.Here's two functions that, if generalized, might be helpful.
The first by @klindsay28 finds the overlap between any two intervals on a number line.
The second computes averaging weights for a single
coord_interval
, givencoord_bounds
.A more general resample functionality would have
coord_bounds = time_bound_in
andcoord_interval = time_bound_out[i, :]
for every time-level in the destination time coordinate.We need a method to generate the new time-coordinate.
The text was updated successfully, but these errors were encountered: