Pro mvn_sta_l2_load, files = files, trange = trange, sta_apid = sta_apid, user_pass = user_pass, no_time_clip = no_time_clip, _extra = _extra
If(keyword_set(files)) Then Begin
filex = files
Endif Else Begin
tr0 = timerange(trange)
start_day_dbl = time_double(time_string(tr0[0], precision = -3))
ndays = ceil((tr0[1]-start_day_dbl)/86400.0d0)
days = start_day_dbl+86400.0d0*dindgen(ndays)
daystr = time_string(days, precision = -3, format = 6)
If(is_string(sta_apid)) Then Begin
If(n_elements(sta_apid) Eq 1) Then Begin
app_id = strsplit(sta_apid, ' ', /extract)
Endif Else app_id = sta_apid
app_id = strlowcase(strcompress(app_id, /remove_all))
Endif Else app_id = ['2a', 'c?', 'd?']
app_id1 = ''
For j = 0, n_elements(app_id)-1 Do Begin
a1 = strmid(app_id[j], 0, 1)
a2 = strmid(app_id[j], 1, 1)
If(a2 Eq '?' Or a2 Eq'*') Then Begin
If(a1 Eq 'c') Then Begin
aj = a1+['0','2','4','6','8','a','c','d','e','f']
Endif Else If(a1 Eq 'd') Then Begin
aj = a1+['0', '1', '4', '6', '7', '8', '9', 'a', 'b']
Endif Else aj = '2a'
Endif Else aj = app_id[j]
app_id1 = [app_id1, aj]
Endfor
If(n_elements(app_id1) Gt 1) Then app_id = app_id1[1:*] Else Begin
app_id = ['2a', 'c'+['0','2','4','6','8','a','c','d','e','f'], 'd'+['0', '1', '4', '6', '7', '8', '9', 'a', 'b']]
Endelse
napp_id = n_elements(app_id)
filex = ''
For j = 0, napp_id-1 Do For k = 0, ndays-1 Do Begin
yyyy = strmid(daystr[k], 0, 4) & mmmm = strmid(daystr[k], 4, 2)
filejk0 = 'maven/data/sci/sta/l2/'+yyyy+'/'+mmmm+'/mvn_sta_l2_'+app_id[j]+'*_'+daystr+'_v??.cdf'
filejk = mvn_pfp_file_retrieve(filejk0, user_pass = user_pass)
question_mark = strpos(filejk, '?')
If(is_string(filejk) && question_mark[0] Eq -1) Then filex = [filex, filejk]
Endfor
If(n_elements(filex) Gt 1) Then filex = filex[1:*] Else Begin
dprint, 'No files found fitting input criteria'
Return
Endelse
Endelse
filex_u = filex[bsort(filex)]
filex = filex_u[uniq(filex_u)]
nfiles = n_elements(filex)
app_ids_all = ''
For j = 0, nfiles-1 Do Begin
xxxx = strsplit(file_basename(filex[j]), '_', /extract)
app_ids_all = [app_ids_all, strmid(xxxx[3], 0, 2)]
Endfor
app_ids_all0 = app_ids_all[1:*]
app_ids_all = app_ids_all0[uniq(app_ids_all0)]
napp_ids_all = n_elements(app_ids_all)
For j = 0, napp_ids_all-1 Do Begin
datj = -1
ssj = where(app_ids_all0 Eq app_ids_all[j], nssj)
If(nssj Eq 0) Then Begin
dprint, 'No files for apid: '+app_ids_all[j]
Endif Else Begin
ck = 0
For k = 0, nssj-1 Do Begin
datk = mvn_sta_cmn_l2read(filex[ssj[k]])
If(is_struct(datk)) Then Begin
If(~is_struct(datj)) Then datj = temporary(datk) $
Else datj = mvn_sta_cmn_concat(temporary(datj), temporary(datk))
Endif
Endfor
Endelse
If(~keyword_set(files) and ~keyword_set(no_time_clip)) Then datj = mvn_sta_cmn_tclip(datj, tr0)
Case app_ids_all[j] of
'2a': Begin
common mvn_2a, mvn_2a_ind, mvn_2a_dat
mvn_2a_dat = temporary(datj) & mvn_2a_ind = 0
End
'c0': Begin
common mvn_c0, mvn_c0_ind, mvn_c0_dat
mvn_c0_dat = temporary(datj) & mvn_c0_ind = 0
End
'c2': Begin
common mvn_c2, mvn_c2_ind, mvn_c2_dat
mvn_c2_dat = temporary(datj) & mvn_c2_ind = 0
End
'c4': Begin
common mvn_c4, mvn_c4_ind, mvn_c4_dat
mvn_c4_dat = temporary(datj) & mvn_c4_ind = 0
End
'c6': Begin
common mvn_c6, mvn_c6_ind, mvn_c6_dat
mvn_c6_dat = temporary(datj) & mvn_c6_ind = 0
End
'c8': Begin
common mvn_c8, mvn_c8_ind, mvn_c8_dat
mvn_c8_dat = temporary(datj) & mvn_c8_ind = 0
End
'ca': Begin
common mvn_ca, mvn_ca_ind, mvn_ca_dat
mvn_ca_dat = temporary(datj) & mvn_ca_ind = 0
End
'cc': Begin
common mvn_cc, mvn_cc_ind, mvn_cc_dat
mvn_cc_dat = temporary(datj) & mvn_cc_ind = 0
End
'cd': Begin
common mvn_cd, mvn_cd_ind, mvn_cd_dat
mvn_cd_dat = temporary(datj) & mvn_cd_ind = 0
End
'ce': Begin
common mvn_ce, mvn_ce_ind, mvn_ce_dat
mvn_ce_dat = temporary(datj) & mvn_ce_ind = 0
End
'cf': Begin
common mvn_cf, mvn_cf_ind, mvn_cf_dat
mvn_cf_dat = temporary(datj) & mvn_cf_ind = 0
End
'd0': Begin
common mvn_d0, mvn_d0_ind, mvn_d0_dat
mvn_d0_dat = temporary(datj) & mvn_d0_ind = 0
End
'd1': Begin
common mvn_d1, mvn_d1_ind, mvn_d1_dat
mvn_d1_dat = temporary(datj) & mvn_d1_ind = 0
End
'd2': Begin
common mvn_d2, mvn_d2_ind, mvn_d2_dat
mvn_d2_dat = temporary(datj) & mvn_d2_ind = 0
End
'd3': Begin
common mvn_d3, mvn_d3_ind, mvn_d3_dat
mvn_d3_dat = temporary(datj) & mvn_d3_ind = 0
End
'd4': Begin
common mvn_d4, mvn_d4_ind, mvn_d4_dat
mvn_d4_dat = temporary(datj) & mvn_d4_ind = 0
End
'd6': Begin
common mvn_d6, mvn_d6_ind, mvn_d6_dat
mvn_d6_dat = temporary(datj) & mvn_d6_ind = 0
End
'd7': Begin
common mvn_d7, mvn_d7_ind, mvn_d7_dat
mvn_d7_dat = temporary(datj) & mvn_d7_ind = 0
End
'd8': Begin
common mvn_d8, mvn_d8_ind, mvn_d8_dat
mvn_d8_dat = temporary(datj) & mvn_d8_ind = 0
End
'd9': Begin
common mvn_d9, mvn_d9_ind, mvn_d9_dat
mvn_d9_dat = temporary(datj) & mvn_d9_ind = 0
End
'da': Begin
common mvn_da, mvn_da_ind, mvn_da_dat
mvn_da_dat = temporary(datj) & mvn_da_ind = 0
End
'db': Begin
common mvn_db, mvn_db_ind, mvn_db_dat
mvn_db_dat = temporary(datj) & mvn_db_ind = 0
End
Endcase
Endfor
Return
End