pyRTX.core.analysis_utils

Functions

computeRADEC(vecs[, periodicity])

Computes the right ascension and declination for a set of vectors.

compute_body_positions(target, epochs, ...)

Computes the relative positions of a target body with respect to an observing body.

compute_body_states(target, epochs, frame, obs)

Computes the relative position and velocity of a target body with respect to an observing body.

convertEpoch(monteEpoch)

Convert a Monte epoch string to a spice epoch string

convertTIFtoMesh([tifFile, latSampling, ...])

Converts a TIFF map to a format that can be used to assign values to a planetary mesh.

epochRange([startEpoch, duration, step])

Generates a range of epochs.

epochRange2([startEpoch, endEpoch, step])

Generates a range of epochs between a start and end epoch.

getSunAngles([scName, scFrame, epoch, ...])

Computes the right ascension and declination of the Sun as seen from a spacecraft.

get_spacecraft_area(spacecraft, rays[, ra, ...])

Computes the apparent area of a spacecraft as seen from a given direction.

get_sun_exposed_area(sc, rtx, epoch)

Computes the sun-exposed area of a spacecraft.

Classes

LookupTable(linspace_x, linspace_y, values)

A class for storing and interpolating 2D lookup tables.

LookupTableND([axes, values, info, np_array])

A class for storing and interpolating N-dimensional lookup tables.

ScatterLookup()

A class for dealing with zone-scattered lookup tables.

TiffInterpolator([axes, values])

A class for interpolating TIFF image data.

class pyRTX.core.analysis_utils.LookupTable(linspace_x, linspace_y, values)[source]

A class for storing and interpolating 2D lookup tables.

This class is used to store results in the shape aof a lookup table. This is mainly used to store the resultas of a set of raytracing results example: the solar pressure for a body is computed for a grid of RA/DEC values. these values can be stored in the LookupTable object and later retrieved. This class offers the possibility of not oly retrieving pre-computed values, but aslso interpolating between grid points.

NOTE: the grid of the lookup table does not need to be regular the interpolation is based on numpy griddata method which is able to cope with unstructured grids

The main way of retrieving values is through indexing. The following are implemented:

LUT[a,b]: if a, b are in the original lookup table, the original values are returned, otherwise they are interpolated LUT[:,:] or LUT[a:b, c:d]: return the original lut sliced as requested LUT[:,a]: return the original lut (all elements of first axis, integer-indexed elements of second axis) LUT[array-like, array-like]: return the lookup table interpolated in the array-like points

Parameters:
  • linspace_x (np.array(N,)) – The x axis of the lookup table

  • linspace_y (np.array(M,)) – The y axis of the lookup table

  • values (np.ndarray (N,M,1)) – The lookup table values

__init__(linspace_x, linspace_y, values)[source]

Initializes the LookupTable object.

Parameters:
set_interpType(interpType)[source]

Sets the interpolation type.

Parameters:

interpType (str) – The interpolation method to use (e.g., ‘linear’, ‘cubic’).

interp_point(x, y)[source]

Interpolates the lookup table at a single point.

Parameters:
  • x (float) – The x-coordinate of the point.

  • y (float) – The y-coordinate of the point.

Returns:

The interpolated value.

Return type:

float

__getitem__(idxs)[source]

Allows indexing into the lookup table.

Parameters:

idxs (tuple) – A tuple of indices for each dimension of the lookup table.

Returns:

The interpolated value(s) at the given indices.

Return type:

float or numpy.ndarray

quickPlot(xlabel=None, ylabel=None, title=None, conversion=1, clabel=None, cmap='viridis', saveto=None)[source]

Produces a quick plot of the lookup table.

Parameters:
  • xlabel (str, optional) – The label for the x-axis.

  • ylabel (str, optional) – The label for the y-axis.

  • title (str, optional) – The title of the plot.

  • conversion (float, default 1) – A conversion factor for the plotted values.

  • clabel (str, optional) – The label for the color bar.

  • cmap (str, default 'viridis') – The colormap to use.

  • saveto (str, optional) – The path to save the plot to.

class pyRTX.core.analysis_utils.LookupTableND(axes=None, values=None, info=None, np_array=None)[source]

A class for storing and interpolating N-dimensional lookup tables.

Same concept as the LookupTable class, but allowing for multi-dimensional (>2) tables

Parameters:
  • axes (tuple of np.array) – The axes of the lookup table

  • values (np.ndarray(N,M,L,...,1)) –

  • info (str) – A string field to store information about the lookup table. This is set as a class property so it can be requested trhough instance.info

  • np_array (np.array) – unset

__init__(axes=None, values=None, info=None, np_array=None)[source]

Initializes the LookupTableND object.

Parameters:
  • axes (tuple of numpy.ndarray, optional) – The axes of the lookup table.

  • values (numpy.ndarray, optional) – The values at the grid points.

  • info (str, optional) – Information about the lookup table.

  • np_array (numpy.ndarray, optional) – Unused.

set_interpType(interpType)[source]

Sets the interpolation type.

Parameters:

interpType (str) – The interpolation method to use (e.g., ‘linear’, ‘cubic’).

get_idx(ind, search_list)[source]

Gets the index of a value in a list.

Parameters:
Returns:

The index of the value.

Return type:

int

interp_point(vals)[source]

Interpolates the lookup table at a single point.

Parameters:

vals (tuple) – A tuple of coordinates of the point.

Returns:

The interpolated value.

Return type:

float

__getitem__(idxs)[source]

Allows indexing into the lookup table.

Parameters:

idxs (tuple) – A tuple of indices for each dimension of the lookup table.

Returns:

The interpolated value(s) at the given indices.

Return type:

float or numpy.ndarray

axisExtent()[source]

Returns the extent of each axis.

Returns:

A list of [min, max] pairs for each axis.

Return type:

list

quickPlot(xlabel=None, ylabel=None, title=None, conversion=1, clabel=None, cmap='viridis', saveto=None)[source]

Produces a quick plot of a 2D slice of the lookup table.

Parameters:
  • xlabel (str, optional) – The label for the x-axis.

  • ylabel (str, optional) – The label for the y-axis.

  • title (str, optional) – The title of the plot.

  • conversion (float, default 1) – A conversion factor for the plotted values.

  • clabel (str, optional) – The label for the color bar.

  • cmap (str, default 'viridis') – The colormap to use.

  • saveto (str, optional) – The path to save the plot to.

class pyRTX.core.analysis_utils.ScatterLookup[source]

A class for dealing with zone-scattered lookup tables.

Intended for creating a lookup table of sets of computed values that lie in distinct, DISJUNCT, zones of the axes space. Example: the value of a variable has been computed in X = [0,1] Y = [0,1] and X = [3,4] Y = [-2,-1]

After instantiating the empty class, the different zones are added. Example:

sc = ScatterLookup()
zone1 = LookupTableND(*args, **kwargs)
zone2 = LookupTableND(*args, **kwargs)
sc.addZone(zone1)
sc.addZone(zone2)

The value retrieval follows the same rules of indexing as the LookupTable and LookupTableND classes

__init__()[source]

Initializes the ScatterLookup object.

add_zone(ZoneLookup='')[source]

Adds a zone to the lookup table.

Parameters:

ZoneLookup (pyRTX.core.analysis_utils.LookupTableND) – The lookup table for the new zone.

__getitem__(idxs)[source]

Allows indexing into the lookup table.

Parameters:

idxs (tuple) – A tuple of indices for each dimension of the lookup table.

Returns:

The interpolated value(s) at the given indices.

Return type:

float or numpy.ndarray

zone_determination(idxs)[source]

Determines which zone the given indices belong to.

Parameters:

idxs (tuple) – A tuple of indices for each dimension of the lookup table.

Returns:

The index of the zone.

Return type:

int

class pyRTX.core.analysis_utils.TiffInterpolator(axes=None, values=None)[source]

A class for interpolating TIFF image data.

__init__(axes=None, values=None)[source]

Initializes the TiffInterpolator object.

Parameters:
interpolator(vals)[source]

Performs the interpolation.

Parameters:

vals (tuple) – A tuple of coordinates at which to interpolate.

Returns:

The interpolated values.

Return type:

numpy.ndarray

set_interpType(interpType)[source]

Sets the interpolation type.

Parameters:

interpType (str) – The interpolation method to use (e.g., ‘linear’, ‘cubic’).

get_idx(ind, search_list)[source]

Gets the index of a value in a list.

Parameters:
Returns:

The index of the value.

Return type:

int

interp_point(vals)[source]

Interpolates the TIFF image at a single point.

Parameters:

vals (tuple) – A tuple of coordinates of the point.

Returns:

The interpolated value.

Return type:

float

__getitem__(idxs)[source]

Allows indexing into the TIFF image.

Parameters:

idxs (tuple) – A tuple of indices for each dimension of the TIFF image.

Returns:

The interpolated value(s) at the given indices.

Return type:

float or numpy.ndarray

pyRTX.core.analysis_utils.getSunAngles(scName=None, scFrame=None, epoch=None, correction='LT+S')[source]

Computes the right ascension and declination of the Sun as seen from a spacecraft.

Parameters:
  • scName (str, optional) – The name of the spacecraft.

  • scFrame (str, optional) – The reference frame of the spacecraft.

  • epoch (float, optional) – The epoch for the calculation.

  • correction (str, default 'LT+S') – The aberration correction to use.

Returns:

A tuple containing the right ascension and declination in radians.

Return type:

tuple

pyRTX.core.analysis_utils.epochRange(startEpoch=None, duration=None, step=100)[source]

Generates a range of epochs.

Parameters:
  • startEpoch (str or float, optional) – The start epoch in a format recognized by SPICE or as a float.

  • duration (float, optional) – The duration of the epoch range in seconds.

  • step (int, default 100) – The step size in seconds.

Returns:

An array of epochs.

Return type:

numpy.ndarray

pyRTX.core.analysis_utils.epochRange2(startEpoch=None, endEpoch=None, step=100)[source]

Generates a range of epochs between a start and end epoch.

Parameters:
  • startEpoch (str or float, optional) – The start epoch in a format recognized by SPICE or as a float.

  • endEpoch (str or float, optional) – The end epoch in a format recognized by SPICE or as a float.

  • step (int, default 100) – The step size in seconds.

Returns:

An array of epochs.

Return type:

numpy.ndarray

pyRTX.core.analysis_utils.computeRADEC(vecs, periodicity=360)[source]

Computes the right ascension and declination for a set of vectors.

Parameters:
  • vecs (numpy.ndarray) – An array of shape (N, 3) containing the vectors.

  • periodicity (int, default 360) – The periodicity of the right ascension in degrees.

Returns:

A tuple containing the right ascension and declination in radians.

Return type:

tuple

pyRTX.core.analysis_utils.convertTIFtoMesh(tifFile='', latSampling='', inferSampling=False, lonSampling='', planet='', lat0=-1.5707963267948966, lat1=1.5707963267948966, lon0=0, lon1=6.283185307179586)[source]

Converts a TIFF map to a format that can be used to assign values to a planetary mesh.

Parameters:
  • tifFile (str, default '') – The path to the TIFF file.

  • latSampling (float, default '') – The latitude sampling step in radians.

  • inferSampling (bool, default False) – Whether to infer the sampling from the TIFF file.

  • lonSampling (float, default '') – The longitude sampling step in radians.

  • planet (pyRTX.Planet, default '') – The Planet object containing the mesh.

  • lat0 (float, default -numpy.pi/2) – The minimum latitude.

  • lat1 (float, default numpy.pi/2) – The maximum latitude.

  • lon0 (float, default 0) – The minimum longitude.

  • lon1 (float, default 2*numpy.pi) – The maximum longitude.

Returns:

An interpolator for mapping the TIFF values to the mesh.

Return type:

TiffInterpolator

pyRTX.core.analysis_utils.convertEpoch(monteEpoch)[source]

Convert a Monte epoch string to a spice epoch string

pyRTX.core.analysis_utils.get_spacecraft_area(spacecraft, rays, ra=0.0, dec=0.0, epoch=None)[source]

Computes the apparent area of a spacecraft as seen from a given direction.

Parameters:
  • spacecraft (pyRTX.Spacecraft) – The spacecraft object.

  • rays (pyRTX.PixelPlane) – The pixel plane for raytracing.

  • ra (float, default 0.0) – The right ascension of the viewing direction in radians.

  • dec (float, default 0.0) – The declination of the viewing direction in radians.

  • epoch (float, optional) – The epoch for the computation.

Returns:

The apparent area of the spacecraft.

Return type:

float

pyRTX.core.analysis_utils.get_sun_exposed_area(sc, rtx, epoch)[source]

Computes the sun-exposed area of a spacecraft.

Parameters:
  • sc (pyRTX.Spacecraft) – The spacecraft object.

  • rtx (pyRTX.RayTracer) – The ray tracer object.

  • epoch (float) – The epoch for the computation.

Returns:

The sun-exposed area of the spacecraft.

Return type:

float

pyRTX.core.analysis_utils.compute_body_positions(target, epochs, frame, obs, abcorr='LT + S')[source]

Computes the relative positions of a target body with respect to an observing body.

Parameters:
  • target (str) – The name of the target body.

  • epochs (list of float) – A list of epochs.

  • frame (str) – The reference frame of the output position vector.

  • obs (str) – The name of the observing body.

  • abcorr (str, default 'LT + S') – The aberration correction flag.

Returns:

A list of position vectors.

Return type:

list

pyRTX.core.analysis_utils.compute_body_states(target, epochs, frame, obs, abcorr='LT + S')[source]

Computes the relative position and velocity of a target body with respect to an observing body.

Parameters:
  • target (str) – The name of the target body.

  • epochs (list of float) – A list of epochs.

  • frame (str) – The reference frame of the output state vector.

  • obs (str) – The name of the observing body.

  • abcorr (str, default 'LT + S') – The aberration correction flag.

Returns:

A list of state vectors (position and velocity).

Return type:

list