#378 sub-second precision for %s timefmt parsing (seconds since Unix epoch)

None
closed-out-of-date
nobody
None
5
2014-02-01
2014-01-27
kxroberto
No

Feature request: sub-second (double flout) precision for timefmt %s parsing (seconds since Unix epoch ) - as %S already does for second fields.

I often have sub second UNIX time stamp columns with numbers like "1390816308.582"

Currently 'set timefmt "%s"' takes only full seconds an strips the fractional digits.

1 Attachments

Discussion

  • Ethan Merritt
    Ethan Merritt
    2014-01-27

    The "%s" format already does what you ask. (See attached demo file).
    I am guessing that whatever problem you are seeing comes at the stage of formatting the output, not the input.

    (Also note that strictly speaking you don't need a time format to read in raw seconds/usecs. It's just a floating point number like any other x coordinate).

     
  • Ethan Merritt
    Ethan Merritt
    2014-01-27

    • Group: -->
     
  • Ethan Merritt
    Ethan Merritt
    2014-01-28

    • status: open --> open-works-for-me
     
  • kxroberto
    kxroberto
    2014-01-28

    I tested your demo also. It allows the fractional digits in input file, but eats them as zero. See the output of your 'set table' demo. And when actually plotting, both in 'set term windows' and 'set term wxt', it shows the points snapped to full second positions, never at the real fractional positions.

    Its on Windows, latest version 4.6.3 - fresh from sf.

    When I provide data with a time stamp scheme like timefmt "...%H:%S" (...34:12.123) it works throughout with full resolution plots, but usually its inconvenient to provide such fidgety stringy formats.

    --- usecs.bug
    Warning: empty y range [1:1], adjusting to [0.99:1.01]

    gnuplot.exe usecs.bug

    Curve 0 of 1, 6 points

    Curve title: "'-' using 1:(1):2"

    x y label type

    "2014 Jan 27 19:56:47.000" 1 "A"
    "2014 Jan 27 19:56:47.000" 1 "B"
    "2014 Jan 27 19:56:47.000" 1 "C"
    "2014 Jan 27 19:56:47.000" 1 "D"
    "2014 Jan 27 19:56:48.000" 1 "E"
    "2014 Jan 27 19:56:50.000" 1 "F"

    --- usecs.bug data:
    1390852607.1 A
    1390852607.2 B
    1390852607.4 C
    1390852607.8 D
    1390852608.4 E
    1390852610.0 F


    gnuplot> show ver

        G N U P L O T
        Version 4.6 patchlevel 3    last modified April 2013
        Build System: MS-Windows 32 bit
    
        Copyright (C) 1986-1993, 1998, 2004, 2007-2013
        Thomas Williams, Colin Kelley and many others
    
        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help FAQ"
        immediate help:   type "help"  (plot window: hit 'h')
    

    Another real word test data snippet:

    1378829950.19 3688 3731 391 66 0 3705 3705 18116 9 773
    1378829955.22 3700 3731 386 75 0 3702 3705 31139 8 775
    1378829960.25 3705 3735 386 64 1 3710 3707 44159 8 776

     
  • kxroberto
    kxroberto
    2014-01-28

    (Also note that strictly speaking you don't need a time format to read in raw seconds/usecs. It's just a floating point number like any other x coordinate).

    Having something like set format x "%H:%M:S" then any combination of "set xdata time/unset xdata" and "set timefmt '%s'/unset timefmt" will either result in "Bad format character" or in snapping to full seconds. That doesn't work. (I also know from some past experiiment that gnuplot has a different time base from yr 2000 or so, not Unix epoch, inconveniently requiring extra math if it would work somehow).
    Only "set format x" solves perhaps the fractionals problem, but then you have no time format display at all but an absurd big number - you can't discern sub digit position anyway then.

     
    Last edit: kxroberto 2014-01-28
  • Ethan Merritt
    Ethan Merritt
    2014-01-28

    Aha. Thanks for showing the gnuplot version number.

    Yes, I can reproduce your output in version 4.6.3 but the test script works correctly in version 4.6.4 and in current CVS.

            G N U P L O T
            Version 4.6 patchlevel 4    last modified 2013-09-20 
            Build System: Linux i686
    
            Copyright (C) 1986-1993, 1998, 2004, 2007-2013
            Thomas Williams, Colin Kelley and many others
    
            gnuplot home:     http://www.gnuplot.info
            faq, bugs, etc:   type "help FAQ"
            immediate help:   type "help"  (plot window: hit 'h')
    
    Terminal type set to 'qt'
    gnuplot> load 'usecs.bug'
    
    # Curve 0 of 1, 6 points
    # Curve title: "'-' using 1:(1):2:xticlabels(1)"
    # x y label type
    "2014 Jan 27 19:56:47.100"  1  "A"
    "2014 Jan 27 19:56:47.200"  1  "B"
    "2014 Jan 27 19:56:47.400"  1  "C"
    "2014 Jan 27 19:56:47.800"  1  "D"
    "2014 Jan 27 19:56:48.400"  1  "E"
    "2014 Jan 27 19:56:50.000"  1  "F"
    

    And indeed, here is the relevant entry in ChangeLog:
    2013-07-02
    * src/time.c (gstrptime): Pass through fractional seconds read with
    time format "%s"

    Anyhow, your entirely reasonably feature request has already been implemented and is in the current release version (4.6.4).

    If you have any other requests/suggestions, feel free to add them.

    Ethan
    
     
    Last edit: Ethan Merritt 2014-01-28
  • kxroberto
    kxroberto
    2014-01-28

    Thanks, I wait until the gp Windows version is up to 4.6.4

     
  • Ethan Merritt
    Ethan Merritt
    2014-01-28

    Re: use of floating point input together with time-format output

    It depends on exactly what you are trying to plot. For many purposes the most convenient way to input fractional seconds and treat it as a full or partial date stamp is to use normal axis formats ("unset xdata") and filter the x coordinate values through strftime(x) to generate a string using time formats.

    FWIW gnuplot's internal epoch has been changed to match the standard unix epoch in the development version. But that change will not appear in a release package until version 5.

     
  • Ethan Merritt
    Ethan Merritt
    2014-02-01

    • status: open-works-for-me --> closed-out-of-date