PSD and spectrogram plotting with GMT

Hi,
I intend to plot computed PSD and spectrogram using text files but i seem not to be getting the main resource to achieve it. I will be happy and grateful to get some support from this great community.

If I understand you correctly you have already computed PSD externally and just want to plot it? That can be done with plot I would think, but cannot advice further since I dont know what your file looks like.
Alternatively, spectrum1d computes PSD and has documentation on what the output is, which then is typically plotted with plot. Gallery example 3 shows some aspects of this (part of a much more elaborate example).

Thank you for your reply @pwessel.

data.txt (12.3 KB)
I have been able to plot a Spectrogram using the code below, but I don’t know why the output is not covering the whole y(period) range 0.01 - 100
new_plot.ps (33.2 KB)

==============================code
#!/bin/csh

set plotfile = new_plot.ps

gmt set FONT_LABEL 12p
gmt set FONT_ANNOT_PRIMARY 10p
gmt set FONT_ANNOT_SECONDARY 10p
gmt set PS_PAGE_ORIENTATION portrait
gmt set PS_MEDIA a4
gmt makecpt -Cjet -T-180/-90/10 >! pixel.cpt

gmt set FORMAT_DATE_IN yyyy-mm-dd FORMAT_DATE_MAP o
gmt set FORMAT_TIME_PRIMARY_MAP abbreviated PS_CHAR_ENCODING ISOLatin1+

awk ‘{if ($4 > -99999 && $4 < 0)print $1"T"$2,$3,$4}’ data.txt >! grd_A.dat
gmt xyz2grd grd_A.dat -Ggrd_A.grd -I250+/100+ -R2012-05-09T/2012-09-22T23:30:00/0.01/100

gmt set FORMAT_DATE_MAP u TIME_WEEK_START Sunday FORMAT_TIME_SECONDARY_MAP Chararacter
gmt grdimage grd_A.grd -R -JX14c/6.5cl -Bpxa3Kf1k+l"Date" -Bpy10f3+l"Period (s)" -BSWne+t"BHZ_Spectrogram" -Bsx1r -Cpixel.cpt -K >! $plotfile

gmt psscale -Cpixel.cpt -Dx14.2c/0+v+w6/0.3 -Ba20:“Amplitude”: -O >> $plotfile

open -a Preview new_plot.ps

Probably because you do not have much points between periods 10 and 100? Note you are using a log scale so the linear grid has to be resampled and your increments are perhaps funny (100 points between 0.1 and 100). You can try adding -nn to grdimage to just bypass spline interpolation and see the nearest node points as a clue. Hard to tell - and your data file covers Oct not like your script.