Search code examples
idl-programming-language

Read values from multiple files in IDL


I have several files from which I'm trying to extract variables for brightness temperature, BT. I want to put all the variables into one array. This is what I have and so far. I've opened all the files but I can't figure out how to combine all the values.

filelist = FINDFILE(in_path+"ATMS-v11r1_npp_s"+date_str+"*nc",count=nfiles)

FOR i = 0, nfiles -1 DO BEGIN

PE1_fid=NCDF_OPEN(filelist(i))
field = 'BT'
NCDF_VARGET, pe1_fid, field, pe1_data

ENDFOR

Solution

  • With IDL version 8 or later you can simplify the code a bit, independent how many entries each of the e1_data fields contains:

    filelist = FILE_SEARCH(in_path + 'ATMS-v11r1_npp_s' + date_str + '*nc', count=nfiles)
    
    bt = []
    FOR i = 0,nfiles-1 DO BEGIN
      pe1_fid = = ncdf_open(filelist[i])
      field = 'BT'
      ncdf_varget, pe1_fid, field, e1_data
      bt = [bt, e1_data]
    ENDFOR