I'm trying to load multiple images and want to automate the variable naming to make the variable name = the file input name
.
For example:
image1=read_binary('image1.img',DATA_START=0,DATA_TYPE=1,DATA_DIMS=[450, 750,3], ENDIAN=native)
Just wondering if this is possible and how?
Mike's @mgalloy answer is the best way to do this.
The others could have issues depending on your situation (e.g., if you have have a lot of files or need to run this in the Virtual Machine), but certainly work.
Before hashes, this is how I used to do it:
The
Scope_VarFetch
is the magic command that creates a variable with a particular name (given as a string), and assigns data to it. You can also retrieve variables in a similar manner.But, it's much easier to use some of the more modern features of IDL. That same code using hashes and a ForEach?
If order matters, you can use a ordered hash