;+ ;NAME: ; thm_ui_cal_data ;PURPOSE: ; Calls thm_cal_*** routines on input tplot variable names ;CALLING SEQUENCE: ; thm_ui_cal_data, state, datatype ;INPUT: ; state = the state structure of the calling widget ; datatype = the type of data to calibrate, 'EFI','FBK','FIT', 'FGM', 'MOM' ;OUTPUT: ; None explicit, the state structure is updated ;HISTORY: ; 4-feb-2007, jmm, jimm@ssl.berkeley.edu ; 7-feb-2007, jmm, rewritten ;$LastChangedBy$ ;$LastChangedDate$ ;$LastChangedRevision$ ;$URL$ ; ;- Pro thm_ui_cal_data, state, datatype, _extra = _extra dtyp = strcompress(/remove_all, strupcase(datatype)) vnames = tnames() probes = strmid(vnames, 2, 1) ssu = uniq(probes) probe = probes[ssu] np = n_elements(probe) history_ext = '' tr = time_double([state.st_time, state.en_time]) Case dtyp Of 'EFI': Begin ;check loaded data for probes, and datatypes thm_cal_efi, valid_names = vvv ;for each probe, check for valid datatypes use_probe = bytarr(np) vars = '' For j = 0, np-1 Do Begin this_probe = where(probes Eq probe[j]) ;gotta be true for some dtyptest = strmid(vnames[this_probe], 4, 3) ctest = where_arr(vvv, dtyptest) If(ctest[0] Ne -1) Then Begin use_probe[j] = 1 For i = 0, n_elements(ctest)-1 Do $ vars = [vars, thm_tplot_var(probe[j], vvv[ctest[i]])] Endif Endfor ok = where(use_probe Eq 1, nok) If(nok Eq 0) Then Begin message, /info, 'No Data calibrated, Please load data' Endif Else Begin scsin = probe[ok] history_ext = thm_ui_multichoice_history(' probe = ', scsin) thm_cal_efi, scs = scsin, /verbose, trange = tr history_ext = [history_ext, 'thm_cal_efi, scs=probe, /verbose'] Endelse End 'FBK': Begin ;check loaded data for probes, and datatypes thm_cal_fbk, valid_names = vvv ;for each probe, check for valid datatypes use_probe = bytarr(np) vars = '' For j = 0, np-1 Do Begin this_probe = where(probes Eq probe[j]) ;gotta be true for some dtyptest = strmid(vnames[this_probe], 4, 3) ctest = where_arr(vvv, dtyptest) If(ctest[0] Ne -1) Then Begin use_probe[j] = 1 For i = 0, n_elements(ctest)-1 Do $ vars = [vars, thm_tplot_var(probe[j], vvv[ctest[i]])] Endif Endfor ok = where(use_probe Eq 1, nok) If(nok Eq 0) Then Begin message, /info, 'No Data calibrated, Please load data' Endif Else Begin scsin = probe[ok] history_ext = thm_ui_multichoice_history(' probe = ', scsin) thm_cal_fbk, scs = scsin, /verbose, trange = tr history_ext = [history_ext, 'thm_cal_fbk, scs=probe, /verbose'] Endelse End 'FIT': Begin ;check loaded data for probes, and datatypes thm_load_fit, valid_names = vvv ;for each probe, check for valid datatypes use_probe = bytarr(np) vars = '' For j = 0, np-1 Do Begin this_probe = where(probes Eq probe[j]) ;gotta be true for some dtyptest = strmid(vnames[this_probe], 4, 3) ctest = where_arr(vvv, dtyptest) If(ctest[0] Ne -1) Then Begin use_probe[j] = 1 For i = 0, n_elements(ctest)-1 Do $ vars = [vars, thm_tplot_var(probe[j], vvv[ctest[i]])] Endif Endfor ok = where(use_probe Eq 1, nok) If(nok Eq 0) Then Begin message, /info, 'No Data calibrated, Please load data' Endif Else Begin scsin = probe[ok] history_ext = thm_ui_multichoice_history(' probe = ', scsin) thm_cal_fit, scs = scsin, /verbose, trange = tr history_ext = [history_ext, 'thm_cal_fit, scs=probe, /verbose'] Endelse End 'MOM': Begin ;check loaded data for probes, and datatypes thm_load_mom, /valid, datatype = vvv ;for each probe, check for valid datatypes use_probe = bytarr(np) For j = 0, np-1 Do Begin this_probe = where(probes Eq probe[j]) ;gotta be true for some dtyptest = strmid(vnames[this_probe], 4, 3) ctest = where_arr(vvv, dtyptest) If(ctest[0] Ne -1) Then use_probe[j] = 1 Endfor ok = where(use_probe Eq 1, nok) If(nok Eq 0) Then Begin message, /info, 'No Data calibrated, Please load data' Endif Else Begin scsin = 'th'+probe[ok] history_ext = thm_ui_multichoice_history(' probe = ', scsin) thm_cal_mom, scs = scsin, /verbose history_ext = [history_ext, 'thm_mom_cal, scs=''th''+probe, /verbose'] Endelse ;set the new variables to active all_vars = tnames() new_ssn = where_arr(all_vars, vnames, /notequal) If(new_ssn[0] Ne -1) Then vars = all_vars[new_ssn] Else vars = '' End Else: message, /info, 'Not Yet Implemented' Endcase ;set active dataset to new data If(n_elements(vars) Gt 1) Then Begin vars = vars[1:*] history_ext1 = thm_ui_multichoice_history(' varnames = ', vars) data_ss = thm_ui_set_active_dset(vars, state) Endif End