Population¶
-
class
sorts.population.population.
Population
(fields=None, dtypes=None, space_object_fields=None, state_fields=None, epoch_field=None, propagator=None, propagator_args={}, propagator_options={})[source]¶ Bases:
object
Encapsulates a population of space objects as an array and functions for returning instances of space objects.
Default columns:
0: oid - Object ID
1: a - Semi-major axis in m
2: e - Eccentricity
3: i - Inclination in degrees
4: raan - Right Ascension of ascending node in degrees
5: aop - Argument of perihelion in degrees
6: mu0 - Mean anoamly in degrees
7: mjd0 - Epoch of object given in Modified Julian Days
Any column that is added will have its name used in initializing the Space object.
A population’s column data can also be accessed as a python dictionary or a table according to row number, e.g.
#this returns all Right Ascension of ascending node as a numpy vector vector = my_population['raan'] #this gets row number 3 (since we use 0 indexing) row = my_population[2]
but it is also configured to be able to try to convert to uniform type array and perform numpy like slices. If a column data type cannot be converted to the default data type numpy.nan is inserted instead.
#This will convert the internal data structure to a uniform type array and select all rows and columns 4 and onwards. This is time-consuming on large populations as it actually copies to data. vector = my_population[:,4:] # This is significantly faster as a single column is easy to extract and no conversion is needed data_point = my_population[123,2]
This indexing system can also be used for data manipulation:
my_population['raan'] = vector my_population[2] = row my_population[:,4:] = matrix my_population[123,2] = 2.3 my_population[123,11] = 'test'
Notice that in the above example the value to be assigned always has the correct size corresponding to the index and slices, a statement like
x[:,3:7] = 3
is not possible, instead one would writex[:,3:7] = np.full((len(pop), 4), 3.0, dtype='f')
.#TODO: THESE HAVE CHANGED, UPDATE THEM!!!!
- Variables
objs (numpy.ndarray) – Array containing population data. Rows correspond to objects and columns to variables.
name (str) – Name of population.
fields (list) – List of strings containing column descriptions.
space_object_uses (list) – List of booleans describing what columns should be included when initializing a space object. This allows for extra data to be stored in the population without passing it to the space object.
propagator (PropagatorBase) – Propagator class pointer used for
space_object.SpaceObject
.propagator_options (dict) – Propagator initialization keyword arguments.
- Parameters
name (str) – Name of population.
fields (list) – List of strings containing column descriptions for addition data besides the default columns.
dtypes (list) – List of strings containing numpy data type description. Defaults to ‘f’.
space_object_fields (list) – List of booleans describing what columns should be included when initializing a space object. This allows for extra data to be stored in the population without passing it to the space object.
propagator (PropagatorBase) – Propagator class pointer used for
space_object.SpaceObject
.propagator_options (dict) – Propagator initialization keyword arguments.
Methods
__init__
([fields, dtypes, …])Initialize self.
add_field
(name[, dtype])Add a field to the population data.
allocate
(length)Allocate the internal data array for assignment of objects.
copy
()Return a copy of the current Population instance.
delete
(inds)Remove the rows according to the given indices.
filter
(col, fun)Filters the population using a boolean function, keeping true values.
get_fields
(fields[, n, named, dtype])Get the orbital elements for one row from internal data array.
get_object
(n)Get the one row from the population as a
space_object.SpaceObject
instance.get_orbit
(n[, fields, M_cent, degrees, anomaly])Get the one row from the population as a
pyorb.Orbit
instance.get_states
([n, named, dtype])Use the defined state parameters to get a copy of the states
load
(fname, propagator[, …])next
()print
([n, fields])save
(fname)Attributes
This is the shape of the internal data matrix