Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #279 and #100 plotting updates #282

Draft
wants to merge 75 commits into
base: v0.2.9_dev
Choose a base branch
from

Conversation

bnubald
Copy link
Collaborator

@bnubald bnubald commented Jul 9, 2024

Resolves #279 and #100

  • Uses Cartopy to enable north-facing plots.
  • Enable defining region for forecast output based on lat/lon bounds and not just pixel bounds.
  • Enable gridlines optionally.
  • Enable coastlines with mp4 animation output (Fixing xarray_to_video and coastlines #100).

There is still work to be done on using the lat/lon which will likely need some refactoring of the Masks class. When process_regions is called and Masks is provided to it here:

if args.region:
seas, fc, obs, masks = process_regions(args.region,
[seas, fc, obs, masks])

It defines a pixel based slice which is set by getitem in the Masks class. (This is the case for all times process_regions is called in forecast.py above)

def __getitem__(self, item):
"""Sets slice of region wanted for masking, and allows method chaining.
This might be a semantically dodgy thing to do, but it works for the mo
Args:
item: Index/slice to extract.
"""
logging.info("Mask region set to: {}".format(item))
self._region = item
return self

But, the Masks class needs to account for when the bounds are defined by lat/lon. This is needed when the Mask is used to weight the metric, for example:

# obtain mask
agcm = masks.get_active_cell_da(obs_da)
# binary for observed (i.e. truth)
binary_obs_da = obs_da > threshold
# binary for forecast
binary_fc_da = fc_da > threshold
# compute binary accuracy metric
binary_fc_da = (binary_fc_da == binary_obs_da). \
astype(np.float16).weighted(agcm)
binacc_fc = (binary_fc_da.mean(dim=['yc', 'xc']) * 100)

@bnubald bnubald linked an issue Jul 31, 2024 that may be closed by this pull request
bnubald added 24 commits August 8, 2024 11:56
Also, revert to default cartopy NaturalEarth coastlines, since GSHHS not updated, OSMNX for large reasons slow
Fixes interpolation streaking issue across land regions when using different projections
Use more aggressive AdaptiveScaler for land and coastline plotting features
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant