comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: linfit with string time array (x)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: linfit with string time array (x) [message #63425] Tue, 11 November 2008 05:39 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I will point out that if you like JULDAY and use it,
> sooner or later it is going to confuse you. It confused
> me so much I apparently wrote two articles about the
> problem. Take your pick:
>
> http://www.dfanning.com/misc_tips/julday.html
> http://www.dfanning.com/misc_tips/julianday.html

Well, one of those articles was written by Mark
Had field. (The best one). Probably why I didn't remember it in
the first place. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: linfit with string time array (x) [message #63426 is a reply to message #63425] Tue, 11 November 2008 05:36 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer writes:

> If you like julday just use julday. :)

I will point out that if you like JULDAY and use it,
sooner or later it is going to confuse you. It confused
me so much I apparently wrote two articles about the
problem. Take your pick:

http://www.dfanning.com/misc_tips/julday.html
http://www.dfanning.com/misc_tips/julianday.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: linfit with string time array (x) [message #63430 is a reply to message #63426] Tue, 11 November 2008 00:51 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
julia.walterspiel@gmail.com schrieb:
> On 11 Nov., 06:45, l...@lbnc.de wrote:
>> On 10 Nov, 16:43, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
>>
>>
>>
>>> if the numbers are written in a time format it is better to show an
>>> example. Those need to be converted into a number. I would suggest to
>>> use julian seconds (seconds since 2000-01-01 00:00:00 UTC)
>> But why?! Why go through the bother when IDL has JULDAY and CALDAT?
>> With the LABEL_DATE function you get nice annotations of axes and you
>> don't need to worry about whether the routines you download somewhere
>> of the web are actually right.
>>
>> To answer the original question, as Reimar alrady said, you need to
>> convert the strings to some sort of numeric value, for example julian
>> day. For that you need to parse the year, month, day, hour, minute,
>> second from your string and pass the to, for example, JULDAY. The IDL
>> documentation knows more about how to use JULDAY and LABEL_DATE.
>>
>> Cheers
>> Lasse Clausen
>
> hi guys
> well I thought I had already converted the string to some sort of
> numeric value but I guess it was just the problem of doing what Reimar
> said (new = double(date)). here's how I extracted my date from the
> file name:
>
> date = STRMID(filename_short, 10,7)
> year = Fix(StrMid(StrTrim(date,2), 0, 4))
> dayofyear = Fix(StrMid(StrTrim(date,2), 4, 3))
> CALDAT, JULDAY(1, dayofyear, year), month, day
> date = julday(month, day, year)
>
> --> then my date of data looks like this: 2451605


IDL> date = julday(1, 1, 2008)
% Compiled module: JULDAY.
IDL> print,date
2454467
IDL> help,date
DATE LONG = 2454467


If you use help you get the type of the var. It is of type long not string.

If you haven't read the article
http://www.dfanning.com/math_tips/sky_is_falling.html
it is quite interesting to see how a computer knows a number.

>
> That's what confuses me; a number that is obviously considered a
> string. so I guess IDL doesn't take the "number" but rather what is
> behind the calculation (julday) and refers to that as a string? Or am
> I misunderstanding something?
> It works fine when I convert it to double, so thanks for that input. I

you are welcome


cheers
Reimar
Re: linfit with string time array (x) [message #63431 is a reply to message #63430] Tue, 11 November 2008 00:38 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
lbnc@lbnc.de schrieb:
> On 10 Nov, 16:43, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
>> if the numbers are written in a time format it is better to show an
>> example. Those need to be converted into a number. I would suggest to
>> use julian seconds (seconds since 2000-01-01 00:00:00 UTC)
>
> But why?! Why go through the bother when IDL has JULDAY and CALDAT?
> With the LABEL_DATE function you get nice annotations of axes and you
> don't need to worry about whether the routines you download somewhere
> of the web are actually right.

Well you have to write your own tests for nearly everything you use or
program by your own (or have been by others). A simple doctest example
in the code does help a lot. (idl has no unittest framework)
Sometimes you should use a calculator or/and look into some book of
tables. And if you look into books it is better to not believe only on
one book. ;)

I never have seen any unit tests by idl developing team in the last 15
years. But I have send them some test examples for every bug I found. So
we can assume they do unittests. But they are not part of the product.

Sometimes it is better to use your own well tested routine. ;)

>
> To answer the original question, as Reimar alrady said, you need to
> convert the strings to some sort of numeric value, for example julian
> day. For that you need to parse the year, month, day, hour, minute,
> second from your string and pass the to, for example, JULDAY. The IDL
> documentation knows more about how to use JULDAY and LABEL_DATE.

If you like julday just use julday. :)

cheers
Reimar
Re: linfit with string time array (x) [message #63432 is a reply to message #63431] Tue, 11 November 2008 00:28 Go to previous messageGo to next message
julia.walterspiel is currently offline  julia.walterspiel
Messages: 35
Registered: July 2008
Member
On 11 Nov., 06:45, l...@lbnc.de wrote:
> On 10 Nov, 16:43, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
>
>
>
>> if the numbers are written in a time format it is better to show an
>> example. Those need to be converted into a number. I would suggest to
>> use julian seconds (seconds since 2000-01-01 00:00:00 UTC)
>
> But why?! Why go through the bother when IDL has JULDAY and CALDAT?
> With the LABEL_DATE function you get nice annotations of axes and you
> don't need to worry about whether the routines you download somewhere
> of the web are actually right.
>
> To answer the original question, as Reimar alrady said, you need to
> convert the strings to some sort of numeric value, for example julian
> day. For that you need to parse the year, month, day, hour, minute,
> second from your string and pass the to, for example, JULDAY. The IDL
> documentation knows more about how to use JULDAY and LABEL_DATE.
>
> Cheers
> Lasse Clausen

hi guys
well I thought I had already converted the string to some sort of
numeric value but I guess it was just the problem of doing what Reimar
said (new = double(date)). here's how I extracted my date from the
file name:

date = STRMID(filename_short, 10,7)
year = Fix(StrMid(StrTrim(date,2), 0, 4))
dayofyear = Fix(StrMid(StrTrim(date,2), 4, 3))
CALDAT, JULDAY(1, dayofyear, year), month, day
date = julday(month, day, year)

--> then my date of data looks like this: 2451605

That's what confuses me; a number that is obviously considered a
string. so I guess IDL doesn't take the "number" but rather what is
behind the calculation (julday) and refers to that as a string? Or am
I misunderstanding something?
It works fine when I convert it to double, so thanks for that input. I
Re: linfit with string time array (x) [message #63434 is a reply to message #63432] Mon, 10 November 2008 21:45 Go to previous messageGo to next message
lbnc is currently offline  lbnc
Messages: 15
Registered: January 2005
Junior Member
On 10 Nov, 16:43, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
>
> if the numbers are written in a time format it is better to show an
> example. Those need to be converted into a number. I would suggest to
> use julian seconds (seconds since 2000-01-01 00:00:00 UTC)

But why?! Why go through the bother when IDL has JULDAY and CALDAT?
With the LABEL_DATE function you get nice annotations of axes and you
don't need to worry about whether the routines you download somewhere
of the web are actually right.

To answer the original question, as Reimar alrady said, you need to
convert the strings to some sort of numeric value, for example julian
day. For that you need to parse the year, month, day, hour, minute,
second from your string and pass the to, for example, JULDAY. The IDL
documentation knows more about how to use JULDAY and LABEL_DATE.

Cheers
Lasse Clausen
Re: linfit with string time array (x) [message #63448 is a reply to message #63434] Mon, 10 November 2008 08:43 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

julia.walterspiel@gmail.com schrieb:
> hi
>
> i want to fit a line through my data with the linfit function but my x-
> axis is in string format. Is there a way to avoid transforming the
> string time array into non-string (e.g. other function which is as
> easy as linfit)?
>
> cheers
> juls

well you need floating point values.

and it is not difficult just write double(x) if you have many digits.

if the numbers are written in a time format it is better to show an
example. Those need to be converted into a number. I would suggest to
use julian seconds (seconds since 2000-01-01 00:00:00 UTC)

cheers
Reimar

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFJGGTF5aOc3Q9hk/kRAgZkAKCqoaj4km9s4V1tre57uVzPa19g5gCg tCPN
l9pwWZ9qIqW/e6Xb13C0vU8=
=Ed+7
-----END PGP SIGNATURE-----
Re: linfit with string time array (x) [message #63558 is a reply to message #63431] Tue, 11 November 2008 12:31 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Nov 11, 1:38 am, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
> program by your own (or have been by others). A simple doctest example
> in the code does help a lot. (idl has no unittest framework)

Nothing part of IDL's library, but I do have a unit testing framework:

http://michaelgalloy.com/2007/07/03/update-to-mgunit.html

By the way, do you have an automated way to run the doctest examples
you are talking about? I have thought about adding something like that
to IDLdoc.

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: usersym keywords -- why?
Next Topic: linfit with string time array (x)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:44:23 PDT 2025

Total time taken to generate the page: 0.00635 seconds