pro mvn_kp_config_file, insitu_data_dir=insitu_data_dir, iuvs_data_dir=iuvs_data_dir, $
update_prefs=update_prefs, insitu_only=insitu_only
install_result = routine_info('mvn_kp_config_file',/source)
install_directory = strsplit(install_result.path,'mvn_kp_config_file.pro',/extract,/regex)
install_directory = install_directory+path_sep()+'..'+path_sep()
insitu_data_dir = ''
iuvs_data_dir = ''
if not keyword_set(update_prefs) then begin
preference_exists = file_search(install_directory+path_sep()+'kp_preferences.txt',count=kp_pref_exists)
if kp_pref_exists ne 0 then begin
openr,lun,install_directory+'kp_preferences.txt',/get_lun
while not eof(lun) do begin
line=''
readf,lun,line
tokens = strsplit(line,' ',/extract)
if tokens[0] ne ';' then begin
case tokens[0] of
'insitu_data_dir:': insitu_data_dir = tokens[1]
'iuvs_data_dir:' : iuvs_data_dir = tokens[1]
else : print, 'Unknown preference: ', tokens[0], ' ', tokens[1]
endcase
endif
endwhile
free_lun,lun
if insitu_data_dir eq '' then begin
print, 'Error: No insitu_data_dir: /path/ found in kp_preferences.txt file.'
error_msg = 'Re run mvn_kp_read with /UPDATE_PREFS or manually fix kp_preferences.txt file.'
message, error_msg
endif
if iuvs_data_dir eq '' and not keyword_set(insitu_only) then begin
print, "kp_preferences.txt file only contains insitu path. Requesting path to IUVS data..."
iuvs_data_dir = dialog_pickfile(path=install_directory,/directory,title='Choose the directory containing IUVS KP data files')
if iuvs_data_dir eq '' then message, "Canceled directory choice. Must choose path to IUVS data. Exiting..."
update_prefs=1
endif
endif else begin
insitu_data_dir = dialog_pickfile(path=install_directory,/directory,title='Choose the directory containing insitu KP data files')
if insitu_data_dir eq '' then message, "Canceled directory choice. Must choose path to in situ data. Exiting..."
if not keyword_set(insitu_only) then begin
iuvs_data_dir = dialog_pickfile(path=install_directory,/directory,title='Choose the directory containing IUVS KP data files')
if iuvs_data_dir eq '' then message, "Canceled directory choice. Must choose path to IUVS data. Exiting..."
endif
update_prefs=1
endelse
endif else begin
insitu_data_dir = dialog_pickfile(path=install_directory,/directory,title='Choose the directory containing insitu KP data files')
if insitu_data_dir eq '' then message, "Canceled directory choice. Not updating Preferences file. Exiting..."
if not keyword_set(insitu_only) then begin
iuvs_data_dir = dialog_pickfile(path=install_directory,/directory,title='Choose the directory containing IUVS KP data files')
if iuvs_data_dir eq '' then message, "Canceled directory choice. Not updating Preferences file. Exiting..."
endif
update_prefs=1
endelse
if keyword_set(update_prefs) then begin
openw,lun,install_directory+'kp_preferences.txt',/get_lun
printf,lun,'; IDL Toolkit KP Reader Preferences File'
printf,lun,'insitu_data_dir: '+insitu_data_dir
if iuvs_data_dir ne '' then printf,lun,'iuvs_data_dir: '+iuvs_data_dir
free_lun,lun
print, "Updated/created kp_preferences.txt file."
endif
end