mrschweizer / PyThat

This is a community package which helps reading .h5 files created by ThatecOS and converting them to xarray objects and netcdf files. This software is not maintained by and has no affiliations to THATec Innovation GmbH.
MIT License
4 stars 1 forks source link

Add norm on function #18

Closed mrschweizer closed 1 year ago

mrschweizer commented 1 year ago
def substract_background(x, y, dim=None, f_max=2, f_min = None):
    """
    Use a reference measurement to substract the background. Background is renormalized to match the intensity of the
    main measurement in the specified interval and then substracted from the main.
    :param x: xarray object
    :param y: xarray object (background)
    :param name: Name of the Frequency coordinate axis along which the frequency is to be selected
    :param f_min: specifies the minimum of the frequency area over which is to be normalized
    :param f_max: specifies the maximum of the frequency area over which is to be normalized
    :return: x without background, xarray object
    """

    norm = x.sel({dim: slice(f_min, f_max)}).sum(dim)
    return x - y/y.sel({dim: slice(f_min, f_max)}).sum(dim)*norm
mrschweizer commented 1 year ago

resolved dbf3798