Skip to content

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

Closed

Description

@hazardgoat

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

Activity

  1. added
    bug
    on Jul 3, 2021
  2. seisman commented on Jul 3, 2021

    @seisman
    Member

    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.

  3. seisman commented on Jul 3, 2021

    @seisman
    Member

    @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
    
    
  4. added
    upstream
    on Jul 3, 2021
  5. added this to the 0.5.0 milestone on Jul 3, 2021
  6. seisman commented on Jul 3, 2021

    @seisman
    Member

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

  7. weiji14 commented on Oct 13, 2021

    @weiji14
    Member

    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?

  8. modified the milestones: 0.5.0, 0.6.0 on Oct 13, 2021
  9. seisman commented on Jan 4, 2022

    @seisman
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugupstream

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions