def calc_segment_times(d):
    """ Helper function for set_pipeline to define segmenttimes list, given nsegments definition
    """

    # this casts to int (flooring) to avoid 0.5 int rounding issue. 
    stopdts = n.linspace(d['nskip']+d['t_overlap']/d['inttime'], d['nints'], d['nsegments']+1)[1:]   # nseg+1 assures that at least one seg made
    startdts = n.concatenate( ([d['nskip']], stopdts[:-1]-d['t_overlap']/d['inttime']) )
            
    segmenttimes = []
    for (startdt, stopdt) in zip(d['inttime']*startdts, d['inttime']*stopdts):
        starttime = qa.getvalue(qa.convert(qa.time(qa.quantity(d['starttime_mjd']+startdt/(24*3600),'d'),form=['ymd'], prec=9)[0], 's'))[0]/(24*3600)
        stoptime = qa.getvalue(qa.convert(qa.time(qa.quantity(d['starttime_mjd']+stopdt/(24*3600), 'd'), form=['ymd'], prec=9)[0], 's'))[0]/(24*3600)
        segmenttimes.append((starttime, stoptime))
    d['segmenttimes'] = n.array(segmenttimes)
    totaltimeread = 24*3600*(d['segmenttimes'][:, 1] - d['segmenttimes'][:, 0]).sum()            # not guaranteed to be the same for each segment
    d['readints'] = n.round(totaltimeread / (d['inttime']*d['nsegments'])).astype(int)
    d['t_segment'] = totaltimeread/d['nsegments']
def calc_segment_times ( d ) : stopdts = n . linspace ( d [ 'nskip' ] + d [ 't_overlap' ] / d [ 'inttime' ] , d [ 'nints' ] , d [ 'nsegments' ] + 1 ) [ 1 : ] startdts = n . concatenate ( ( [ d [ 'nskip' ] ] , stopdts [ : - 1 ] - d [ 't_overlap' ] / d [ 'inttime' ] ) ) segmenttimes = [ ] for ( startdt , stopdt ) in zip ( d [ 'inttime' ] * startdts , d [ 'inttime' ] * stopdts ) : starttime = qa . getvalue ( qa . convert ( qa . time ( qa . quantity ( d [ 'starttime_mjd' ] + startdt / ( 24 * 3600 ) , 'd' ) , form = [ 'ymd' ] , prec = 9 ) [ 0 ] , 's' ) ) [ 0 ] / ( 24 * 3600 ) stoptime = qa . getvalue ( qa . convert ( qa . time ( qa . quantity ( d [ 'starttime_mjd' ] + stopdt / ( 24 * 3600 ) , 'd' ) , form = [ 'ymd' ] , prec = 9 ) [ 0 ] , 's' ) ) [ 0 ] / ( 24 * 3600 ) segmenttimes . append ( ( starttime , stoptime ) ) d [ 'segmenttimes' ] = n . array ( segmenttimes ) totaltimeread = 24 * 3600 * ( d [ 'segmenttimes' ] [ : , 1 ] - d [ 'segmenttimes' ] [ : , 0 ] ) . sum ( ) d [ 'readints' ] = n . round ( totaltimeread / ( d [ 'inttime' ] * d [ 'nsegments' ] ) ) . astype ( int ) d [ 't_segment' ] = totaltimeread / d [ 'nsegments' ]
Helper function for set_pipeline to define segmenttimes list, given nsegments definition