Skip to content

Commit

Permalink
Merge pull request #74 from ks905383/main
Browse files Browse the repository at this point in the history
Add in main updates
  • Loading branch information
ks905383 authored Aug 8, 2024
2 parents 8f5a448 + d8ad4f3 commit 6b2affe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Installation
The easiest and recommended way to install :py:mod:`xagg` is through ``conda`` or ``mamba``::

# Mamba
mamba install -c conda-forge xagg==0.3.2.0
mamba install -c conda-forge xagg==0.3.2.1

# Conda
conda install -c conda-forge xagg==0.3.2.0
conda install -c conda-forge xagg==0.3.2.1


``xagg`` can also be installed through ``pip``::
Expand Down
9 changes: 4 additions & 5 deletions tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ def test_to_netcdf(agg=agg):
coords = {'poly_idx':(('poly_idx'),[0]),
'run':(('run'),[0,1])})

# Load
ds_out = xr.open_dataset('test.nc')

# Test
xr.testing.assert_allclose(ds_ref,ds_out)
# Load and Test
with xr.open_dataset('test.nc') as ds_out:
xr.testing.assert_allclose(ds_ref,ds_out)

finally:
# Remove test export file
os.remove('test.nc')
Expand Down
10 changes: 8 additions & 2 deletions xagg/diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ def diag_fig(wm,poly_id,pix_overlap_info,
raise TypeError('If using list polygon ids, all list members must be integers corresponding to polygon idxs in `wm.agg`.')
poly_idx = poly_id

# Turn into dataset if dataarray
if type(pix_overlap_info)==xr.core.dataarray.DataArray:
if pix_overlap_info.name is None:
pix_overlap_info = pix_overlap_info.to_dataset(name='var')
else:
pix_overlap_info = pix_overlap_info.to_dataset()

# Get pixel polygons/overlaps, if necessary
if ((type(pix_overlap_info) == xr.core.dataset.Dataset)
or (type(pix_overlap_info) == xr.core.dataarray.DataArray)):
if ((type(pix_overlap_info) == xr.core.dataset.Dataset):
pix_polys = create_raster_polygons(pix_overlap_info)
else:
pix_polys = pix_overlap_info
Expand Down

0 comments on commit 6b2affe

Please sign in to comment.