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

Home » Public Forums » archive » Re: newbie question.. again :)
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: newbie question.. again :) [message #35742] Thu, 10 July 2003 06:34
alex_panton is currently offline  alex_panton
Messages: 5
Registered: June 2003
Junior Member
thank you for you wonderful words of wisodom :) a couple of tweaks and
i now have a working program thank you so much !

cheers


alex



Timm Weitkamp <timm.weitkamp@nowhere> wrote in message news:<Pine.LNX.4.44.0307100404290.16258-100000@localhost.localdomain>...
> Alex,
>
> What follows below may or may not run like this (it should, but it's sort
> of late here now). But I hope it helps anyway.
>
> Timm
>
> <http://people.web.psi.ch/weitkamp>
>
>
> storeDir = 'g:\goes9_processed\btcloudfree\subtraction'
> cd, storeDir
> files02=findfile('*2.tiff', count=num02files)
>
> ; You want one single output .csv file, right? So you'll have to open it
> ; *outside* the loop that goes over the images
>
> outfilename = 'g:\test\out.csv'
> openw, uOut, /get_lun
>
> ; Now loop over all the Tiffs, and every time write one more line
> ; to the output file
>
> for y = 0, num02files-1 do begin
>
> ; Read your TIFF image in a 2D array
>
> tiff = read_tiff(files02[y])
>
> ; Extract a 5x5 region of interest
>
> radianceValues = tiff[145:145+4, 180:180+4]
>
> ; Calculate moments
>
> stats = MOMENT(radianceValues)
>
> ; Concatenate 5x5 image data and moments
> ; into one single 1D array. This will be
> ; the line to write to the .csv file.
>
> outValues = [radiancevalues[*], stats]
>
> ; How many numbers are there in that line?
> ; (need this information for the format code)
>
> nVal = N_ELEMENTS(outValues)
> formStr = '(' + STRTRIM(nVal,2) + '(F1, :,", "))'
>
> fileLine = STRING(outValues, FORMAT=formStr)
> printf, uOut, fileLine
>
> endfor
>
> free_lun, uOut
>
>
>
> On 09.07.03 at 14:12 -0700, Alexandra Panton wrote:
>
>> hey thanks for replying:) i didn't post my code 'cos its a bit on the
>> messy side bare in mind i have only been using this for about 2 weeks
>> ! I re read my post hmm, I have like 91 files, I want to extract the
>> same 5 by 5 area on each image. Put this all into one row (this is
>> cool can do this) what i can't do is get say, image2 to go into row 2
>> .. if that makes sense? .csv or anything really just want to be able
>> to export it to something evil like a spreadsheet :)
>>
>> here goes ....
>>
>> store=('g:\goes9_processed\btcloudfree\subtraction')
>> outstore=('g:\test')
>> cd, store
>> y=3
>> x=1
>> files02=findfile('*2.tiff', count=num02files)
>> print, num02files
>>
>>
>> while(num02files gt y) do begin
>> cd, store
>> InfileName02=files02(y)
>> print, Infilename02
>> ok=query_tiff(Infilename02) ;checks to see if the tiff file exists
>>
>> if (ok eq 1) then begin
>>
>> tiffread=read_tiff(Infilename02) ; reads tiff
>> storage_array=make_array(25,y ,/byte) ;my array that i want to
>> write to
>> radiancevalues=extrac(tiffread,145,180,5,5) ;extracts a 5 by 5
>> array from the coordinates given
>> radiancevalues=rebin(radiancevalues,25,1) ;puts it all on one line
>> len02=strlen(InfileName02)
>> striptext02=strmid(Infilename02,0,len02-7)
>> stats=moment(radiancevalues)
>> outname=striptext02+'test'+'.csv' ;configures the output filename
>> storage_array=radiancevalues[*] ;*trying* to get radiance values
>> into one array but can't get it to work *sighs*
>> cd, outstore
>> openw,1,outname, width=2000 ;opens outputfile
>>
>> for i=0,num02files-1 do begin
>> printf,1,storage_array,stats, format='(25(f,","),f)'
>> endfor
>> close,1
>> free_lun,1
>> ;endfor
>>
>> endif else begin
>> print, 'no matching file name found in directory'
>> endelse
>>
>> y=y+1
>> endwhile
>>
>> end
>>
>> ..and google groups messed up my format something chronic, my
>> apologies
>>
>> cheers for any help you can give
>>
>> alex
>>
>>
>>
>>
>>
>> Timm Weitkamp <timm.weitkamp@nowhere> wrote in message news:<Pine.LNX.4.44.0307091614210.15330-100000@localhost.localdomain>...
>>> Today at 09:31 -0400, Haje Korth wrote:
>>>
>>>> Alex,
>>>> I am not quite sure what you are trying to do and I for sure do not know
>>>> what a .csv file is
>>>
>>> I think a .csv file is a "comma-separated values" Ascii file.
>>>
>>>> but here is an idea: The area you extravt is a 2-d
>>>> array with dimensions xdim and ydim if rectangular. If I understand you
>>>> correctly your number of collumns x is xdim*ydim. In order to map the 2d
>>>> array into a 1d array, which is one row in your file, you use
>>>> 'reform(2d-array,xdim*ydim)'. In order to process all your files you just
>>>> loop through them.
>>>
>>> Or, even simpler (assuming that you want to map a 2D array "a" into a 1D
>>> array "b"): b = a[*].
>>>
>>> Alex: I understand you already wrote some code but it doesn't work as you
>>> would like it to. Would you mind posting it and pointing out to us the
>>> part where you're stuck?
>>>
>>> Timm
>>
Re: newbie question.. again :) [message #35745 is a reply to message #35742] Wed, 09 July 2003 20:24 Go to previous message
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
Alex,

What follows below may or may not run like this (it should, but it's sort
of late here now). But I hope it helps anyway.

Timm

<http://people.web.psi.ch/weitkamp>


storeDir = 'g:\goes9_processed\btcloudfree\subtraction'
cd, storeDir
files02=findfile('*2.tiff', count=num02files)

; You want one single output .csv file, right? So you'll have to open it
; *outside* the loop that goes over the images

outfilename = 'g:\test\out.csv'
openw, uOut, /get_lun

; Now loop over all the Tiffs, and every time write one more line
; to the output file

for y = 0, num02files-1 do begin

; Read your TIFF image in a 2D array

tiff = read_tiff(files02[y])

; Extract a 5x5 region of interest

radianceValues = tiff[145:145+4, 180:180+4]

; Calculate moments

stats = MOMENT(radianceValues)

; Concatenate 5x5 image data and moments
; into one single 1D array. This will be
; the line to write to the .csv file.

outValues = [radiancevalues[*], stats]

; How many numbers are there in that line?
; (need this information for the format code)

nVal = N_ELEMENTS(outValues)
formStr = '(' + STRTRIM(nVal,2) + '(F1, :,", "))'

fileLine = STRING(outValues, FORMAT=formStr)
printf, uOut, fileLine

endfor

free_lun, uOut



On 09.07.03 at 14:12 -0700, Alexandra Panton wrote:

> hey thanks for replying:) i didn't post my code 'cos its a bit on the
> messy side bare in mind i have only been using this for about 2 weeks
> ! I re read my post hmm, I have like 91 files, I want to extract the
> same 5 by 5 area on each image. Put this all into one row (this is
> cool can do this) what i can't do is get say, image2 to go into row 2
> .. if that makes sense? .csv or anything really just want to be able
> to export it to something evil like a spreadsheet :)
>
> here goes ....
>
> store=('g:\goes9_processed\btcloudfree\subtraction')
> outstore=('g:\test')
> cd, store
> y=3
> x=1
> files02=findfile('*2.tiff', count=num02files)
> print, num02files
>
>
> while(num02files gt y) do begin
> cd, store
> InfileName02=files02(y)
> print, Infilename02
> ok=query_tiff(Infilename02) ;checks to see if the tiff file exists
>
> if (ok eq 1) then begin
>
> tiffread=read_tiff(Infilename02) ; reads tiff
> storage_array=make_array(25,y ,/byte) ;my array that i want to
> write to
> radiancevalues=extrac(tiffread,145,180,5,5) ;extracts a 5 by 5
> array from the coordinates given
> radiancevalues=rebin(radiancevalues,25,1) ;puts it all on one line
> len02=strlen(InfileName02)
> striptext02=strmid(Infilename02,0,len02-7)
> stats=moment(radiancevalues)
> outname=striptext02+'test'+'.csv' ;configures the output filename
> storage_array=radiancevalues[*] ;*trying* to get radiance values
> into one array but can't get it to work *sighs*
> cd, outstore
> openw,1,outname, width=2000 ;opens outputfile
>
> for i=0,num02files-1 do begin
> printf,1,storage_array,stats, format='(25(f,","),f)'
> endfor
> close,1
> free_lun,1
> ;endfor
>
> endif else begin
> print, 'no matching file name found in directory'
> endelse
>
> y=y+1
> endwhile
>
> end
>
> ..and google groups messed up my format something chronic, my
> apologies
>
> cheers for any help you can give
>
> alex
>
>
>
>
>
> Timm Weitkamp <timm.weitkamp@nowhere> wrote in message news:<Pine.LNX.4.44.0307091614210.15330-100000@localhost.localdomain>...
>> Today at 09:31 -0400, Haje Korth wrote:
>>
>>> Alex,
>>> I am not quite sure what you are trying to do and I for sure do not know
>>> what a .csv file is
>>
>> I think a .csv file is a "comma-separated values" Ascii file.
>>
>>> but here is an idea: The area you extravt is a 2-d
>>> array with dimensions xdim and ydim if rectangular. If I understand you
>>> correctly your number of collumns x is xdim*ydim. In order to map the 2d
>>> array into a 1d array, which is one row in your file, you use
>>> 'reform(2d-array,xdim*ydim)'. In order to process all your files you just
>>> loop through them.
>>
>> Or, even simpler (assuming that you want to map a 2D array "a" into a 1D
>> array "b"): b = a[*].
>>
>> Alex: I understand you already wrote some code but it doesn't work as you
>> would like it to. Would you mind posting it and pointing out to us the
>> part where you're stuck?
>>
>> Timm
>
Re: newbie question.. again :) [message #35747 is a reply to message #35745] Wed, 09 July 2003 14:12 Go to previous message
alex_panton is currently offline  alex_panton
Messages: 5
Registered: June 2003
Junior Member
hey thanks for replying:) i didn't post my code 'cos its a bit on the
messy side bare in mind i have only been using this for about 2 weeks
! I re read my post hmm, I have like 91 files, I want to extract the
same 5 by 5 area on each image. Put this all into one row (this is
cool can do this) what i can't do is get say, image2 to go into row 2
.. if that makes sense? .csv or anything really just want to be able
to export it to something evil like a spreadsheet :)

here goes ....

store=('g:\goes9_processed\btcloudfree\subtraction')
outstore=('g:\test')
cd, store
y=3
x=1
files02=findfile('*2.tiff', count=num02files)
print, num02files


while(num02files gt y) do begin
cd, store
InfileName02=files02(y)
print, Infilename02
ok=query_tiff(Infilename02) ;checks to see if the tiff file exists

if (ok eq 1) then begin

tiffread=read_tiff(Infilename02) ; reads tiff
storage_array=make_array(25,y ,/byte) ;my array that i want to
write to
radiancevalues=extrac(tiffread,145,180,5,5) ;extracts a 5 by 5
array from the coordinates given
radiancevalues=rebin(radiancevalues,25,1) ;puts it all on one line
len02=strlen(InfileName02)
striptext02=strmid(Infilename02,0,len02-7)
stats=moment(radiancevalues)
outname=striptext02+'test'+'.csv' ;configures the output filename
storage_array=radiancevalues[*] ;*trying* to get radiance values
into one array but can't get it to work *sighs*
cd, outstore
openw,1,outname, width=2000 ;opens outputfile

for i=0,num02files-1 do begin
printf,1,storage_array,stats, format='(25(f,","),f)'
endfor
close,1
free_lun,1
;endfor

endif else begin
print, 'no matching file name found in directory'
endelse

y=y+1
endwhile

end

..and google groups messed up my format something chronic, my
apologies

cheers for any help you can give

alex





Timm Weitkamp <timm.weitkamp@nowhere> wrote in message news:<Pine.LNX.4.44.0307091614210.15330-100000@localhost.localdomain>...
> Today at 09:31 -0400, Haje Korth wrote:
>
>> Alex,
>> I am not quite sure what you are trying to do and I for sure do not know
>> what a .csv file is
>
> I think a .csv file is a "comma-separated values" Ascii file.
>
>> but here is an idea: The area you extravt is a 2-d
>> array with dimensions xdim and ydim if rectangular. If I understand you
>> correctly your number of collumns x is xdim*ydim. In order to map the 2d
>> array into a 1d array, which is one row in your file, you use
>> 'reform(2d-array,xdim*ydim)'. In order to process all your files you just
>> loop through them.
>
> Or, even simpler (assuming that you want to map a 2D array "a" into a 1D
> array "b"): b = a[*].
>
> Alex: I understand you already wrote some code but it doesn't work as you
> would like it to. Would you mind posting it and pointing out to us the
> part where you're stuck?
>
> Timm
Re: newbie question.. again :) [message #35751 is a reply to message #35747] Wed, 09 July 2003 07:28 Go to previous message
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
Today at 09:31 -0400, Haje Korth wrote:

> Alex,
> I am not quite sure what you are trying to do and I for sure do not know
> what a .csv file is

I think a .csv file is a "comma-separated values" Ascii file.

> but here is an idea: The area you extravt is a 2-d
> array with dimensions xdim and ydim if rectangular. If I understand you
> correctly your number of collumns x is xdim*ydim. In order to map the 2d
> array into a 1d array, which is one row in your file, you use
> 'reform(2d-array,xdim*ydim)'. In order to process all your files you just
> loop through them.

Or, even simpler (assuming that you want to map a 2D array "a" into a 1D
array "b"): b = a[*].

Alex: I understand you already wrote some code but it doesn't work as you
would like it to. Would you mind posting it and pointing out to us the
part where you're stuck?

Timm

--
Timm Weitkamp <http://people.web.psi.ch/weitkamp>
Re: newbie question.. again :) [message #35753 is a reply to message #35751] Wed, 09 July 2003 06:31 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Alex,
I am not quite sure what you are trying to do and I for sure do not know
what a .csv file is, but here is an idea: The area you extravt is a 2-d
array with dimensions xdim and ydim if rectangular. If I understand you
correctly your number of collumns x is xdim*ydim. In order to map the 2d
array into a 1d array, which is one row in your file, you use
'reform(2d-array,xdim*ydim)'. In order to process all your files you just
loop through them.

Haje

PS: I curse at IDL all the time, so don't feel bad! :-) (I still think it is
a great product though.)

--
Dr. Haje Korth
Space Physics Group
The Johns Hopkins University
Applied Physics Laboratory
MS MP3-E128
11100 Johns Hopkins Road
Laurel, MD 20723-6099
USA
Phone: 240-228-4033 (Washington), 443-778-4033 (Baltimore)
Fax: 240-228-0386 (Washington), 443-778-0386 (Baltimore)
e-mail: haje.korth@jhuapl.edu


"Alexandra Panton" <alex_panton@hotmail.com> wrote in message
news:dee4362e.0307090052.2ce7f506@posting.google.com...
> This is probably a really obvious question, but I can't find the
> answer to it anywhere :) and I have been cursing my computer, idl and
> the world in general for a couple of days so thought I'd see if anyone
> can help me out!
>
> all i want to do is extract the same area from 500+ images - this i
> can do fine but i want to add each extracted portion to the next line
> in an array so i can generate a .csv file with x columns and y rows =
> to the number of images. see very simple! I can generate the rows and
> columns ok just i get a file with all the same data
>
> if someone can help me out with what function i should be looking for
> i will be eternally grateful!
>
> cheers
>
> alex
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 6.0 release schedule
Next Topic: UNIX v. Windows Filepaths

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

Current Time: Fri Oct 10 08:37:35 PDT 2025

Total time taken to generate the page: 1.20254 seconds