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

Document that -J is not required anymore for modern mode? #8695

Open
Esteban82 opened this issue Feb 19, 2025 · 9 comments
Open

Document that -J is not required anymore for modern mode? #8695

Esteban82 opened this issue Feb 19, 2025 · 9 comments
Assignees
Labels
documentation Improve documentation

Comments

@Esteban82
Copy link
Member

As I understand it, -J is an optional argument for all GMT modules. And from what I see in the following code, the default values are defined by these lines in src/gmt_inti.c:

gmt/src/gmt_init.c

Lines 16127 to 16148 in 82a5564

if (got_J == false) { /* No history, apply default projection, but watch out for subplots and time-axis */
unsigned int geo = gmtinit_is_region_geographic (GMT, *options, mod_name);
if (geo) /* Max dimension lon/lat plot of 15 cm */
snprintf (scl, GMT_LEN64, "Q15c+du");
else { /* Use 15cm square but watch out for panels and time-axes */
char *Tcode[2] = {"", "T"};
unsigned int xy[2];
xy[GMT_X] = (gmt_get_column_type (GMT, GMT_IN, GMT_X) == GMT_IS_ABSTIME);
xy[GMT_Y] = (gmt_get_column_type (GMT, GMT_IN, GMT_Y) == GMT_IS_ABSTIME);
if (P && (P->dir[GMT_X] == -1 || P->dir[GMT_Y] == -1)) /* Nonstandard Cartesian axes directions */
snprintf (scl, GMT_LEN64, "X%gi%s/%gi%s", P->dir[GMT_X]*P->w, Tcode[xy[GMT_X]], P->dir[GMT_Y]*P->h, Tcode[xy[GMT_Y]]);
else if (GMT->common.R.aspect == 1) /* Want the same scale in x and y and x should be 15 cm */
snprintf (scl, GMT_LEN64, "X15c%s/0", Tcode[xy[GMT_X]]);
else if (GMT->common.R.aspect == -1) /* Want the same scale in x and y and y should be 15 cm */
snprintf (scl, GMT_LEN64, "X0/15c%s", Tcode[xy[GMT_X]]);
else
snprintf (scl, GMT_LEN64, "X15c%s/15c%s", Tcode[xy[GMT_X]], Tcode[xy[GMT_Y]]);
}
if ((opt = GMT_Make_Option (API, 'J', scl)) == NULL) return NULL; /* Failure to make option */
if ((*options = GMT_Append_Option (API, opt, *options)) == NULL) return NULL; /* Failure to append option */
GMT_Report (API, GMT_MSG_DEBUG, "Modern: Adding -J%s to options since there is no history available.\n", scl);
}

However, I cannot find this mentioned in the documentation anywhere. Is this the case? Or is there any good reason not to do it?
I offer to document it if needed.

This is related #8694.

@Esteban82 Esteban82 added the documentation Improve documentation label Feb 19, 2025
@Esteban82 Esteban82 self-assigned this Feb 19, 2025
@seisman
Copy link
Member

seisman commented Feb 19, 2025

Is it still required in classic mode?

@Esteban82
Copy link
Member Author

Is it still required in classic mode?

Yes, I think is required for classic mode. (I will update the name of the issue).

@Esteban82 Esteban82 changed the title Document that -J is not required anymore? Document that -J is not required anymore for modern mode? Feb 19, 2025
@joa-quim
Copy link
Member

No, it's not required in classic neither.

@seisman
Copy link
Member

seisman commented Feb 20, 2025

No, it's not required in classic neither.

I believe it's still required in classic mode.

$ gmt grdimage @earth_relief_01d > map.ps
grdimage [ERROR]: Must specify a map projection with the -J option

@Esteban82
Copy link
Member Author

Weird. For me, this command worked:
gmt grdimage @earth_relief_01d > map.ps

But I got this wrong:

gmt psbasemap -R0/15/0/15 -Baf > plot.ps
psbasemap [ERROR]: Must specify a map projection with the -J option

I am using GMT 6.6.0_82a5564_2025.02.18 on linux.

@joa-quim
Copy link
Member

Dongdong must be using an older GMT version. When not provided grdimage sets a default -J

https://github.com/GenericMappingTools/gmt/blob/master/src/grdimage.c#L1705-L1707

@Esteban82
Copy link
Member Author

https://github.com/GenericMappingTools/gmt/blob/master/src/grdimage.c#L1705-L1707

In that line, I see that Q15c+ is used while Q15c+du is used in gmt_init.c. Shouldn't be the same?

@seisman
Copy link
Member

seisman commented Feb 20, 2025

Dongdong must be using an older GMT version. When not provided grdimage sets a default -J

https://github.com/GenericMappingTools/gmt/blob/master/src/grdimage.c#L1705-L1707

You're right that I'm using GMT 6.5.0, but those lines were added in #8440.

@joa-quim
Copy link
Member

+du Honestly I don't remember what that does and seems a very minor thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improve documentation
Projects
None yet
Development

No branches or pull requests

3 participants