Add load_earth_mask function for GSHHG Global Earth Mask dataset#2310
Add load_earth_mask function for GSHHG Global Earth Mask dataset#2310
Conversation
Co-authored-by: Dongdong Tian <seisman.info@gmail.com> Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
|
/format |
| - 2: Lake | ||
| - 3: Island | ||
| - 4: Pond | ||
| """ |
There was a problem hiding this comment.
This function now returns a dataarray like below:
<xarray.DataArray 'z' (lat: 181, lon: 361)>
array([[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
[1., 1., 1., ..., 1., 1., 1.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]], dtype=float32)
Coordinates:
* lon (lon) float64 -180.0 -179.0 -178.0 -177.0 ... 178.0 179.0 180.0
* lat (lat) float64 -90.0 -89.0 -88.0 -87.0 -86.0 ... 87.0 88.0 89.0 90.0
Attributes:
long_name: z
actual_range: [0. 2.]
The data dtype is float32, but the original grid @earth_mask_01d_g contains int8 values. Ideally, the function should return a grid with integer values.
There was a problem hiding this comment.
How would I change the value types across the entire array?
There was a problem hiding this comment.
How would I change the value types across the entire array?
I don't know. Need to read the xarray docs.
There was a problem hiding this comment.
Likely we need to use xarray.DataArray.astype to convert the data from float32 to int8, i.e., return grid.astype("int8").
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
|
It looks like the number of |
This sounds good to me. |
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Add
load_earth_maskto load the remote GSHHG Global Earth Mask dataset.Addresses: #1786
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version