function cont_edges, det_id, mer_table=mer_table, time=time, lookup=lookup,$ ut_edges=ut_edges, linear_table=ctable common cont_edges_com, edges_lad, pendleton_edges checkvar, pendleton_edges, 2 checkvar, det_id, 0 xvec = [findgen(65), findgen(31)*2+65, findgen(32)*8+127] ;xvec is used to convert the table channel boundaries into linear pha channels ;lookup tables for standard edges from linear pha ;prior to 91/6/1 checkvar,time, '1-jun-1991' t = anytim(time,/seconds) ; lookup_table = rd_text( loc_file( 'lad_lookup_table.dat',path='SSWDB_BATSE')) wtable = where( strtrim(lookup_table,2) ne '', ntable) table=lonarr(18, ntable -1) reads, lookup_table(1:*), table ut_edges = [(tjd2ymd(table(0,*),sec=table(1,*)))(*),sys2ut()] table = table(2:*,*) ; ;At some point the first channel had the counts from the last channel moved into it! ;We will choose to ignore it although keep ourselves aware of it wstrange = where( table(0,*) gt table(1,*), nstrange) wtable = where( t ge ut_edges, ntable) wtable = (ntable -1) < (n_elements(table(0,*))-1) > 0 if (where( wtable(0) eq wstrange))(0) ne -1 then begin print,'NB, Channel 0 includes what normally is the last channel and ULD' print,'The edges returned DO NOT account for this' ilast = xvec(table(0,wstrange)) endif else ilast = 1900 if nstrange ge 1 then table(0,wstrange) = 0 ctable1 = [table(*,wtable(0)),128] > 5 ctable = [xvec( table(*,wtable(0)) ), ilast] > 5 ;5 is the nominal LLD position standard_table = [xvec( table(*,2) ), ilast] ;stop if keyword_set(mer_table) then ctable = mer_table if keyword_set(lookup) or pendleton_edges then begin if n_elements(edges_lad) eq 0 then begin edges_lad = fltarr(17,8) openr,lu,/get, loc_file( path='SSWDB_BATSE','batse_cont_edges.dat' ) readf,lu,edges_lad free_lun,lu endif edges = edges_lad(*,det_id) if total( abs(ctable-standard_table) ) ne 0 then $ edges = interpol(edges,standard_table, ctable) endif else begin ;coefs = get_lad_gain( t ) ;edges = coefs(0,det_id) + ctable * coefs(1,det_id) + ctable^ 0.5 * coefs(2,det_id) edge_products, lad_pha_edges(det_id, t ), edges_1=edges edges = edges(ctable1) endelse edge_products, edges, edges_2=edges return, edges > (discla_edges(det_id))(0) end