# Path: concert/quantities.py

# 
# Path: concert/imageprocessing.py
# def flat_correct(radio, flat, dark=None):
#     """
#     Flat field correction of a radiograph *radio* with *flat* field.
#     If *dark* field is supplied it is taken into account as well.
#     """
#     if dark is not None:
#         flat = flat - dark
#         radio = radio - dark
#     valid = np.where(flat != 0)
#     result = np.zeros(radio.shape, dtype=np.float32)
#     result[valid] = radio[valid] / flat[valid]
# 
#     return result


import logging
import time
import numpy as np
from concert.quantities import q
from concert.imageprocessing import flat_correct as make_flat_correct
    Average images as they come from *producer*.
    """
    average = None
    i = 0

    async for data in producer:
        if average is None:
            average = np.zeros_like(data, dtype=np.float32)
        average = (average * i + data) / (i + 1)
        yield average
        i += 1


async def flat_correct(flat, producer, dark=None):
    """
    flat_correct(flat, producer, dark=None)

    Flat correcting coroutine which takes a *flat* field and a *dark* field (if given) from
    *producer* and calculates a flat corrected radiograph.
    """
    flat = flat.astype(np.float32)

    async for radio in producer:
        yield make_flat_correct(radio, flat, dark=dark)


async def absorptivity(producer):
    r"""
    absorptivity(producer)


# Path: concert/quantities.py

# 
# Path: concert/imageprocessing.py
# def flat_correct(radio, flat, dark=None):
#     """
#     Flat field correction of a radiograph *radio* with *flat* field.
#     If *dark* field is supplied it is taken into account as well.
#     """
#     if dark is not None:
#         flat = flat - dark
#         radio = radio - dark
#     valid = np.where(flat != 0)
#     result = np.zeros(radio.shape, dtype=np.float32)
#     result[valid] = radio[valid] / flat[valid]
# 
#     return result


# Path: concert/coroutines/filters.py
import logging
import time
import numpy as np
from concert.quantities import q
from concert.imageprocessing import flat_correct as make_flat_correct

    Average images as they come from *producer*.
    """
    average = None
    i = 0

    async for data in producer:
        if average is None:
            average = np.zeros_like(data, dtype=np.float32)
        average = (average * i + data) / (i + 1)
        yield average
        i += 1


async def flat_correct(flat, producer, dark=None):
    """
    flat_correct(flat, producer, dark=None)

    Flat correcting coroutine which takes a *flat* field and a *dark* field (if given) from
    *producer* and calculates a flat corrected radiograph.
    """
    flat = flat.astype(np.float32)

    async for radio in producer:
        yield make_flat_correct(radio, flat, dark=dark)


async def absorptivity(producer):
    r"""
    absorptivity(producer)


    Get the absorptivity from a flat corrected stream of images.  The intensity