Gmt regress unsets -J and -R options for subsequent psxy

I wrote a script for GMT 6.0.0 basically:
gmt psbasemap -Jxparams -Rlimits -K > outfile
gmt psxy (simple dataset of x-y pairs) -Jx -R -O -K >> outfile
gmt regress -Fxm (on my simple dataset) | gmt psxy -Jx -R -O >> outfile

Normally the values of the “params” and “limits” given to -Jx and -R in the psbasemap call persist for subsequent calls if I just put “-Jx -R” as I have done for the first call to psxy. But for the call to psxy after the “gmt regress” I get the error message “psxy [ERROR]: Found no history for option -Jx”. If I insert the “params” after the -Jx but not the “limits” after the -R in the call to psxy after the “gmt regress” I get the error message “psxy [ERROR]: Found no history for option -R”. Only when I include the “params” and “limits” for both -Jx and -R does the script run to completion.

My demo script is below. If you invoke it with input value 1 it gives the first error message, with input value 2 it gives the second, and with input value 0 or anything else it runs to completion.

The data are rubbish but as far as I can tell, the regression is correct.

#! /bin/bash
# show that gmt regress needs -J and -R parameters repeated.
#
xscale="0.00000005T"
yscale=50.0
xmin="2003-01-01"
xmax="2018-01-01"
ymin=0.4
ymax=0.6
outf=testgmtregressbug.ps
noJnoR=$1
/bin/rm $outf
gmt psbasemap -Jx${xscale}/${yscale} -R${xmin}/${xmax}/${ymin}/${ymax} -Bpxf1Ya6Y+l"Year" -Bpyf0.02a0.1+l"amplitude" -BSWne+t"regression test" -K > $outf
gmt psxy -Jx -R -G0 -Sc0.1 -O -K <<EOF >>$outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
if [[ $noJnoR == 1 ]]; then
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx -R -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
elif [[ $noJnoR == 2 ]]; then
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx${xscale}/${yscale} -R -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
else
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx${xscale}/${yscale} -R${xmin}/${xmax}/${ymin}/${ymax} -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
fi

Your first psxy call does not have <<EOF to start with.

How bizarre! The EOF is in the running version (or it wouldn’t have worked). It should of course be between the “<” and the “>”… I know what happened! The Markup interpreter in the editing box on the Forum website interprets anything between “<” and “>” as a markup and deletes it if it doesn’t recognise it. Please assume that the EOF is where it should be!

Please, wrap your code under pairs of triple back ticks ```

Thanks, Joaquim - try this:

# show that gmt regress needs -J and -R parameters repeated.
#
xscale="0.00000005T"
yscale=50.0
xmin="2003-01-01"
xmax="2018-01-01"
ymin=0.4
ymax=0.6
outf=testgmtregressbug.ps
noJnoR=$1
/bin/rm $outf
gmt psbasemap -Jx${xscale}/${yscale} -R${xmin}/${xmax}/${ymin}/${ymax} -Bpxf1Ya6Y+l"Year" -Bpyf0.02a0.1+l"amplitude" -BSWne+t"regression test" -K > $outf
gmt psxy -Jx -R -G0 -Sc0.1 -O -K <<EOF >>$outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
if [[ $noJnoR == 1 ]]; then
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx -R -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
elif [[ $noJnoR == 2 ]]; then
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx${xscale}/${yscale} -R -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
else
gmt gmtregress -Fxm <<EOF | gmt psxy -Jx${xscale}/${yscale} -R${xmin}/${xmax}/${ymin}/${ymax} -W1 -O >> $outf
2003 0.476015
2004 0.479425
2005 0.505088
2006 0.511108
2007 0.511847
2008 0.498661
2009 0.533295
2010 0.535205
2011 0.528177
2012 0.551124
2013 0.618761
2014 0.468526
2015 0.479023
2016 0.462185
2017 0.477878
EOF
fi

I had already done it in your first post.

Your script runs fine in current master version.

If you give it the command line parameter 1 or 2, does it fail? i.e.
“scriptname 1” or “scriptname 2”?

No failures, runs fine with 0, 1 and 2.
We had changes regarding file locks that might had been responsible for the failures.

Joaquim - thanks very much - I’m still running 6.0.0: I don’t know if I can upgrade easily but presumably 6.1.0 has solved this problem so I will try.

Nope, that change in the file locks was after 6.1.0. But we’ll be issuing a 6.1.1 shortly.