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

Enhance meca and coupe w.r.t. adjusting positions and connecting with a line #7778

Merged
merged 23 commits into from Sep 9, 2023

Conversation

PaulWessel
Copy link
Member

This PR started with the discussions on #7777. To prepare this, I found that there were much duplicated #define statements in psmeca.c and pscoupe.c so I pulled those into meca.h. Then, given we want a "-A"-like option in coupe I placed the -A parser from psmeca.c into utilmeca.c as well as the usage message now that it will have more modifiers. Then there is a common structure defined in meca that is included in Ctrl as member A or D. This reduces the amount of code needed to implement the desired features. This initial commit just does that - no actual "-D" option will be acted on yet. However, the parser has been extended to process +c and +o but they are basically ignored.

… line

This PR started with the discussions on #7777.  To prepare this, I found that there were much duplicated #define statements in psmeca and pscoupe.c so I pulled those into meca.h. Then, given we want a "-A"-like option in coupe I placed the -A parser from psmeca.c into utilmeca.c as well as the usage message now that it will have more modifiers.  Then there is a common structure defined in meca that is included in Ctrl as member A or D.  This reduces the amount of code needed to implement the desired features.
THis initial commit jus does that - no actual "-D" option will be acted on yet.
Seems like coupe is working with new -D.  Have not tested meca yet but since it worked before I dont expect troubles.
@PaulWessel
Copy link
Member Author

Hi @seisman, draft version 1 is pushed. I tested coupe with -D+o (reads the alternative coordinates as offsets instead) and -Dodx/dy (same offset from projected location for all points). Things not tested (but hope they work as is):

Use CPT in coupe and with -D (should be completely decoupled)
Do same tests with meca

Questions:

  1. Would be easy to add modifier -D +gfill if you want to paint that circle with another color than the beachball. Could also all +g- which would not fill the circle.
  2. I did not implement a +c to affect conversions. meca will always expect an alternative plot location in geographical coordinates, whereas coupe should aways expect offsets in plot units. So unless I am missing something I do not see a need for any +c.. When +o is given we read those two columns as plot units in both modules.

@PaulWessel
Copy link
Member Author

Once things work we should make a test or two.

@PaulWessel
Copy link
Member Author

OK, I added documentation for coupe -D and updated meca -A docs as well.
Have a look. I decided it only made sense in coupe that the two alternative coordinates are in distance, depth since if they were lon lat then the conversion to distance,depth requires (lon, lat, depth) and we would presumably have to use epicenter depth to do that. If would be simple to do but would require a new +c modifier just for coupe. Then coupe could do (with -D):

Default assume the two cols are distance, depth in the crossection
+c No, they are lon, lat and with epicentre depth compute distance, depth for the alternate location in the crossection
+o offset the final alternate location by dx/dy:
With +c, only +odx/dy is allowed since already read two cols to compute alternative coordinates.
Without +c, if just +o then the two cols have variable dx dy in plot units.
Without +c, +odx/dy adjusts the alternate locations by this fixed offset.

Comments? Shall I add +c to coupe.

@PaulWessel
Copy link
Member Author

Note I got bored and added +g[fill] for how to fill the circle [Default is same as beachball as before] but also modified +s to be +s[symbol]size where symbol can be any of the standard geometric plot symbols [c].
Might be done?

@PaulWessel
Copy link
Member Author

gmt coupe meca.dat -Sa1c -Aa111/33/119/33+d90+w500+z0/50+r -Q -JX15c/-8c -B -D+o+sa6p+gyellow -Gred -png map
map

Should we do something with the label justification if +o gives a negative dy? i.e., TC -> BC?

@PaulWessel PaulWessel added the add-changelog Add PR to the changelog label Sep 3, 2023
@PaulWessel
Copy link
Member Author

Hi @seisman, I ended up adding +c to coupe -D since people plotting with meca may have alternative geographic coordinates which they use with meca -A but coupe would normally expect _distance, dept_h coordinates instead. The -D+c projects the alternative geographic coordinates into the crossectional plane. After than, **+**odx/dy can be used to shift any further since hard to know where things project. With no +c then we expect distance, depth in those columns. In that case, **+**odx/dy can be used to apply a constant shift to all alternative events. If just +o is given then we initialise the alternate plot locations as the same as the original plot location, then add variable dx dy read from those two special columns.

See what you think. I have updated docs.

src/seis/meca.h Outdated Show resolved Hide resolved
doc/rst/source/supplements/seis/psmeca.rst Outdated Show resolved Hide resolved
doc/rst/source/supplements/seis/pscoupe.rst Outdated Show resolved Hide resolved
src/seis/pscoupe.c Outdated Show resolved Hide resolved
src/seis/pscoupe.c Outdated Show resolved Hide resolved
src/seis/psmeca.c Outdated Show resolved Hide resolved
@seisman
Copy link
Member

seisman commented Sep 4, 2023

The codes look pretty good to me. I still need some time for more testings.

PaulWessel and others added 5 commits September 4, 2023 16:15
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@PaulWessel
Copy link
Member Author

Thanks for spotting those glitches.

@seisman
Copy link
Member

seisman commented Sep 5, 2023

Bug in parsing the trailing text:

gmt meca meca.dat -Sa1c -JM10c -B -R110/120/30/36 -A+o -png map << EOF
112 31.05  30  90   0  4  2.0 1.0 Strike-slip                                   
115 34 15  30  60  90  5  1.0 1.0 Reverse
118 32 45  30  60 -90  6  1.0 1.0 Normal
EOF

@PaulWessel
Copy link
Member Author

Will look, but you are giving both a file (meca.dat) and feed from stdin. Intentional?

@PaulWessel
Copy link
Member Author

Good test, It tries to convert to a number. But help me with this:

In record looks like this:

112 31.05 30 90 0 4 2.0 1.0 Strike-slip

and -Sa sets the number of input columns to 7 But you are giving only 6 and then the two extra. So se set GMT_Set_Columns to 7 and then the trailing text is "1.0 Strike-slip".

Is the n_cols settings when parsing 'S' expecting 6 ir 7?

@seisman
Copy link
Member

seisman commented Sep 5, 2023

Good test, It tries to convert to a number. But help me with this:

In record looks like this:

112 31.05 30 90 0 4 2.0 1.0 Strike-slip

and -Sa sets the number of input columns to 7 But you are giving only 6 and then the two extra. So se set GMT_Set_Columns to 7 and then the trailing text is "1.0 Strike-slip".

Is the n_cols settings when parsing 'S' expecting 6 ir 7?

Sorry, my mistake. It's weird that I lost the depth column when copying and paste the data.

@PaulWessel
Copy link
Member Author

Oh, now I see it; the decimals tricked you. Looks OK?

map

@seisman
Copy link
Member

seisman commented Sep 5, 2023

Yes, it looks good. Will do more tests.

@PaulWessel
Copy link
Member Author

Some issues

using +s and x (cross) requires -W to change pen and +c to set pen color to event depth color. Maybe computer cross pen width from size is more practical. At least as default
The issue with label justifications and offsets dc day

@seisman
Copy link
Member

seisman commented Sep 7, 2023

This PR looks pretty good to me.

@PaulWessel PaulWessel changed the title WIP Enhance meca and coupe w.r.t. adjusting positions and connecting with a line Enhance meca and coupe w.r.t. adjusting positions and connecting with a line Sep 9, 2023
@PaulWessel PaulWessel added the documentation Improve documentation label Sep 9, 2023
@PaulWessel
Copy link
Member Author

Hi @seisman, I am done with this branch. All 13 seis scripts passes and unless you see anything funny I hope you can approve it and we can merge. Then onto stroke-symbol revitalization!

@PaulWessel PaulWessel merged commit f3bcba5 into master Sep 9, 2023
6 checks passed
@PaulWessel PaulWessel deleted the refresh-seis-adjust branch September 9, 2023 12:36
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 documentation Improve documentation enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants