Skip to content

Add new greenspline option -K for statistics output to file or stdout#8162

Merged
PaulWessel merged 9 commits intomasterfrom
greenspline-K
Dec 8, 2023
Merged

Add new greenspline option -K for statistics output to file or stdout#8162
PaulWessel merged 9 commits intomasterfrom
greenspline-K

Conversation

@PaulWessel
Copy link
Member

See #8158 for some background. Rather than messing with the verbose output, this PR instead adds -K option that will wrote a data table with header and 7-8 values which makes it easier to access. Updated docs as well. Suggest @Esteban82 gives this a try and report back if there are any issues or request. You will see I basically write both the misfit and variance statistics to the file (variance first, then misfit) and then if -W is active we append one more output (chi^2) at the end. This ensures that the first 7 columns are in a fixed order and the 8th optional column is only there if -W is set. @joa-quim, done merge this into master until @Esteban82 has given it a try later today.

See #8158 for some background.  This PR instead adds -K option that will wrote a data table with header and 7-8 values which makes it easier to access.
@PaulWessel PaulWessel added the new feature PR that implements a new feature or capability in GMT label Dec 8, 2023
@PaulWessel PaulWessel added this to the 6.5.0 milestone Dec 8, 2023
@PaulWessel PaulWessel self-assigned this Dec 8, 2023
@joa-quim
Copy link
Member

joa-quim commented Dec 8, 2023

Isn't -K a global option?

@joa-quim
Copy link
Member

joa-quim commented Dec 8, 2023

And where is that #define GMT_N_API_ENUMS 263 coming from that makes the Validator check to fail?

@PaulWessel
Copy link
Member Author

Isn't -K a global option?

No, see movie -K for instance. But, I agree there is no point using -K if there are other letters available, e.g., -F, -M . I will change it to -F instead.

@PaulWessel
Copy link
Member Author

If we add an enum we must run src/gmt_make_enum_dicts.sh to update that include file for the API. Idid I forget?

@joa-quim
Copy link
Member

joa-quim commented Dec 8, 2023

But what is the validator compares against to know the number of enums has changed? And what is right, the 261c or 263?

@Esteban82
Copy link
Member

It looks fine. I test it with this:

gmt greenspline -R0/7.2/-0.2/7 -I0.05 -GMM1993.grd @Table_5_11.txt -Sr0.99 -Z1 -Vi -Kstatistics.txt -Emisfit.txt

Statistics.txt:

# Misfit & Variance Evaluation: Data	Model	Explained(%)	N	Mean	Std.dev	RMS
3.5767e+07	3.5767e+07	100	52	-5.24708e-14	7.94742e-14	9.45932e-14

Small Issue

The creation of that file depends on -E. So, if I use the command below, the file is not generated.

gmt greenspline -R0/7.2/-0.2/7 -I0.05 -GMM1993.grd @Table_5_11.txt -Sr0.99 -Z1 -Vi -Kstatistics2.txt

So, maybe should be clarify in the docs? Or maybe we should a modifier to -E instead of a new letter?

@PaulWessel
Copy link
Member Author

Sorry, forget. Just pushed it to master now. It is 263.

@PaulWessel
Copy link
Member Author

Will switch from -K to -F and will update docs etc to say -E is needed.

Need to requires a file since -E with no file will write to stdou; cannot have two such stdouts.
@PaulWessel
Copy link
Member Author

Switched to -F, requires -E, and -F must set a file since -E has an optional file and will write to stdout. Cannot both write to stdout.

@PaulWessel
Copy link
Member Author

@Esteban82, please update build and check again since there were several changes.

@Esteban82
Copy link
Member

I got an error:

 gmt greenspline -R0/7.2/-0.2/7 -I0.05 -GMM1993.grd @Table_5_11.txt -Sr0.99 -Z1  -Vi -Emisfit.txt  -Fstats.txt
greenspline [ERROR]: Option -r: Syntax is -r[g|p]
greenspline [ERROR]: Option -r parsing failure. Correct syntax:

  -r[g|p]
     Set (g)ridline- or (p)ixel-registration (-r with no argument sets pixel registration). If -r is not given then we default to gridline registration.
greenspline [ERROR]: Offending option -rstats.txt

@PaulWessel
Copy link
Member Author

Me too! Will fix...

@PaulWessel
Copy link
Member Author

Fixed.

@PaulWessel
Copy link
Member Author

OOPS: More changes:

I will instead use option letter -M. The reason is two-fold:

  1. The ancient -F for -r was parsed in greenspline so I took that out - not the best solution.
  2. gpsgridder should get exactly the same option, but its -F is taken. -M is available in both modules

@Esteban82
Copy link
Member

Ok. BTW I will be away from my PC for the following days.

@PaulWessel
Copy link
Member Author

PaulWessel commented Dec 8, 2023

OK, the new feature is now set via -E[misfitfile][+rreportfile]. The benefits are

  1. No need to messing with complicated -F form the olden days.
  2. No need to add a new option, just a modifier
  3. This also means we would not have to set -E in addition to the initial -K or -M to do this since it is now a modifier of -E so -E is obviously set.
  4. green spline actually has an unimplemented -M for passing in previous eigenvalues. May happen at some point and then it is nice that -M is not taken already.

Give @Esteban82 is off, perhaps @joa-quim can have a look. Should be harmless since only about a report to a file.

Fixed synopsis message and a few issue related to freeing files that were forgotten in gpsgridder and green spline. gpsgridder now has the same -E modifier etc.

@PaulWessel PaulWessel merged commit 3ce2b95 into master Dec 8, 2023
@PaulWessel PaulWessel deleted the greenspline-K branch December 8, 2023 16:22
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jan 4, 2024
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 new feature PR that implements a new feature or capability in GMT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants