Skip to content

Commit

Permalink
Save any default CPT for remote datasets in hidden grid header (#6178)
Browse files Browse the repository at this point in the history
* Save any default CPT in hidden grid header

This addresses #6167 when we cut a subset from, sa, earth_relief_10m and then no longer know what the CPT should be.

* use allocated string cpt instead

* Init remote_id to -1

* polish

* Fix save CPT and highpass

* Update gmt_support.c

* Add small tests

* formatting

* Remove boundary annotations

* Save the current CPT from grdcut if modern mode
  • Loading branch information
PaulWessel committed Jan 3, 2022
1 parent 58234c5 commit e729a9b
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 29 deletions.
7 changes: 4 additions & 3 deletions src/gmt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -8198,11 +8198,12 @@ void * GMT_Create_Session (const char *session, unsigned int pad, unsigned int m

if ((API = calloc (1, sizeof (struct GMTAPI_CTRL))) == NULL) return_null (NULL, GMT_MEMORY_ERROR); /* Failed to allocate the structure */
API->verbose = (mode >> 16); /* Pick up any -V settings from gmt.c */
API->pad = pad; /* Preserve the default pad value for this session */
API->remote_id = GMT_NOTSET; /* Not read a remote grid yet */
API->pad = pad; /* Preserve the default pad value for this session */
API->print_func = (print_func == NULL) ? gmtapi_print_func : print_func; /* Pointer to the print function to use in GMT_Message|Report */
API->do_not_exit = mode & GMT_SESSION_NOEXIT; /* Deprecated, we no longer call exit anywhere in the API (gmt_api.c) */
API->external = (mode & GMT_SESSION_EXTERNAL) ? 1 : 0; /* if false|0 then we don't list read and write as modules */
if (API->external && mode & GMT_SESSION_NOGDALCLOSE) API->external = 2; /* Avoid calling GDALDestroyDriverManager */
API->external = (mode & GMT_SESSION_EXTERNAL) ? 1 : 0; /* if false|0 then we don't list read and write as modules */
if (API->external && mode & GMT_SESSION_NOGDALCLOSE) API->external = 2; /* Avoid calling GDALDestroyDriverManager */
API->shape = (mode & GMT_SESSION_COLMAJOR) ? GMT_IS_COL_FORMAT : GMT_IS_ROW_FORMAT; /* if set then we must use column-major format [row-major] */
API->runmode = mode & GMT_SESSION_RUNMODE; /* If nonzero we set up modern GMT run-mode, else classic */
API->no_history = mode & GMT_SESSION_NOHISTORY; /* If nonzero we disable the gmt.history mechanism (shorthands) entirely */
Expand Down
2 changes: 1 addition & 1 deletion src/gmt_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ extern "C" {
#include "gmt_common_math.h" /* Shared math functions */
#include "gmt.h" /* All GMT high-level API */
#include "gmt_private.h" /* API declaration needed by libraries */
#include "gmt_constants.h" /* All basic constant definitions */
#include "gmt_hidden.h" /* Hidden bookkeeping structure for API containers */

struct GMT_CTRL; /* forward declaration of GMT_CTRL */

#include "gmt_notposix.h" /* Non-POSIX extensions */

#include "gmt_constants.h" /* All basic constant definitions */
#include "gmt_modern.h" /* Modern mode constant definitions */
#include "gmt_macros.h" /* All basic macros definitions */
#include "gmt_dimensions.h" /* Constant definitions created by configure */
Expand Down
4 changes: 4 additions & 0 deletions src/gmt_grdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ void gmt_copy_gridheader (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *to, stru
if (Hto->title) gmt_M_str_free (Hto->title); /* Since we will duplicate via from */
if (Hto->command) gmt_M_str_free (Hto->command); /* Since we will duplicate via from */
if (Hto->remark) gmt_M_str_free (Hto->remark); /* Since we will duplicate via from */
if (Hto->cpt) gmt_M_str_free (Hto->cpt); /* Since we will duplicate via from */
gmt_M_memcpy (to, from, 1, struct GMT_GRID_HEADER); /* Copies full contents but also duplicates the hidden address */
to->hidden = Hto; /* Restore the original hidden address in to */
gmt_M_memcpy (to->hidden, from->hidden, 1, struct GMT_GRID_HEADER_HIDDEN); /* Copies full contents of hidden area */
Expand All @@ -766,6 +767,7 @@ void gmt_copy_gridheader (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *to, stru
if (Hfrom->title) Hto->title = strdup (Hfrom->title);
if (Hfrom->command) Hto->command = strdup (Hfrom->command);
if (Hfrom->remark) Hto->remark = strdup (Hfrom->remark);
if (Hfrom->cpt) Hto->cpt = strdup (Hfrom->cpt);
}

/*! gmt_grd_is_global returns true for a geographic grid with exactly 360-degree range (with or without repeating column) */
Expand Down Expand Up @@ -2112,6 +2114,7 @@ void gmt_grd_init (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, struct
if (HH->command) gmt_M_str_free (HH->command); /* Free previous string */
if (HH->title) gmt_M_str_free (HH->title); /* Free previous string */
if (HH->remark) gmt_M_str_free (HH->remark); /* Free previous string */
if (HH->cpt) gmt_M_str_free (HH->cpt); /* Free previous string */
gmt_M_memcpy (mem, header->mem_layout, 4, char);
gmt_M_memset (header, 1, struct GMT_GRID_HEADER);
HH->index_function = ptr;
Expand Down Expand Up @@ -2932,6 +2935,7 @@ void gmt_free_header (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER **header) {
if (HH->title) gmt_M_str_free (HH->title);
if (HH->command) gmt_M_str_free (HH->command);
if (HH->remark) gmt_M_str_free (HH->remark);
if (HH->cpt) gmt_M_str_free (HH->cpt);
gmt_M_free (GMT, h->hidden);
gmt_M_free (GMT, *header);
}
Expand Down
1 change: 1 addition & 0 deletions src/gmt_hidden.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct GMT_GRID_HEADER_HIDDEN {
char name[GMT_GRID_NAME_LEN256]; /* Actual name of the file after any ?<varname> and =<stuff> has been removed */
char varname[GMT_GRID_VARNAME_LEN80];/* NetCDF: variable name */
char *title; /* Title string not limited to GMT_GRID_TITLE_LEN80 characters */
char *cpt; /* Name of default CPT for a remote grid subset written via grdcut */
char *command; /* Command/history string not limited to GMT_GRID_TITLE_LEN80 characters */
char *remark; /* Remark/description string not limited to GMT_GRID_REMARK_LEN160 characters */
int row_order; /* NetCDF: k_nc_start_south if S->N, k_nc_start_north if N->S */
Expand Down
1 change: 1 addition & 0 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -15561,6 +15561,7 @@ struct GMT_CTRL *gmt_init_module (struct GMTAPI_CTRL *API, const char *lib_name,
wesn[YHI] = ceil ((wesn[YHI] / d_inc) - GMT_CONV8_LIMIT) * d_inc;
gmt_M_memcpy (API->tile_wesn, wesn, 4, double); /* Retain this knowledge in case it was obtained via map_setup for an oblique area */
API->got_remote_wesn = true; /* In case we need to use this subset when reading a grid or image */
API->remote_id = k_data2;
}
if (dry_run)
goto dry_run;
Expand Down
26 changes: 19 additions & 7 deletions src/gmt_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4742,8 +4742,9 @@ int gmtlib_nc_get_att_text (struct GMT_CTRL *GMT, int ncid, int varid, char *nam
/*! . */
int gmtlib_nc_get_att_vtext (struct GMT_CTRL *GMT, int ncid, int varid, char *name, struct GMT_GRID_HEADER *h, char *text, size_t textlen) {
/* Similar to gmtlib_nc_get_att_text and used for title, history, and remark which, if longer than what can fit in header
* are stored as allocated strings in the struct GMT_GRID_HEADER_HIDDEN structure.
* are stored as allocated strings in the struct GMT_GRID_HEADER_HIDDEN structure. We also place cpt in the hidden struct if found.
* ncid, varid, name, text : as in nc_get_att_text
* If text is NULL then we do not access it
* h : the pointer to the grid header structure
* textlen : maximum number of characters to copy to string text
*/
Expand All @@ -4752,9 +4753,13 @@ int gmtlib_nc_get_att_vtext (struct GMT_CTRL *GMT, int ncid, int varid, char *na
size_t attlen, trunclen;
char *att = NULL;

if (name == NULL) {
GMT_Report (GMT->parent, GMT_MSG_ERROR, "Attribute name passed to gmtlib_nc_get_att_vtext is NULL\n");
return GMT_RUNTIME_ERROR;
}
status = nc_inq_attlen (ncid, varid, name, &attlen);
if (status != NC_NOERR) { /* No such attribute */
*text = '\0';
if (text) text[0] = '\0';
return status;
}
att = calloc (attlen+1, sizeof (char)); /* Allocate the memory for the full string plus text terminator */
Expand All @@ -4777,13 +4782,20 @@ int gmtlib_nc_get_att_vtext (struct GMT_CTRL *GMT, int ncid, int varid, char *na
HH->remark = att;
wipe = false;
}
else if (strcmp (name, "cpt") == 0) {
if (HH->cpt) gmt_M_str_free (HH->cpt); /* Free previous string */
HH->cpt = att;
wipe = false;
}
}
if (text) { /* Only copy over if text was passed */
trunclen = MIN (attlen, textlen-1); /* attlen does not include terminating '\0') */
strncpy (text, att, trunclen); /* Copy att to text */
text[trunclen] = '\0'; /* Terminate string */
}
trunclen = MIN (attlen, textlen-1); /* attlen does not include terminating '\0') */
strncpy (text, att, trunclen); /* Copy att to text */
text[trunclen] = '\0'; /* Terminate string */
}
else /* Not successful, set ouput string to empty */
*text = '\0';
else if (text) /* Not successful, set output string to empty unless NULL */
text[0] = '\0';
if (wipe) gmt_M_str_free (att); /* Free since not placed in hidden structure */
return status;
}
Expand Down
7 changes: 7 additions & 0 deletions src/gmt_nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head
/* Valid range is already in packed units, so do not convert */
header->z_min = dummy[0], header->z_max = dummy[1];
}
if (gmtlib_nc_get_att_vtext (GMT, ncid, z_id, "cpt", header, NULL, 0)) /* Found cpt attribute */
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "netCDF grid %s has a default CPT %s.\n", HH->cpt);

if (gmt_M_is_dnan (header->z_min) && gmt_M_is_dnan (header->z_max)) {
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "netCDF grid %s information has zmin = zmax = NaN. Reset to 0/0.\n", HH->name);
header->z_min = header->z_max = 0.0;
Expand Down Expand Up @@ -1029,6 +1032,10 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head

/* Define z variable. Attempt to remove "scale_factor" or "add_offset" when no longer needed */
gmtnc_put_units (ncid, z_id, header->z_units);
if (GMT->parent->remote_info && GMT->parent->remote_id != GMT_NOTSET && GMT->parent->remote_info[GMT->parent->remote_id].CPT[0] != '-') { /* Subset of remote grid with default CPT, save name as an attribute */
HH->cpt = strdup (GMT->parent->remote_info[GMT->parent->remote_id].CPT);
gmt_M_err_trap (nc_put_att_text (ncid, z_id, "cpt", strlen (HH->cpt), HH->cpt));
}

if (header->z_scale_factor != 1.0) {
gmt_M_err_trap (nc_put_att_double (ncid, z_id, "scale_factor", NC_DOUBLE, 1U, &header->z_scale_factor));
Expand Down
1 change: 1 addition & 0 deletions src/gmt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ struct GMTAPI_CTRL {
char *O_OPT, *K_OPT, *P_OPT, *c_OPT;
/* structure array of remote file information (sorted alphabetically) */
int n_remote_info; /* How many remote server files we know of */
int remote_id; /* Currently used remote ID or -1 */
struct GMT_DATA_INFO *remote_info;
bool server_announced; /* Set to true after we have announced which GMT data server we are using */
struct GMT_COMMON *common_snapshot; /* Holds the latest GMT common option settings after a module completes. */
Expand Down
2 changes: 1 addition & 1 deletion src/gmt_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ EXTERN_MSC int gmt_find_macro (char *arg, unsigned int n_macros, struct GMT_MATH
EXTERN_MSC int gmt_load_macros (struct GMT_CTRL *GMT, char *mtype, struct GMT_MATH_MACRO **M);
EXTERN_MSC struct GMT_OPTION * gmt_substitute_macros (struct GMT_CTRL *GMT, struct GMT_OPTION *options, char *mfile);
EXTERN_MSC void gmt_free_macros (struct GMT_CTRL *GMT, unsigned int n_macros, struct GMT_MATH_MACRO **M);
EXTERN_MSC char * gmt_cpt_default (struct GMTAPI_CTRL *API, char *cpt, char *file);
EXTERN_MSC char * gmt_cpt_default (struct GMTAPI_CTRL *API, char *cpt, char *file, struct GMT_GRID_HEADER *h);
EXTERN_MSC void gmt_sort_array (struct GMT_CTRL *GMT, void *base, uint64_t n, unsigned int type);
EXTERN_MSC bool gmt_polygon_is_open (struct GMT_CTRL *GMT, double x[], double y[], uint64_t n);
EXTERN_MSC int gmt_polygon_centroid (struct GMT_CTRL *GMT, double *x, double *y, uint64_t n, double *Cx, double *Cy);
Expand Down
2 changes: 2 additions & 0 deletions src/gmt_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ void gmt_set_unspecified_remote_registration (struct GMTAPI_CTRL *API, char **fi
ext = gmt_chop_ext (infile);
/* If the remote file is found then there is nothing to do */
if ((k_data = gmt_remote_dataset_id (API, infile)) == GMT_NOTSET) goto clean_up;
API->remote_id = k_data;
L = strlen (API->remote_info[k_data].dir) - 1; /* Length of dir minus trailing slash */
strncpy (dir, API->remote_info[k_data].dir, L); dir[L] = '\0'; /* Duplicate dir without slash */
p = strrchr (dir, '/') + 1; /* Start of final subdirectory (skipping over the slash we found) */
Expand All @@ -498,6 +499,7 @@ void gmt_set_unspecified_remote_registration (struct GMTAPI_CTRL *API, char **fi
}
gmt_M_str_free (*file_ptr);
*file_ptr = strdup (newfile);
API->remote_id = k_data;
goto clean_up;
}
}
Expand Down
40 changes: 32 additions & 8 deletions src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -8337,7 +8337,7 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign
return (X);
}

char * gmt_cpt_default (struct GMTAPI_CTRL *API, char *cpt, char *file) {
char * gmt_cpt_default (struct GMTAPI_CTRL *API, char *cpt, char *file, struct GMT_GRID_HEADER *h) {
/* Return which type of default CPT this data set should use.
* If cpt is specified then that is what we will use. If not, then
* we determine if file is a remote data set, and if it is and has a
Expand All @@ -8346,20 +8346,42 @@ char * gmt_cpt_default (struct GMTAPI_CTRL *API, char *cpt, char *file) {
int k_data;
static char *srtm_cpt = "srtm";
char *curr_cpt = NULL;
struct GMT_GRID_HEADER_HIDDEN *HH = gmt_get_H_hidden (h);

if (cpt) return strdup (cpt); /* CPT was already specified */
if (file == NULL) return NULL; /* No file given, so there */
if (API->GMT->current.setting.run_mode == GMT_MODERN && (curr_cpt = gmt_get_current_item (API->GMT, "cpt", false))) return curr_cpt; /* Use current CPT */
if (cpt) {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: Use specific CPT: %s\n", cpt);
return strdup (cpt); /* CPT was already specified, so use it */
}
if (file == NULL) {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: No file given so cannot determine\n");
return NULL; /* No file given, so nothing to work with */
}
if (API->GMT->current.setting.run_mode == GMT_MODERN && (curr_cpt = gmt_get_current_item (API->GMT, "cpt", false))) {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: Use current CPT: %s\n", curr_cpt);
return curr_cpt; /* Use current CPT */
}
if (HH->cpt && HH->cpt[0] != '-') {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: Use grid header default CPT: %s\n", HH->cpt);
return (strdup (HH->cpt)); /* Found default CPT in the grid header */
}

/* Check if we are reading a remote dataset with a default CPT */
if ((k_data = gmt_remote_dataset_id (API, file)) == GMT_NOTSET) {
size_t LOX;
if ((k_data = gmt_get_tile_id (API, file)) == GMT_NOTSET)
return NULL; /* Go with the default, whatever that is */
LOX = strlen (file) - 8; /* Position of the L|O|X flag */
if (file[LOX] == 'L') return strdup (srtm_cpt);
if (file[LOX] == 'L') {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: Use SRTM default CPT: %s\n", srtm_cpt);
return strdup (srtm_cpt);
}
}
if (API->remote_info[k_data].CPT[0] == '-') {
GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: No CPT default for remote dataset %s\n", file);
return (NULL);
}
if (API->remote_info[k_data].CPT[0] == '-') return (NULL);

GMT_Report (API, GMT_MSG_INFORMATION, "gmt_cpt_default: Use dataset default CPT: %s\n", API->remote_info[k_data].CPT);
return (strdup (API->remote_info[k_data].CPT));
}

Expand Down Expand Up @@ -8489,7 +8511,8 @@ struct GMT_PALETTE *gmt_get_palette (struct GMT_CTRL *GMT, char *file, enum GMT_

if (mode == GMT_CPT_REQUIRED) { /* The calling function requires the CPT to be present; GMT_Read_Data will work or fail accordingly */
P = GMT_Read_Data (GMT->parent, GMT_IS_PALETTE, GMT_IS_FILE, GMT_IS_NONE, GMT_READ_NORMAL|continuous, NULL, file, NULL);
gmt_save_current_cpt (GMT, P, 0); /* Save for use by session, if modern */
if (GMT->parent->gwf_dir == NULL || file == NULL || strstr (file, GMT->parent->gwf_dir) == NULL) /* Avoid writing a sessions CPT to a sessions CPT */
gmt_save_current_cpt (GMT, P, 0); /* Save for use by session, if modern mode */
return (P);
}

Expand Down Expand Up @@ -8553,7 +8576,8 @@ struct GMT_PALETTE *gmt_get_palette (struct GMT_CTRL *GMT, char *file, enum GMT_
else
GMT_Report (GMT->parent, GMT_MSG_ERROR, "No CPT file or master given?\n");

gmt_save_current_cpt (GMT, P, 0); /* Save for use by session, if modern */
if (GMT->parent->gwf_dir == NULL || file == NULL || strstr (file, GMT->parent->gwf_dir) == NULL) /* Avoid writing a sessions CPT to a sessions CPT */
gmt_save_current_cpt (GMT, P, 0); /* Save for use by session, if modern */
return (P);
}

Expand Down
2 changes: 1 addition & 1 deletion src/grd2kml.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ EXTERN_MSC int GMT_grd2kml (void *V_API, int mode, void *args) {
}

if (!Ctrl->C.active || gmt_is_cpt_master (GMT, Ctrl->C.file)) { /* If no cpt given or just a master then we must compute a scaled one from the full-size grid and use it throughout */
char *cpt = gmt_cpt_default (API, Ctrl->C.file, Ctrl->In.file);
char *cpt = gmt_cpt_default (API, Ctrl->C.file, Ctrl->In.file, G->header);
char cptfile[PATH_MAX] = {""};
struct GMT_PALETTE *P = NULL;
if ((P = gmt_get_palette (GMT, cpt, GMT_CPT_OPTIONAL, G->header->z_min, G->header->z_max, Ctrl->C.dz)) == NULL) {
Expand Down
9 changes: 7 additions & 2 deletions src/grdcut.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,14 @@ EXTERN_MSC int GMT_grdcut (void *V_API, int mode, void *args) {
/* Send the subset of the grid or image to the gridfile destination. */

if (Ctrl->In.type == GMT_IS_GRID) { /* Write a grid */
if (GMT_Set_Comment (API, GMT_IS_GRID, GMT_COMMENT_IS_OPTION | GMT_COMMENT_IS_COMMAND, options, G)) Return (API->error);
if (GMT_Write_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_CONTAINER_AND_DATA, NULL, Ctrl->G.file, G) != GMT_NOERROR) {
if (GMT_Set_Comment (API, GMT_IS_GRID, GMT_COMMENT_IS_OPTION | GMT_COMMENT_IS_COMMAND, options, G))
Return (API->error);
if (GMT_Write_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_CONTAINER_AND_DATA, NULL, Ctrl->G.file, G) != GMT_NOERROR)
Return (API->error);
if (GMT->current.setting.run_mode == GMT_MODERN && HH->cpt) { /* Save the CPT as the current CPT for a modern mode session */
struct GMT_PALETTE *P = gmt_get_palette (GMT, HH->cpt, GMT_CPT_OPTIONAL, G->header->z_min, G->header->z_max, 0.0);
if (GMT_Destroy_Data (API, &P) != GMT_NOERROR)
Return (API->error);
}
}
else { /* Write an image */
Expand Down
2 changes: 1 addition & 1 deletion src/grdimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
has_content = (got_z_grid) ? false : true; /* Images always have content but grids may be all NaN */
if (got_z_grid) { /* Got a single grid so need to convert z to color via a CPT */
if (Ctrl->C.active) { /* Read a palette file */
char *cpt = gmt_cpt_default (API, Ctrl->C.file, Ctrl->In.file);
char *cpt = gmt_cpt_default (API, Ctrl->C.file, Ctrl->In.file, Grid_orig->header);
if ((P = gmt_get_palette (GMT, cpt, GMT_CPT_OPTIONAL, Grid_orig->header->z_min, Grid_orig->header->z_max, Ctrl->C.dz)) == NULL) {
GMT_Report (API, GMT_MSG_ERROR, "Failed to read CPT %s.\n", Ctrl->C.file);
gmt_free_header (API->GMT, &header_G);
Expand Down
2 changes: 1 addition & 1 deletion src/grdview.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ EXTERN_MSC int GMT_grdview (void *V_API, int mode, void *args) {

if (Ctrl->C.active) {
char *dataset_cpt = (Ctrl->G.active && Ctrl->G.n == 1 && !gmt_M_file_is_image (Ctrl->G.file[0])) ? Ctrl->G.file[0] : Ctrl->In.file;
char *cpt = gmt_cpt_default (API, Ctrl->C.file, dataset_cpt);
char *cpt = gmt_cpt_default (API, Ctrl->C.file, dataset_cpt, Topo->header);
if ((P = gmt_get_palette (GMT, cpt, GMT_CPT_OPTIONAL, Topo->header->z_min, Topo->header->z_max, Ctrl->C.dz)) == NULL) {
Return (API->error);
}
Expand Down
4 changes: 2 additions & 2 deletions test/grdcut/polycut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ gmt begin polycut
gmt grdcut @earth_relief_30m -FFR.txt+c+i -GFR_not.grd
# Like first, but retain input region
gmt grdcut @earth_relief_30m -FFR.txt -GFR_world.grd
gmt grdimage FR_world.grd -B -Rd -JQ0/18c
gmt grdimage FR_world.grd -B -Rd -JQ0/18c -Cturbo
gmt subplot begin 1x2 -Fs8.5c -Scb -Srl -RFR -JM8.5c -M0.35c -Yh+1c
gmt grdimage FR_only.grd -c
gmt grdimage FR_only.grd -Cturbo -c
gmt grdimage FR_not.grd -c
gmt subplot end
gmt end show
4 changes: 2 additions & 2 deletions test/grdfilter/highpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ gmt grdfilter AFR.nc -Fg100+h -D2 -GHc.nc -I15m
gmt grdfilter AFR.nc -Fg100 -D2 -GLc.nc -I15m
gmt grdfilter AFR.nc -Fg100+h -D2 -GHf.nc
gmt grdfilter AFR.nc -Fg100 -D2 -GLf.nc
gmt grdimage AFR.nc -JM3i -I -P -K -Baf -BWSne -Y0.75i > $ps
gmt grdimage AFR.nc -JM3i -I -P -K -Baf -BWSne -Y0.75i -Cturbo > $ps
gmt grdimage Lc.nc -J -I -O -K -Baf -BWsne -Y3.25i >> $ps
gmt grdimage Hc.nc -J -I -O -K -Baf -BWsne -Y3.25i >> $ps
gmt grdimage AFR.nc -J -I -O -K -Baf -BWSnE -X3.5i -Y-6.5i >> $ps
gmt grdimage AFR.nc -J -I -O -K -Baf -BWSnE -X3.5i -Y-6.5i -Cturbo >> $ps
gmt grdimage Lf.nc -J -I -O -K -Baf -BWsnE -Y3.25i >> $ps
gmt grdimage Hf.nc -J -I -O -Baf -BWsnE -Y3.25i >> $ps
Binary file added test/grdimage/defcpt.ps
Binary file not shown.
Loading

0 comments on commit e729a9b

Please sign in to comment.