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

The -R string from three coutries crossing 180 was bad #8266

Closed
wants to merge 2 commits into from

Conversation

PaulWessel
Copy link
Member

The USA, Russia, and Fiji are the only country polygons that cross lon = 180. That gave us odd -Rw/e/s/n strings such as 172.436/-66.9489/18.9099/71.3907 for the US. With west > east we run into trouble when building the list of remote file tiles (e.g., the @earth_relief ******_p.jp2 that needs to be downloaded). The result was a blank map. I verified this was the same with GMT 6.4 so it is not a new bug; it has probably been there since Day 1 of remote data set implementation but nobody used -RUS, -RRU or -RFJ before. This PR simply does the sanity check that if if east < west we subtract 360 from west, since it is assumed all global files are on the -Rd layout. With this fix the plots for the three countries now works, as shown below (these were all blank frames before):

gmt grdimage @earth_relief_05m -B -RUS -png USA
USA

gmt grdimage @earth_relief_05m -B -RRU -png RU
RU

gmt grdimage @earth_relief_05m -B -RFJ -png FJ
FJ

Since this is a long-standing bug we can choose what to do:

  1. It is Sunday, so we could in a hurry build new GMT6.5 installers and the problem has been dealt with
  2. Shit, horse is out of the barn and we simply should do 6.5.1 in a few days.
  3. If we have lived with this since 2016 then perhaps we can live with it until 6.6?

Please opine. Note @joa-quim this particular PR has nothing to do with code freeze concern since it was there so long.

The USA, Russia, and Fiji are the only country polygons that cross lon = 180.  That gave us odd -Rw/e/s/n strings such as 172.436/-66.9489/18.9099/71.3907 for the US. With west > east we run into trouble when building the list of remote file tiles (e.g., the @earth_relief ******_p.jp2 that needs to be downloaded).  The result was a blank map. I verified this was the same with GMT 6.4 so it is not a new bug; it has probably been there since Day 1 of remote data set implementation but nobody used -RUS, -RRU or -RFJ before.
This PR simply does the sanity check that if if east < west we subtract 360 from west, since it is assumed all global files are on the -Rd layout.  With this fix the plots for the three countries now works.
@PaulWessel PaulWessel added the bug Something isn't working label Jan 7, 2024
@PaulWessel PaulWessel requested a review from a team January 7, 2024 16:41
@PaulWessel PaulWessel self-assigned this Jan 7, 2024
@Esteban82
Copy link
Member

I would go with 2 or 3. I think 1 is a bad idea.

@seisman
Copy link
Member

seisman commented Jan 7, 2024

I verified this was the same with GMT 6.4 so it is not a new bug;

It works well for me with GMT 6.4.0 on macOS:

$ gmt --version
6.4.0

$ gmt grdimage @earth_relief_05m -B -RUS -png USA -Vi
begin [INFORMATION]: Creating a workflow directory /Users/seisman/.gmt/sessions/gmt_session.88924
gmt [INFORMATION]: Using country and state data from dcw-gmt
gmt [INFORMATION]: Title  : DCW-GMT - The Digital Chart of the World for the Generic Mapping Tools
gmt [INFORMATION]: Source : Processed by the GMT Team, 2023-AUG-11
gmt [INFORMATION]: Version: 2.1.2
gmt [INFORMATION]: DCW version 2.1.2 requires GMT version 6.1.1 or later.
gmt [INFORMATION]: United States
gmt [INFORMATION]: Region implied by DCW polygons is 172.436/293.051/18.9099/71.3907
grdimage [INFORMATION]: Using country and state data from dcw-gmt
grdimage [INFORMATION]: Title  : DCW-GMT - The Digital Chart of the World for the Generic Mapping Tools
grdimage [INFORMATION]: Source : Processed by the GMT Team, 2023-AUG-11
grdimage [INFORMATION]: Version: 2.1.2
grdimage [INFORMATION]: DCW version 2.1.2 requires GMT version 6.1.1 or later.
grdimage [INFORMATION]: United States
grdimage [INFORMATION]: Region implied by DCW polygons is 172.436/293.051/18.9099/71.3907
grdimage [INFORMATION]: Read header from file /var/folders/mz/d3wtwjtx4fg8qlds5lgt1c240000gn/T/=tiled_218_PX_kOza6W
grdimage [INFORMATION]: Spherical approximation used
grdimage [INFORMATION]: Central meridian not given, default to 232.744
grdimage [INFORMATION]: Auto-frame interval for x-axis (item 0): a30f10
grdimage [INFORMATION]: Auto-frame interval for y-axis (item 0): a15f5
grdimage [INFORMATION]: Map scale is 894.119 km per cm or 1:8.94119e+07.
grdimage [INFORMATION]: Allocate and read data from file /var/folders/mz/d3wtwjtx4fg8qlds5lgt1c240000gn/T/=tiled_218_PX_kOza6W
grdblend [INFORMATION]: Reading Data Table from file /var/folders/mz/d3wtwjtx4fg8qlds5lgt1c240000gn/T/=tiled_218_PX_kOza6W
grdblend [INFORMATION]: netCDF grid /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90E000.earth_relief_05m_p.nc has a default CPT geo.
grdblend [INFORMATION]: netCDF grid /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90W180.earth_relief_05m_p.nc has a default CPT geo.
grdblend [INFORMATION]: Blend file /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90E000.earth_relief_05m_p.nc in 0/180/-90/90 with normal weight 1 [-223-1936]
grdblend [INFORMATION]: File @S90W180.earth_relief_05m_p.nc grid region needed longitude adjustment to fit final grid region
grdblend [INFORMATION]: File @S90W180.earth_relief_05m_p.nc inner grid region needed longitude adjustment to fit final grid region
grdblend [INFORMATION]: Blend file /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90W180.earth_relief_05m_p.nc in 180/360/-90/90 with normal weight 1 [-223-1936]
grdblend [INFORMATION]: Processing input grids
grdblend [INFORMATION]: netCDF grid /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90E000.earth_relief_05m_p.nc has a default CPT geo.
grdblend [INFORMATION]: netCDF grid /Users/seisman/.gmt/server/earth/earth_relief/earth_relief_05m_p/S90W180.earth_relief_05m_p.nc has a default CPT geo.
grdblend [INFORMATION]: Processed row     631 of 631
grdblend [INFORMATION]: Referencing grid data to GMT_GRID memory location
grdblend [INFORMATION]: gmt_grd_BC_set: Set boundary condition for all edges: natural
grdblend [INFORMATION]: gmt_grd_BC_set: Set boundary condition for left   edge: natural
grdblend [INFORMATION]: gmt_grd_BC_set: Set boundary condition for right  edge: natural
grdblend [INFORMATION]: gmt_grd_BC_set: Set boundary condition for bottom edge: natural
grdblend [INFORMATION]: gmt_grd_BC_set: Set boundary condition for top    edge: natural
grdblend [INFORMATION]: Blended grid size of @GMTAPI@-S-O-G-G-G-Y-000001 is 1448 x 631
grdblend [INFORMATION]: All nodes assigned values
grdimage [INFORMATION]: gmt_grd_BC_set: Set boundary condition for all edges: natural
grdimage [INFORMATION]: gmt_grd_BC_set: Set boundary condition for left   edge: natural
grdimage [INFORMATION]: gmt_grd_BC_set: Set boundary condition for right  edge: natural
grdimage [INFORMATION]: gmt_grd_BC_set: Set boundary condition for bottom edge: natural
grdimage [INFORMATION]: gmt_grd_BC_set: Set boundary condition for top    edge: natural
grdimage [INFORMATION]: gmt_cpt_default: Use dataset default CPT: geo
grdimage [INFORMATION]: Reading CPT from File /Users/seisman/opt/miniconda/envs/pygmt/share/gmt/cpt/gmt/geo.cpt
grdimage [INFORMATION]: Auto-stretching CPT file gmt/geo to fit data range -8380.5 to 4862
grdimage [INFORMATION]: Write CPT to File /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt
grdimage [INFORMATION]: Save current CPT file to /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt !
grdimage [INFORMATION]: Evaluate image pixel colors
grdimage [INFORMATION]: Basic z(x,y) -> color image with no illumination.
grdimage [INFORMATION]: Plotting 24-bit color image
PSL: Too many colors to make colormap - using 24-bit direct color instead.
PSL: DEFLATE compressed 2741064 to 1388618 bytes (49.3% savings at compression level 5)
grdimage [INFORMATION]: Selected current /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt file cpt
colorbar [INFORMATION]: Using country and state data from dcw-gmt
colorbar [INFORMATION]: Title  : DCW-GMT - The Digital Chart of the World for the Generic Mapping Tools
colorbar [INFORMATION]: Source : Processed by the GMT Team, 2023-AUG-11
colorbar [INFORMATION]: Version: 2.1.2
colorbar [INFORMATION]: DCW version 2.1.2 requires GMT version 6.1.1 or later.
colorbar [INFORMATION]: United States
colorbar [INFORMATION]: Region implied by DCW polygons is 172.436/293.051/18.9099/71.3907
colorbar [INFORMATION]: Axis sub-item f set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item a set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item f set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item a set more than once (typo?)
colorbar [INFORMATION]: Selected current /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt file cpt
colorbar [INFORMATION]: Selected current /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt file cpt
colorbar [INFORMATION]: Processing input CPT
colorbar [INFORMATION]: Reading CPT from File /Users/seisman/.gmt/sessions/gmt_session.88924/gmt.cpt
colorbar [INFORMATION]:   CPT range from -8380.5 to 4862
colorbar [INFORMATION]: Spherical approximation used
colorbar [INFORMATION]: Central meridian not given, default to 232.744
colorbar [INFORMATION]: Map scale is 894.119 km per cm or 1:8.94119e+07.
colorbar [INFORMATION]: Linear projection implies y-axis distance exaggeration relative to the x-axis by a factor of 2802.99
colorbar [INFORMATION]: Map scale is 1.10354 km per cm or 1:110354.
colorbar [INFORMATION]: Axis sub-item f set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item a set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item f set more than once (typo?)
colorbar [INFORMATION]: Axis sub-item a set more than once (typo?)
colorbar [INFORMATION]: Auto-frame interval for x-axis (item 0): a2000f1000
PSL: Too many colors to make colormap - using 24-bit direct color instead.
PSL: DEFLATE compressed 8505 to 3222 bytes (62.1% savings at compression level 5)
end [INFORMATION]: Process GMT figure queue: 1 figures found
end [INFORMATION]: Processing GMT figure #0 [USA png ]
psconvert [INFORMATION]: Processing /Users/seisman/.gmt/sessions/gmt_session.88924/gmt_0.ps-...
psconvert [INFORMATION]: Find HiResBoundingBox ...
psconvert [INFORMATION]: Figure dimensions: Width: 456.723 points [16.1122 cm]  Height: 238.86 points [8.42645 cm]
psconvert [INFORMATION]: [2852.95 2830.63 3309.67 3069.49]...
psconvert [INFORMATION]: Convert to PNG...
end [INFORMATION]: Destroying the current workflow directory /Users/seisman/.gmt/sessions/gmt_session.88924

@PaulWessel
Copy link
Member Author

OK, maybe you had the necessary tiles. I started with scratch and it was unable to get them just for those three examples.

@joa-quim
Copy link
Member

joa-quim commented Jan 7, 2024

Please opine. Note @joa-quim this particular PR has nothing to do with code freeze concern since it was there so long.

We have tons of open bugs reports. I have built the Win installers 3 of 4 times (installers build is not an instantaneous step). Let's stop now.

@PaulWessel
Copy link
Member Author

I am fine with that, too.

@seisman
Copy link
Member

seisman commented Jan 7, 2024

Just in case you're still interested, the bug was introduced in #7805.

@yvonnefroehlich
Copy link
Member

I verified this was the same with GMT 6.4 so it is not a new bug;

Hm. Not sure. For me, it works for both Windows with GMT 6.4 and Linux with GMT 6.4.0_965606f_2022.03.14. But it fails with GMT 6.5 on Windows.

@PaulWessel
Copy link
Member Author

Just in case you're still interested, the bug was introduced in #7805.

I see. So that section sort of assumed that west < east but for those three countries gmt_DCW_operation returns 172.436/-66.9489/18.9099/71.3907 for the US and that get caught in those tests. So perhaps 6.4 was OK for the images if you already had the tiles. I did not and I verified there was a problem selecting the right tiles and download then with the above bug. Obviously work around with coordinates.

FYI, just getting the -R string (which I think @joa-quim was after in #7805):

GMT 6.4: gmt pscoast -EUS gives -R172.436111/293.051109/18.909859/71.390686
master before fix (i.e. 6.5 installers): -R172.436111/-66.948891/18.909859/71.390686
branch with fix: -R-187.563889/-66.948891/18.909859/71.390686

So first and last are the same ±360 and because the data sets are in -Rd I picked the negatives.

@seisman seisman added this to the 6.6.0 milestone Jan 8, 2024
Give more sensible warning if remote server is set or not set but cannot find file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants