;+ ;Procedure: THM_LOAD_FIT ; ;Purpose: Loads THEMIS FIT data ; ;keywords: ; probe = Probe name. The default is 'all', i.e., load all available probes. ; This can be an array of strings, e.g., ['a', 'b'] or a ; single string delimited by spaces, e.g., 'a b' ; datatype = The type of data to be loaded, can be an array of strings ; or single string separate by spaces. The default is 'all' ; TRANGE= (Optional) Time range of interest (2 element array), if ; this is not set, the default is to prompt the user. Note ; that if the input time range is not a full day, a full ; day's data is loaded ; level = the level of the data, the default is 'l1', or level-1 ; data. A string (e.g., 'l2') or an integer can be used. 'all' ; can be passed in also, to get all levels. ; CDF_DATA: named variable in which to return cdf data structure: only works ; for a single spacecraft and datafile name. ; VARNAMES: names of variables to load from cdf: default is all. ; /GET_SUPPORT_DATA: load support_data variables as well as data variables ; into tplot variables. ; /DOWNLOADONLY: download file but don't read it. ; /valid_names, if set, then this routine will return the valid probe, datatype ; and/or level options in named variables supplied as ; arguments to the corresponding keywords. ; files named varible for output of pathnames of local files. ; /VERBOSE set to output some useful info ;Example: ; thg_load_fit,/get_suppport_data,probe=['a', 'b'] ;Notes: ; ; $LastChangedBy: jimm $ ; $LastChangedDate: 2007-11-09 16:33:14 -0800 (Fri, 09 Nov 2007) $ ; $LastChangedRevision: 2009 $ ; $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/tags/tdas_3_01/idl/themis/spacecraft/fields/thm_load_fit.pro $ ;- pro thm_load_fit_post, sname=probe, datatype=dt, level=level, $ tplotnames=tplotnames, $ suffix=suffix, proc_type=proc_type, coord=coord, $ delete_support_data=delete_support_data,sigma=sigma,$ _extra=_extra if not keyword_set(coord) then coord='dsl' for l=0, n_elements(tplotnames)-1 do begin tplot_var = tplotnames[l] dtl = strmid(tplot_var, 4, 3) get_data, tplot_var, data=d_str, limit=l_str, dlimit=dl_str if data_type(dl_str) eq 8 && dl_str.cdf.vatt.var_type eq 'data' $ then begin if strmatch(level, 'l1') then begin data_att = { data_type:'raw'} str_element, dl_str, 'data_att', data_att, /add store_data, tplot_var, data=d_str, limit=l_str, dlimit=dl_str endif endif ;if strmatch(level, 'l2') then begin ; unit=dl_str.cdf.vatt.units ; coord_sys=strlowcase(strmid (dl_str.cdf.vatt.coordinate_system,0,3)) ; data_att = { data_type:'calibrated', coord_sys:coord_sys, $ ; units:unit} ; labels = [ 'bx', 'by', 'bz'] ; endif endfor if (level eq 'l1' ) and (~keyword_set(proc_type) || strmatch(proc_type, 'calibrated')) then begin thm_cal_fit,/verbose,probe=probe,datatype=dt,in_suf=suffix,out_suf=suffix,coord=coord endif ;if coord ne 'dsl' then begin ; thm_cotrans, probe=probes, datatype=dt,out_coord = coord, $ ; in_suffix=suffix, $ ; out_suffix=suffix ;endif if keyword_set(delete_support_data) then begin if size(dt, /n_dim) eq 0 then dt = strsplit(dt, ' ', /extract) for i = 0, n_elements(dt)-1L do begin if tnames('th'+probe+'_'+dt[i]+'_hed') ne '' then del_data, 'th'+probe+'_'+dt[i]+'_hed' endfor endif end pro thm_load_fit,probe=probe, datatype=datatype, trange=trange, $ level=level, verbose=verbose, downloadonly=downloadonly, $ cdf_data=cdf_data,get_support_data=get_support_data, $ relpathnames_all=relpathnames_all,nodownload=nodownload,$ varnames=varnames, valid_names = valid_names, files=files, $ progobj=progobj,type=type, suffix=suffix,coord=coord,sigma=sigma if arg_present(relpathnames_all) then begin downloadonly=1 no_download=1 end valid_probes = ['a','b','c','d','e'] valid_raw = ['fit'] valid_calibrated = ['fgs','efs','fit_efit','fit_bfit','efs_0','efs_dot0','fgs_sigma','efs_sigma'] valid_datatypes = ssl_set_union(valid_raw,valid_calibrated) ;validate inputs if not keyword_set(datatype) then datatype = valid_datatypes $ else datatype = thm_check_valid_name(strlowcase(datatype),valid_datatypes,/include_all) if not keyword_set(probe) then probe=valid_probes vlevels='l1 l2' ;valid data levels vlevels = strsplit(vlevels, ' ', /extract) ; deflevel='l2' deflevel = 'l1' ; parse out data level if keyword_set(deflevel) then lvl = deflevel else lvl = 'l1' if n_elements(level) gt 0 then begin if size(level, /type) Eq 7 then begin If(level[0] Ne '') Then lvl = strcompress(strlowcase(level), /remove_all) endif else lvl = 'l'+strcompress(string(fix(level)), /remove_all) endif lvls = thm_check_valid_name(strlowcase(lvl), vlevels) if not keyword_set(lvls) then return if n_elements(lvls) gt 1 then begin message, /info, level = -1, $ 'only one value may be specified for level' return endif if lvls eq 'l2' and keyword_set(type) then begin print,"Type keyword not valid for level 2 data." return endif if not keyword_set(suffix) then suffix = '' if not keyword_set(type) then type='calibrated' if not keyword_set(coord) then coord='dsl' if lvls eq 'l1'then begin ;; default action for loading level 1 is to calibrate if ~keyword_set(type) || strmatch(type, 'calibrated') then begin ;; we're calibrating, so make sure we get support data if not keyword_set(get_support_data) then begin get_support_data = 1 delete_support_data = 1 endif endif endif if not keyword_set(datatype) then begin if (lvls eq 'l1') and type eq 'calibrated' then begin dt = ['fit','fgs','efs','fgs_sigma','efs_sigma'] endif if (lvls eq 'l1') and type eq 'raw' then dt = ['fit'] if (lvls eq 'l2') then dt = ['fgs','efs'] endif else if n_elements(datatype) gt 1 then begin dt=['fit',datatype] endif else if size(/dimensions,datatype) eq 0 then begin dt='fit '+datatype endif else dt=['fit',datatype] thm_load_xxx,sname=probe, datatype=dt, trange=trange, $ level=level, verbose=verbose, downloadonly=downloadonly, $ cdf_data=cdf_data,get_cdf_data=arg_present(cdf_data), $ get_support_data=get_support_data, $ varnames=varnames, valid_names = valid_names, files=files, $ vsnames = 'a b c d e', $ type_sname = 'probe', no_download=no_download, $ vdatatypes = 'fit fgs efs fit_efit fit_bfit efs_0 efs_dot0 fgs_sigma efs_sigma', $ file_vdatatypes='fit fit fit fit fit fit fit fit fit',$ vlevels = 'l1 l2', $ vL2coord = 'dsl gse gsm', $ deflevel = deflevel,proc_type=type, $ post_process_proc='thm_load_fit_post',$ version = 'v01', suffix=suffix,$ progobj=progobj,delete_support_data=delete_support_data,$ coord=coord,sigma=sigma,$ _extra = _extra ;delete unrequested data ;the following code is copied over ;from thm_load_fft, and is probably ;overkill in this function, ;but copying it over was a quick solution if(lvl eq 'l1' and not keyword_set(valid_names)) then begin list = ssl_set_complement(datatype,valid_datatypes) if(size(list, /n_dim) eq 0 && list eq -1L) then return var_list = array_cross(probe, list) var_strings = reform('th' + var_list[0, *] + '_' + var_list[1, *] + suffix) for i = 0, n_elements(var_strings) -1L do begin if(tnames(var_strings[i]) ne '') then del_data, var_strings[i] endfor endif end