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

Home » Public Forums » archive » Unable to allocate memory: to make array for panchromatic file
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
Unable to allocate memory: to make array for panchromatic file [message #89180] Thu, 31 July 2014 00:40 Go to next message
phamlien24 is currently offline  phamlien24
Messages: 6
Registered: July 2014
Junior Member
I would like to create a file image from panchromatic image with the new image = the panchromatic *0.05678345/0.2846000 in IDL. However, the result has error:
% Unable to allocate memory: to make array.
Not enough space
% Execution halted at: Q_RAD_SIXSIN_GEN_P_221936 35

This is my code:

PRO q_rad_sixsin_gen_p_221936
ENVI, /RESTORE_BASE_SAVE_FILES
ENVI_BATCH_INIT, LOG_FILE='batch.txt'

input_dir = 'D:\BA34\Panchromatic\BA34_pan_221936_10oct25'
input_dir_name_lenght=STRLEN(input_dir)
imagelist=FILE_SEARCH('D:\BA34\Panchromatic\BA34_pan_221936_ 10oct25\*.tif',COUNT=count)

COMPILE_OPT IDL2
FORWARD_FUNCTION ENVI_GET_DATA, ENVI_GET_MAP_INFO

FOR h=0, count-1 Do Begin
path_filename=imagelist[h]


K_pan= 0.05678345

Pan_Width= 0.2846000

envi_open_file, imagelist[h], r_fid=fid,NO_REALIZE=1
ENVI_FILE_QUERY,fid,DIMS=dims,NS=ns,NL=nl,sname=sname
map_info=envi_get_map_info(fid=fid)
filenamelength=STRLEN(sname)
outname=STRMID(sname,0,filenamelength-4)
dims=[-1L, 0, ns-1, 0, nl-1]
pan = ENVI_GET_DATA(FID=fid,dims=dims,pos=0)
br=fltarr(ns,1,nl)
br = (pan *(K_pan)/(Pan_Width))*0.1
envi_write_envi_file, br, map_info=map_info, out_name=outname+'_rad.dat', r_fid=fid, interleave=1
envi_file_mng, id=fid, /remove


ENDFOR
END

Thanks so much for your help.

Lien
Re: Unable to allocate memory: to make array for panchromatic file [message #89181 is a reply to message #89180] Thu, 31 July 2014 01:07 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
Hi,

On 31.07.2014 09:40, phamlien24@gmail.com wrote:
> % Unable to allocate memory: to make array.
> Not enough space

try to "clean" your code.

Avoid declaring too many variables and either reassign the ones that are
not used anymore and pollute your memory or make use of temporary()

For example, this is bad:
IDL> ones = fltarr(5000,5000) + 1
IDL> twos = ones + 1

After these two statements you'll have two large arrays in memory even
if "ones" is not needed anymore. Two alternatives:

; Reassign
IDL> twos = fltarr(5000,5000) + 1
IDL> twos = twos + 1

; Temporary
IDL> ones = fltarr(5000,5000) + 1
IDL> twos = temporary(ones) + 1

To take an example of your code:

br=fltarr(ns,1,nl)
br = (pan *(K_pan)/(Pan_Width))*0.1

The first assignment is useless and memory expensive. Since IDL is
dynamically typed, there is absolutely no need to declare the variable
"br" since it will be overwritten on the next line.

Cheers,

Fabien
Re: Unable to allocate memory: to make array for panchromatic file [message #89183 is a reply to message #89180] Thu, 31 July 2014 01:27 Go to previous messageGo to next message
phamlien24 is currently offline  phamlien24
Messages: 6
Registered: July 2014
Junior Member
Thanks for your advice, Fabien. After deleting the code: br=fltarr(ns,1,nl). I can run IDL. However, the another problem occur. The resulting file have many bands such as : band 1, band 10, band 100, band 1000... It should be just only one band.

I don't know what I am wrong in the code.

Thanks for your consideration.

Lien
Re: Unable to allocate memory: to make array for panchromatic file [message #89184 is a reply to message #89180] Thu, 31 July 2014 01:47 Go to previous messageGo to next message
phamlien24 is currently offline  phamlien24
Messages: 6
Registered: July 2014
Junior Member
On Thursday, 31 July 2014 19:40:55 UTC+12, phaml...@gmail.com wrote:
> I would like to create a file image from panchromatic image with the new image = the panchromatic *0.05678345/0.2846000 in IDL. However, the result has error:
>
> % Unable to allocate memory: to make array.
>
> Not enough space
>
> % Execution halted at: Q_RAD_SIXSIN_GEN_P_221936 35
>
>
>
> This is my code:
>
>
>
> PRO q_rad_sixsin_gen_p_221936
>
> ENVI, /RESTORE_BASE_SAVE_FILES
>
> ENVI_BATCH_INIT, LOG_FILE='batch.txt'
>
>
>
> input_dir = 'D:\BA34\Panchromatic\BA34_pan_221936_10oct25'
>
> input_dir_name_lenght=STRLEN(input_dir)
>
> imagelist=FILE_SEARCH('D:\BA34\Panchromatic\BA34_pan_221936_ 10oct25\*.tif',COUNT=count)
>
>
>
> COMPILE_OPT IDL2
>
> FORWARD_FUNCTION ENVI_GET_DATA, ENVI_GET_MAP_INFO
>
>
>
> FOR h=0, count-1 Do Begin
>
> path_filename=imagelist[h]
>
>
>
>
>
> K_pan= 0.05678345
>
>
>
> Pan_Width= 0.2846000
>
>
>
> envi_open_file, imagelist[h], r_fid=fid,NO_REALIZE=1
>
> ENVI_FILE_QUERY,fid,DIMS=dims,NS=ns,NL=nl,sname=sname
>
> map_info=envi_get_map_info(fid=fid)
>
> filenamelength=STRLEN(sname)
>
> outname=STRMID(sname,0,filenamelength-4)
>
> dims=[-1L, 0, ns-1, 0, nl-1]
>
> pan = ENVI_GET_DATA(FID=fid,dims=dims,pos=0)
>
> br=fltarr(ns,1,nl)
>
> br = (pan *(K_pan)/(Pan_Width))*0.1
>
> envi_write_envi_file, br, map_info=map_info, out_name=outname+'_rad.dat', r_fid=fid, interleave=1
>
> envi_file_mng, id=fid, /remove
>
>
>
>
>
> ENDFOR
>
> END
>
>
>
> Thanks so much for your help.
>
>
>
> Lien

Thanks so much for your help, Fabien.
Re: Unable to allocate memory: to make array for panchromatic file [message #89191 is a reply to message #89180] Thu, 31 July 2014 04:26 Go to previous message
Josh Sixsmith is currently offline  Josh Sixsmith
Messages: 13
Registered: December 2012
Junior Member
Also, seeing as you are making use of the ENVI routines, why don't use the 'MATH_DOIT" routine to create your panchromatic array? It'll tile the array thereby using even less memory.

Josh
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Any alternatives of "circle" ('o') symbol using New Graphics?
Next Topic: Ellipse in (lon, lat)

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

Current Time: Wed Oct 08 15:14:42 PDT 2025

Total time taken to generate the page: 0.00598 seconds