-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding API test for plotting a global matrix/grid for different centr…
…al meridians (#3811) (#3812) * Explore passing matrix to grdimage for different central longitudes * Update testapi_matrix_360.c * Try rotating the grid * Update testapi_matrix_360.c * Add the test script * Update gmt_api.c Co-authored-by: Paul Wessel <pwessel@hawaii.edu>
- Loading branch information
1 parent
7f34541
commit 2b0f9fe
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "gmt_dev.h" | ||
|
||
/* Testing the passing of a matrix to grdimage for global projection | ||
* when the central meridian changes. This currently fails as in | ||
* https://github.com/GenericMappingTools/pygmt/issues/515#issue-655281714 | ||
*/ | ||
|
||
int main () { | ||
unsigned int mode = GMT_SESSION_EXTERNAL; | ||
struct GMT_MATRIX *M = NULL; | ||
char input[GMT_VF_LEN], args[256] = {""}; | ||
struct GMTAPI_CTRL *API = NULL; | ||
|
||
API = GMT_Create_Session ("test", 2U, mode, NULL); | ||
|
||
/* Read in earth_relief_01d as a matrix from text file and set correct region, inc, registartion */ | ||
M = GMT_Read_Data (API, GMT_IS_MATRIX, GMT_IS_FILE, GMT_IS_SURFACE, GMT_READ_NORMAL, NULL, "@earth_relief_01d.txt", NULL); | ||
M->range[0] = -180; M->range[1] = 180; M->range[2] = -90; M->range[3] = 90.0; | ||
M->inc[0] = M->inc[1] = 1.0; | ||
M->registration = 1; | ||
/* Create a virtual file to pass as a grid */ | ||
GMT_Open_VirtualFile (API, GMT_IS_GRID|GMT_VIA_MATRIX, GMT_IS_SURFACE, GMT_IN|GMT_IS_REFERENCE, M, input); | ||
/* Call grdimage with central longitude 0, which is the center of the grid */ | ||
sprintf (args, "%s -Rg -JH0/6i -Bg30 -K -Cgeo -P", input); | ||
GMT_Call_Module (API, "grdimage", GMT_MODULE_CMD, args); | ||
GMT_Init_VirtualFile (API, 0, input); | ||
/* Call grdimage with central longitude 180 which means grid needs to be rotated 180 */ | ||
sprintf (args, "%s -R -JH180/6i -Bg30 -O -Cgeo -Y3.5i", input); | ||
GMT_Call_Module (API, "grdimage", GMT_MODULE_CMD, args); | ||
GMT_Close_VirtualFile (API, input); | ||
|
||
if (GMT_Destroy_Session (API)) return EXIT_FAILURE; | ||
exit (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Test the C API for passing a global grid as a matrix to grdimage | ||
# and have the central meridian work correctly. | ||
|
||
ps=apimat_360.ps | ||
testapi_matrix_360 > $ps |