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

Home » Public Forums » archive » Re: reading ascii in array merging with strsplit
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: reading ascii in array merging with strsplit [message #52475] Thu, 08 February 2007 01:39
Andrea Pitacco is currently offline  Andrea Pitacco
Messages: 3
Registered: March 2004
Junior Member
On 6 Feb 2007 05:46:39 -0800, "leatherback"
<jelle.ferwerda@rmit.edu.au> wrote:

> Hi All,
>
> I use a template to read_ascii data of the following format:
>
> D9 6-2-1998 17:00 37,59 0,59 36,5
>
> Which returns a structure of arrays.
>
> However, the date (6-2-1998) and time (17:00) I need to convert to
> julian time, which takes
>
> JULDAY(Month, Day, Year, Hour, Minute, Second)
>
> I -could- for each entry in the list do a strsplit:
>
> daysarr = STRTRIM(strsplit(data.date[ThisLine], '-', /extract), 2)
> timearr = STRTRIM(strsplit(data.time[ThisLine], ':', /extract), 2)

Dear Jelle,
if you are heading to Julian time and your date&time timestamp is a
single string tag of an array of structures, you may conveniently read
and transform the whole vector using just using the native ReadS
instruction and an appropriate FORMAT.

As the online help "synthetically" writes, ReadS can act on a vector.
What is essential, is to provide it with a properly dimensioned
double-precision destination array:

jtime = DblArr(N_Elements(data))
ReadS, data.timestamp, jtime, FORMAT =
'(C(CYI,X,CMOI,X,CDI,X,CHI,X,CMI,X,CSI))'

Regards, Andrea


Andrea Pitacco
Dept. of Environmental Agronomy, University of Padova, Italy
Re: reading ascii in array merging with strsplit [message #52513 is a reply to message #52475] Tue, 06 February 2007 08:34 Go to previous message
leatherback is currently offline  leatherback
Messages: 15
Registered: November 2005
Junior Member
Hi Brian,

Thank you for that. One step closer to an efficient & working code.

Jelle.

Animal Behavior Research Group
Department of Zoology / University of Oxford
South Parks Road / Oxford / OX13PS
United Kingdom
Re: reading ascii in array merging with strsplit [message #52515 is a reply to message #52513] Tue, 06 February 2007 08:02 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Yes it does (I had to check)

IDL> print, anytim2jd(['6-2-1998 17:00', '6-3-1998 17:00'])
{ 2455765 0.20833333}{ 2455793 0.20833333}

The return is a little annoying but can be mitigated by simply adding
them together.

IDL> help, anytim2jd(['6-2-1998 17:00', '6-3-1998 17:00']), /str
** Structure <84bd97c>, 2 tags, length=12, data length=12, refs=1:
INT LONG 2455765
FRAC DOUBLE 0.20833333
IDL> jd = anytim2jd(['6-2-1998 17:00', '6-3-1998 17:00'])
IDL> jd = jd.int+jd.frac
IDL> help, jd
JD DOUBLE = Array[2]


I am sure you can write something easy as well but I always hate to
reinvent the wheel more than I have to.

Brian

------------------------------------------------------------ ---------------
Brian A. Larsen
Dept. of Physics
Space Science and Engineering Lab (SSEL)
Montana State University - Bozeman
Bozeman, MT 59717





On Feb 6, 7:51 am, "leatherback" <jelle.ferwe...@rmit.edu.au> wrote:
> Hey Brian,
>
> Thanks for your reply. Before I start installing all sort of material
> I do not need.. Does this solarsoft accept ARRAYS of dates too?
>
> Cheers,
>
> jelle.
Re: reading ascii in array merging with strsplit [message #52519 is a reply to message #52515] Tue, 06 February 2007 06:51 Go to previous message
leatherback is currently offline  leatherback
Messages: 15
Registered: November 2005
Junior Member
Hey Brian,

Thanks for your reply. Before I start installing all sort of material
I do not need.. Does this solarsoft accept ARRAYS of dates too?

Cheers,

jelle.
Re: reading ascii in array merging with strsplit [message #52520 is a reply to message #52519] Tue, 06 February 2007 06:46 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
I just did this yesterday. Depending on what idl libraries you have
installed this becomes trivial. Using the solarsoft library (http://
www.lmsal.com/solarsoft/ssw_install.html) there is a function that
makes this really easy. Unless you do solar physics, you should only
need the binaries check box (any maybe not ever that) making it
relatively small to download and install.

print, anytim2jd('6-2-1998 17:00')
{ 2455765 0.20833333}

I have gotten so used to solarsoft that I can no longer remember what
is solarsoft and what is standard idl as there are a heck of a lot of
routines for all sorts of things sin solarsoft.

Brian



------------------------------------------------------------ ---------------
Brian A. Larsen
Dept. of Physics
Space Science and Engineering Lab (SSEL)
Montana State University - Bozeman
Bozeman, MT 59717







On Feb 6, 6:46 am, "leatherback" <jelle.ferwe...@rmit.edu.au> wrote:
> Hi All,
>
> I use a template to read_ascii data of the following format:
>
> D9 6-2-1998 17:00 37,59 0,59 36,5
>
> Which returns a structure of arrays.
>
> However, the date (6-2-1998) and time (17:00) I need to convert to
> julian time, which takes
>
> JULDAY(Month, Day, Year, Hour, Minute, Second)
>
> I -could- for each entry in the list do a strsplit:
>
> daysarr = STRTRIM(strsplit(data.date[ThisLine], '-', /extract), 2)
> timearr = STRTRIM(strsplit(data.time[ThisLine], ':', /extract), 2)
>
> and create the julian day:
>
> Jul_Day = julday(daysarr[1],daysarr[0],daysarr[0],timearr[0],
> timearr[1], 0)
>
> This seems very elaborate if you repeat this hundreds of thousands of
> times. Is there a better solution to this? Can I somehow specify a
> template with multiple field separators?
>
> Thanks,
>
> Jelle.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL programmer wanted
Next Topic: Re: Strange IDL Help probelm 6.3

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

Current Time: Wed Oct 08 20:01:13 PDT 2025

Total time taken to generate the page: 0.00623 seconds