Skip to content

Commit 4a7211d

Browse files
committed
resolve xarray dims->sizes
1 parent 893f82e commit 4a7211d

4 files changed

Lines changed: 4 additions & 6 deletions

File tree

pyxlma/lmalib/grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def assign_regular_bins(dsg, ds, var_to_grid_map, pixel_id_var='pixel_id',
132132
var_dim = ds[var_name].dims[0]
133133
else:
134134
assert var_dim == ds[var_name].dims[0]
135-
if ds.dims[var_dim] < 1:
135+
if ds.sizes[var_dim] < 1:
136136
# No data on the dim, set in_range to nothing and stop checking other vars
137137
in_range = []
138138
have_data = False

pyxlma/lmalib/io/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def dataset(filenames, sort_time=True):
113113
ds = to_dataset(lma_file, event_id_start=next_event_id).set_index(
114114
{'number_of_stations':'station_code', 'number_of_events':'event_id'})
115115
lma_data.append(ds)
116-
next_event_id += ds.dims['number_of_events']
116+
next_event_id += ds.sizes['number_of_events']
117117
except:
118118
raise
119119
ds = combine_datasets(lma_data)

pyxlma/lmalib/traversal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, dataset, entity_id_vars, parent_id_vars):
7777
self.child_to_parent = collections.OrderedDict()
7878
self.parent_to_child = collections.OrderedDict()
7979
for (entity_var, parent_var) in self._descend():
80-
if dataset.dims[dataset[entity_var].dims[0]] == 0:
80+
if dataset.sizes[dataset[entity_var].dims[0]] == 0:
8181
# No data, so groupby will fail in xarray > 0.13
8282
entity_grouper = None
8383
else:
@@ -86,7 +86,7 @@ def __init__(self, dataset, entity_id_vars, parent_id_vars):
8686
if parent_var is None:
8787
parent_grouper = None
8888
else:
89-
if dataset.dims[dataset[parent_var].dims[0]] == 0:
89+
if dataset.sizes[dataset[parent_var].dims[0]] == 0:
9090
# No data, so groupby will fail in xarray > 0.13
9191
parent_grouper = None
9292
else:

tests/test_coords.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def test_geographic():
2020
geosys = GeographicSystem()
2121
ecef_coords = geosys.toECEF(test_lons, test_lats, test_alts)
2222
lons, lats, alts = geosys.fromECEF(*ecef_coords)
23-
2423
assert np.allclose(ecef_coords[0], test_ecef_X)
2524
assert np.allclose(ecef_coords[1], test_ecef_Y)
2625
assert np.allclose(ecef_coords[2], test_ecef_Z)
@@ -32,7 +31,6 @@ def test_geographic_one_point():
3231
geosys = GeographicSystem()
3332
ecef_coords = geosys.toECEF(np.atleast_1d(test_lons[-1]), np.atleast_1d(test_lats[-1]), np.atleast_1d(test_alts[-1]))
3433
lons, lats, alts = geosys.fromECEF(*ecef_coords)
35-
3634
assert np.allclose(ecef_coords[0], test_ecef_X[-1])
3735
assert np.allclose(ecef_coords[1], test_ecef_Y[-1])
3836
assert np.allclose(ecef_coords[2], test_ecef_Z[-1])

0 commit comments

Comments
 (0)