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

Home » Public Forums » archive » Re: read_ascii for many rows / possible to create automatic names for variables
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: read_ascii for many rows / possible to create automatic names for variables [message #57142 is a reply to message #57140] Wed, 05 December 2007 07:22 Go to previous messageGo to previous message
britta.mey is currently offline  britta.mey
Messages: 14
Registered: August 2007
Junior Member
On Dec 5, 3:48 pm, bmey <britta....@gmail.com> wrote:
> On Dec 5, 3:38 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>> bmey writes:
>>> i'm still a beginner in programming, therefore the next question.
>
>> I thought you might be. :-)
>
>>> When i read the whole array, how can i then proceed? I want to calculate
>>> for each pixel (each column) the arithmetic mean of the values and
>>> store these mean values as a new variable.
>
>> I would do something like this.
>
>> rows = File_Lines('myfile.dat')
>> Openr, lun, 'myfile.dat', /Get_Lun
>> line = ""
>> ReadF, lun, line
>> cols = N_Elements(StrSplit(line, ' ', /Extract))
>> Point_lun, lun, 0
>> data = FltArr(cols, rows)
>> ReadF, lun, data
>> Free_Lun, lun
>
>> colMeans = Total(data, 2) / rows
>
>> 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.")
>
> Hi,
>
> thaks. I'll try and hope i will manage this :-).
>
> Britta

Hi,

first i am happy that there didn't appear an error message (i am great
in producing syntax errors), therefore i did it copy correctly. :-)

But something seems to be wrong, because either IDL sorts the results
in a different order or (what makes more sense for me) i made a
mistake.

A part of the file looks like this, for example:

41.857.653 11 37 36.653 140 138 138 142 138
41.858.825 11 37 37.825 140 136 134 139 136
41.859.956 11 37 38.956 140 142 135 143 140
41.860.098 11 37 40.098 139 140 137 142 140
41.861.240 11 37 41.240 141 141 137 142 138
41.862.391 11 37 42.391 142 137 134 140 138
41.864.523 11 37 43.523 140 141 138 142 135
41.865.645 11 37 44.645 140 136 134 142 136
41.866.796 11 37 45.796 138 140 135 141 135
41.867.928 11 37 46.928 139 138 138 141 140
41.868.060 11 37 48.060 138 138 135 144 136
41.869.241 11 37 49.241 141 138 140 144 137
41.870.333 11 37 50.333 140 137 132 143 138
41.871.484 11 37 51.484 140 139 137 142 135
41.873.596 11 37 52.596 142 139 136 140 137
41.874.708 11 37 53.708 141 137 137 141 138
41.875.859 11 37 54.859 137 137 133 142 138
41.876.971 11 37 55.971 140 136 135 142 135
41.877.073 11 37 57.073 140 140 135 140 136
41.878.224 11 37 58.224 142 141 133 143 136
41.879.346 11 37 59.346 138 139 136 140 137
41.880.437 11 38 00.437 140 138 133 141 139
41.882.599 11 38 01.599 140 140 137 142 137
41.883.711 11 38 02.711 139 135 137 141 135
41.884.822 11 38 03.822 139 138 138 141 138
41.885.914 11 38 04.914 140 140 137 142 136


The first column are seconds, second column - hour, third - minutes,
fourth - seconds (if idl doesn't count column 2 to 4 as one column) ,
sixth to tenth - data output from the spectrometer. The result of
colMeans(6) should be approximately 136 (more or less :-), in the
original file there are a lot more columns and also more rows). For
print, colMeans(6) i obtain 1974.44. :-(

Is the value 2 in colMeans = Total(data, 2)/rows the number of
dimensions? Why do i use 2? To obtain a 1-dimensional array (scalar)
as a result?

I'm quite sure that these are really stupid questions for you, so
thank you for your patience.

Britta
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: array operations and memory consumption
Next Topic: pson + !p.multi + xyouts

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

Current Time: Sun Oct 12 15:03:39 PDT 2025

Total time taken to generate the page: 0.88170 seconds