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

Possible text bug with fig.meca when plotting from a file #1367

Closed
Tracked by #1644
hazardgoat opened this issue Jul 3, 2021 · 5 comments
Closed
Tracked by #1644

Possible text bug with fig.meca when plotting from a file #1367

hazardgoat opened this issue Jul 3, 2021 · 5 comments
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Milestone

Comments

@hazardgoat
Copy link

hazardgoat commented Jul 3, 2021

Description of the problem
I think I may have run across a bug with fig.meca when attempting to plot from a file. Column names are being plotted in the bottom left corner, and the issue disappears when column names are removed from the file.

Full code that generated the error

import pygmt
import os

# Main File Path ----------------------------------
main_dir = r'C:\Users\USER\Desktop\TESTING'

# Save Path ----------------------------------
save_name = os.path.join(main_dir, 'Results', 'map_TEST.png')

# Focal Mechanism Path ----------------------------------    
focal_mecha = os.path.join(main_dir, 'Data', 'selected_fm.csv')


fig = pygmt.Figure()

fig.basemap(
    region = [-115.85, -115.35, 32.80, 33.38],
    projection = 'M6i',
    frame = True
)
fig.coast(
    land = 'grey',
    water = 'lightskyblue2',
)
fig.meca(
    spec = focal_mecha,
    convention = 'aki',
    scale = '1.0c',
    offset = True,
    )

fig.savefig(save_name)
print('done')

System information
PyGMT information:
version: v0.4.0
System information:
python: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
executable: C:\Users\USER\AppData\Local\Programs\Python\Python39\python.exe
machine: Windows-10-10.0.19043-SP0
Dependency information:
numpy: 1.21.0
pandas: 1.2.5
xarray: 0.18.2
netCDF4: 1.5.7
packaging: 20.9
ghostscript: 9.54.0
gmt: 6.2.0
GMT library information:
binary dir: C:/Users/USER/AppData/Local/Programs/Python/Python39
cores: 4
grid layout: rows
library path: c:/programs/gmt6/bin/gmt_w64.dll
padding: 2
plugin dir: c:/programs/gmt6/bin/gmt_plugins
share dir: c:/programs/gmt6/share
version: 6.2.0

My data:
selected_fm.csv

My map output:
map_TEST

@hazardgoat hazardgoat added the bug Something isn't working label Jul 3, 2021
@seisman
Copy link
Member

seisman commented Jul 3, 2021

It's not a bug. For text files with a header like

longitude	latitude	depth	strike	dip	rake	magnitude	offset_longitude	offset_latitude	label_mag

you have to tell GMT or PyGMT to skip the header.

@seisman
Copy link
Member

seisman commented Jul 3, 2021

@PaulWessel I'm wondering if meca can be more clever about these headers.

You can run the following command to reproduce the issue. You will see the "header line" appear at the lower left corner of the map:

gmt meca -Sa1c -R-116/-115/32.5/33.5 -Baf -pdf map << EOF
longitude	latitude	depth	strike	dip	rake	magnitude	offset_longitude	offset_latitude	label_mag
-115.52666 33.01917 10.11 314 85 -171 5.32 -115.52666 33.17
-115.52783 33.017 8.69 143 87 158 5.44 -115.52783 32.117
-115.6275 33.08567 9.29 158 86 -151 5.75 -115.6275 33.18567
-115.78167 33.08183 8.2 280 86 171 6.2 -115.78167 33.18183
-115.83434 33.01367 5.45 127 72 -159 6.6 -115.83434 33.11367
-115.634 33.14283 5.64 190,62 -106 5.11 -115.634 33.24283
EOF

But, it seems plot can skip the header line quietly.

gmt plot -R-116/-115/32.5/33.5 -Baf -Sc0.2c -pdf points << EOF
longitude	latitude	depth	strike	dip	rake	magnitude	offset_longitude	offset_latitude	label_mag
-115.52666 33.01917 10.11 314 85 -171 5.32 -115.52666 33.17
-115.52783 33.017 8.69 143 87 158 5.44 -115.52783 32.117
-115.6275 33.08567 9.29 158 86 -151 5.75 -115.6275 33.18567
-115.78167 33.08183 8.2 280 86 171 6.2 -115.78167 33.18183
-115.83434 33.01367 5.45 127 72 -159 6.6 -115.83434 33.11367
-115.634 33.14283 5.64 190,62 -106 5.11 -115.634 33.24283
EOF

@seisman seisman added the upstream Bug or missing feature of upstream core GMT label Jul 3, 2021
@seisman seisman added this to the 0.5.0 milestone Jul 3, 2021
@seisman
Copy link
Member

seisman commented Jul 3, 2021

This is caused by an upstream issue and has been fixed by GenericMappingTools/gmt#5427.

@weiji14
Copy link
Member

weiji14 commented Oct 13, 2021

So running conda install -c conda-forge/label/dev gmt=6.3.0 or building GMT from source (see https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md) should allow users to get the patched version of GMT.

Not sure if we need to add a test for this (probably not), but I think we can close this in PyGMT v0.6.0 once we bump the minimum GMT version to 6.3.0, agree?

@weiji14 weiji14 modified the milestones: 0.5.0, 0.6.0 Oct 13, 2021
@weiji14 weiji14 mentioned this issue Dec 4, 2021
31 tasks
@seisman
Copy link
Member

seisman commented Jan 4, 2022

I think we can close the issue without adding a test.

@seisman seisman closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Projects
None yet
Development

No branches or pull requests

3 participants