-
Notifications
You must be signed in to change notification settings - Fork 224
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
Fix fixture_xr_image to open earth_day_01d_p directly with rioxarray #2963
Changes from 7 commits
eeb6c63
f4e263a
4f02cb3
98f30ac
64cd663
b80652f
b8c9c3c
2a41ddb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
outs: | ||
- md5: e2a9a57f61bdca0c21ddec3e1ae5d819 | ||
size: 16595 | ||
- md5: e55d9848135fc14c9cfc3d2c85bd82bb | ||
size: 16472 | ||
path: test_tilemap_no_clip_False.png | ||
hash: md5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
outs: | ||
- md5: 86ce085faad17433dfabba675d0379ee | ||
size: 38836 | ||
- md5: 53949854f32b450e55f1be86102387e9 | ||
size: 38816 | ||
path: test_tilemap_no_clip_True.png | ||
hash: md5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
outs: | ||
- md5: 6da0601f305a6c3391e4a1aa0aee6173 | ||
size: 37139 | ||
- md5: 5f225e4dd26f44e07bcbd8e713c67dbe | ||
size: 37343 | ||
path: test_tilemap_ogc_wgs84.png | ||
hash: md5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
outs: | ||
- md5: 2965f6711c5878014491c7e6f791048e | ||
size: 62077 | ||
- md5: 14f7afd5d48ed6aed88d495783f0ba42 | ||
size: 62398 | ||
path: test_tilemap_web_mercator.png | ||
hash: md5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
""" | ||
Test Figure.grdimage on 3-band RGB images. | ||
""" | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
import xarray as xr | ||
from pygmt import Figure, which | ||
|
||
rasterio = pytest.importorskip("rasterio") | ||
rioxarray = pytest.importorskip("rioxarray") | ||
|
||
|
||
|
@@ -19,26 +15,8 @@ def fixture_xr_image(): | |
""" | ||
geotiff = which(fname="@earth_day_01d_p", download="c") | ||
with rioxarray.open_rasterio(filename=geotiff) as rda: | ||
if len(rda.band) == 1: | ||
with rasterio.open(fp=geotiff) as src: | ||
df_colormap = pd.DataFrame.from_dict( | ||
data=src.colormap(1), orient="index" | ||
) | ||
array = src.read() | ||
|
||
red = np.vectorize(df_colormap[0].get)(array) | ||
green = np.vectorize(df_colormap[1].get)(array) | ||
blue = np.vectorize(df_colormap[2].get)(array) | ||
# alpha = np.vectorize(df_colormap[3].get)(array) | ||
|
||
rda.data = red | ||
da_red = rda.astype(dtype=np.uint8).copy() | ||
rda.data = green | ||
da_green = rda.astype(dtype=np.uint8).copy() | ||
rda.data = blue | ||
da_blue = rda.astype(dtype=np.uint8).copy() | ||
|
||
xr_image = xr.concat(objs=[da_red, da_green, da_blue], dim="band") | ||
if len(rda.band) == 3: | ||
xr_image = rda.load() | ||
Comment on lines
17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait for GenericMappingTools/gmtserver-admin#257, to see if the 3-band GeoTIFF file stays, or we revert back to the quantized/indexed GeoTIFF file from before Sep 2023. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gonna assume that the 3-band GeoTIFF will stay for now, so that we can move on with the GMT 6.5.0 update. Marked this PR as ready for review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about splitting this PR into two separate RPs so if the upstream decide to to back to the indexed geotiff file, we can easily revert the changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kinda want to take the code from this fixture and just make a |
||
assert xr_image.sizes == {"band": 3, "y": 180, "x": 360} | ||
return xr_image | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
earth_day_01d_p.tif
grid downloaded with GMT 6.5.0 shows this:If I run
gmt which @earth_day_01d_p
with GMT 6.4.0, it errors withgmtwhich [ERROR]: File earth_day_01d_p.tif not found!
. Did something change on the GMT data server?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the old
@earth_day_01d_p
(unzip earth_day_01d_p.tif.zip) from #2937 cached at https://github.com/GenericMappingTools/pygmt/actions/runs/7376169058 that was used in GMT 6.4.0:See how the GMT 6.4.0 version has 1 band with a Color Table, compared to 3 bands with GMT 6.5.0 release as in https://github.com/GenericMappingTools/pygmt/pull/2963/files#r1444072938.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, asked about the dataset changes upstream at GenericMappingTools/gmtserver-admin#257.