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

Home » Public Forums » archive » Re: IDL batch indexing
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: IDL batch indexing [message #59138] Tue, 11 March 2008 10:39 Go to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Beverly LaMarr schrieb:
> In article <b0bd3b46-ab67-4216-b3ff-dfbd88535fcb@s37g2000prg.googlegroups.com>,
> Raghu <raghuram.narasimhan@gmail.com> writes:
>> Hi all,
>>
>> I am writing a batch processing routine in order to do some querying.
>>
>> Steps:
>>
>> 1) Read in 30 images ( could be 60 or more..hence using batch)
>>
>> Since i am using a file_search method to read in all the files, i want
>> each file to be given a unique name or ID because i need to compare
>> them with each other. So, instead of reading in 30 files separately
>> and assigning variable names to them, i want to do it automatically
>> using a counter in a loop or something like that.
>>
>> Eg: if i=0 and numfiles=30,
>> i want to name the first file thats read b1, second file b2, third b3,
>> 30th as b30.
>> Once these are named, i want to be able to compare b1 to b2 or b3 to
>> b5 etc.
>> So, its not just about naming these files since that can be done with
>> a strmid function.
>>
>> my idea was something like
>>
>> names=file_search(*.img,count=numfiles)
>> while i lt numfiles
>> b[i]=names(i)
>>
>> I have tried it and it says b is not defined. I am guessing i cannot
>> name variables dynamically.
>>
>> I don't know if i am very clear about my problem.
>> Basically, i want to be able to assign unique variable names to each
>> file thats read so that i can use those unique IDs to query and
>> compare.
>>
>> Any ideas ? i can give more information or try to be clearer about my
>> problem if necessary.
>>
>> Raghu
>
>
>
> Hi,
>
> I think I know what you want - and it's something that I have to do too.
>
> You could try using execute:
>
> in your loop, read each file in as "infile" then
> res=execute(b[i]+'=infile')
>
>
> In the end you'll have a variable for each value of b[i].

>
>
> The other way to go, if all of the files have the same format, would be to use
> a structure like:
> alldata=replicate({name:a,data:fltarr(100,100)},numfiles)
> where you just replace the "fltarr(100,100)" bit with whatever your data looks
> like - you could even have it check the first file to figure the format on it's
> own.
> Then in your loop you just read into alldata[i].data
>
>
> Bev
>

Ah

if that is the case you may want to use a structure.
You can do something like


for i=0,5 do begin
tag = 'A'+strtrim(i,2)
if i eq 0 then struct=create_Struct(tag,i) else $
struct=create_Struct(struct, tag,i)
endfor

help,struct,/str
end



IDL> example
** Structure <78bff8>, 6 tags, length=12, data length=12, refs=1:
A0 INT 0
A1 INT 1
A2 INT 2
A3 INT 3
A4 INT 4
A5 INT 5



You can access each tag with it's position index e.g.
IDL> print, struct.(0) - struct.(1)
-1


You may want to avoid to use execute otherwise that will block you from
using your code with the virtual machine of idl.


cheers
Reimar
Re: IDL batch indexing [message #59148 is a reply to message #59138] Tue, 11 March 2008 08:16 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Mar 11, 2:06 am, metachronist <rkombi...@gmail.com> wrote:
> On Mar 11, 2:30 pm, Raghu <raghuram.narasim...@gmail.com> wrote:
>
>> Hi all,
>
>> I am writing a batch processing routine in order to do some querying.
>
>> Steps:
>
>> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
>> Since i am using a file_search method to read in all the files, i want
>> each file to be given a unique name or ID because i need to compare
>> them with each other. So, instead of reading in 30 files separately
>> and assigning variable names to them, i want to do it automatically
>> using a counter in a loop or something like that.
>
>> Eg: if i=0 and numfiles=30,
>> i want to name the first file thats read b1, second file b2, third b3,
>> 30th as b30.
>> Once these are named, i want to be able to compare b1 to b2 or b3 to
>> b5 etc.
>> So, its not just about naming these files since that can be done with
>> a strmid function.
>
>> my idea was something like
>
>> names=file_search(*.img,count=numfiles)
>> while i lt numfiles
>> b[i]=names(i)
>
>> I have tried it and it says b is not defined. I am guessing i cannot
>> name variables dynamically.
>
>> I don't know if i am very clear about my problem.
>> Basically, i want to be able to assign unique variable names to each
>> file thats read so that i can use those unique IDs to query and
>> compare.
>
>> Any ideas ? i can give more information or try to be clearer about my
>> problem if necessary.
>
>> Raghu
>
> this worked for me.
> --
> names=file_search('*.img',count=numfiles)
> b=strarr(numfiles)
> for i=0,numfiles-1 do b[i]=names[i]
> --
> /rk

or just
b=file_search('*.img',count=numfiles)

;^)
Re: IDL batch indexing [message #59150 is a reply to message #59148] Tue, 11 March 2008 05:49 Go to previous messageGo to next message
fergason is currently offline  fergason
Messages: 3
Registered: March 2008
Junior Member
In article <b0bd3b46-ab67-4216-b3ff-dfbd88535fcb@s37g2000prg.googlegroups.com>,
Raghu <raghuram.narasimhan@gmail.com> writes:
> Hi all,
>
> I am writing a batch processing routine in order to do some querying.
>
> Steps:
>
> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
> Since i am using a file_search method to read in all the files, i want
> each file to be given a unique name or ID because i need to compare
> them with each other. So, instead of reading in 30 files separately
> and assigning variable names to them, i want to do it automatically
> using a counter in a loop or something like that.
>
> Eg: if i=0 and numfiles=30,
> i want to name the first file thats read b1, second file b2, third b3,
> 30th as b30.
> Once these are named, i want to be able to compare b1 to b2 or b3 to
> b5 etc.
> So, its not just about naming these files since that can be done with
> a strmid function.
>
> my idea was something like
>
> names=file_search(*.img,count=numfiles)
> while i lt numfiles
> b[i]=names(i)
>
> I have tried it and it says b is not defined. I am guessing i cannot
> name variables dynamically.
>
> I don't know if i am very clear about my problem.
> Basically, i want to be able to assign unique variable names to each
> file thats read so that i can use those unique IDs to query and
> compare.
>
> Any ideas ? i can give more information or try to be clearer about my
> problem if necessary.
>
> Raghu



Hi,

I think I know what you want - and it's something that I have to do too.

You could try using execute:

in your loop, read each file in as "infile" then
res=execute(b[i]+'=infile')


In the end you'll have a variable for each value of b[i].


The other way to go, if all of the files have the same format, would be to use
a structure like:
alldata=replicate({name:a,data:fltarr(100,100)},numfiles)
where you just replace the "fltarr(100,100)" bit with whatever your data looks
like - you could even have it check the first file to figure the format on it's
own.
Then in your loop you just read into alldata[i].data


Bev
Re: IDL batch indexing [message #59153 is a reply to message #59150] Tue, 11 March 2008 01:38 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Raghu schrieb:
> Hi all,
>
> I am writing a batch processing routine in order to do some querying.
>
> Steps:
>
> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
> Since i am using a file_search method to read in all the files, i want
> each file to be given a unique name or ID because i need to compare
> them with each other. So, instead of reading in 30 files separately
> and assigning variable names to them, i want to do it automatically
> using a counter in a loop or something like that.
>
> Eg: if i=0 and numfiles=30,
> i want to name the first file thats read b1, second file b2, third b3,
> 30th as b30.
> Once these are named, i want to be able to compare b1 to b2 or b3 to
> b5 etc.
> So, its not just about naming these files since that can be done with
> a strmid function.
>
> my idea was something like
>
> names=file_search(*.img,count=numfiles)
> while i lt numfiles
> b[i]=names(i)
>
> I have tried it and it says b is not defined. I am guessing i cannot
> name variables dynamically.
>
> I don't know if i am very clear about my problem.
> Basically, i want to be able to assign unique variable names to each
> file thats read so that i can use those unique IDs to query and
> compare.
>
> Any ideas ? i can give more information or try to be clearer about my
> problem if necessary.
>
> Raghu

Hi

well they are already uniq by their index

names[0] is the first file
names[29] is the last one

cheers
Reimar
Re: IDL batch indexing [message #59154 is a reply to message #59153] Tue, 11 March 2008 00:06 Go to previous messageGo to next message
rkombiyil is currently offline  rkombiyil
Messages: 59
Registered: March 2006
Member
On Mar 11, 2:30 pm, Raghu <raghuram.narasim...@gmail.com> wrote:
> Hi all,
>
> I am writing a batch processing routine in order to do some querying.
>
> Steps:
>
> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
> Since i am using a file_search method to read in all the files, i want
> each file to be given a unique name or ID because i need to compare
> them with each other. So, instead of reading in 30 files separately
> and assigning variable names to them, i want to do it automatically
> using a counter in a loop or something like that.
>
> Eg: if i=0 and numfiles=30,
> i want to name the first file thats read b1, second file b2, third b3,
> 30th as b30.
> Once these are named, i want to be able to compare b1 to b2 or b3 to
> b5 etc.
> So, its not just about naming these files since that can be done with
> a strmid function.
>
> my idea was something like
>
> names=file_search(*.img,count=numfiles)
> while i lt numfiles
> b[i]=names(i)
>
> I have tried it and it says b is not defined. I am guessing i cannot
> name variables dynamically.
>
> I don't know if i am very clear about my problem.
> Basically, i want to be able to assign unique variable names to each
> file thats read so that i can use those unique IDs to query and
> compare.
>
> Any ideas ? i can give more information or try to be clearer about my
> problem if necessary.
>
> Raghu

this worked for me.
--
names=file_search('*.img',count=numfiles)
b=strarr(numfiles)
for i=0,numfiles-1 do b[i]=names[i]
--
/rk
Re: IDL batch indexing [message #59230 is a reply to message #59138] Fri, 14 March 2008 21:00 Go to previous message
raghuram is currently offline  raghuram
Messages: 32
Registered: February 2008
Member
On Mar 11, 10:39 am, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
> Beverly LaMarr schrieb:
>
>
>
>
>
>> In article < b0bd3b46-ab67-4216-b3ff-dfbd88535...@s37g2000prg.googlegroup s.com >,
>>  Raghu <raghuram.narasim...@gmail.com> writes:
>>> Hi all,
>
>>> I am writing a batch processing routine in order to do some querying.
>
>>> Steps:
>
>>> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
>>> Since i am using a file_search method to read in all the files, i want
>>> each file to be given a unique name or ID because i need to compare
>>> them with each other. So, instead of reading in 30 files separately
>>> and assigning variable names to them, i want to do it automatically
>>> using a counter in a loop or something like that.
>
>>> Eg: if i=0 and numfiles=30,
>>> i want to name the first file thats read b1, second file b2, third b3,
>>> 30th as b30.
>>> Once these are named, i want to be able to compare b1 to b2 or b3 to
>>> b5 etc.
>>> So, its not just about naming these files since that can be done with
>>> a strmid function.
>
>>> my idea was something like
>
>>> names=file_search(*.img,count=numfiles)
>>> while i lt numfiles
>>> b[i]=names(i)
>
>>> I have tried it and it says b is not defined. I am guessing i cannot
>>> name variables dynamically.
>
>>> I don't know if i am very clear about my problem.
>>> Basically, i want to be able to assign unique variable names to each
>>> file thats read so that i can use those unique IDs to query and
>>> compare.
>
>>> Any ideas ? i can give more information or try to be clearer about my
>>> problem if necessary.
>
>>> Raghu
>
>> Hi,
>
>> I think I know what you want - and it's something that I have to do too.
>
>> You could try using execute:
>
>> in your loop, read each file in as "infile" then
>> res=execute(b[i]+'=infile')
>
>> In the end you'll have a variable for each value of b[i].
>
>> The other way to go, if all of the files have the same format, would be to use
>> a structure like:
>> alldata=replicate({name:a,data:fltarr(100,100)},numfiles)
>> where you just replace the "fltarr(100,100)" bit with whatever your data looks
>> like - you could even have it check the first file to figure the format on it's
>> own.
>> Then in your loop you just read into alldata[i].data
>
>> Bev
>
> Ah
>
> if that is the case you may want to use a structure.
> You can do something like
>
> for i=0,5 do begin
>    tag = 'A'+strtrim(i,2)
> if i eq  0 then struct=create_Struct(tag,i) else $
>     struct=create_Struct(struct, tag,i)
> endfor
>
> help,struct,/str
> end
>
> IDL> example
> ** Structure <78bff8>, 6 tags, length=12, data length=12, refs=1:
>    A0              INT              0
>    A1              INT              1
>    A2              INT              2
>    A3              INT              3
>    A4              INT              4
>    A5              INT              5
>
> You can access each tag with it's position index e.g.
> IDL> print, struct.(0) - struct.(1)
>       -1
>
> You may want  to avoid to use execute otherwise that will block you from
> using your code with the virtual machine of idl.
>
> cheers
> Reimar- Hide quoted text -
>
> - Show quoted text -

Thanks people.
I think got a fairly good idea of how to go about it.
Will get back once it works. Seems like structures is the way to go.

Raghu
Re: IDL batch indexing [message #59254 is a reply to message #59154] Thu, 13 March 2008 09:09 Go to previous message
rkombiyil is currently offline  rkombiyil
Messages: 59
Registered: March 2006
Member
On Mar 11, 4:06 pm, metachronist <rkombi...@gmail.com> wrote:
> On Mar 11, 2:30 pm, Raghu <raghuram.narasim...@gmail.com> wrote:
>
>
>
>> Hi all,
>
>> I am writing a batch processing routine in order to do some querying.
>
>> Steps:
>
>> 1) Read in 30 images ( could be 60 or more..hence using batch)
>
>> Since i am using a file_search method to read in all the files, i want
>> each file to be given a unique name or ID because i need to compare
>> them with each other. So, instead of reading in 30 files separately
>> and assigning variable names to them, i want to do it automatically
>> using a counter in a loop or something like that.
>
>> Eg: if i=0 and numfiles=30,
>> i want to name the first file thats read b1, second file b2, third b3,
>> 30th as b30.
>> Once these are named, i want to be able to compare b1 to b2 or b3 to
>> b5 etc.
>> So, its not just about naming these files since that can be done with
>> a strmid function.
>
>> my idea was something like
>
>> names=file_search(*.img,count=numfiles)
>> while i lt numfiles
>> b[i]=names(i)
>
>> I have tried it and it says b is not defined. I am guessing i cannot
>> name variables dynamically.
>
>> I don't know if i am very clear about my problem.
>> Basically, i want to be able to assign unique variable names to each
>> file thats read so that i can use those unique IDs to query and
>> compare.
>
>> Any ideas ? i can give more information or try to be clearer about my
>> problem if necessary.
>
>> Raghu
>
> this worked for me.
> --
> names=file_search('*.img',count=numfiles)
> b=strarr(numfiles)
> for i=0,numfiles-1 do b[i]=names[i]
> --
> /rk

Well, Reimar is right. I have never used file_search, I always make
rather heavy use spawn along with the *inx "find" command for such
needs. I thought of it only as a programming error, in the sense 'b'
can be defined based on 'numfiles'. Anyway, my mistake, names is
already an array, heh..
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: WindowsXP IDLWorkbench hang issue
Next Topic: Re: Longstanding Map Overlay Problem Solved!

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

Current Time: Wed Oct 08 13:55:24 PDT 2025

Total time taken to generate the page: 0.00569 seconds