subr lp_image_selector, t1, t2 ty,'in lp_image_selector, t1, t2 =', t1, t2 ;works on the currently open hourly file, appends results to existing ones ;if t1 is -1, then we reset the internal counters if t1 eq -1 then { $lp_select_count = 0 ;need a global accumulator also last_tai = 0 ;used by the minimum delta t check return } if defined($lp_select_count) eq 0 then { $lp_select_count = 0 ;need a global accumulator also last_tai = 0 ;used by the minimum delta t check } ;nselected is the number exp_lo = float(xmtextfieldgetstring($lp_range_lo_wq(1))) rms_lo = float(xmtextfieldgetstring($lp_range_lo_wq(2))) exp_hi = float(xmtextfieldgetstring($lp_range_hi_wq(1))) rms_hi = float(xmtextfieldgetstring($lp_range_hi_wq(2))) range_flag = exp_lo ne 0 or exp_hi ne 0 or rms_lo ne 0 or rms_hi ne 0 offset_sel = xmtextfieldgetstring($lp_range_lo_wq(3)) if strpos(lowcase(offset_sel),'any') ge 0 or num_elem(offset_sel) eq 0 then offset_sel = -30000 else offset_sel = float(offset_sel) ty,'offset_sel =', offset_sel ;also a minimum delta time s = xmtextfieldgetstring($lp_select_time_txt(8)) decode_time_str, s, h3, m3, s3 min_time_bwt = s3 + 60.*m3 + 3600.*h3 ty,'min_time_bwt = ', min_time_bwt ;read the current time arrays and screen these first, since this is for ;a whole day we expect that some of the data will be selected npaths = num_elem($lp_select_ind) if npaths le 0 then return ;the results are put in a bunch of 1-D arrays that match, we time sort ;them later, first we have to load via path which is the same as the "camera" ns = 0 for k= 0, npaths-1 do { ty,'path', k while (1) { ;something to break out of path = $lp_paths($lp_select_ind(k)) dataread, t, path + 'lp_times.catinfo' ntot = num_elem(t) ;any in our time range? pmatch = sieve(t ge t1 and t le t2) if isscalar(pmatch) then break ;got some, read the other arrays and narrow it down dataread, w, path + 'lp_waves.catinfo' ;w is just one element for the simple filter camera cases, an array for the TF if num_elem(w) eq 1 then w = zero(intarr(ntot)) + w(0) if $lp_wave_selection then pmatch = sieve(pmatch, w(pmatch) eq $lp_wave_selection) ;pmatch will be all times and waves that fit so far if isscalar(pmatch) then break ;check polarization, 0 means any and hence no check, but we ;need to make the array even if there is none for our items list ;may not be any polarization (e.g., none for G band or K line) if dataread(pol, path + 'lp_polw.catinfo') eq 1 then { if $lp_pol_selection then pmatch = sieve(pmatch, pol(pmatch)%16 eq $lp_pol_selection) } else pol = zero(intarr(ntot)) + 0xffff ;and the next level, the offset if isscalar(pmatch) then break ;offset is also an optional parameter, check it only if it exists if dataread(offs, path + 'lp_offsets.catinfo') eq 1 then { if offset_sel ne -30000 then pmatch = sieve(pmatch, offs(pmatch) eq offset_sel) } else offs = zero(intarr(ntot)) + 0xffff if isscalar(pmatch) then break dataread, et, path + 'lp_exposure.catinfo' dataread, rms, path + 'lp_rms.catinfo' ;check the exposure and the rms if range_flag then { pmatch = sieve(pmatch, et(pmatch) ge exp_lo) if isscalar(pmatch) then break if exp_hi gt 0 then pmatch = sieve(pmatch, et(pmatch) le exp_hi) if isscalar(pmatch) then break pmatch = sieve(pmatch, rms(pmatch) ge rms_lo) if isscalar(pmatch) then break if rms_hi gt 0 then pmatch = sieve(pmatch, rms(pmatch) le rms_hi) } if isscalar(pmatch) then break ;here if we selected anything, get the various arrays we don't have yet dataread, imean, path + 'lp_imean.catinfo' dataread, nx, path + 'lp_nx.catinfo' dataread, ny, path + 'lp_ny.catinfo' ;;d, pmatch,w,offs,pol,et,rms,imean,nx,ny ;condense to the selected ones t = t(pmatch) w = w(pmatch) pol = pol(pmatch) offs = offs(pmatch) et = fix(1.E3*et(pmatch)) rms = fix(1.E6*rms(pmatch)) imean = imean(pmatch) nx = nx(pmatch) ny = ny(pmatch) ;;d, pmatch,w,offs,pol,et,rms,imean,nx,ny break ;we have to break out the while loop if we haven't already } ;if we got any from this path, append to total so far if isarray(pmatch) then { nt = num_elem(pmatch) ;;ty,'nt =', nt if $lp_select_count then { ;append $lp_selected_paths = [$lp_selected_paths, path + '/images/'] ip = num_elem($lp_selected_paths) - 1 pq = zero(intarr(nt)) + ip xq = [[pq],[pmatch],[w],[offs],[pol],[et],[rms],[imean],[nx],[ny]] xq = xq(>1,>0) $lp_selected_items = [$lp_selected_items, xq] $lp_selected_times = [$lp_selected_times, t] } else { ;first hits $lp_selected_paths = strarr(1) $lp_selected_paths(0) = path + '/images/' pq = zero(intarr(nt)) $lp_selected_times = t $lp_selected_items = [[pq],[pmatch],[w],[offs],[pol],[et],[rms],[imean],[nx],[ny]] $lp_selected_items = $lp_selected_items(>1,>0) } $lp_select_count += nt ;total, including previous runs if option set ty,'ns =', ns ns += nt ;just the ones in this run } ty,'end of path', k } ;end of path loop ;add these to the list widget, if any if ns le 0 then return k = $lp_select_count k = k - ns ;the next new one for i= 0, ns-1 do { sw = wavestring(k, 0, $lp_selected_items,$lp_selected_times) j = $lp_selected_items(1,k) sq = sprintf('%4d %4d %s',k,j, sw) k = k+1 xmlistadditem, $lpselectedwidget, sq } xmsetlabel, $lpselect_lab1, sprintf('%d images', $lp_select_count) endsubr ;===============================================================================