spinifex.ionospheric.index_tools

Some useful multipurpose functions to interpolate on grids

Classes

Indices

Indices of the closest two points in a possibly wrapping selection and the inverse distance weights

SortedIndices

Indices of the closest two points in a possibly wrapping selection

Weights

Weights of the closest two points in a possibly wrapping selection

Functions

_get_weights(→ Weights)

Calculate weights based on distance of goal to selection

compute_index_and_weights(→ Indices)

helper function to get indices and weights for interpolating tecmaps

get_indices(→ Indices)

find the indices of the closest two points in a possibly wrapping array selection

get_indices_axis(→ Indices)

get indices of the closest two points in a possibly wrapping selection for an array

get_interpol(→ float)

get distance weighted sum of data

get_sorted_indices(→ SortedIndices)

find distances of a lon/lat grid to a point and return sorted list of indices

wrap_around_zero(→ numpy.typing.NDArray[numpy.float64])

Function to calculate the remainder of data such that this is centered around zero

Module Contents

class spinifex.ionospheric.index_tools.Indices[source]

Bases: NamedTuple

Indices of the closest two points in a possibly wrapping selection and the inverse distance weights

idx1: numpy.typing.NDArray[numpy.int64][source]

Index of the first closest point

idx2: numpy.typing.NDArray[numpy.int64][source]

Index of the second closest point

w1: numpy.typing.NDArray[numpy.float64][source]

Weight of the first closest point

w2: numpy.typing.NDArray[numpy.float64][source]

Weight of the second closest point

class spinifex.ionospheric.index_tools.SortedIndices[source]

Bases: NamedTuple

Indices of the closest two points in a possibly wrapping selection

distance: numpy.typing.NDArray[numpy.float64][source]

Distances

indices: numpy.typing.NDArray[numpy.int64][source]

Indices sorted by distance

class spinifex.ionospheric.index_tools.Weights[source]

Bases: NamedTuple

Weights of the closest two points in a possibly wrapping selection

w1: numpy.typing.NDArray[numpy.float64][source]

Weight of the first closest point

w2: numpy.typing.NDArray[numpy.float64][source]

Weight of the second closest point

spinifex.ionospheric.index_tools._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[source]

Calculate weights based on distance of goal to selection

Parameters

goalNDArray

array of points to get weights for

index1NDArray

indices in selection for goals (index1, index2) per goal

index2NDArray

indices in selection for goals (index1, index2) per goal

selectionNDArray

array to select from

wrap_unitfloat, optional

if goal/selection is a wrapable (e.g. angle) set this unit (e.g. 360), by default 0

Returns

namedtuple

tuple with weights

spinifex.ionospheric.index_tools.compute_index_and_weights(maparray: numpy.typing.NDArray[numpy.float64], mapvalues: float | numpy.typing.NDArray[numpy.float64]) Indices[source]

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

spinifex.ionospheric.index_tools.get_indices(goal: float, selection: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 0) Indices[source]

find the indices of the closest two points in a possibly wrapping array selection

Parameters

goalfloat

location of point

selectionNDArray

array of points

wrap_unitfloat, 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

spinifex.ionospheric.index_tools.get_indices_axis(goal: numpy.typing.NDArray[numpy.float64], selection: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 0) Indices[source]

get indices of the closest two points in a possibly wrapping selection for an array of goals

Parameters

goalNDArray[np.float64]

array of points for which to get the indices

selectionNDArray[np.float64]

array from which to get the indices

wrap_unitfloat, optional

set if selection is a wrapping entity (e.g. angles), by default 0

Returns

Indices

object with indices and weights

spinifex.ionospheric.index_tools.get_interpol(data: numpy.typing.NDArray[numpy.float64], dist: numpy.typing.NDArray[numpy.float64]) float[source]

get distance weighted sum of data

Parameters

dataNDArray[np.float64]

input data

distNDArray[np.float64]

distances (inverse weights)

Returns

float

weighted sum of data

spinifex.ionospheric.index_tools.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[source]

find distances of a lon/lat grid to a point and return sorted list of indices

Parameters

lonfloat

longitude

latfloat

latitude

avail_lonNDArray[np.float64]

array of available longitudes (must have same length as avail_lon)

avail_latNDArray[np.float64]

array of available latitudes (must have same length as avail_lat)

wrap_unitfloat, 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

spinifex.ionospheric.index_tools.wrap_around_zero(data: numpy.typing.NDArray[numpy.float64], wrap_unit: float = 2 * np.pi) numpy.typing.NDArray[numpy.float64][source]

Function to calculate the remainder of data such that this is centered around zero

Parameters

dataNDArray[np.float64]

input data

wrap_unitfloat, optional

unit for wrapping, by default 2*np.pi

Returns

NDArray[np.float64]

wrapped data