How to use the pyxrf.core.utils.grid_interpolate function in pyxrf

To help you get started, we’ve selected a few pyxrf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NSLS-II / PyXRF / pyxrf / model / draw_image_rgb.py View on Github external
if v_high - v_low < 1:  # This should not happen in practice, but check just in case
                v_high = v_low + 1

            v_low, v_high = v_low / 100.0, v_high / 100.0
            c = 1.0 / (v_high - v_low)
            data_out = (data_in - v_low) * c

            return np.clip(data_out, 0, 1.0)

        # Interpolate non-uniformly spaced data to uniform grid
        if grid_interpolate_local:
            data_r, _, _ = grid_interpolate(data_r,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_g, _, _ = grid_interpolate(data_g,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_b, _, _ = grid_interpolate(data_b,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])

        # Normalize data
        data_r = _norm_data(data_r)
        data_g = _norm_data(data_g)
        data_b = _norm_data(data_b)

        data_r = _stretch_range(data_r, rgb_l_h[self.index_red]['low'], rgb_l_h[self.index_red]['high'])
        data_g = _stretch_range(data_g, rgb_l_h[self.index_green]['low'], rgb_l_h[self.index_green]['high'])
        data_b = _stretch_range(data_b, rgb_l_h[self.index_blue]['low'], rgb_l_h[self.index_blue]['high'])

        R, G, B, RGB = make_cube(data_r,
github NSLS-II / PyXRF / pyxrf / model / draw_image_rgb.py View on Github external
v_low, v_high = v_low / 100.0, v_high / 100.0
            c = 1.0 / (v_high - v_low)
            data_out = (data_in - v_low) * c

            return np.clip(data_out, 0, 1.0)

        # Interpolate non-uniformly spaced data to uniform grid
        if grid_interpolate_local:
            data_r, _, _ = grid_interpolate(data_r,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_g, _, _ = grid_interpolate(data_g,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_b, _, _ = grid_interpolate(data_b,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])

        # Normalize data
        data_r = _norm_data(data_r)
        data_g = _norm_data(data_g)
        data_b = _norm_data(data_b)

        data_r = _stretch_range(data_r, rgb_l_h[self.index_red]['low'], rgb_l_h[self.index_red]['high'])
        data_g = _stretch_range(data_g, rgb_l_h[self.index_green]['low'], rgb_l_h[self.index_green]['high'])
        data_b = _stretch_range(data_b, rgb_l_h[self.index_blue]['low'], rgb_l_h[self.index_blue]['high'])

        R, G, B, RGB = make_cube(data_r,
                                 data_g,
                                 data_b)
github NSLS-II / PyXRF / pyxrf / model / draw_image_rgb.py View on Github external
if (v_low <= 0) and (v_high >= 100):
                return data_in

            if v_high - v_low < 1:  # This should not happen in practice, but check just in case
                v_high = v_low + 1

            v_low, v_high = v_low / 100.0, v_high / 100.0
            c = 1.0 / (v_high - v_low)
            data_out = (data_in - v_low) * c

            return np.clip(data_out, 0, 1.0)

        # Interpolate non-uniformly spaced data to uniform grid
        if grid_interpolate_local:
            data_r, _, _ = grid_interpolate(data_r,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_g, _, _ = grid_interpolate(data_g,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])
            data_b, _, _ = grid_interpolate(data_b,
                                            self.data_dict['positions']['x_pos'],
                                            self.data_dict['positions']['y_pos'])

        # Normalize data
        data_r = _norm_data(data_r)
        data_g = _norm_data(data_g)
        data_b = _norm_data(data_b)

        data_r = _stretch_range(data_r, rgb_l_h[self.index_red]['low'], rgb_l_h[self.index_red]['high'])
        data_g = _stretch_range(data_g, rgb_l_h[self.index_green]['low'], rgb_l_h[self.index_green]['high'])
github NSLS-II / PyXRF / pyxrf / model / draw_image.py View on Github external
maxv = np.max(data_dict)
                low_limit = (maxv-minv)*low_ratio + minv
                high_limit = (maxv-minv)*high_ratio + minv

                # Set some minimum range for the colorbar (otherwise it will have white fill)
                if math.isclose(low_limit, high_limit, abs_tol=2e-20):
                    if abs(low_limit) < 1e-20:  # The value is zero
                        dv = 1e-20
                    else:
                        dv = math.fabs(low_limit * 0.01)
                    high_limit += dv
                    low_limit -= dv

                if not scatter_show_local:
                    if grid_interpolate_local:
                        data_dict, _, _ = grid_interpolate(data_dict,
                                                           self.data_dict['positions']['x_pos'],
                                                           self.data_dict['positions']['y_pos'])
                    im = grid[i].imshow(data_dict,
                                        cmap=grey_use,
                                        interpolation=plot_interp,
                                        extent=(xd_min, xd_max, yd_max, yd_min),
                                        origin='upper',
                                        clim=(low_limit, high_limit))
                    grid[i].set_ylim(yd_axis_max, yd_axis_min)
                else:
                    xx = self.data_dict['positions']['x_pos']
                    yy = self.data_dict['positions']['y_pos']

                    # The following condition prevents crash if different file is loaded while
                    #    the scatter plot is open (PyXRF specific issue)
                    if data_dict.shape == xx.shape and data_dict.shape == yy.shape: