pro SUB_accumulate_step5_tims_nobs, $ publisher_ts, nobs_total_ts, nobs_qced_ts, julian_ts, $ publisher, nobs_total, nobs_qced, pointStart_julian if n_elements(publisher) eq 0 then begin ; if publisher is empty, then insert dummy column; required by json format if n_elements(nobs_total_ts) gt 0 then begin size_this = size(nobs_total_ts, /dim) nobs_total_ts = [nobs_total, fltarr([1,size_this[1:-1]])+!values.f_nan] nobs_qced_ts = [nobs_qced, fltarr([1,size_this[1:-1]])+!values.f_nan] julian_ts = [julian_ts, pointStart_julian] endif endif else begin if n_elements(nobs_total_ts) eq 0 then begin ; the first element, simply give the current value publisher_ts = publisher nobs_total_ts = reform(nobs_total, [1, size(nobs_total, /dim)]) nobs_qced_ts = reform(nobs_qced, [1, size(nobs_qced, /dim)]) julian_ts = pointStart_julian endif else begin existing = 0 for combine_loop = 0, n_elements(publisher)-1 do begin this_id = where(publisher_ts eq publisher[combine_loop], this_num) if this_num eq 0 then begin ; new combine, rebuild the whole line for the new combine ; print,'new combine' publisher_ts = [publisher_ts, publisher[combine_loop]] size_this = size(nobs_total_ts,/dim) ; switch dim 0 (time) and dim 1 (combine), to add new combine nobs_total_ts= [transpose(nobs_total_ts, [1,0,2,3]), fltarr([1, size_this[0], size_this[2:-1]])+!values.f_nan] nobs_total_ts = transpose(nobs_total_ts, [1,0,2,3]) nobs_qced_ts= [transpose(nobs_qced_ts, [1,0,2,3]), fltarr([1, size_this[0], size_this[2:-1]])+!values.f_nan] nobs_qced_ts = transpose(nobs_qced_ts, [1,0,2,3]) ;; if the new combine is the first in current combine list, then we need to additionally append column (along time) ;; if not the first, not need if combine_loop eq 0 then begin ; only append once size_this = size(nobs_total_ts,/dim) nobs_total_ts= [nobs_total_ts, fltarr([1, size_this[1], size_this[2:-1]])+!values.f_nan] nobs_qced_ts= [nobs_qced_ts, fltarr([1, size_this[1], size_this[2:-1]])+!values.f_nan] julian_ts = [julian_ts, pointStart_julian] existing=1 endif nobs_total_ts[-1, -1, *, *] = nobs_total[combine_loop, *, *] nobs_qced_ts[-1, -1, *, *] = nobs_qced[combine_loop, *, *] endif else begin ; existing combine, append to column ; print,'existing combine', existing ; print, 'combine_loop',combine_loop if existing eq 0 then begin ; only append once ; save, /variable, filename='test.sav' ; stop size_this = size(nobs_total_ts,/dim) nobs_total_ts = [nobs_total_ts, fltarr([1,size_this[1], size_this[2:-1]])+!values.f_nan] nobs_qced_ts = [nobs_qced_ts, fltarr([1,size_this[1], size_this[2:-1]])+!values.f_nan] julian_ts = [julian_ts, pointStart_julian] existing = 1 endif nobs_total_ts[-1, this_id,*, *] = nobs_total[combine_loop, *, *] nobs_qced_ts[-1, this_id,*, *] = nobs_qced[combine_loop, *, *] endelse ;print,'-----------' endfor ; combine_loop endelse ; n_elements(var_mean_all) eq 0 endelse ; n_elements(var_combine) eq 0 end