;+------------------------------------------------------------------- ; pro read_los_spectra, ncid, spectra_array, $ vspec_array = vspec_array, debug = debug ; ; Purpose: Reads TIDI NetCDF spectra data from an already open file. ; ; Inputs: ; ncid NetCDF id for the open TIDI NetCDF file ; ; Outputs: ; spectra_array all spectra of the file stored in an array ; ; Options: ; vspec_array = ; all spectra variances of the file stored in an array ; ; /debug only do 1 telescope... for testing ; ; Author: Marie L. Cooper ; Created: 03-13-2003 ; History: MLC, 13 Mar 2003 - creation of code ; MLC, 01 Apr 2003 - got rid of unnecessary parameters ; ;-------------------------------------------------------------------- ; ; Store the software name, if not a RETRIEVE products (LOS, RAW-LOS) ; then print error message and exit. ; ncdf_attget, ncid, 'software_name', att_value, /global sw_name = strtrim( string(att_value), 2 ) if ( sw_name ne 'RETRIEVE' ) then goto, err_at_end ; ; First read in the spectral index and telescope IDs. ; print, 'patience, please - reading spec_index and the telescope IDs' ncdf_varget, ncid, 'spec_index', spec_index ncdf_varget, ncid, 'tel_id', tel_id ; ; Read in the missing values of spectra and the variances so you can ; fill in the empty parts of spectra_array and vspec_array with them. ; ncdf_attget, ncid, 'spec045', 'missing_value', spec_missing_val ncdf_control, 0, /noverbose ii = ncdf_varid(ncid, 'vspec045') ncdf_control, 0, /verbose if (ii ge 0) then begin ncdf_attget, ncid, 'vspec045', 'missing_value', vspec_missing_val endif else begin if ( KEYWORD_SET( vspec_array ) ) then $ print, 'The variances of the spectra were not available - RAW-LOS file??' vspec_missing_val = 0.0 endelse ; ; Now read in the arrays of spectra - for each telescope ; if ( NOT KEYWORD_SET( debug ) ) then $ print, 'patience, please - reading the spectra for 4 telescopes' $ else print, 'patience, DEBUG - reading spectra for only 1 telescope' ncdf_varget, ncid, 'spec045', spec045 if ( NOT KEYWORD_SET( debug ) ) then begin print, 'patience, please...' ncdf_varget, ncid, 'spec135', spec135 ncdf_varget, ncid, 'spec225', spec225 ncdf_varget, ncid, 'spec315', spec315 ncdf_varget, ncid, 'spec405', spec405 endif ; ; Now their variances ; if ( KEYWORD_SET( vspec_array ) ) then begin print, 'patience, please - now reading spectral variances for 4 telescopes' ncdf_varget, ncid, 'vspec045', vspec045 ncdf_varget, ncid, 'vspec135', vspec135 ncdf_varget, ncid, 'vspec225', vspec225 ncdf_varget, ncid, 'vspec315', vspec315 ncdf_varget, ncid, 'vspec405', vspec405 endif ; ; Now we need to store the spectra and their variances in an array ; that matches the spec_index array's index. ; help, spec_index help, spec045 ; ; So create the spectra_array that will be passed back to the ; calling routine. Note: The dimension of 75 is the largest possible ; size of the field of view. ; max_size_fov = 75 spectra_array = fltarr( N_ELEMENTS( spec_index ), max_size_fov ) ; ; Now fill in the spectra_array with the correct values. ; if ( KEYWORD_SET( vspec_array ) ) then $ vspec_array = fltarr( N_ELEMENTS( spec_index ), max_size_fov ) num_recs = N_ELEMENTS( spec_index ) - 1L if ( KEYWORD_SET( debug ) ) then num_recs = 9L for i = 0L, num_recs do begin spectra_array[i,0:max_size_fov-1] = spec_missing_val count = spec_index[i] - 1L if ( tel_id[i] eq 045 ) then begin num = N_ELEMENTS( spec045[*,count] ) - 1L spectra_array[i,0:num] = spec045[0:num,count] endif if ( NOT KEYWORD_SET( debug ) ) then begin if ( tel_id[i] eq 135 ) then begin num = N_ELEMENTS( spec135[*,count] ) - 1L spectra_array[i,0:num] = spec135[0:num,count] endif if ( tel_id[i] eq 225 ) then begin num = N_ELEMENTS( spec225[*,count] ) - 1L spectra_array[i,0:num] = spec225[0:num,count] endif if ( tel_id[i] eq 315 ) then begin num = N_ELEMENTS( spec315[*,count] ) - 1L spectra_array[i,0:num] = spec315[0:num,count] endif if ( tel_id[i] eq 405 ) then begin num = N_ELEMENTS( spec405[*,count] ) - 1L spectra_array[i,0:num] = spec405[0:num,count] endif endif else begin if ( i lt 10 ) then begin fmstr = '(i,'+TRIM(max_size_fov)+'(f13.5,$))' print, format = fmstr, tel_id[i], spectra_array[i,0:max_size_fov-1] print, '' endif endelse ; ; Now do the same for the variances (vspec_array), if option is set. ; if ( KEYWORD_SET( vspec_array ) ) then begin vspec_array[i,0:max_size_fov-1] = vspec_missing_val if ( tel_id[i] eq 045 ) then begin num = N_ELEMENTS( vspec045[*,count] ) - 1L vspec_array[i,0:num] = vspec045[0:num,count] endif if ( tel_id[i] eq 135 ) then begin num = N_ELEMENTS( vspec135[*,count] ) - 1L vspec_array[i,0:num] = vspec135[0:num,count] endif if ( tel_id[i] eq 225 ) then begin num = N_ELEMENTS( vspec225[*,count] ) - 1L vspec_array[i,0:num] = vspec225[0:num,count] endif if ( tel_id[i] eq 315 ) then begin num = N_ELEMENTS( vspec315[*,count] ) - 1L vspec_array[i,0:num] = vspec315[0:num,count] endif if ( tel_id[i] eq 405 ) then begin num = N_ELEMENTS( vspec405[*,count] ) - 1L vspec_array[i,0:num] = vspec405[0:num,count] endif endif endfor end_of_program: return err_at_end: print, 'This file is not an LOS or RAW-LOS file.' print, 'No spectra is stored.' goto, end_of_program END ;:;