X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 18 Jan 2012 02:02 PM by  anon
setting up 'data_ignore_value' in envi header in IDL code
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:23
New Member


--
18 Jan 2012 02:02 PM
    Hello, I have some code that masks user selected input files by a user selected mask and now I want to apply a 'data ignore value' of 0 to the output files. I'm trying this with the 'envi_setup_head' routine. I get an ENVI header file in any case without the part where I set up the header, but I cannot get the 'data ignore value' set to 0, as I want. If anyone can figure out the solution to modify the code below, it'd be wonderful. Thanks, Mike --------------------------------------------------------------------------------------------------------------------------- PRO ml_multiple_mask ;;****************************************** ;; Created by ML - May 26, 2011 ;; ;; This program applies a user-selected mask ;; to user-selected images. ;; ;; Input files can be selected from user- ;; specified directories and the output ;; files can be written to a specified ;; directory by modifying this code (see ;; comments throughout code for details). ;; ;;****************************************** ;ML set starting directory cd, 'C:\B_Working\IDL_forHoma_Jan18_2012' ; Select input files (Select all your images) files_list = DIALOG_PICKFILE(/READ,title ='Select input files',/multiple_files) ; Select the mask File mask_file = DIALOG_PICKFILE(/read, title = 'Select Mask File') ENVI_OPEN_FILE, mask_file, r_fid=m_fid ; Count the number of files num_files = N_elements (files_list) FOR count = 0, num_files-1 DO BEGIN ; Selects the n- file. Output file name is ; "input_file_name"+"-masked" (remove suffix .tif) in_file = files_list [count] out_file = file_basename(files_list [count], '.tif') +'_masked2' ENVI_OPEN_FILE, in_file, r_fid=fid IF (fid EQ -1 OR m_fid EQ -1) THEN RETURN ; get some useful information and set the output filename. ENVI_FILE_QUERY, fid, ns=ns, nl=nl, nb=nb, bname=bname ; Set the keyword parameters dims = [-1l, 0, ns-1, 0, nl-1] pos = LINDGEN(nb) m_pos = [0l] ; Call the 'doit' to apply the mask ENVI_MASK_APPLY_DOIT, fid=fid, pos=pos, dims=dims, m_fid=m_fid, $ m_pos=m_pos, value=0, out_name=out_file, in_memory=0, $ r_fid=r_fid ; Set up the Header to include the data ignore value [this is the part I think doesnt' quite work] ENVI_SETUP_HEAD, fname=out_file, data_ignore_value=0, interleave=0, offset=0, data_type=4, $ ns=ns, nl=nl, nb=nb, /write ENDFOR END

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    18 Jan 2012 02:25 PM
    Hi Mike, If you open up the resulting header file that you create with a text editor, do you see the data ignore value set? It would look something like: data ignore value = 1 If it is there, then you are writing it successfully to the header file. I don't see anything wrong with your code . However, since the mask_apply_doit is already producing a file with a header, you might try using the undocumented routine ENVI_CHANGE_HEAD, which can be used to change an existing header rather than writing a new one. For example, after the apply mask: envi_change_head, r_fid, data_ignore_value=0, /write Note that changing the header of an open file (or creating a new one) does not show up (if you go to Edit ENVI Header to find it) unless you remove the file and re-open it.

    Deleted User



    New Member


    Posts:23
    New Member


    --
    19 Jan 2012 07:12 AM
    Hi MariM, Thank you for your super quick reply and you were right on! The code actually does work, but I just looked at the initially loaded output files where the header change wasn't reflected in the ABL. However, after removing the files and reloading them into the ABL, the data ignore value was set correctly and that change could be seen also by simply opening the header files in a txt editor. Thanks again, Mike

    Deleted User



    New Member


    Posts:23
    New Member


    --
    19 Jan 2012 07:47 AM
    Hi again, I noticed with the ENVI_SETUP_HEAD I'm loosing the projection information (I guess I would have to specify it again with this routine). But using ENVI_CHANGE_HEAD is the best solution to add the data ignore value without loosing any other header information, plus the automatically loaded files already reflect the header change. Perfect! Thanks again, Mike
    You are not authorized to post a reply.