Simple time-series with thresholds

A simple time-series of El Niño 3.4 index

code excerpt :

ENSO

gmt psxy -R$day1/$day2/-3/3 -JX16ct/9c enso_pos.txt -Sb1u+B$ensothd1p -Wfaint,$myred -P $open > $psENSO
gmt psxy -R -J enso_neg.txt -Sb1u+B$ensothd1m -Wfaint,$myblue $add >> $psENSO
gmt psxy -R -J $TSenso -W1.25,black $add >> $psENSO

gmt psxy -R -J -W1.25p,black $add <<EOF>> $psENSO
0 0
15000 0
EOF
gmt psxy -R -J -W1p,$myred,- $add <<EOF>> $psENSO
0 $ensothd1p
15000 $ensothd1p
EOF
gmt psxy -R -J -W1p,$myblue,- $add <<EOF>> $psENSO
0 $ensothd1m
15000 $ensothd1m
EOF
gmt psxy -R -J -W1p,$myred,. $add <<EOF>> $psENSO
0 $ensothd2p
15000 $ensothd2p
EOF
gmt psxy -R -J -W1p,$myblue,. $add <<EOF>> $psENSO
0 $ensothd2m
15000 $ensothd2m
EOF

gmt set FONT_ANNOT_PRIMARY 8p
gmt pslegend -R -J -DjBR -F $add <<EOF>> $psENSO
S 6p - 16p - 1.25p,black 24p SST anomaly
S 6p - 16p - 1p,$myred,- 24p +1 STD
S 6p - 16p - 1p,$myblue,. 24p -2 STD
G 3p
S 6p - 16p - 8p,$myred 24p El Niño
G 3p
S 6p - 16p - 8p,$myblue 24p La Niña
EOF
gmt set FONT_ANNOT_PRIMARY 12p

gmt psbasemap -R -J -Bya0.5f0.1+l"Temperature anomaly" -Bxa5Yf1Y+a45 -BWSen+t"ENSO (niño3.4) index" $close >> $psENSO

gmt psconvert -Tg -A $psENSO

Thanks for these examples, but could you please update the entire script that generate them? The idea here is not to show only the result but to allow also that others can reuse/modify the examples.

Hi,
If you’re asking on how to generate the points themselves, I didn’t do it with GMT. Most of the time I use MATLAB and export to netcdf or txt …

Then, a perfect target for a gmtmex script :wink:

I actually tried 2 years ago… and failed.
I could call “gmt” , but couldn’t plot anything. I haven’t tried again since.

You can try again. Post the difficulties in Q&A

Probably after osX next release, I need to do a cleansing of the system, especially the libraries (shared, brew, perso …)

I would appreciate if somebody could post a simple script to plot GPS time series with error bars in GMT 6.1.1. I am new to GMT and it is difficult for me to learn coding by the documentation. Thank you in advance!

Hi Anuar. Welcome. Error bars like the one of example 3? To plot things depends on your data file. Maybe it would be better if you create another issue with an example of your data file and your script (if you have one).

Hi Esteban! Thank you very much for your prompt response! I truly appreciate that! Yes, just like example 3 but with time along the x axis. I have actually tried just copy codes from the example 3 along with other examples and played around with different parameters to understand their purpose but could not succeed. Let me create a new issue with my current script and data as you suggested and elaborate on the challenges I am facing with. Thank you for your attention!

1 Like