clatlan / cdiutils

A python package to help Coherent Diffraction Imaging (CDI) practitioners in their analysis.
MIT License
10 stars 6 forks source link

data cleaning class #19

Open kyolson opened 11 months ago

kyolson commented 11 months ago

A new class that is used to preprocess the data could be introduced. This would contain functions that allow filtering, noise removal and others after the data is loaded.

This would ideally be implemented after the loading but before the com/max reference pixel is found, someplace inside the pre-processor.

        if noise_threshold:
            try:
                print('--------Using Noise Threshold----------')
                print(f"Setting intensity values under {noise_threshold} to {floor}")

                super_threshold_indices = data < noise_threshold
                data[super_threshold_indices] = floor
            except TypeError:
                raise KeyError(
                f"Parameters noise_threshold and floor must both be given"
                ", if the threshold function is to be used.")

        if remove_constant:
            # try:
            print('--------Subtracting Constant----------')

            data = data - remove_constant
            zeros = data < 0
            data[zeros] = 0