;+ pro test_read_tidi_data, verbose = verbose ;; ;; Open a TIDI line-of-sight file. (RAW-LOS, LOS-FIT & LOS-BCK also work) ;; open_tidi_file, ncid, date = 2002100, type = 'RAW-LOS', version = 'C' ;; ;; Get the TIDI global attributes from the opened file. ;; get_tidi_atts, atts, ncid = ncid help, atts, /structure ;; ;; Get the TIDI binning table information, if the file is a RETRIEVE product. ;; if ( atts.software_name eq 'RETRIEVE' ) then begin get_bin_info, ncid, bin_table_info help, bin_table_info, /structure print, 'binning id: ', bin_table_info.bin_table_id print, 'field size: ', bin_table_info.field_size endif ;; ;; Setting the requested time variable to zero ensures that you get ;; the first time of the file. ;; requested_time = 0L sc_lat = fltarr(1L) sc_lon = fltarr(1L) ;; ;; Read file until end of file is reached. ;; no_more_data = 1 while ( no_more_data ) do begin read_tidi_data, ncid, requested_time, tidi_rec, $ next_time, this_time, /mtime, end_of_file = end_of_file, err = err ;; ;; Read errors will normally appear in the very first read ;; if ( err ne 0 ) then begin print, 'An error reading the data has occurred.', err return endif ;; ;; The variable 'tidi_rec' now contains the records with a mission ;; time matching the first in the file. (In most LOS files, this means ;; that tidi_rec is a five element array of structures.) ;; if ( requested_time eq 0L ) then begin print, 'Read data for time = ',strtrim(string(this_time),2) help, tidi_rec if (KEYWORD_SET(verbose)) then help,tidi_rec,/struct ;View data structure endif if ( KEYWORD_SET(verbose) or requested_time eq 0L ) then $ print, 'time,date: ', tidi_rec[0].time, ' ',tidi_rec[0].ut_date, $ ' req_time,next_time: ', requested_time, ' ',next_time ;; ;; Store variables 'sc_lat' and 'sc_lon' for plotting. I'm only ;; storing the value given for field of view (FOV) telescope 1 since ;; the spacecraft latitude and longitude will not change based on FOV. ;; ;; I'm storing the values for the spectra for each telescope. The ;; first array structure is for the calibration field, and then each ;; telescope in order comes after that. ;; if ( requested_time eq 0L ) then begin sc_lat[0L] = tidi_rec[1].sc_lat sc_lon[0L] = tidi_rec[1].sc_lon spectra_tel1[0L] = tidi_rec[1].spectra spectra_tel2[0L] = tidi_rec[2].spectra spectra_tel3[0L] = tidi_rec[3].spectra spectra_tel4[0L] = tidi_rec[4].spectra endif else begin sc_lat = [ sc_lat, tidi_rec[1].sc_lat ] sc_lon = [ sc_lon, tidi_rec[1].sc_lon ] spectra_tel1 = [ spectra, tidi_rec[1].spectra ] spectra_tel2 = [ spectra, tidi_rec[2].spectra ] spectra_tel3 = [ spectra, tidi_rec[3].spectra ] spectra_tel4 = [ spectra, tidi_rec[4].spectra ] endelse ;; ;; One way to end the read loop is with the option 'end_of_file'. ;; if ( end_of_file ) then begin print, 'The end_of_file flag is set <- Reached end of file.' no_more_data = 0 endif ;; ;; Another way to end the read loop is to check if 'this_time' is ;; the same as 'next_time'. ;; if ( this_time eq next_time ) then begin print, 'This time equals next time <- Reached end of file.' no_more_data = 0 endif ;; ;; Set the next time read to the 'next_time' given from read_tidi_data. ;; requested_time = next_time endwhile ;; ;; You must use close_tidi_data, if you'd like to open another TIDI ;; file before exiting IDL. (Only one file open at a time for now.) ;; close_tidi_file, ncid ;; ;; Plot the stored values of spacecraft coordinates. ;; plot, sc_lon, sc_lat, title = 'Spacecraft Latitude vs. Longitude', $ xtitle = 'Longitude (degrees)', ytitle = 'Latitude (degrees)', psym = 3 END ;-