glassure.pattern module
- exception glassure.pattern.BkgNotInRangeError(pattern_name: str)
Bases:
Exception
- class glassure.pattern.Pattern(x: ndarray | None = None, y: ndarray | None = None, name: str = '')
Bases:
objectA Pattern is a set of x and y values. It can be loaded from a file or created from scratch and can be modified by different methods. It builds the basis for all calculations in glassure.
- Parameters:
x – x values of the pattern
y – y values of the pattern
name – name of the pattern
- property data: tuple[ndarray, ndarray]
Returns the data of the pattern as a tuple of x and y values.
- Returns:
tuple of x and y values
- extend_to(x_value: float, y_value: float) Pattern
Extends the current pattern to a specific x_value by filling it with the y_value. Does not modify inplace but returns a new filled Pattern
- Parameters:
x_value – Point to which extending the pattern should be smaller than the lowest x-value in the pattern or
vice versa :param y_value: number to fill the pattern with :return: extended Pattern
- static from_dict(json_dict: dict) Pattern
Creates a new Pattern from a dictionary representation of a Pattern.
- Parameters:
json_dict – dictionary representation of a Pattern
- Returns:
new Pattern
- static from_file(filename: str, skip_rows: int = 0) Pattern | '-1'
Loads a pattern from a file. The file can be either a .xy or a .chi file. The .chi file will be loaded with skiprows=4 by default.
- Parameters:
filename – path to the file
skip_rows – number of rows to skip when loading the data (header)
- limit(x_min: float, x_max: float) Pattern
Limits the pattern to a specific x-range. Does not modify inplace but returns a new limited Pattern
- Parameters:
x_min – lower limit of the x-range
x_max – upper limit of the x-range
- Returns:
limited Pattern
- load(filename: str, skiprows: int = 0)
Loads a pattern from a file. The file can be either a .xy or a .chi file. The .chi file will be loaded with skiprows=4 by default.
- Parameters:
filename – path to the file
skiprows – number of rows to skip when loading the data (header)
- name: str = ''
- rebin(bin_size: float) Pattern
Returns a new pattern, which is a rebinned version of the current one.
- Parameters:
bin_size – Size of the bins
- Returns:
rebinned Pattern
- save(filename: str, header: str = '')
Saves the Pattern to a two-column xy file.
- Parameters:
filename – path to the file
header – header to be written to the file
- smooth(amount: float) Pattern
Smoothing the pattern by applying a gaussian filter. Returns the smoothed pattern. :param amount: amount of smoothing to be applied
- to_dict() dict
Returns a dictionary representation of the pattern which can be used to save the pattern to a json file.
- Returns:
dictionary representation of the pattern
- x: ndarray | None = None
- y: ndarray | None = None
- glassure.pattern.serialize(value)
- glassure.pattern.validate(value)