Re: linfit with string time array (x) [message #63430 is a reply to message #63426] |
Tue, 11 November 2008 00:51   |
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
|
|
|