;+ ;Procedure: THM_LOAD_ASI ; ; KEYWORD PARAMETERS: ; site = Observatory name, example, thm_load_gmag, site = 'fykn', the ; default is 'all', i.e., load all available stations . This ; can be an array of strings, e.g., ['fykn', 'gako'] or a ; single string delimited by spaces, e.g., 'fykn gako' ; datatype = request 'ast' or 'asf', default is 'asf', can also be '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 'l2', or level-2 ; data. A string (e.g., 'l2') or an integer can be used. 'all' ; can be passed in also, to get all levels. ; /VERBOSE : set to output some useful info ; /downloadonly, if set, then only download the data, do not load it ; into variables. ; /valid_names, if set, then this will return the valid site, datatype ; and/or level options in named variables, for example, ; ; thm_load_gmag, site = xxx, /valid_names ; ; will return the array of valid sites in the ; variable xxx ; /CURSOR get time range with cursor ; /TIME specify just one time (record) for data ; ;Example: ; thm_load_asi,'fykn',time='2006-01-01/04:29:53' ; ;Notes: ; ; To get an array of valid names make the following call; ; thm_load_asi,site=vn,/valid_names ; No further action will be taken. ; ; ;Written by: Davin Larson, Jan 5 2007 ; $LastChangedBy: kenb-mac $ ; $LastChangedDate: 2006-12-26 08:58:00 -0800 (Tue, 26 Dec 2006) $ ; $LastChangedRevision: 159 $ ; $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/trunk/idl/themis/ground/thm_load_asi.pro $ ;- ; ; find the correct file names, based on datatype, and site function thm_load_asi_relpath, sname=site, dt=dt, time=time, trange=trange, $ _extra=_extra ; set begin and end of trange if keyword_set(time) then trange=[time,time] relpath = 'thg/l1/asi/'+ site + '/' ending = '_v01.cdf' prefix = 'thg_l1_'+dt+'_' + site + '_' ; asf are hour files, ast are daily files hour_res=(dt eq 'asf') return, file_dailynames(relpath,prefix,ending,/YEARDIR,$ trange=trange,hour_res=hour_res) end ; load data for a single time or a time range into tplot variables pro thm_load_asi_cdf_to_tplot, files=files, all=all, verbose=verbose, $ get_support_data=get_support_data, $ varnames=varnames, time=time if keyword_set(time) then begin ; read only one record out of CDF-file info=cdf_info(files[0]) if (size(info,/type) eq 2) then return ti = (where(strpos(info.vars.name,'time') ne -1))[0] res=cdf_load_vars(files[0],varnames=info.vars[ti].name,info=info,/verbose) timearr = *res.vars[ti].dataptr ; we allow for 1.5 seconds time offset if (size(time,/type) eq 5) then record=where(abs(timearr-time) le 1.5,count) else $ ; double record=where(abs(timearr-time_double(time)) le 1,count) ; string if (count eq 1) then cdf2tplot,/all,varnames=varnames,file=files,verbose=verbose,record=record[0] endif else $ cdf2tplot,/all,varnames=varnames,file=files,verbose=verbose end pro thm_load_asi,site = site, datatype = datatype, trange = trange, $ level = level, verbose = verbose, $ downloadonly = downloadonly, $ valid_names = valid_names, $ cursor=cursor, time=time, $ _extra = _extra if keyword_set(cursor) then begin ; get time with cursor ctime,t,vname=var trange = minmax(t) ; Use the cursor to determine what asi's to load. site = strmid(var,3,4,/reverse) if (verbose gt 10) then stop,time_string(trange),site endif thm_load_xxx,sname=site, datatype=datatype, trange=trange, $ time=time, cursor=cursor, $ 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 = 'atha chbg ekat fsmi fsim fykn gako gbay gill '+ $ 'inuv kapu kian mcgr nain pgeo pina rank snkq tpas whit', $ type_sname = 'site', $ vdatatypes = 'asf ast', $ vlevels = 'l1', $ deflevel = 'l1', $ version = 'v01', $ relpath_funct = 'thm_load_asi_relpath', $ cdf_to_tplot = 'thm_load_asi_cdf_to_tplot', $ _extra = _extra end