-
Notifications
You must be signed in to change notification settings - Fork 346
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
psmeca: Make the last few columns of input optional #2018
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment before the Set_Columns line to remind us:
/* Because psmeca reads optional columns we cannot insist records are all the same, hence VAR below */
I have a few failing tests locally. Need to check them |
OK, let me know. |
@PaulWessel This one doesn't work. It seems the last column "10km" is read as a float value "10.0" instead of a string.
|
I may be able to fix that since "km" is not a valid unit, but I can imagine some users thinking that any string can be used for that title, and if they give 00101 then we will read that as 101 and not as a string. This is the problem of allowing variable record lengths with or without a string at the end... |
I may have a working solution. We can still use |
Yes we can do that. In fact, in my longer posting earlier I was about to write that scheme but decided to see if the VAR would be enough. But it cannot tell the trailing text. I am adding a minor improvement to the parsing (it will check if the trailing chars after the last digit or single period in a string is more than one or (if one) does not match a known unit, then it is deemed text. But as mentioned this will not catch strings that look like numbers. So you suggestion is more foolproof. I will still commit my fix since it applies in general and will not parse 10km as a number. |
If you want to try the above, note that you will need to do this:
To handle proper parsing of 135:45W etc. |
If you want to take a first crack at this then I can help with any pesky details. |
OK. I'll look into it later. |
Maybe something like this?. This assumes you may give an event title but not new x,y
|
caeb619
to
2d5c9e6
Compare
7d75d6a
to
cf77595
Compare
@PaulWessel I followed your first solution, as the second one doesn't work if event title contains several whitespaces (e.g. I also added a test to check psmeca with different input columns. Now all tests pass. |
How do you handle the difference between lon lat title and A longer title both will give n_scanned 3, no? |
I don't have a clever way to handle that, so I assume the newX and newY must be given if event title is needed. It's also consistent with older GMT4 or GMT5 behavior. |
OK, I guess a clever solution would check if the resulting xynew coordinates are NaNs or not, and if they both are then change event_title to be the whole trailing text, e.g.
|
For a title like "10 km", |
Odd, this is what I was fixing with #2020 and it caught the 10km title from before. |
A title "Strike slip" also gives me 0.0 and 0.0, not NaN. |
I have trouble switching to this branch - it complains about conflicts etc... I would approve and then try your case with 3 word title? |
Try these commands?
|
OK now. Sorry, was in middle of building the full docs. Please give me a command or two that fails so I can debug. |
The title is "10 km". |
The FIX cols set 9 cols, and your data record has 9 including the title. isn't the title in addition to the required cols? IF 10 km is the title then there should be 6 cols only? |
Probably never mind. Xcode does not wipe and rebuild the supplements when the source changes, so I need to rebuild the whole thing. Your code seems to do 6 but my debugger says 9... |
If GMT_IS_NAN is returned we must set to NaN manually.
@PaulWessel Your fix works well except that newX and newY need to be reset to 0.0 if they're NaN. I've made the fix and updated the test script. |
I still have a question. If
I have to give "newX newY". i.e. This works:
|
It should by lat lon in both places I think. I suggest we change the if test on ix to be if (GMT->current.setting.io_lonlat_toggle[GMT_IN]) { which is cleaner than the ix stuff. |
Also, the checking of xynew versus zero is no good. The day may come when you want to give 0,0 as the new coordinates and then you cannot. Please do this instead:
|
I made the change aa7fa4b to fix the issue with
I agree, but it's used for a long time, and I have seen many scripts using |
Looks good to me. |
You mean people will place 0 0 when they use -C but don't want another placement instead of not giving the coordinates? Maybe we could handle it under compatibility and say this will break in GMT 7 and warn if we get 0,0 instead of NaN NaN until then? |
Yes, this is exactly what the GMT4 manpage says:
|
Of, a simpler time when NaNs were just bread eaten by Indians... |
On the road. Certainly we can handle that case?
Paul Wessel, Professor and Chair
Dept. of Earth Sciences (formerly Geology & Geophysics)
SOEST, U of Hawaii at Manoa
…On November 9, 2019 at 6:30:06 PM, Dongdong Tian ***@***.***) wrote:
Just realize that it's a bad idea to allow "title"-only input.
The Global CMT project (the most used focal mechanism solution data
source) returns:
-176.96 -29.25 48 7.68 0.09 -7.77 1.39 4.52 -3.26 26 X Y 010176A
Our current implementation gives
[image: image]
<https://user-images.githubusercontent.com/3974108/68538828-90cb6980-0348-11ea-8340-d48e189a20ca.png>
It means breaking many people's results.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2018?email_source=notifications&email_token=AGJ7IXZGPLPDVAIPNH62WSDQS6E45A5CNFSM4JLJOPI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDUVC7Q#issuecomment-552161662>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJ7IX3AQVQPQIWW6H2COQLQS6E45ANCNFSM4JLJOPIQ>
.
|
The Global CMT project (the most used focal mechanism solution data source) returns records like -176.96 -29.25 48 7.68 0.09 -7.77 1.39 4.52 -3.26 26 X Y 010176A
@carltape This PR fixes the psmeca input issue reported in #2016. It would be good if you can give it a try. In the new implementation, the new coordinates and event_title are optional. For example, -Sa now can accept following input formats:
|
@carltape Thanks for your reports and tests! This PS has been merged into 6.0 branch. |
Fixes #2016.