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

Home » Public Forums » archive » Re: code help
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: code help [message #75583] Thu, 31 March 2011 09:00
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
You should be able to do it with one histogram - if you have a day "jd" and a time in hours "hour", create a new index that is hours since midnight on the first day:

day0 = min(jd)
index = hour + (jd-day0)*24

and then histogram index. You can then reform the result into a number-of-days x 24 array.

-Jeremy.
Re: code help [message #75584 is a reply to message #75583] Thu, 31 March 2011 08:14 Go to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 31 mar, 14:22, smuzz <smussol...@gmail.com> wrote:
> Hi ---
>
> I am new to programming in IDL and am trying to write a code to avoid
> wasting hundreds of hours fighting with excel.
>
> My data: I have a .csv file with 2 columns. One column has the date
> (mm/dd/yyyy) and the second column has timestamps (hh:mm:ss). Each
> timestamp represents an incidence of a whale call occurrence. See
> below:
>
> 11/20/2007   00:00:53
> 11/20/2007   00:10:42
> 11/20/2007   00:17:50
> 11/20/2007   05:23:56
> 11/20/2007   05:00:10
> 11/20/2007   07:10:01
> 11/21/2007   01:20:23
> 11/21/2007   01:21:34
> ...........
>
> My objectives: I would like to sum the number of  whale call
> occurrences in each hour for the day (hours 0 - 23). Most days have
> hours without any whale call occurrences, so those are not accounted
> for in my .csv file above. Ideally for each day I am trying to get my
> data to look like this (including both absence and presence of whale
> call occurrences):
>
> 11/20/2007
> 0     3
> 1     0
> 2     0
> 3     0
> 4     0
> 5     2
> 6     0
> 7     1
> 8     0
> 9     0
> 10   0
> ....
> 23
>
> 11/21/2007
> 0
> 1
> 2
> 3
> ....
> 23
>
> Any suggestions would be greatly appreciated!
>
> Thanks, S

First transform your original string array in a julian day (double
precision) array, by using C formatting:
IDL> jd = dblarr(N_elements(your_string_array))
IDL> reads, your_string_array, jd, FORMAT='some_C_format'
in your case, some_C_format is
(C(CDI2,1x,CMOI2,1x,CYI4,3x,CHI2,1x,CMI2,1x,CSI2))
Then you can use the histogram function (with reverse indices) to sort
and count your data first by day, then by hours.
alx.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: read 12 bit array
Next Topic: Unable to create netCDF file

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

Current Time: Fri Oct 10 11:14:16 PDT 2025

Total time taken to generate the page: 1.91950 seconds