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

Comment lines in text files not starting with a hash, get lost in GMTdataset #6737

Open
joa-quim opened this issue May 23, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@joa-quim
Copy link
Member

joa-quim commented May 23, 2022

The tut_quakes.ngdc starts with

Historical Tsunami Earthquakes from the NGDC Database

 Year Mo Da Lat+N Long+E   Dep Mag
 1987 01 04  49.77  149.29 489 4.1
...

If I read it to Julia the two comment lines are lost

julia> D = gmtread("@tut_quakes.ngdc", table=true);

julia> D.comment
2-element Vector{String}:
 ""
 ""

Adding # to the tut_... file

#Historical Tsunami Earthquakes from the NGDC Database

#Year Mo Da Lat+N Long+E   Dep Mag
 1987 01 04  49.77  149.29 489 4.1
...

now shows

julia> D.comment
2-element Vector{String}:
 "Historical Tsunami Earthquakes from the NGDC Database"
 "Year Mo Da Lat+N Long+E   Dep Mag"
@joa-quim joa-quim added the bug Something isn't working label May 23, 2022
@PaulWessel
Copy link
Member

The GMT doc example using that file uses -h3 to tell GMT that there are 3 non-standard record of header to consider. For example, this command works fine:

gmt convert @tut_quakes.ngdc -h3 
# Historical Tsunami Earthquakes from the NGDC Database
# 
# Year Mo Da Lat+N Long+E   Dep Mag
# Command : gmt gmtconvert /Users/pwessel/.gmt/cache/tut_quakes.ngdc -h3
1987    1       4       49.77   149.29  489     4.1
...

@joa-quim
Copy link
Member Author

But they are comment lines (they are skipped automatically), so should show up in D.comment, as they do if prefixed with a #

@PaulWessel
Copy link
Member

Well, yes and no. They are not comment lines as GMT sees it. So what you propose would not be backwards compatible behavior. I think after I introduced the gmtio_examine_current_record function we may handle such records better than in the past (when that command without -h3 would complain and exit). So not sure what you want to do here? Eliminate -h entirely?

@joa-quim
Copy link
Member Author

Remember that this started with the idea that Matlab wanted a % sign to signal a comment, but *nix wants a # and batch a REM so what about accepting anything that's a string to mean a comment? But now (and then) are comments different from headers?

I don't particularly care about this issue. Just seemed incomprehensible why some are considered comments and other not.

@joa-quim
Copy link
Member Author

joa-quim commented Jul 1, 2024

Funny that it only take -h1 to make it recognize all leading text lines as comments.

julia> gmtread("@tut_quakes.ngdc", table=true, h=1)
Comment:        ["Historical Tsunami Earthquakes from the NGDC Database", "Year Mo Da Lat+N Long+E   Dep Mag"]
BoundingBox: [1987.0, 1988.0, 1.0, 12.0, 1.0, 31.0, 35.02, 49.77, 132.29, 149.89, 10.0, 576.0, 4.0, 6.8]

115×7 GMTdataset{Float64, 2}
 Row │   Year    Mo    Da  Lat+N  Long+E    Dep  Mag
─────┼───────────────────────────────────────────────
   1 │ 1987.0   1.0   4.0  49.77  149.29  489.0  4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants