pro mvn_kp_read_iuvs_return_substruct, iuvs_record_temp, begin_time, end_time, instruments
MVN_KP_IUVS_STRUCT_INIT, iuvs_record_time_temp, instruments=instruments
any_within_bounds = 0
if instruments.periapse then begin
for peri_index = 0, n_elements(iuvs_record_temp.periapse.time_start)-1 do begin
if (iuvs_record_temp.periapse[peri_index].time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.periapse[peri_index].time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.periapse[peri_index] = iuvs_record_temp.periapse[peri_index]
any_within_bounds = 1
endif
endif
endfor
endif
if instruments.c_e_limb then begin
if (iuvs_record_temp.corona_e_limb.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_e_limb.time_start, begin_time, end_time)
if check then iuvs_record_time_temp.corona_e_limb = iuvs_record_temp.corona_e_limb
endif
endif
if instruments.c_e_disk then begin
if (iuvs_record_temp.corona_e_disk.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_e_disk.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.corona_e_disk = iuvs_record_temp.corona_e_disk
any_within_bounds = 1
endif
endif
endif
if instruments.c_e_high then begin
if (iuvs_record_temp.corona_e_high.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_e_high.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.corona_e_high = iuvs_record_temp.corona_e_high
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_limb then begin
if (iuvs_record_temp.corona_lo_limb.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_lo_limb.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.corona_lo_limb = iuvs_record_temp.corona_lo_limb
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_disk then begin
if (iuvs_record_temp.corona_lo_disk.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_lo_disk.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.corona_lo_disk = iuvs_record_temp.corona_lo_disk
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_high then begin
if (iuvs_record_temp.corona_lo_high.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.corona_lo_high.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.corona_lo_high = iuvs_record_temp.corona_lo_high
any_within_bounds = 1
endif
endif
endif
if instruments.apoapse then begin
if (iuvs_record_temp.apoapse.time_start ne '') then begin
check = MVN_KP_TIME_BOUNDS(iuvs_record_temp.apoapse.time_start, begin_time, end_time)
if check then begin
iuvs_record_time_temp.apoapse = iuvs_record_temp.apoapse
any_within_bounds = 1
endif
endif
endif
if any_within_bounds then begin
iuvs_record_time_temp.orbit = iuvs_record_temp.orbit
iuvs_record_temp = iuvs_record_time_temp
endif else begin
iuvs_record_temp = -1
endelse
return
end
pro mvn_kp_read_iuvs_file, filename, iuvs_record, begin_time=begin_time, end_time=end_time, $
save_files=save_files, text_files=text_files, instruments=instruments
debug = getenv('MVNTOOLKIT_DEBUG')
if not keyword_set(debug) then begin
on_error, 1
endif
if keyword_set(begin_time) and keyword_set(end_time) then begin
time_bounds=1
any_within_bounds = 0
endif else begin
time_bounds=0
any_within_bounds = 1
endelse
if keyword_set(save_files) then begin
MVN_KP_IUVS_STRUCT_INIT, iuvs_record, instruments=instruments
periapse = 0
apoapse = 0
corona_echelle_limb = 0
corona_echelle_disk = 0
corona_echelle_high = 0
corona_lores_high = 0
corona_lores_limb = 0
corona_lores_disk = 0
restore,filename
if instruments.periapse then begin
if size(periapse,/type) eq 8 then begin
for peri_index = 0,n_elements(periapse.time_start)-1 do begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(periapse[peri_index].time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, periapse[peri_index], 'PERIAPSE',index=peri_index
any_within_bounds = 1
endif
endfor
endif
endif
if instruments.apoapse then begin
if size(apoapse,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(apoapse.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, apoapse, 'APOAPSE',index=0
any_within_bounds = 1
endif
endif
endif
if instruments.c_e_high then begin
if size(corona_echelle_high,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_echelle_high.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_echelle_high, 'CORONA_ECHELLE_HIGH'
any_within_bounds = 1
endif
endif
endif
if instruments.c_e_limb then begin
if size(corona_echelle_limb,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_echelle_limb.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_echelle_limb, 'CORONA_ECHELLE_LIMB'
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_high then begin
if size(corona_lores_high,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_lores_high.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_lores_high, 'CORONA_LORES_HIGH'
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_limb then begin
if size(corona_lores_limb,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_lores_limb.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_lores_limb, 'CORONA_LORES_LIMB'
any_within_bounds = 1
endif
endif
endif
if instruments.c_l_disk then begin
if size(corona_lores_disk,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_lores_disk.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_lores_disk, 'CORONA_LORES_DISK'
any_within_bounds = 1
endif
endif
endif
if instruments.c_e_disk then begin
if size(corona_echelle_disk,/type) eq 8 then begin
if time_bounds eq 1 then begin
check = MVN_KP_TIME_BOUNDS(corona_echelle_disk.time_start, begin_time, end_time)
endif else begin
check=1
endelse
if check eq 1 then begin
MVN_KP_IUVS_BINARY_ASSIGN, iuvs_record, corona_echelle_disk, 'CORONA_ECHELLE_DISK'
any_within_bounds = 1
endif
endif
endif
iuvs_record.orbit = periapse[0].orbit_number
if not any_within_bounds then begin
iuvs_record = -1
endif
endif else if keyword_set(text_files) then begin
MVN_KP_READ_IUVS_ASCII, filename, iuvs_record
if time_bounds then begin
mvn_kp_read_iuvs_return_substruct, iuvs_record, begin_time, end_time, instruments
endif
endif else begin
MVN_KP_IUVS_CDF_READ, iuvs_record, filename, instruments=instruments
if time_bounds then begin
MVN_KP_READ_IUVS_RETURN_SUBSTRUCT, iuvs_record, begin_time, end_time, instruments
endif
endelse
end