spinifex.ionospheric.index_tools ================================ .. py:module:: spinifex.ionospheric.index_tools .. autoapi-nested-parse:: Some useful multipurpose functions to interpolate on grids Classes ------- .. autoapisummary:: spinifex.ionospheric.index_tools.Indices spinifex.ionospheric.index_tools.SortedIndices spinifex.ionospheric.index_tools.Weights Functions --------- .. autoapisummary:: spinifex.ionospheric.index_tools._get_weights spinifex.ionospheric.index_tools.compute_index_and_weights spinifex.ionospheric.index_tools.get_indices spinifex.ionospheric.index_tools.get_indices_axis spinifex.ionospheric.index_tools.get_interpol spinifex.ionospheric.index_tools.get_sorted_indices spinifex.ionospheric.index_tools.wrap_around_zero Module Contents --------------- .. py:class:: Indices Bases: :py:obj:`NamedTuple` Indices of the closest two points in a possibly wrapping selection and the inverse distance weights .. py:attribute:: idx1 :type: numpy.typing.NDArray[numpy.int64] Index of the first closest point .. py:attribute:: idx2 :type: numpy.typing.NDArray[numpy.int64] Index of the second closest point .. py:attribute:: w1 :type: numpy.typing.NDArray[numpy.float64] Weight of the first closest point .. py:attribute:: w2 :type: numpy.typing.NDArray[numpy.float64] Weight of the second closest point .. py:class:: SortedIndices Bases: :py:obj:`NamedTuple` Indices of the closest two points in a possibly wrapping selection .. py:attribute:: distance :type: numpy.typing.NDArray[numpy.float64] Distances .. py:attribute:: indices :type: numpy.typing.NDArray[numpy.int64] Indices sorted by distance .. py:class:: Weights Bases: :py:obj:`NamedTuple` Weights of the closest two points in a possibly wrapping selection .. py:attribute:: w1 :type: numpy.typing.NDArray[numpy.float64] Weight of the first closest point .. py:attribute:: w2 :type: numpy.typing.NDArray[numpy.float64] Weight of the second closest point .. py:function:: _get_weights(goal: numpy.typing.NDArray[numpy.float64], index1: numpy.typing.NDArray[numpy.int64], index2: numpy.typing.NDArray[numpy.int64], selection: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 0) -> Weights Calculate weights based on distance of goal to selection Parameters ---------- goal : NDArray array of points to get weights for index1 : NDArray indices in selection for goals (index1, index2) per goal index2 : NDArray indices in selection for goals (index1, index2) per goal selection : NDArray array to select from wrap_unit : float, optional if goal/selection is a wrapable (e.g. angle) set this unit (e.g. 360), by default 0 Returns ------- namedtuple tuple with weights .. py:function:: compute_index_and_weights(maparray: numpy.typing.NDArray[numpy.float64], mapvalues: float | numpy.typing.NDArray[numpy.float64]) -> Indices helper function to get indices and weights for interpolating tecmaps Only works for the non wrapping axes. So time and latitude Args: maparray (NDArray) : array to get indices in mapvalues (float | np.array ): values to get indices for Returns: Tuple[np.array, np.array, np.array]: idx1,idx2 and weights for idx2, idx2 is always >= idx1 .. py:function:: get_indices(goal: float, selection: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 0) -> Indices find the indices of the closest two points in a possibly wrapping array selection Parameters ---------- goal : float location of point selection : NDArray array of points wrap_unit : float, optional if goal/selection is a wrapping entity (e.g. angles) set this to the wrap value (e.g. 360), by default 0 Returns ------- Indices: sorted list of index1 and index2 .. py:function:: get_indices_axis(goal: numpy.typing.NDArray[numpy.float64], selection: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 0) -> Indices get indices of the closest two points in a possibly wrapping selection for an array of goals Parameters ---------- goal : NDArray[np.float64] array of points for which to get the indices selection : NDArray[np.float64] array from which to get the indices wrap_unit : float, optional set if selection is a wrapping entity (e.g. angles), by default 0 Returns ------- Indices object with indices and weights .. py:function:: get_interpol(data: numpy.typing.NDArray[numpy.float64], dist: numpy.typing.NDArray[numpy.float64]) -> float get distance weighted sum of data Parameters ---------- data : NDArray[np.float64] input data dist : NDArray[np.float64] distances (inverse weights) Returns ------- float weighted sum of data .. py:function:: get_sorted_indices(lon: float, lat: float, avail_lon: numpy.typing.NDArray[numpy.float64], avail_lat: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 360.0) -> SortedIndices find distances of a lon/lat grid to a point and return sorted list of indices Parameters ---------- lon : float longitude lat : float latitude avail_lon : NDArray[np.float64] array of available longitudes (must have same length as avail_lon) avail_lat : NDArray[np.float64] array of available latitudes (must have same length as avail_lat) wrap_unit : float, optional if goal/selection is a wrapping entity (e.g. angles) set this to the wrap value (e.g. 360), by default 360.0 Returns ------- SortedIndices sorted indices and distances in the array Raises ------ ArrayShapeError if the shape of avail_lon is not equal to the shape of avail_lat .. py:function:: wrap_around_zero(data: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 2 * np.pi) -> numpy.typing.NDArray[numpy.float64] Function to calculate the remainder of data such that this is centered around zero Parameters ---------- data : NDArray[np.float64] input data wrap_unit : float, optional unit for wrapping, by default 2*np.pi Returns ------- NDArray[np.float64] wrapped data