This module provides tools for creating and viewing spherical plots.
The spherical plotting tool, using Mayavi, requires two sets of data in order to create the spherical plot: the vertex locations in (x,y,z) and the spatial relationship between the vertices, i.e. triangulation of nearest neighbours. This spatial relationship is required to create surface elements between the vertices. If the spatial relationship is not known, the data is merely a cloud of points, with no surface content.
The easiest way to create the spatial relationships between the vertices was to use a complex hull polygon model of an object. The polygon or wireframe model has the requires vertices and spatial relationships.
In the original application of this tool, a series of spheres were created using MeshLab. The essential property of these spheres was that the vertices on the surface of the spheres were spaced equidistant over the surface, i.e. an optimal spatial sampling distribution. The files were exported as OFF files, and should be in the pyradi data/plotspherical directory. There are 6 possible input files, each with different number of samples on the unit sphere: 12, 42, 162, 642, 2562 or 10242.
Any object, with the required vertices and spatial relationships can be used. it does not have to be equi-sampled spheres.
Note that the spherical plot has no way to discriminate between negative values and a pi phase shift: there is confusion between sign and direction. This is inherent in the conversion between cartesian and spherical coordinates. The user has to make provision for this, possibly by plotting only negative or only positive values.
The data must be in the OFF wireframe format.
The sphere data available in pyradi/data/plotspherical are:
Filename | Resolution | Number | Number |
---|---|---|---|
. | (degrees) | points | triangles |
sphere_0_12 | 63.4 | 12 | 20 |
sphere_1_42 | 33.9 | 42 | 80 |
sphere_2_162 | 17.2 | 162 | 320 |
sphere_3_642 | 8.6 | 642 | 1280 |
sphere_4_2562 | 4.32 | 2562 | 5120 |
sphere_5_10242 | 2.16 | 10242 | 20480 |
sphere_6_40962 | 1.08 | 40962 | 81920 |
sphere_7_163842 | 0.54 | 163842 | 327680 |
This tool was originally developed to create trajectory files for the Denel/CSIR OSSIM simulation. The code was restructured for greater universal application, but the final example is still an OSSIM case.
See the __main__ function for examples of use.
This package was partly developed to provide additional material in support of students and readers of the book Electro-Optical System Analysis and Design: A Radiometry Perspective, Cornelius J. Willers, ISBN 9780819495693, SPIE Monograph Volume PM236, SPIE Press, 2013. http://spie.org/x648.html?product_id=2021423&origin_id=x646
Reads an OFF file and returns the vertices and triangles in numpy arrays.
The OFF file is read and the data captured in the array structures. This is a fairly trivial reading task.
Reads an OFF file and returns object attitude and position.
Calculate the pitch and yaw angles to point the object’s X-axis towards the OFF file vertex directions.
Euler order is yaw-pitch-roll, with roll equal to zero. Yaw is defined in xy plane. Pitch is defined in xz plane. Roll is defined in yz plane.
The object is assumed to stationary at the position (xPos, yPos, zPos), the position arrays are the same length as the attitude angle arrays, but all values in each individual array are all the same.
Reads an OFF file and returns sensor attitude and position.
Calculate the sensor attitude and position such that the sensor always look at the object located at ( xTargPos, yTargPos, zTargPos), at a constant distance.
Euler order is yaw-pitch-roll, with roll equal to zero. Yaw is defined in xy plane. Pitch is defined in xz plane. Roll is defined in yz plane.
The object is assumed to stationary at the position (xTargPos, yTargPos, zTargPos).
Reads OFF file and create OSSIM trajectory files for rotating object or orbiting sensor.
This function writes a file in the custom OSSIM trajectory file format. Use this function as an example on how to use the ryplotspherical functionality in your application.
The velocity and engine settings are constant for all views at the values specified.
The deltaTime parameter is used to define the time increment to be used in the trajectory file.
Two additional files are also written to assist with the subsequent viewing.
- The vertex file contains the normalised direction vectors between the object and observer. Depending on the trajectory type (see above), the sensor and object switch locations for these vectors. These vectors are the directions of sampled intensity values.
- The triangles file defines triangles that provides the spatial linking between adjacent vectors, used when plotting the data. We plot the complex hull comprising these triangles, with vertices along the direction vectors, with length given by the simulated data set.
OSSIM Users: For examples of how to use these trajectory files, see test points tp01l (that is lowercase L) and tp01m. The scenario files are present in the the appropriate test point directory (l and m) and the plotting routines are in the tp01 utils directory.
Create OSSIM trajectory files for rotating object or orbiting sensor for constant increments in azimuth and elevation (yaw and pitch).
This function writes a file in the custom OSSIM trajectory file format. Use this function as an example on how to use the ryplotspherical functionality in your application.
The velocity and engine settings are constant for all views at the values specified.
The deltaTime parameter is used to define the time increment to be used in the trajectory file.
Two additional files are also written to assist with the subsequent viewing.
- The azimuth file contains the sample values around the equator. The value ranges from zero to two*pi
- The elevation file contains the sample values from North pole to South pole. The value ranges from -pi to +pi
Reads an OFF file and returns sensor attitude and position.
Calculate the sensor attitude and position such that the sensor always look at the object located at ( xTargPos, yTargPos, zTargPos), at a constant distance.
Euler order is yaw-pitch-roll, with roll equal to zero. Yaw is defined in xy plane. Pitch is defined in xz plane. Roll is defined in yz plane.
The object is assumed to stationary at the position (xTargPos, yTargPos, zTargPos).
Reads an OFF file and returns object attitude and position.
Calculate the pitch and yaw angles to point the object’s X-axis towards the OFF file vertex directions.
Euler order is yaw-pitch-roll, with roll equal to zero. Yaw is defined in xy plane. Pitch is defined in xz plane. Roll is defined in yz plane.
The object is assumed to stationary at the position (xPos, yPos, zPos), the position arrays are the same length as the attitude angle arrays, but all values in each individual array are all the same.
Plot the spherical data given a data set, triangle set and vertex set.
The vertex set defines the direction cosines of the individual samples. The triangle set defines how the surfrace must be structured between the samples. The data set defines, for each direction cosine, the length of the vector.
Plot the spherical data given a data set, triangle set and vertex set.
The vertex set defines the direction cosines of the individual samples. The triangle set defines how the surfrace must be structured between the samples. The data set defines, for each direction cosine, the length of the vector.
There is no means to discriminate between negative and pi phase shift. In this function we plot colour ratio values initially in absolute form, then only positive and then only negative values. In between these two shells the values are going through zero.
Plot spherical data (azimuth, elevation and value) given in spherical format
This function assumes that the polar data is defined in terms of elevation angle with zero at the equator and azimuth measured around the equator, from 0 to 2pi. All angles are in degrees.
All axes, x, y, and z are scaled with the magnitude of value in the (azim, elev) direction.
The colour on the surface represents the value at the given azim/elev location.
Plot spherical data (azimuth, elevation and value) given in polar format.
This function assumes that the polar data is defined in terms of elevation angle with zero at the equator and azimuth measured around the equator, from 0 to 2pi. All angles are in degrees.
The x and y axes are scaled with the maximum magnitude of value. The z axis is scaled with the actual magnitude of value in the (azim, elev) direction.
The colour on the surface represents the value at the given azim/elev location.
Plot spherical data on a sphere.
This function assumes that the polar data is defined in terms of elevation angle with zero at the equator and azimuth measured around the equator, from 0 to 2pi. All angles are in degrees.
The x, y, and z values defines vertices on a sphere. The colour on the sphere represents the value at the given azim/elev location.