GithubHelp home page GithubHelp logo

flat field issue about csxtools HOT 3 CLOSED

mpmdean avatar mpmdean commented on June 23, 2024
flat field issue

from csxtools.

Comments (3)

ambarb avatar ambarb commented on June 23, 2024

Thanks @mpmdean . We are working on code for one big PR for various issues. For others that run into this prroblem, you may use the work around below by setting half=True.

import logging
logger = logging.getLogger(__name__)
import numpy as np

from csxtools.image import rotate90, stackmean
from csxtools.utils import  calculate_flatfield, get_images_to_3D,  get_fastccd_images

def get_fastccd_flatfield(light, dark, flat=None, limits=(0.6, 1.4), half=False, half_args = (7, 486)):
    """MODIFIED from csxtools original: Calculate a flatfield 
    This routine calculates the flatfield using the
    :func:calculate_flatfield() function after obtaining the images from
    the headers.
    Parameters
    ----------
    light : databroker header
        The header containing the light images
    dark : databroker header
        The header from the run containin the dark images
    flat : flatfield image (optional)
        The array to be used for the initial flatfield
    half : calculate for just the "good" half - hard coded
        Default is False
    half_args : Tuple for exluding entire sides of detector (left versus right)
        Left side is refers the the left side of the image after raw data is 
        processed with get_fastccd_images().  Default arguments are for the left side
        using the FrameStore mode.
    Returns
    -------
    array_like
        Flatfield correction
    """
    images = get_images_to_3D(get_fastccd_images(light, dark, flat))
    images = stackmean(images)
    if half == True:
        #rows because "super columns" are the large 10 pixel bins, but camera is on side.
        row_start, row_stop = half_args
        images[:,row_start:row_stop] = np.nan
        #plt.figure()
        #im = plt.imshow(images, vmin =0, vmax = 500)
        #cbar = plt.colorbar(im)
        #cbar.set_label('ADU gain corrected')
    flat = calculate_flatfield(images, limits)
    removed = np.sum(np.isnan(flat))
    if removed != 0:
        logger.warning("Flatfield correction removed %d pixels (%.2f %%)" %
                       (removed, removed * 100 / flat.size))
    return flat

from csxtools.

ambarb avatar ambarb commented on June 23, 2024

Issue #77 covers this

from csxtools.

mpmdean avatar mpmdean commented on June 23, 2024

I didn't spot that prior version of the same issue. I think this can be closed.

from csxtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.