pyRTX.core.analysis_utils
Functions
|
Computes the right ascension and declination for a set of vectors. |
|
Computes the relative positions of a target body with respect to an observing body. |
|
Computes the relative position and velocity of a target body with respect to an observing body. |
|
Convert a Monte epoch string to a spice epoch string |
|
Converts a TIFF map to a format that can be used to assign values to a planetary mesh. |
|
Generates a range of epochs. |
|
Generates a range of epochs between a start and end epoch. |
|
Computes the right ascension and declination of the Sun as seen from a spacecraft. |
|
Computes the apparent area of a spacecraft as seen from a given direction. |
|
Computes the sun-exposed area of a spacecraft. |
Classes
|
A class for storing and interpolating 2D lookup tables. |
|
A class for storing and interpolating N-dimensional lookup tables. |
A class for dealing with zone-scattered lookup tables. |
|
|
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 tablelinspace_y (
np.array(M,)) – The y axis of the lookup tablevalues (
np.ndarray (N,M,1)) – The lookup table values
- __init__(linspace_x, linspace_y, values)[source]
Initializes the LookupTable object.
- Parameters:
linspace_x (
numpy.ndarray) – The x-coordinates of the grid.linspace_y (
numpy.ndarray) – The y-coordinates of the grid.values (
numpy.ndarray) – The values at the grid points.
- set_interpType(interpType)[source]
Sets the interpolation type.
- Parameters:
interpType (
str) – The interpolation method to use (e.g., ‘linear’, ‘cubic’).
- __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:
- 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, default1) – 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:
- __init__(axes=None, values=None, info=None, np_array=None)[source]
Initializes the LookupTableND object.
- Parameters:
axes (
tupleofnumpy.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:
ind (
float) – The value to search for.search_list (
listornumpy.ndarray) – The list to search in.
- Returns:
The index of the value.
- Return type:
- __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:
- axisExtent()[source]
Returns the extent of each axis.
- Returns:
A list of [min, max] pairs for each axis.
- Return type:
- 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, default1) – 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
- 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.
- 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:
axes (
tupleofnumpy.ndarray, optional) – The axes of the TIFF image.values (
numpy.ndarray, optional) – The pixel values of the TIFF image.
- interpolator(vals)[source]
Performs the interpolation.
- Parameters:
vals (
tuple) – A tuple of coordinates at which to interpolate.- Returns:
The interpolated values.
- Return type:
- 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:
ind (
float) – The value to search for.search_list (
listornumpy.ndarray) – The list to search in.
- Returns:
The index of the value.
- Return type:
- 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:
- Returns:
A tuple containing the right ascension and declination in radians.
- Return type:
- pyRTX.core.analysis_utils.epochRange(startEpoch=None, duration=None, step=100)[source]
Generates a range of epochs.
- Parameters:
- Returns:
An array of epochs.
- Return type:
- pyRTX.core.analysis_utils.epochRange2(startEpoch=None, endEpoch=None, step=100)[source]
Generates a range of epochs between a start and end epoch.
- Parameters:
- Returns:
An array of epochs.
- Return type:
- 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, default360) – The periodicity of the right ascension in degrees.
- Returns:
A tuple containing the right ascension and declination in radians.
- Return type:
- 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, defaultFalse) – 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, defaultnumpy.pi/2) – The maximum latitude.lon0 (
float, default0) – The minimum longitude.lon1 (
float, default2*numpy.pi) – The maximum longitude.
- Returns:
An interpolator for mapping the TIFF values to the mesh.
- Return type:
- 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, default0.0) – The right ascension of the viewing direction in radians.dec (
float, default0.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:
- pyRTX.core.analysis_utils.get_sun_exposed_area(sc, rtx, epoch)[source]
Computes the sun-exposed area of a spacecraft.
- 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:
- Returns:
A list of position vectors.
- Return type: