Skip to content

Commit

Permalink
Preparing 0.7.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
forman committed Mar 16, 2021
1 parent ef54d24 commit df83144
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 45 deletions.
7 changes: 4 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Changes in 0.7.1.dev1 (in development)
## Changes in 0.7.1

* Added `s3fs` requirement that has been removed by accident.
* Dataset normalisation no longer includes reordering increasing
latitude coordinates, as this creates datasets that are no longer writable
to Zarr. (#347)
* Added missing requirements `requests` and `urllib3`.
* Updated package requirements
- Added `s3fs` requirement that has been removed by accident.
- Added missing requirements `requests` and `urllib3`.

## Changes in 0.7.0

Expand Down
12 changes: 1 addition & 11 deletions test/core/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_normalize_lon_lat(self):
actual = normalize_dataset(dataset)
assertDatasetEqual(actual, expected)

def test_normalize_inverted_lat(self):
def test_normalize_does_not_reorder_increasing_lat(self):
first = np.zeros([3, 45, 90])
first[0, :, :] = np.eye(45, 90)
ds = xr.Dataset({
Expand All @@ -123,16 +123,6 @@ def test_normalize_inverted_lat(self):
'time': [datetime(2000, x, 1) for x in range(1, 4)]}).chunk(
chunks={'time': 1})

first = np.zeros([3, 45, 90])
first[0, :, :] = np.flip(np.eye(45, 90), axis=0)
expected = xr.Dataset({
'first': (['time', 'lat', 'lon'], first),
'second': (['time', 'lat', 'lon'], np.zeros([3, 45, 90])),
'lat': np.linspace(88, -88, 45),
'lon': np.linspace(-178, 178, 90),
'time': [datetime(2000, x, 1) for x in range(1, 4)]}).chunk(
chunks={'time': 1})

actual = normalize_dataset(ds)
xr.testing.assert_equal(actual, ds)

Expand Down
31 changes: 1 addition & 30 deletions xcube/core/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,11 @@ def normalize_dataset(ds: xr.Dataset) -> xr.Dataset:
ds = _normalize_lat_lon_2d(ds)
ds = _normalize_dim_order(ds)
ds = _normalize_lon_360(ds)

# xcube viewer currently requires decreasing latitude co-ordinates, so
# we invert them here if necessary.

# TODO: commented out as _ensure_lat_decreasing() produces
# chunks in "lat" that have the smallest chunk first. This will
# fail when writing to Zarr. (Hack for #347)
# See also https://github.com/pydata/xarray/issues/2300
# ds = _ensure_lat_decreasing(ds)

ds = normalize_missing_time(ds)
ds = _normalize_jd2datetime(ds)
return ds


def _ensure_lat_decreasing(ds: xr.Dataset) -> xr.Dataset:
"""
If the latitude is increasing, invert it to make it decreasing.
:param ds: some xarray dataset
:return: a normalized xarray dataset
"""
try:
if not _is_lat_decreasing(ds.lat):
ds = ds.sel(lat=slice(None, None, -1))
except AttributeError:
# The dataset doesn't have 'lat', probably not geospatial
pass
except ValueError:
# The dataset still has an ND 'lat' array
pass
return ds


def _normalize_lat_lon(ds: xr.Dataset) -> xr.Dataset:
"""
Rename variables named 'longitude' or 'long' to 'lon', and 'latitude' to 'lon'.
Expand Down Expand Up @@ -371,7 +343,7 @@ def normalize_missing_time(ds: xr.Dataset) -> xr.Dataset:
return ds


def adjust_spatial_attrs(ds: xr.Dataset, allow_point: bool=False) -> xr.Dataset:
def adjust_spatial_attrs(ds: xr.Dataset, allow_point: bool = False) -> xr.Dataset:
"""
Adjust the global spatial attributes of the dataset by doing some
introspection of the dataset and adjusting the appropriate attributes
Expand Down Expand Up @@ -697,7 +669,6 @@ def _is_lat_decreasing(lat: xr.DataArray) -> bool:


def _normalize_dim_order(ds: xr.Dataset) -> xr.Dataset:

copy_created = False

for var_name in ds.data_vars:
Expand Down
2 changes: 1 addition & 1 deletion xcube/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

version = '0.7.1.dev1'
version = '0.7.1'

0 comments on commit df83144

Please sign in to comment.