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
In clisops.utils.dataset_utils the offset used to roll the dataset is calculated using the resolution of the data:
def calculate_offset(lon, first_element_value):
"""
Calculate the number of elements to roll the dataset by in order to have
longitude from within requested bounds.
:param lon: longitude coordinate of xarray dataset.
:param first_element_value: the value of the first element of the longitude array to roll to.
"""
# get resolution of data
res = lon.values[1] - lon.values[0]
# calculate how many degrees to move by to have lon[0] of rolled subset as lower bound of request
diff = lon.values[0] - first_element_value
# work out how many elements to roll by to roll data by 1 degree
index = 1 / res
# calculate the corresponding offset needed to change data by diff
offset = int(round(diff * index))
return offset
The resolution is not necessarily the same throughout the dataset so we need a better solution to calculate the offset.
The text was updated successfully, but these errors were encountered:
Description
In
clisops.utils.dataset_utils
the offset used to roll the dataset is calculated using the resolution of the data:The resolution is not necessarily the same throughout the dataset so we need a better solution to calculate the offset.
The text was updated successfully, but these errors were encountered: