Normalized FlatField

The FlatField class is responsible for storing the flatfield correction factors. It provides methods to read and create normalized flatfields.

Note

The method read_module_parameters_from_file expects a text file in the format below. Each line denotes the DG parameters for each module.

module 0 center  643.320033188550 +- 0.0000 conversion 0.657661167459868E-04 +- 0.0000 offset  0.00000000000000     +- 0.0000
module 1 center  633.044070300816 +- 0.0000 conversion 0.657618957538105E-04 +- 0.0000 offset  5.00486981153634     +- 0.0000

If youre file format deviates from the above format implement your custom file reader inheriting from the class SimpleFileInterface (SimpleFileInterface) and pass it to the function.

Note

The method read_bad_channels_from_file expects a text file using the format below. Each line denotes the index of a bad channel. Consecutive bad channels can be stored on one line e.g. channels with 20-42 are bad channels.

1
2
20-42
100
1002-1004

If youre file format deviates from the above format implement your custom file reader inheriting from the class SimpleFileInterface (SimpleFileInterface) and pass it to the function.

class FlatField

Public Functions

FlatField(std::shared_ptr<MythenDetectorSpecifications> mythen_detector_)

Constructor for FlatField class.

Parameters:

mythen_detector_ – ptr to MythenDetectorSpecifications storing all mythen specific parameters

void set_scale_factor(const double scale_factor_)

set scale factor to scale incident intensity to reasonable values e.g. can be set to incident intensity of first acquisition

double get_scale_factor() const

get scale factor

void set_soft_window(const std::pair<double, double> soft_window_)

set soft window bounds [degrees] to exclude strips with lower exposure.

std::pair<double, double> get_soft_window() const

get soft window bounds [degrees]

double solid_angle(const size_t module_index, size_t strip_index) const

calculates solid angle of strip

Parameters:
  • module_index – index of module

  • strip_index – local strip index of module e.g. 0-1279

Returns:

solid angle of strip

void create_normalized_flatfield_from_filelist(const std::vector<std::filesystem::path> &filelist, std::shared_ptr<MythenFileReader> file_reader)

creates normalized flatfield from list of files containing flatfield acquisitions

Parameters:
  • filelist – list of files containing flatfield acquisitions

  • file_reader – custom file reader to read mythen acquisition files

void read_normalized_flatfield_from_file(const std::string &filename, const std::shared_ptr<SimpleFileInterface> file_reader = std::make_shared<CustomFlatFieldFile>())

read normalized flatfield and std from file

Parameters:
  • filename – name of file

  • file_reader – custom file_reader to read flatfield file default: ascii file with

void read_module_parameters_from_file(const std::filesystem::path &filename, const std::shared_ptr<SimpleFileInterface> file_reader = std::make_shared<InitialAngCalParametersFile>())

reads DG calibration parameters from file

Parameters:
  • filename – name of file

  • file_reader – custom file_reader to read DG parameters file (default InitialAngCalParametersFile: following format module [module_index] center [center] +- [error] conversion [conversion] +- [error] offset [offset] +- [error])

void read_bad_channels_from_file(const std::filesystem::path &filename, const std::shared_ptr<SimpleFileInterface> file_reader = std::make_shared<CustomBadChannelsFile>())

reads bad channels from file

Parameters:
  • filename – bad channels filename

  • file_reader – file_reader to read bad channels file (default: CustomBadChannelsFile: following format line by line either single strip index or block of strip indices seperated by ‘-’ e.g. 0-10)

void set_bad_channels(const NDArray<bool, 1> &bad_channels_)
NDArray<bool, 1> get_bad_channels() const
void set_normalized_flatfield(const NDArray<double, 2> &flat_field_)

set flatfield from NDArray

void set_normalized_flatfield(NDArray<double, 2> &&flat_field_)
NDArray<double, 2> get_normalized_flatfield() const
NDView<double, 2> get_normalized_flatfield_view() const
double diffraction_angle_from_DG_parameters(const size_t module_index, const double detector_angle, size_t strip_index, const double distance_to_strip) const

calculates diffraction angle from DG module parameters (used in Beer’s Law)

Parameters:
  • detector_angle – detector position [degrees]

  • strip_index – local strip index of module e.g. 0-1279

  • distance_to_strip – distance to strip (if 0.0 calculates diffraction angle at center of strip) [given in strips]

Returns:

diffraction angle [degrees]

Private Functions

double elastic_correction(const double detector_angle) const

elastic correction to diffraction angle

Parameters:

detector_angle – detector angle [degrees]

Returns:

elastic correction to diffraction angle [degrees]

Private Members

double scale_factor = {1.0}

scale_factor is used to scale incident intensity to ~ one

std::shared_ptr<MythenDetectorSpecifications> mythen_detector

detector specifications of Mythen detector

DGParameters DGparameters = {}

DG module parameters stored as 2D array of shape (num_modules, 3) where the three parameters are center, conversion and offset.

NDArray<double, 2> flat_field

normalized flatfield stored as 2D array of shape (num_strips, 2) where the two values are normalized flatfield value and standard deviation value sof -1.0 denote strips which are not covered by any flatfield acquisition or are marked as bad.

NDArray<bool, 1> bad_channels = {}

boolean array of size of total number of strips/channels in detector, stores ‘TRUE’ if strip is a bad channel otherwise ‘FALSE’

std::pair<double, double> soft_window = {3.0, 34.0}

soft window bounds [degrees] to exclude strips with lower exposure.