@pwessel : Is it worth implementing into gmt with an extra option now that @wsja has basically done it?
Looking at this, could your modnorm value be added as a column to the output file that -E sets? Would be pretty simple for me to add that, possibly via a -E modifier.
But first, why were you unable to use -C+f?
Append +f file to save the eigenvalues to the specified file for further analysis
The eigenvalues is not what I need, I need the alphas, dependent on n_use
.
From C+f I get what I think would be what be the singular values (The diagonal elements of S, from G = USV^T; they are in the 1e18 - 1e0 range. I would expect the alpha
s to span at most 5 or 6 orders of magnitude). Moreover, I only get one set of e
values (e
= number of data points = number of model parameters), not e
times e
.
Yes, that would probably be the easiest one. In fact, two extra columns would be nice: model norm (as modnorm
, above) and data norm (with the weights applied just as in the misfit function).
OK, got you this time. Let me see if I can whip out a branch for your testing,
I dont know what you mean here. obs is an array.
obs[k] * obs[k]
OK, that is what I did. See if you can test this branch and comment on what is missing: https://github.com/GenericMappingTools/gmt/pull/7358
I think there is some syntactical mishap:
Should it be:
-E+nfile (this throws an: [Session greenspline (0)]: Error returned from GMT API: GMT_ERROR_ON_FOPEN (15)
)
or
-Efile+n (which does not recognize the +n
flag, but simply appends an “+n” to the file name)
Syntax is
-E[misfitfile][+n]
There is no modifier to set the filename (existing syntax) but you gotta append the new modifier +n if you want effect.
Yes, I understand. However, this is not what the current implementation is doing. When writing:
greenspline $dep -G$svd -L $R -Sp -Z2 -I$I -C+c -W -Emisfit.dat+n
gmt creates a file called “misfit.dat+n”, without any extra column. The +n modifier is currently not recognized, but appended to the filename.
Are you sure you have checked out the branch green-modnorm? Or are you rebuilding master which will not do anything.?
$ git branch
* green-modnorm
master
$ cd build
$ cmake --build . --target install
Where my ConfigUser.cmake
has:
set (CMAKE_INSTALL_PREFIX /home/myusername/.local)
set (GMT_INSTALL_MODULE_LINKS TRUE)
and
$ which greenspline
/home/myusername/.local/bin/greenspline
This previously worked well with my local commits and greenspline was the (almost) only thing recompiling after I pulled in your changes. Am I doing anything incorrectly?
My output is this (note version and synopsis. Not I have nothing to run it on so cannot say if you are wrong but the code looks for +n and strips it off like we do in lots of places in Gmt;
gmt greenspline -
gmt greenspline [core] 6.5.0_b0ef92b-dirty_2023.03.31 - Interpolate using Green's functions for splines in 1-3 dimensions
usage: gmt greenspline [<table>] -G<outfile> [-A<gradientfile>+f<format>] [-C[[n|r|v]<val>[%]][+c][+f<file>][+i][+n]] [-D<information>]
[-E[<misfitfile>][+n]] [-I<dx>[/<dy>[/<dz>]]] [-L[t][r]] [-N<nodefile>] [-Q[<az>|<x/y/z>]] [-R<xmin>/<xmax>[/<ymin>/<ymax>[/<zmin>/<zmax>]]] [-Sc|⏎
…l|t|r|p|q[<pars>]] [-T<maskgrid>] [-V[q|e|w|t|i|c|d]] [-W[w]] [-Z<mode>] [-bi<record>[+b|l]] [-d[i|o]<nodata>[+c<col>]] [-e[~]<pattern>|/<regexp>/⏎
…[i]|+f<file>] [-f[i|o]<colinfo>] [-gx|y|z|d|X|Y|D<gap>[<unit>][+a][+c<col>][+n|p]] [-h[i|o][<nrecs>][+c][+d][+m<segheader>][+r<remark>][+t<title>]]
[-i<cols>[+l][+d<divisor>][+s<scale>|d|k][+o<offset>][,...][,t[<word>]]] [-o<cols>[,...][,t[<word>]]] [-q[i|o][~]<rows>[,...][+c<col>][+a|t|s]]
[-r[g|p]] [-s[<cols>][+a][+r]] [-wy|a|w|d|h|m|s|c<period>[/<phase>][+c<col>]] [-:[i|o]] [--PAR=<value>]
I confirm I got the same version and usage.
dep.dat could be:
-126.757 | 50.312 | 27.6715 | 5 |
---|---|---|---|
-126.543 | 50.248 | 32.0467 | 3 |
-126.601 | 50.203 | 30.2045 | 6 |
-127.772 | 50.157 | 15.3931 | 5 |
-126.809 | 50.142 | 28.6611 | 2 |
-126.661 | 50.165 | 27.6259 | 3 |
-126.575 | 50.167 | 28.7127 | 4 |
-126.57 | 50.161 | 31.2128 | 2 |
-126.441 | 50.121 | 31.4285 | 3 |
-125.365 | 50.032 | 48.5193 | 4 |
and
R=-R-130/-120/40/60
I=0.05
G=tmp.grd
greenspline dep.dat -G$G -L $R -Sp -Z2 -I$I -C+c -W -Emisfit.dat+n
would reproduce the problem on my side.
yep, No coffee == more likely to do copy/paste bugs. do a git pull
Thanks.
I now got the extra column, but it only holds 0’s, which can’t be right. I’d expect monotonically increasing values.
I suppose:
S->data[4][e] = modnorm; /* Model norm at this point */
should only be executed when the for-loop has terminated?
– I just tested it — Nope
modnorm
itself is having a value and is increasing, though, just not written to file.
Probably my error. See if things at line 2649 and ~2680 are now correct for your cumulative sum. There is obviously something I am blind too…
I do not see a new commit right now.