Menu

#268 trouble with fit range on timedata

None
closed
nobody
None
5
2 days ago
2021-06-10
saucy
No

I added a related problem to the end of #256 but did not get a reply.

Having resolved my finger trouble and general senility issues, there remains a failure of fit when specifying a range in the fit command.

This intial fit and plot is fine:

30.03.21 117 79 63 1 89.4
31.03.21 108 72 66 2 87
01.04.21 103 69 69 3 86.4
02.04.21 116 72 69 4 85.7
03.04.21 120 73 67 5 86.2
04.04.21 116 72 59 6 85.5
05.04.21 108 65 59 7 84.5
06.04.21 113 66 53 8 84.2
07.04.21 101 73 59 9 83.2

set xdata time
formatstr="%d.%m.%y"

set timefmt formatstr         
datafile="sample.log"

plot datafile u 1:6 w l

lin(x)=m*(x-d0)+c
# cursor float for 1.6e9
d0=1.617e09;m=-.5/3600./24.;c=90; fit ["30.03.21":*] lin(x) datafile u 1:6 via m,c

plot datafile u 1:6 w l   #, lin(x)

If I set a range in the plot , it works.

plot ["30.03.21":"14.04.21"] datafile u 1:6  w l linecol rgb "gray" tit "flat battery" 

However, the same range on fit fails ( note the format of the range in the error is not "%d.%m.%y"

gnuplot> d0=1.617e09;m=-.5/3600./24.;c=90; fit ["30.03.21":"14.04.21"] lin(x) datafile u 1:6 via m,c
         Read 17 points
         Skipped 17 points outside range [x=30.03:14.04]
         No data to fit

If I leave the "max" arg empty or give it * , it works ( but it's obviously not the required range ).

["30.03.21":]
["30.03.21":*]

What am I missing ??

TIA.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2021-06-10

    I can reproduce this error in version 5.2.8 but these commands work without error in current gnuplot (version 5.4). So it must have been fixed in between version 5.2 and version 5.4.

    Work-around:
    It works in version 5.2 if you convert the time string to give a numerical range in the fit command :

    fit [strptime(formatstr,"30.03.21"):strptime(formatstr,"14.04.21")] lin(x) datafile u 1:6 via m,c
    
     
  • saucy

    saucy - 2021-06-10

    Priceless ! Thank you so much. In fact it is just the second arg which seems to present this bug.

    That work around is great. I was running a master build of gnuplot a few years back but I like to keep the number of non distro builds to a minimum.

    Many thanks for the rapid fix. That will see me through until Fed catches up to 5.4 :)

     
  • Ethan Merritt

    Ethan Merritt - 2 days ago
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.