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

GMTDataArrayAccessor: Fallback to default grid registration and gtype if the grid source file doesn't exist #2009

Merged
merged 15 commits into from
Feb 20, 2023
Merged
4 changes: 4 additions & 0 deletions pygmt/accessors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
GMT accessor methods.
"""
from pathlib import Path

import xarray as xr
from pygmt.exceptions import GMTInvalidInput
from pygmt.src.grdinfo import grdinfo
Expand Down Expand Up @@ -29,6 +31,8 @@ def __init__(self, xarray_obj):
self._obj = xarray_obj
try:
self._source = self._obj.encoding["source"] # filepath to NetCDF source
if not Path(self._source).exists():
raise ValueError(f"Grid source file {self._source} doesn't exist.")
seisman marked this conversation as resolved.
Show resolved Hide resolved
# Get grid registration and grid type from the last two columns of
# the shortened summary information of `grdinfo`.
self._registration, self._gtype = map(
Expand Down