pro Read_NetCDF_File,filename,data,VNAMES=vnames,GATTS=gatts ;read JHU AMPERE project Net CDF data file, such as 20170907Amp_invert.ncdf NCDF_LIST, filename, /VARIABLES, VNAME=vnames print,vnames ;the variable names NCDF_GET, filename, vnames, ncvar, ERROR=errvar, FOUND=found, GATT=gatts, MISSING=missing ;, /QUIET, /STRUCT help,errvar help,ncvar , found, gatt, missing print,gatts ;ncvar is an IDL HASH containing the variables, retrieved using syntax: ; time=ncvar['time','value'] ;The EXECUTE function can be used to add all of them to a dictionary: nvar=n_elements(vnames) data=DICTIONARY() ;items can be added by name, using syntax: data.name=value for i=0,nvar-1 do begin ;the last three can be skipped if desired name=vnames[i] ;i.e., data.time=ncvar['time','value'] data[name]=ncvar[name,'value'] ;exestr="data."+name+"=ncvar['"+name+"','value']" ;print,exestr ;r=execute(exestr) ENDFOR END