octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59418] Document work-arounds for single-preci


From: Lars Kindermann
Subject: [Octave-bug-tracker] [bug #59418] Document work-arounds for single-precision OpenGL plots
Date: Sun, 8 Nov 2020 22:16:55 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Follow-up Comment #3, bug #59418 (project octave):

What do you think about this? Where should it be located in
doc/interpreter/plot.txi ?

The limitation to single precision in particular applies to plots of
timeseries against serial dates as used by the datenum(), datestr(),
datestruct(), and datetick() functions.

Serial dates encode timestamps as days elapsed since the year zero with hours,
minutes, seconds as the fractional part. On Dec. 31. 1999 the serial date
representation was 730485. A double precision variable with this integer part
allows for a resolution in its fractional part of 1.2e-10, representing about
5 microseconds. But with single precision this is reduced to about 0.06,
representing 45 minutes. Any attempt to plot timestamped data with finer
granularity will result in a distorted graph.

As a workaround one can subtract 2000 years, i.e. datenum(2000,0,0) or 730485
from the time values. Due to the fact that the calendar structure repeats
every 2000 years, the relation between year, month, day of month and day of
week will stay unchanged and the ticks and ticklabels produced by the
datetick() function will still be correct. Only years will lack the millennium
digit, thus "2020" will be printed as "20".

Just replace plot (t, x) with plot (t - 730485, x)

++
#timestamps of 24 hours in one minute steps
t = datenum(2020,1,1):(1/1440):datenum(2020,1,2);

#some example timeseries data
x = -cos(2*pi*t) + rand(size(t)) / 10;

subplot(1,2,1)
plot(t,x)
datetick x
xlabel "serial date"
title "problem"

subplot(1,2,2)
plot(t - 730485,x)
datetick x
xlabel "2000 years off"
title "workaround"
--


(file #50228)
    _______________________________________________________

Additional Item Attachment:

File name: ttest.png                      Size:26 KB
    <https://file.savannah.gnu.org/file/ttest.png?file_id=50228>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59418>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]