PRO eae_fill_order, eae_rdb ; @cmdb_common ; The CMDB should already be loaded... if cmdb_using_cal then begin @cmdb_cal_integers end else begin @cmdb_trw_integers end for ir=0,n_elements(eae_rdb)-1 do begin icmdb = where(cmdb_fields(*,c_id) EQ eae_rdb(ir).trw_id) icmdb = icmdb(0) ; get the cmdb order iords = where(cmdb_data(icmdb).order NE 999) ords = cmdb_data(icmdb).order(iords) ; Order the orders: lowest positive to max positive then ; least negative to most negative to have first one on ; bright diffracted order orders = ords if n_elements(orders) GT 1 then begin pos_orders = where(orders GT 0, npos) neg_orders = where(orders LE 0, nneg) if npos GT 0 then begin pos_ones = orders(pos_orders) pos_sort = SORT(pos_ones) pos_out = pos_ones(pos_sort) end if nneg GT 0 then begin neg_ones = orders(neg_orders) neg_sort = SORT(ABS(neg_ones)) neg_out = neg_ones(neg_sort) end if npos GT 0 then begin orders = pos_out if nneg GT 0 then orders = [orders, neg_out] end else begin orders = neg_out end end ords = orders ; Put in corrections by hand here to the order lists if eae_rdb(ir).trw_id EQ 'D-HXS-3D-29.005' then begin ; the first value is ~0 order ords(0) = 0 end if eae_rdb(ir).trw_id EQ 'D-HXS-3D-29.003' then begin ; the first value is ~0 order ords(0) = 0 end it_num = 0 READS, eae_rdb(ir).iteration, it_num if it_num LT n_elements(ords) then begin print, eae_rdb(ir).trw_id, ords(it_num) eae_rdb(ir).order = ords(it_num) end else begin print, ' * '+eae_rdb(ir).trw_id+': it_num GE n_elements(ords) ?!' end if eae_rdb(ir).order EQ 99 then eae_rdb(ir).order = 999 end RETURN END