>  Docs Center  >  ENVI API  >  Obsolete  >  MAGIC_MEM_CHECK



This routine is obsolete and should not be used in ENVI application programming interface (API) code.

MAGIC_MEM_CHECK is a memory management function. It should always be called before the processing function. It returns a structure containing the tags IN_MEMORY and OUT_NAME, which are then passed to the processing function (_DOIT).


Result = MAGIC_MEM_CHECK(DIMS=array, FID=file ID, /IN_MEMORY, NB=integer, OUT_NAME=value, OUT_DT={1 | 2 | 3 | 4 | 5 | 6 | 9 | 12 | 13 | 14 | 15})



The “dimensions” keyword is a five-element array of long integers that defines the spatial subset (of a file or array) to use for processing. Nearly every time you specify the keyword FID, you must also specify the spatial subset of the corresponding file (even if the entire file, with no spatial subsetting, is to be processed).

  • DIMS[0]: A pointer to an open ROI; use only in cases where ROIs define the spatial subset. Otherwise, set to -1L.
  • DIMS[1]: The starting sample number. The first x pixel is 0.
  • DIMS[2]: The ending sample number
  • DIMS[3]: The starting line number. The first y pixel is 0.
  • DIMS[4]: The ending line number

To process an entire file (with no spatial subsetting), define DIMS as shown in the following code example. This example assumes you have already opened a file using ENVI_SELECT or ENVI_PICKFILE:

  envi_file_query, fid, dims=dims


The file ID (FID) is a long-integer scalar with a value greater than 0. An invalid FID has a value of -1. The FID is provided as a named variable by any routine used to open or select a file. Often, the FID is returned from the keyword R_FID in the ENVIRasterToFID routine. Files are processed by referring to their FIDs. If you work directly with the file in IDL, the FID is not equivalent to a logical unit number (LUN).


Set this keyword to specify that output should be stored in memory. If you do not set IN_MEMORY, output will be stored on disk and you must specify OUT_NAME (see below).


Use this keyword to specify the number of bands in the output image.


Use this keyword to specify a string with the output filename for the resulting data. If you set the keyword IN_MEMORY, you do not need to specify OUT_NAME.


This keyword indicates the IDL data type of the output data. Set the keyword to one of the following integer values:

  • 1: Byte (8 bits)
  • 2: Integer (16 bits)
  • 3: Long integer (32 bits)
  • 4: Floating-point (32 bits)
  • 5: Double-precision floating-point (64 bits)
  • 6: Complex (2x32 bits)
  • 9: Double-precision complex (2x64 bits)
  • 12: Unsigned integer (16 bits)
  • 13: Unsigned long integer (32 bits)
  • 14: Long 64-bit integer
  • 15: Unsigned long 64-bit integer


After obtaining the processing parameters, call MAGIC_MEM_CHECK to ensure that in-memory items do not exceed the total cache size. After calling MAGIC_MEM_CHECK, use the values stored in M_RES.IN_MEMORY and M_RES.OUT_NAME for the in-memory processing flag or the output filename. if M_RES.CANCEL is set, then you have canceled the operation.

m_res=magic_mem_check(fid=fid,dims=dims, out_dt=1,$
  nb=n_elements(pos), out_name=result.outf.name,$
if (m_res.cancel) then return
in_memory = m_res.in_memory
out_name = m_res.out_name

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us