seis
1
Good afternoon. I am new to pygmt and I donot have more idea on how to plot the image something similar to this
using the data set provided here
Send large files up to 5GB for free
I hope experts may help me overcoming this problem.
Thanks in advance.
Could you share the first lines of your data file please?
seis
3
it looks like this
-5.241162737805681366e-06
-1.219235276324636313e-05
-1.562016048517405562e-05
-1.506173518941282077e-05
seis
5
mmm, it looks to me like a grid format but without header.
If your data is a grid, them you could use grdimage directly.
If your data is a table, them yoiu have to use xyz2grd first (and them grdimage).
seis
9
can you please share an example, how to do it.
Joaquim
10
The xyz2grd manual has several examples.
weiji14
11
The data file is missing labels and units, so not sure how to interpret the numbers, but this should give you a start:
import numpy as np
import pygmt
import xarray as xr
# Load 2D data
array = np.loadtxt(fname="data.txt")
assert array.shape == (750, 1500)
# Convert numpy.array to xarray.DataArray
dataarray = xr.DataArray(data=array)
# Plot figure
fig = pygmt.Figure()
fig.grdimage(
grid=dataarray, cmap="batlow", frame=["xaf+lTime [sec]", "yaf+lFrequency [Hz]"]
)
fig.colorbar(position="JMR")
fig.savefig(fname="freq_over_time.png")
fig.show()
gives
seis
12
Thank you @weiji14 for providing the demo.