Skip to content

Better handling of trailing text in sample1d output - #6098

Merged
PaulWessel merged 7 commits into
masterfrom
sample1d-trailing-text
Dec 9, 2021
Merged

PaulWessel merged 7 commits into
masterfrom
sample1d-trailing-text

Conversation

@PaulWessel

Copy link
Copy Markdown
Contributor

See forum post for discussion. If input records have trailing text then if there are output records at the same times then these should inherit any input trailing text:

in.txt:

1967-01-01 6 A B
1967-01-08 5
1967-01-12 7 C D
1967-01-15 1 E
1967-01-20 2 F G
gmt sample1d -fT --TIME_UNIT=d -I1 -Fa in.txt
1967-01-01T00:00:00	6	A B
1967-01-02T00:00:00	5.60489000795	
1967-01-03T00:00:00	5.33262655712	
1967-01-04T00:00:00	5.15995229261	
1967-01-05T00:00:00	5.06360985953	
1967-01-06T00:00:00	5.02034190299	
1967-01-07T00:00:00	5.00689106812	
1967-01-08T00:00:00	5	
1967-01-09T00:00:00	5.31835669826	
1967-01-10T00:00:00	6.0269814984	
1967-01-11T00:00:00	6.72211554934	
1967-01-12T00:00:00	7	C D
1967-01-13T00:00:00	5.59980754838	
1967-01-14T00:00:00	2.9098328522	
1967-01-15T00:00:00	1	E
1967-01-16T00:00:00	0.364936170213	
1967-01-17T00:00:00	0.130553191489	
1967-01-18T00:00:00	0.31370212766	
1967-01-19T00:00:00	0.931234042553	
1967-01-20T00:00:00	2	F G

If input records have trailing text then if there are output records at the same times then these should inherit any input trailing text .
@PaulWessel PaulWessel added documentation Improve documentation enhancement Improving an existing feature labels Dec 7, 2021
@PaulWessel
PaulWessel requested review from anbj and maxrjones December 7, 2021 22:43
@PaulWessel PaulWessel self-assigned this Dec 7, 2021
@maxrjones

Copy link
Copy Markdown
Member

My concern is that this PR could break workflows that were written with an assumption that sample1d does not output trailing text. If this is considered an enhancement, I think it would be better to set a new modifier to trigger the behavior.

@PaulWessel

Copy link
Copy Markdown
Contributor Author

I did not think any of the options were suitable for a modifier for this so I added an option -E to attempt to deal with trailing text. Default thus remains the same as before.

@anbj

anbj commented Dec 8, 2021 •

Copy link
Copy Markdown
Contributor

Looks good. Extra information is now preserved.

Two other things:

  • I may have one or more rows of the same date. This cause sample1d to stop:
$ cat <<eof | gmt sample1d -fT --TIME_UNIT=d -I1 -Fa
2021-01-01 1
2021-01-02 2
2021-01-02 3
eof
sample1d [ERROR]: x-values are not monotonically increasing/decreasing (at zero-based record 2)!
sample1d [ERROR]: Failure in gmt_intpol near row 3!

Why are duplicate rows (on the 0th column) not allowed? Could it be?

  • In my case, I don't want to interpolates anything else but the 0th column (dates in my case). But sample1d requires a value that it can interpolate (1st column). Any way to make it only look at the 0th column?

@PaulWessel

PaulWessel commented Dec 8, 2021 •

Copy link
Copy Markdown
Contributor Author

I will look to see if we can get away with no data set to resample. Seems like that should be easy. Right now we allow n columns to be resampled and I think 0 should be allowed.
As for duplicates. Remember we are building a spline f(t) and it cannot handle two values at the same time. Just like with surface or greenspline, one would have to average those points before the interpolation. There is -A+d to skip duplicates but that may be limited to spatial curves (cannot remember).

Simple enough.  Also updated the documentation
@PaulWessel

Copy link
Copy Markdown
Contributor Author

Now, sample1d is OK with interpolating just the time column if there are no other data columns, so @anbj can test this out. I also updated the documentation. I agree this is a useful feature (resample a set of time nodes without having to give a data column when none is needed.

@anbj

anbj commented Dec 9, 2021

Copy link
Copy Markdown
Contributor

Super!

cat <<eof | gmt sample1d -fT --TIME_UNIT=d -I1 -Fa -E
2021-01-01 hello
2021-01-10 there
eof
2021-01-01T00:00:00	hello
2021-01-02T00:00:00
2021-01-03T00:00:00
2021-01-04T00:00:00
2021-01-05T00:00:00
2021-01-06T00:00:00
2021-01-07T00:00:00
2021-01-08T00:00:00
2021-01-09T00:00:00
2021-01-10T00:00:00	there

Thank you Paul!

@PaulWessel
PaulWessel merged commit 4d86421 into master Dec 9, 2021
@PaulWessel
PaulWessel deleted the sample1d-trailing-text branch December 9, 2021 22:04
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jan 25, 2022

This branch was previously deployed

1 inactive deployment
Preview — fd52f46e Deployed Dec 9, 2021 by vercel[bot]
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.

3 participants