import random


def makeStarKeyword(
    isFind,
    xyPos,
    randRange,
    centroidRad,
    index = 0,
    xyErr = (1.0, 1.0),
    asymm = 10.0,
    fwhm = 3.0,
    counts = 10000,
    bkgnd = 100,
    ampl = 3000,
):
    """Return a star keyword with values.

    The fields are as follows, where lengths and positions are in binned pixels
    and intensities are in ADUs:
    0       type characer: c = centroid, f = findstars, g = guide star
    1       index: an index identifying the star within the list of stars returned by the command.
    2,3     x,yCenter: centroid
    4,5     x,yError: estimated standard deviation of x,yCenter
    6       radius: radius of centroid region
    7       asymmetry: a measure of the asymmetry of the object;
            the value minimized by PyGuide.centroid.
            Warning: not normalized, so probably not much use.
    8       FWHM major
    9       FWHM minor
    10      ellMajAng: angle of ellipse major axis in x,y frame (deg)
    11      chiSq: goodness of fit to model star (a double gaussian). From PyGuide.starShape.
    12      counts: sum of all unmasked pixels within the centroid radius. From PyGuide.centroid
    13      background: background level of fit to model star. From PyGuide.starShape
    14      amplitude: amplitude of fit to model star. From PyGuide.starShape
    For "g" stars, the two following fields are added:
    15,16   predicted x,y position
    """
    if isFind:
        typeChar = "f"
    else:
        typeChar = "c"
    if randRange > 0:
        xyPos = [random.uniform(val - randRange, val + randRange) for val in xyPos]
    
    return "star=%s, %d, %0.2f, %0.2f, %0.2f, %0.2f, %0.0f, %0.0f, %0.1f, %0.1f, 0.0, 5, %0.0f, %0.1f, %0.1f" % \
        (typeChar, index, xyPos[0], xyPos[1], xyErr[0], xyErr[1], centroidRad, asymm, fwhm, fwhm, counts, bkgnd, ampl)