def overscan(hdu):
    """Overscan subtract a CFHT MEGAPRIME frame.
    oversan(hdu) --> status

    The BIAS section keywords are expected to be BSEC[A|B] (for amps
    A and B) and the AMP sectoin is ASEC[A|B].
    """

    for amp in (['A','B']):
        AMPKW= 'ASEC'+amp
        BIASKW= 'BSEC'+amp
        dsec=re.findall(r'(\d+)',
                       hdu.header.get(AMPKW))
        bias=re.findall(r'(\d+)',
                        hdu.header.get(BIASKW))
        
        ## the X-boundaries set the amp section off from the bias section
        ## (ie. this is a column orriented device)
        al=int(dsec[0])-1
        ah=int(dsec[1])
        bl=int(bias[0])-1
        bh=int(bias[1])
        ### the Y directions must match or the array math fails
        ## b == Bottom
        ## t == Top
        b=max(int(bias[2]),int(dsec[2]))-1
        t=min(int(bias[3]),int(dsec[3]))

        bias = np.add.reduce(hdu.data[b:t,bl:bh],axis=1)/float(len(hdu.data[b:t,bl:bh][0]))
        mean = bias.mean()
        hdu.data[b:t,al:ah] -= bias[:,np.newaxis]
	hdu.data = hdu.data.astype('int16')
        hdu.header.update("BIAS",mean,comment="Mean bias level")
	del(bias)

    ### send back the mean bias level subtracted
    return mean
Overscan subtract a CFHT MEGAPRIME frame.
    oversan(hdu) --> status

    The BIAS section keywords are expected to be BSEC[A|B] (for amps
    A and B) and the AMP sectoin is ASEC[A|B].