;***** Sample IDL code for reading GOES SEM data from a NetCDF file ;***** version date 2011-07-27 ;***** http://ngdc.noaa.gov/stp/satellite/goes/dataaccess.html ;***** If you would like to dump NetCDF attributes to a text file use something like this: ;***** http://www.atmos.umd.edu/~gcm/usefuldocs/hdf_netcdf/ncdfshow.html pro ReadGoesNetCDF COMPILE_OPT IDL2 ;***** ***** You can change input file designation here and the field_name to use in the example file_path = 'D:/IDL_Projects/ReadGoesNetCDF/' file_name = file_path + 'g15_xrs_2s_20110509_20110509.nc' ;file_url = "http://satdat.ngdc.noaa.gov/sem/goes/data/new_full/2011/05/goes15/netcdf/g15_xrs_2s_20110509_20110509.nc" field_name = 'B_FLUX' ;***** ***** print print, '***** ReadGOESNetCDF says ' print, '***** file_name =', file_name print, '***** field_name = ', field_name print ;***** Open the NetCDF file fileId = NCDF_OPEN(file_name) ;***** get an array containing all time_tag values NCDF_VARGET, fileId, 'time_tag', time_tag_array help, time_tag_array ;***** determine the size of the time_tag_array size_array = SIZE(time_tag_array) max_dim = size_array[1] print, 'Record count =', max_dim print ;***** convert time_tag_array to julian day time_tag_array = JULDAY(1, 1, 1970, 0, 0, time_tag_array/1000.0) help, time_tag_array print, 'time_tag_array[0] =', convertJulianToString(time_tag_array[0]) print, 'time_tag_array[', max_dim-1, '] =', convertJulianToString(time_tag_array[max_dim-1]) print ;***** get an array containing all data for this field NCDF_VARGET, fileId, field_name, data_array ;help, "help says ", data_array print, 'data_array[0] =', data_array[0] print, 'data_array[', max_dim-1, '] =', data_array[max_dim-1] print ;***** get a few attributes for this variable NCDF_ATTGET, fileId, field_name, 'description', description NCDF_ATTGET, fileId, field_name, 'plot_label', plot_label NCDF_ATTGET, fileId, field_name, 'units', units NCDF_ATTGET, fileId, field_name, 'nominal_min', nominal_min NCDF_ATTGET, fileId, field_name, 'nominal_max', nominal_max NCDF_ATTGET, fileId, field_name, 'lin_log', lin_log NCDF_ATTGET, fileId, field_name, 'missing_value', missing_value print, field_name, '.description=', string(description) plot_label = string(plot_label) print, field_name, '.plot_label=', plot_label units = string(units) print, field_name, '.units=', units nominal_min = float( string(nominal_min) ) print, field_name, '.nominal_min=', nominal_min nominal_max = float( string(nominal_max) ) print, field_name, '.nominal_max=', nominal_max missing_value = long( string(missing_value) ) print, field_name, '.missing_value=', missing_value yMinValue = missing_value + 1 ylog=0 if( strcmp(lin_log, 'log') ) then begin ylog=1 endif print, field_name, '.lin_log=', lin_log print ;***** generate a plot date_label = LABEL_DATE(DATE_FORMAT = ['%Y %M %D %Hh']) time_tag_array = time_tag_array xrange = [ time_tag_array[0], time_tag_array[max_dim-1] ] yrange = [ nominal_min, nominal_max ] loadct, 5 plot, time_tag_array, data_array, /nodata, $ xrange=xrange, yrange=yrange, xstyle=1, $ ylog=ylog, $ MIN_VALUE=yMinValue, $ title = file_name, $ xtitle = "UT", $ ymargin = [9,4], $ ytitle = plot_label + " " + units, $ XTICKFORMAT=['LABEL_DATE'], $ XTICKUNITS= ['time'] oplot, time_tag_array, data_array, color = 200 NCDF_CLOSE, fileId print, 'done' END ;************************************ ; convert julian day to date time string yyyy-mm-dd hh:mm:ss.sss ; ;************************************ function convertJulianToString, julianDay CALDAT, JulianDay, Month, Day, Year, Hour, Minute, Second dateTimeString = $ strtrim(string(year),2) + '-' + $ strtrim(string(month,format="(I2.2)" ),2) + '-' + $ strtrim(string(Day,format="(I2.2)" ),2) + ' ' + $ strtrim(string(Hour, format="(I2.2)"),2) + ":" + $ strtrim(string(Minute, format="(I2.2)"),2) + ":" + $ strtrim(string(Second, format="(F6.3)"),2) ;print, "gsp_convertJulianToString says :", dateTimeString return, dateTimeString end