Skip to content

Commit

Permalink
Reestablish CPT hinge for master tables (#8111)
Browse files Browse the repository at this point in the history
* Reestablish CPT hinge fof master tables

We (I) somehow lost a line or two in gmt_support.c.  Added a test as well so that we are warned if this tests fails again.  Output is like this:

* Create cpt_hinge.sh

Add test script cpt_hinge.sh.

* Update test PS
  • Loading branch information
PaulWessel authored Nov 30, 2023
1 parent 83b5dfc commit 5b617fe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -8959,6 +8959,7 @@ struct GMT_PALETTE *gmt_get_palette (struct GMT_CTRL *GMT, char *file, enum GMT_
return (P);
}

master = (file && file[0]) ? file : GMT->current.setting.cpt; /* Set master CPT prefix */
P = GMT_Read_Data (GMT->parent, GMT_IS_PALETTE, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL|GMT_CPT_CONTINUOUS, NULL, master, NULL);
if (!P) return (P); /* Error reading file. Return right away to avoid a segv in next line */
/* Stretch to fit the data range */
Expand Down
7 changes: 4 additions & 3 deletions test/baseline/grdimage.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
outs:
- md5: 8219134ac2d69f2e4123365c18252cfa.dir
size: 8666527
nfiles: 30
- md5: e0f5ec57ec18927bec8fc07d3334a8b5.dir
size: 8865922
nfiles: 31
path: grdimage
hash: md5
21 changes: 21 additions & 0 deletions test/grdimage/cpt_hinge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Remote grid with a soft-hinge cpt with/without +h to enable and set it
# Bottom panel: Polar CPT with activated soft-hinge at 0, so z = 0 is white
# Middle panel: Polar CPT with activated soft-hinge at 2000, so z = 2000 is white
# Top panel: Polar CPT with deactivated soft-hinge, so z_mid = --1368.5 is white

gmt begin cpt_hinge ps
# Pass CPT and activate soft hinge at 0
gmt grdimage @earth_relief_06m -RPT -Cpolar+h -B
gmt coast -W0.25p
gmt colorbar -DJRM -Bxa1000 -By+l"Hinge = 0"
# Create new CPT and activate soft hinge at 2000
gmt makecpt -Cpolar+h2000 -T-5766/3029 -H > t.cpt
gmt grdimage @earth_relief_06m -RPT -Ct.cpt -B -Y8c
gmt coast -W0.25p
gmt colorbar -DJRM -Ct.cpt -Bxa1000 -By+l"Hinge = 2000"
# Pass CPT and do not activate any hinge
gmt grdimage @earth_relief_06m -RPT -Cpolar -B -Y8c
gmt coast -W0.25p
gmt colorbar -DJRM -Bxa1000 -By+l"No hinge set"
gmt end show

0 comments on commit 5b617fe

Please sign in to comment.