How to use the jwst.datamodels.dqflags.pixel.keys function in jwst

To help you get started, we’ve selected a few jwst examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacetelescope / jwql / jwql / instrument_monitors / common_monitors / bad_pixel_monitor.py View on Github external
mnemonic : str
        The type of bad pixel to map. The mnemonic must be one of those
        in the JWST calibration pipeline's list of possible mnemonics

    Returns
    -------
    x_loc : list
        List of x locations within ``badpix_image`` containing
        ``mnemonic`` pixels.

    y_loc : list
        List of x locations within ``badpix_image`` containing
        ``mnemonic`` pixels.
    """
    mnemonic = mnemonic.upper()
    possible_mnemonics = dqflags.pixel.keys()
    if mnemonic not in possible_mnemonics:
        raise ValueError("ERROR: Unrecognized bad pixel mnemonic: {}".format(mnemonic))

    # Find locations of this type of bad pixel
    y_loc, x_loc = np.where(badpix_image & dqflags.pixel[mnemonic] > 0)

    # Convert from numpy int to python native int, in order to avoid SQL
    # error when adding to the database tables.
    y_location = [int(element) for element in y_loc]
    x_location = [int(element) for element in x_loc]

    return x_location, y_location