Skip to content

Conversation

@PaulWessel
Copy link
Member

If you create a mask grid (NaN and 1) and want to see how it looks in grdimage you get this annoyance:

gmt grdimage E_obl_inside_mask.grd -B -pdf t
grdimage [ERROR]: Passing zmax <= zmin prevents automatic CPT generation!
grdimage [ERROR]: Failed to read CPT (null).
psconvert [ERROR]: Unable to decode BoundingBox file /Users/pwessel/.gmt/sessions/gmt_session.11534/psconvert_30470c.bb (maybe no non-white features were plotted?)

and a failed plot. The reason is that zmin = zmax = 1 and no CPT can be crafted. Since this is a common situation, this PR allows for this by checking if

  • We have a grid with NaNs
  • The rest of the data are all 1.0

If so we have a NaN mask and we can then set the internal zmax to 2 so that we get a map when no CPT is given.

If you ceate a mask grid (NaN and 1) and want to see how it looks iin grdimage you get this annoyuance:

(base) pwessel@MacAttack-> gmt grdimage E_obl_inside_mask.grd -B -pdf t
grdimage [ERROR]: Passing zmax <= zmin prevents automatic CPT generation!
grdimage [ERROR]: Failed to read CPT (null).
psconvert [ERROR]: Unable to decode BoundingBox file /Users/pwessel/.gmt/sessions/gmt_session.11534/psconvert_30470c.bb (maybe no non-white features were plotted?)

and a failed plot.   The reason is that xmin = zmax = 1 and no CPT can be crafted.  Since this is a common situation, this PR allwos for this by checking if

We have a grid with NaNs
The rest of the data are all 1.0

If so it sets the internal zmax to 2 so that we get a map when no CPT is given.
@PaulWessel PaulWessel added bug Something isn't working enhancement Improving an existing feature labels Aug 3, 2022
@PaulWessel PaulWessel added this to the 6.5.0 milestone Aug 3, 2022
@PaulWessel PaulWessel self-assigned this Aug 3, 2022
Copy link
Member

@Esteban82 Esteban82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving without testing (in case you need it).
Let me know if you have a grid to test it.

@PaulWessel
Copy link
Member Author

Sure:

gmt grdmath -R-50/50/-50/50 -I1 0 0 CDIST 25 LE 0 NAN = mask.grd
gmt grdimage mask.grd -B -png mask

@Esteban82
Copy link
Member

Sure:

gmt grdmath -R-50/50/-50/50 -I1 0 0 CDIST 25 LE 0 NAN = mask.grd
gmt grdimage mask.grd -B -png mask

Thanks. I will merge it because it works.

@seisman
Copy link
Member

seisman commented Aug 3, 2022

Why not increase zmax by one for all zmin=zmax grids?

@Esteban82 Esteban82 merged commit 68e3ebd into master Aug 3, 2022
@Esteban82 Esteban82 deleted the mask-imaging branch August 3, 2022 12:11
@PaulWessel
Copy link
Member Author

Hm, yes I see where you are going with this. It is very possible that a user could create a grid that is constant, say 4.67. Then what? Well, we then get the annoying message. But having a constant grid is not a sin that requires lecturing by us. SO I agree, we should extend this to any grid, mask or not, and without having more info, just add 1.

@PaulWessel
Copy link
Member Author

Assuming that is what you meant, I will make another PR that is more general and does this inside the gmt_get_pallete instead.

@seisman
Copy link
Member

seisman commented Aug 3, 2022

It is very possible that a user could create a grid that is constant, say 4.67. Then what? Well, we then get the annoying message. But having a constant grid is not a sin that requires lecturing by us. SO I agree, we should extend this to any grid, mask or not, and without having more info, just add 1.

Yes, that's exactly what I mean. But adding 1 may not a good idea for small grid values like zmin=zmax=1.0e-5. Perhaps zmax = 2 * zmin is better?

@PaulWessel
Copy link
Member Author

Yes, but depends on the sign I think

PaulWessel added a commit that referenced this pull request Aug 3, 2022
This PR overwrites the changes in #6930 following the discussion therein.  A mask grid is just a special case of a constant grid and such grids are allowed.  However, without upgrading the automatic CPT creation for grids with zero range we run into trouble.

This PR always produces a valid CPT for grids with no range.
PaulWessel added a commit that referenced this pull request Aug 3, 2022
This PR overwrites the changes in #6930 following the discussion therein.  A mask grid is just a special case of a constant grid and such grids are allowed.  However, without upgrading the automatic CPT creation for grids with zero range we run into trouble.

This PR always produces a valid CPT for grids with no range.
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog bug Something isn't working enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants