Uh oh!
There was an error while loading. Please reload this page.
Initialize a GMTDataArrayAccessor - #500
Conversation
An xarray accessor for GMT specific information! Currently holds the gridline/pixel registration and cartesian/geographic type properties. Created a new 'Metadata' section in the API docs for this, and moved info and grdinfo here.
Using a "setter" decorator to set/change class attributes. Wrote some unit tests to ensure code coverage if up to scratch, except that we can't test Pixel Registration properly yet.
| # logging.warning( | ||
| # msg="Cannot find a NetCDF source of xarray grid. " | ||
| # f"Will fallback to using GMT's default setting: {default_reg_and_gtype}" | ||
| # ) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Breaks backward compatibility with GMT 6.0, but simplifies the code (at some expense of readability). Co-Authored-By: Dongdong Tian <seisman.info@gmail.com>
There was a problem hiding this comment.
@seisman, ready to re-review. I was thinking of adding a __repr__ so that users can see what '0' or '1' means when they print the registration/gtype info, but that could go in a separate PR.
There's a lot we can add to this GMTDataArrayAccessor, and I've listed some in #499 (which I'll skip closing for now). This is really just the beginning 😄
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| except KeyError: | ||
| self._registration = 0 # Default to Gridline registration | ||
| self._gtype = 0 # Default to Cartesian grid type | ||
| # logging.warning( |
There was a problem hiding this comment.
Ok, I've removed it for now, but will revisit it when we decide on #487. The intention is to not surprise users by enforcing a particular default registration/gtype (especially users used to using pixel registration/Cartesian coordinate data). The warning would ideally be surpressed by setting e.g. grid.gmt.registration = 1, but I haven't quite worked out how to do so.
| @registration.setter | ||
| def registration(self, value): | ||
| if value in (0, 1): |
There was a problem hiding this comment.
It may be more user friendly if we can also set the properties by grid.gmt.registration = "pixel" and grid.gmt.gtype = "geographic", but I'm OK with the current boolean values, 0 and 1.
There was a problem hiding this comment.
Good idea. Let's leave it for now, but introduce this once we work out how to do the __repr__ as mentioned in #500 (review).
seisman
commented
Jul 11, 2020
Please change to a better title before merging. |
weiji14
commented
Jul 11, 2020
Oops sorry, missed your comment. |
seisman
commented
Jul 11, 2020
Never mind. You can still change the draft release information directly. The title is not descriptive to me. |
weiji14
commented
Jul 11, 2020
Yep, will do that in the release notes. I think the draft one will be overwritten every time a PR is merged. |
Description of proposed changes
An xarray accessor for GMT specific information! Currently holds the gridline/pixel registration and cartesian/geographic type properties. Created a new 'Metadata' section in the API docs for this, and moved info and grdinfo here.
Enables functionality like this:
Will be extremely helpful for #476.
First step in fixing #499; Supersedes/Closes#494.
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.