How to inspect Datenum code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

How to inspect Datenum code

gciriani
I'm getting an error executing datenum, and I would like to inspect the code
to understand what's wrong with my data. How do I access the code please?

The error message is the following:
error: monthstart(1.5): subscripts must be either integers 1 to (2^31)-1 or
logicals
error: called from
    datenum at line 154 column 9
    datetick>__datetick__ at line 213 column 15
    datetick at line 56 column 5
    Brier at line 66 column 3



-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

NJank
On Wed, Sep 6, 2017 at 10:06 AM, gciriani <[hidden email]> wrote:
I'm getting an error executing datenum, and I would like to inspect the code
to understand what's wrong with my data. How do I access the code please?

>> edit datenum

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
In reply to this post by gciriani
Found the code at C:\Octave\Octave-4.2.1\share\octave\4.2.1\m\time\datenum.m

Now the hard part, understanding what goes wrong. The corresponding code
does the following
monthstart (mod (month-1,12) + 1)
and according to to the error message the subscript
mod (month-1,12) + 1
equates to 1.5



-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

NJank
On Wed, Sep 6, 2017 at 10:33 AM, gciriani <[hidden email]> wrote:
Found the code at C:\Octave\Octave-4.2.1\share\octave\4.2.1\m\time\datenum.m

Now the hard part, understanding what goes wrong. The corresponding code
does the following
monthstart (mod (month-1,12) + 1)
and according to to the error message the subscript
mod (month-1,12) + 1
equates to 1.5


hard to troubleshoot blind, if you're getting 1.5 out, then i guess you're putting 1.5 + n*12 in.  If that's not expected, then you need to see what you're passing

from you're previous email, i guess it's coming from your function Brier. 

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
I found a range of dates that causes the error. It might be a bug. Try the
following code which shows that dates greater than 21-Apr-2014 cause a
problem.




-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
This post was updated on .
In reply to this post by NJank
CONTENTS DELETED
The author has deleted this message.
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
This post was updated on .
Not sure what happened to the code I tried to embed previously, regardless
here it is, which shows a bug in datetick for dates greater than 21-Apr-2014.

%dates greater than 21-Apr-2014, cause error in datetick
x = [735621, 735710]; %21-Apr-2014, (serial date 735710)
datestr(x)
figure
plot(x, ones(size(x)))
datetick("x","mmmyy")

x (2) = x(2) + 1; %this date, 22-Apr-2014 and subsequent, causes a problem
datestr(x)
figure
plot(x, ones(size(x)))
datetick("x","mmmyy")





-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
Help-octave@gnu.org
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

Mike Miller-4
On Wed, Sep 06, 2017 at 13:05:36 -0700, gciriani wrote:
> Not sure what happened to the code I tried to embed previously, regardless
> here it is, which shows a bug in datetick for dates greater than

Yes, this is a bug in Octave 4.2.1. Fortunately it has already been
reported and fixed, so the next release of Octave, either 4.2.2 or 4.4,
will include a fixed datenum function.

See https://savannah.gnu.org/bugs/?50508 for details.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

NJank
In reply to this post by gciriani
On Wed, Sep 6, 2017 at 4:05 PM, gciriani <[hidden email]> wrote:
Not sure what happened to the code I tried to embed previously, regardless
here it is, which shows a bug in datetick for dates greater than
21-Apr-2014.




still no code.  I think you need make sure you're just copying/pasting the code as plain text. Otherwise the mailing list is stripping it out.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
NJank wrote
> ... still no code ...

I do see the code now. Previously I had used the raw text tag.


Mike Miller-4 wrote
> ...  the next release of Octave, either 4.2.2 or 4.4, will include a fixed
> datenum function ...

Do you mean a fixed datenum or a fixed datetick? To me it seems a datetick
bug.




-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

Mike Miller-4
On Wed, Sep 06, 2017 at 13:56:35 -0700, gciriani wrote:
> Do you mean a fixed datenum or a fixed datetick? To me it seems a datetick
> bug.

No, the bug is in datenum.

The datetick function figures out how to divide the time range into some
number of ticks.

When the time span is less than 3 months, it is divided evenly into some
intervals that make sense.

When the time span is more than 3 months, as in your example, it
attempts to divide the span into even intervals and may end up passing a
fractional month number into datenum to calculate those values.

The datenum function is now fixed to allow fractional month numbers when
given an array of time values, as in

    datenum ([2017 1 1; 2017 1.5 1; 2017 2 1])

This makes calculating ranges across some span of months easier.

If you want to work around this in Octave 4.2.1, you can use the
"keepticks" option to the datetick function to prevent it from
recalculating the tick intervals.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

Ozzy Lash


On Wed, Sep 6, 2017 at 4:20 PM, Mike Miller <[hidden email]> wrote:
On Wed, Sep 06, 2017 at 13:56:35 -0700, gciriani wrote:
> Do you mean a fixed datenum or a fixed datetick? To me it seems a datetick
> bug.

No, the bug is in datenum.

The datetick function figures out how to divide the time range into some
number of ticks.

When the time span is less than 3 months, it is divided evenly into some
intervals that make sense.

When the time span is more than 3 months, as in your example, it
attempts to divide the span into even intervals and may end up passing a
fractional month number into datenum to calculate those values.

The datenum function is now fixed to allow fractional month numbers when
given an array of time values, as in

    datenum ([2017 1 1; 2017 1.5 1; 2017 2 1])

This makes calculating ranges across some span of months easier.

If you want to work around this in Octave 4.2.1, you can use the
"keepticks" option to the datetick function to prevent it from
recalculating the tick intervals.

--
mike

The change to datenum.m that is in that bug report looks pretty simple to apply by hand, or you could download the current mercurial version of datenum.m http://hg.savannah.gnu.org/hgweb/octave/raw-file/92d60bf45889/scripts/time/datenum.m and replace your old version with it.

Bill

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to inspect Datenum code

gciriani
This post was updated on .
In reply to this post by Mike Miller-4
Mike Miller-4 wrote
> No, the bug is in datenum...

Thanks for clarifying that.

Ozzy Lash wrote
> ...download the current mercurial version of datenum.m
> http://hg.savannah.gnu.org/hgweb/octave/raw-file/92d60bf45889/scripts/time/datenum.m
> and replace your old version with it.

Thanks for pointing out the fix. Now my routine works without error. Problem solved.




-----
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
Help-octave@gnu.org
https://lists.gnu.org/mailman/listinfo/help-octave
Giovanni Ciriani - Windows 10, Octave 4.2.1, configured for x86_64-w64-mingw32