Skip to content

Commit

Permalink
Merge pull request #88 from ks905383/add_diagfig_fixds
Browse files Browse the repository at this point in the history
add fix_ds to diag_fig call
  • Loading branch information
ks905383 authored Oct 29, 2024
2 parents d3d5103 + 11cdf5b commit cc9c006
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/test_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def test_diag_fig_subsetbyname():
fig,ax=wm.diag_fig({'NAME':'Los Angeles'},ds)

assert ax.get_title() == 'Poly #2384: Los Angeles; California; 06; 037; 06037'

def test_diag_fig_nonstandard_dimnames():
# Test to make sure this works if the input `ds` has
# nonstandard coordinate names
# Have to regenerate weightmap from start to really
# test
ds_rn = ds.rename({'lat':'y','lon':'x'}).copy()
wm = pixel_overlaps(ds_rn,gdf)
fig,ax=wm.diag_fig(50,ds_rn)

else:
def test_diag_fig_noimport():
# Should raise ImportError in the no-plot environment
Expand Down
5 changes: 4 additions & 1 deletion xagg/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re
from .options import get_options,set_options
from .auxfuncs import subset_find
from .auxfuncs import subset_find,fix_ds

try:
import cartopy
Expand Down Expand Up @@ -51,6 +51,9 @@ def diag_fig(self,poly_id,ds,fig=None,ax=None):
except ImportError:
raise ImportError('`wm.diag_fig()` separately requires `cartopy`, `matplotlib`, and `cmocean` to function; make sure these are installed first.')

# Standardize input ds coordinates etc.
ds = fix_ds(ds)

# Adjust grids between the input ds and the weightmap grid (in case subset to
# bbox was used)
with set_options(silent=True):
Expand Down

0 comments on commit cc9c006

Please sign in to comment.