sispo.sim package

Submodules

sispo.sim.cb module

Module to define common attributes of celestial bodies.

class sispo.sim.cb.CelestialBody(name, model_file=None)

Parent class for celestial bodies such as satellites or asteroids.

get_position(date=None)

Get position on given date or last calculated.

get_state(date=None)

Get spacecraft state (position, velocity).

get_velocity(date=None)

Get velocity on given date or last calculated.

propagate(start, end, steps, mode=1, factor=2)

Propagates CB either at given start time or from start to end.

If start and end are given start is shifted a bit earlier to detect event at start. end is shifted a bit later to detect event at end.

setup_timesampler(start, end, steps, mode=1, factor=2)

Create and attach TimeSampler to propagator.

exception sispo.sim.cb.CelestialBodyError

Generic error for CelestialBody and child classes.

class sispo.sim.cb.TimeSampler(start, end, steps, mode=1, factor=2)

TimeSampler implementation.

class sispo.sim.cb.TimingEvent

TimingEvent handler.

eventOccurred(s, detector, increasing)

Handle occured event.

resetState(detector, oldState)

Reset TimingEvent handler to given state.

sispo.sim.compositor module

The compositor module combines the different output files of the simulation.

As the simulation module outputs different files for background and foreground and because the intensity of the blender rendered images are not constant, the compositor is required to fix the intensity issue and add the star background.

class sispo.sim.compositor.Frame(frame_id, image_dir=None, stars=None, sssb_only=None, sssb_const_dist=None, light_ref=None)

Class to wrap all data of a single frame.

calc_ref_intensity()

Calculates reference intensitiy using the light reference scene.

calc_sssb_stats(const_dist=False)

Calculate SSSB max and sum corrected with alpha channel.

If const_dist is True, stats of const distant images are calculated.

calc_stars_stats()

Calculate star scene parameters.

light_ref = None
metadata = None
read_complete_frame(frame_id, image_dir)

Reads all images for a given frame id.

This includes Stars, SssbOnly, SssbConstDist, and LightRef.

read_meta_file(frame_id, image_dir)

Reads metafile of a frame.

sssb_const_dist = None
sssb_only = None
stars = None
class sispo.sim.compositor.ImageCompositor(res_dir, img_dir, instrument, sssb, with_infobox, with_clipping)

This class provides functions to combine the final simulation images.

IMG_MIN_SIZE_INFOBOX = (1200, 1000)
INFOBOX_SIZE = {'default': (400, 100), 'min': (200, 50)}
add_infobox(img, metadata, height=None, width=None)

Overlays an infobox to a given image in the lower right corner.

calc_relative_intensity_curve()

Calculates the relative intensity curve for all sssb frames.

clip_color_depth(img)

Reduces color depth to the instrument color depth.

compose(frames=None, max_procs=None)

Composes different images into final image, uses multi-threading.

Parameters:
  • frames (String, Frame or List of Frame) – FrameID, Frame or list of frames for calibration and composition.
  • name_suffix (str) – Image suffix for file I/O. Used for constructing file names to read different images of a frame as well as used for composed image output.
create_sssb_ref(res, scale=5)

Creates a reference sssb image for calibration.

Sort of natural look by using image increased by factor of scale, gaussian blur the result and decimate to match size of other images. opencv resize algorithm needs integer divisable number of pixels to have the same behaviour as skimage.transform.downscale_local_mean. Zero-padding of skimage.transform.downscale_local_mean would be necessary without scaling.

get_frame_ids()

Extract list of frame ids from file names of SssbOnly scenes.

exception sispo.sim.compositor.ImageCompositorError

This is a generic error for the compositor.

sispo.sim.render module

Module providing an interface to a rendering engine (renderer).

This implementation uses the blender python module bpy.

class sispo.sim.render.BlenderController(res_dir, raw_dir, starcat_dir, instrument, sssb, with_infobox, with_clipping)

Class to control blender module behaviour.

configure_camera(camera_name='Camera', lens=<Quantity 35. mm>, sensor=<Quantity 32. mm>, clip_start=1e-05, clip_end=1e+32, mode='PERSP', ortho_scale=7)

Set camera configuration values.

create_camera(camera_name='Camera', scenes=None)

Create new camera and add to relevant scenes.

create_empty(name='Empty', scenes=None)

Create new, empty blender object.

create_scene(scene_name)

Add empty scene.

get_camera(camera_name='Camera')

Target camera towards target.

load_object(filename, object_name, scenes=None)

Load blender object from file.

render(metainfo, scenes=None)

Render given scene.

render_starmap(res, name_suffix)

Render a starmap from given data and field of view.

save_blender_dfile(name_suffix=None, scene=<sphinx.ext.autodoc.importer._MockObject object>)

Save a blender d file.

set_camera_location(camera_name='Camera', location=(0, 0, 0))
set_camera_rot(angle, axis, camera_name='Camera')

Target camera towards target.

set_device(device='AUTO', tile_size=None, scenes=None)

Set cycles rendering device for given scenes.

When device=”AUTO” it is attempted to use GPU first, otherwise fallback is CPU. Currently, assumes set_device is only used once.

set_exposure(exposure=0, scenes=None)

Set exposure value.

set_object_rot(angle, axis, obj)
set_output_file(name_suffix=None, scene=<sphinx.ext.autodoc.importer._MockObject object>)

Set output file path to given scenes with prior extension check.

set_output_format(file_format='OPEN_EXR', color_depth='32', use_preview=True, scenes=None)

Set output file format.

set_resolution(res, scenes=None)

Sets resolution of rendered image.

set_samples(samples=6, scenes=None)

Set number of samples to render for each pixel.

set_scene_defaults(scenes=None)

Sets default settings to a scene.

Parameters:scenes (None, String, bpy.types.Scene, list) – Scene(s) which default settings are applied to.
set_sun_location(sun_loc, scaling, sun)
target_camera(target, camera_name='Camera')

Target camera towards target.

update(scenes=None)

Update scenes.

write_meta_file(metainfo)

Writes metafile for a frame.

exception sispo.sim.render.BlenderControllerError

Generic error for BlenderController.

exception sispo.sim.render.RenderingError

Generic error for rendering process.

sispo.sim.render.get_fov(camera_name, scene_name)

Calculate centre and size of current Field of View (FOV) in degrees.

sispo.sim.render.get_fov_vecs(camera_name, scene_name)

Get camera position and direction vectors.

sispo.sim.render.get_ra_dec(vec)

Calculate Right Ascension (RA) and Declination (DEC) in radians.

sispo.sim.sc module

Defining behaviour of the spacecraft (sc).

class sispo.sim.sc.Instrument(charas=None)

Summarizes characteristics of an instrument.

sense(flux_img)
class sispo.sim.sc.Spacecraft(name, mu, state, trj_date, rot_state=None, oneshot=False)

Handling properties and behaviour of the spacecraft.

static calc_encounter_pos(sssb_pos, min_dist, terminator=True, sunnyside=False)

Calculate the pos of a Spacecraft at closest distance to SSSB.

classmethod calc_encounter_state(sssb_state, min_dist, rel_vel, terminator=True, sunnyside=False)

Calculate the state of a Spacecraft at closest distance to SSSB.

sispo.sim.sim module

Trajectory simulation and object rendering module.

class sispo.sim.sim.Environment(res_dir, starcat_dir, instrument, with_infobox, with_clipping, sssb, sun, lightref, encounter_date, duration, frames, encounter_distance, relative_velocity, with_sunnyside, with_terminator, timesampler_mode, slowmotion_factor, exposure, samples, device, tile_size, oneshot=False, spacecraft=None, opengl_renderer=False)

Simulation environment.

This environment is used to propagate trajectories and render images at each simulation step.

static mzpy_to_pxpz(mzpy_rot)
static pxpz_to_mzpy(pxpz_rot)
render()

Render simulation scenario.

save_results()

Save simulation results to a file.

setup_lightref(settings)

Create lightreference blender object.

setup_renderer()

Create renderer, apply common settings and create sc cam.

setup_spacecraft(spacecraft=None, oneshot=False)

Create Spacecraft and respective blender object.

setup_sssb(settings)

Create SmallSolarSystemBody and respective blender object.

setup_sun(settings)

Create Sun and respective render object.

simulate()

Do simulation.

exception sispo.sim.sim.SimulationError

Generic simulation error.

sispo.sim.sim.blend_to_icrf(sssb_cam_r, sssb_light_r, cam_quat, dist=150000000000.0, verbose=False)

transform manually found (using blender) relative pose and light direction to sc and sssb params in input definition file:

… “spacecraft”: {

“r”: sun_sc_r, “angleaxis”: sc_rot

}, “sssb”: {

“traj”: {
“r”: sun_sssb_r, …
sispo.sim.sim.convert_rot_to_angle_axis(rot, rot_conv)

sispo.sim.sssb module

Defining behaviour of the small solar system body (SSSB).

class sispo.sim.sssb.SmallSolarSystemBody(name, mu, trj, att, model_file=None)

Handling properties and behaviour of SSSB.

sispo.sim.starcat module

Interface for handling data from a star catalogue. Retrieve data as well as render and write images.

class sispo.sim.starcat.StarCatalog(res_dir, starcat_dir=None)

Class to access star catalogs and render stars.

get_stardata(ra, dec, width, height, filename='ucac4.txt')

Retrieve star data from given field of view using UCAC4 catalog.

exception sispo.sim.starcat.StarCatalogError

Generic error for star catalog module.

sispo.sim.utils module

Utilities module contains functions possibly used by all modules.

sispo.sim.utils.check_dir(directory, create=True)

Resolves directory and creates it, if it doesn’t existing.

Parameters:
  • directory (Path or str) – Directory to be created if not existing
  • create (bool) – Set to false if directory should not be created and instead an exception shall be raise
sispo.sim.utils.check_file_ext(filename, extension)

Checks whether filename ends with extension and adds it if not.

sispo.sim.utils.read_mat_string(string)

Converts matrix string into numpy array.

sispo.sim.utils.read_openexr_image(filename)

Read image in OpenEXR file format into numpy array.

sispo.sim.utils.read_png_image(filename)

Reads an image in png file format into numpy array.

sispo.sim.utils.read_vec_string(string)

Converts vector string into numpy array.

sispo.sim.utils.serialise(o)

Serialise numpy arrays to json object.

sispo.sim.utils.write_mat_string(mat, prec)

Write data matrix into string.

sispo.sim.utils.write_openexr_image(filename, image)

Save image in OpenEXR file format from numpy array.

sispo.sim.utils.write_vec_string(vec, prec)

Write data vector into string.

Module contents