Produce a mock transient pulse source for the purposes of characterizing the
    detection success of the current pipeline.
    
    Assumes
    - Code to inject the transients does so by inserting at an array index 
    - Noise level at the center of the data array is characteristic of the
      noise level throughout

    Input
    std   - noise level in visibilities(?) at mid-point of segment
    DMmax - maximum DM at which mock transient can be inserted [pc/cm^3]
    Amin/Amax is amplitude in units of the std (calculated below)
    rmax/rmin is radius range in arcmin
    DMmin is min DM

    Returns
    loff - direction cosine offset of mock transient from phase center [radians]
    moff - direction cosine offset of mock transient from phase center [radians]
    A  - amplitude of transient [std units]
    DM - dispersion measure of mock transient [pc/cm^3]

def make_transient(std, DMmax, Amin=6., Amax=20., rmax=20., rmin=0., DMmin=0.):
    """ Produce a mock transient pulse source for the purposes of characterizing the
    detection success of the current pipeline.
    
    Assumes
    - Code to inject the transients does so by inserting at an array index 
    - Noise level at the center of the data array is characteristic of the
      noise level throughout

    Input
    std   - noise level in visibilities(?) at mid-point of segment
    DMmax - maximum DM at which mock transient can be inserted [pc/cm^3]
    Amin/Amax is amplitude in units of the std (calculated below)
    rmax/rmin is radius range in arcmin
    DMmin is min DM

    Returns
    loff - direction cosine offset of mock transient from phase center [radians]
    moff - direction cosine offset of mock transient from phase center [radians]
    A  - amplitude of transient [std units]
    DM - dispersion measure of mock transient [pc/cm^3]
    """

    rad_arcmin = math.pi/(180*60)
    phimin =  0.0
    phimax = 2*math.pi
    
    # Amplitude of transient, done in units of the std
    # std is calculated assuming that noise level in the middle of the data, 
    # at index d['readints']/2, is characteristic of that throughout the data
    A = random.uniform(Amin, Amax) * std

    # Position of transient, in direction cosines
    r = random.uniform(rmin, rmax)
    phi = random.uniform(phimin, phimax)
    loff = r*math.cos(phi) * rad_arcmin
    moff = r*math.sin(phi) * rad_arcmin

    # Dispersion measure
    DM = random.uniform(DMmin, DMmax)
    return loff, moff, A, DM