satsim.util package — SatSim 0.12.0 documentation

# satsim.util package

## Submodules

## satsim.util.system module

`satsim.util.system.` `configure_eager`(allow_growth=True)

  Configure TensorFlow in eager mode.

  Parameters

    allow_growth – bool, enables memory growth

`satsim.util.system.` `configure_multi_gpu`(gpu_ids, memory=None)

  Configure multiple GPUs to be visible and limit their maximum memory allocation.

  Parameters

    - gpu_ids – array, int array of system GPU ids. On single GPU systems, this should be set to [0].

    - memory – int, maximum memory allocation in megabytes. Default is None for no limit.

  Returns

    string, a list of logical gpu names

  Return type

    gpus

`satsim.util.system.` `configure_single_gpu`(gpu_id, memory=None)

  Configure a single GPU to be visible and limit its maximum memory allocation.

  Parameters

    - gpu_id – int, system GPU id. On single GPU systems, this should be set to 0.

    - memory – int, maximum memory allocation in megabytes. Default is None for no limit.

  Returns

    string, a list of size 1 with the visible gpu name

  Return type

    gpus

`satsim.util.system.` `get_semantic_version`(module)

  Gets the sematic version from a module as an array of integers. Non digit characters will be removed.

  Example:

      import tensorflow as tf

      ver = get_semantic_version(tf)

      # example ver == [2,0,0]

  Parameters

    module – object, a module which has __version__ as a string in semantic format

## satsim.util.thread module

class `satsim.util.thread.` `MultithreadedTaskQueue`(num_threads=5)

  Bases: `object`

  Class to run functions round robin.

  `has_tag`(tag)
  `stop`()

    Call stop on all threads.

  `task`(f, kwargs, tag=None)

    Adds a task to the next thread in the round robin queue.

    Parameters

      - f – function. the function to run

      - kwargs – dict, dictionary containing keyword arguments

  `waitUntilEmpty`()

    Blocks until all threads are done.

class `satsim.util.thread.` `ThreadedTaskQueue`

  Bases: `object`

  Class to run functions as threads in a queue.

  `busy`()

    Returns True if queue is not empty or if a task is running.

  `has_tag`(tag)
  `stop`()

    Stop this thread after current contents in queue are cleared.

  `task`(f, kwargs, tag=None)

    Adds a task to this thread.

    Parameters

      - f – function. the function to run

      - kwargs – dict, dictionary containing keyword arguments

  `waitUntilEmpty`()

    Blocks until last task is finished.

## satsim.util.timer module

`satsim.util.timer.` `get_timing`()

  Returns all stopwatch recordings from tic and toc.

  Returns

    A dict, recorded times where the key is the name given in tic and toc

`satsim.util.timer.` `tic`(name=None, i=None)

  tic starts a stopwatch timer to measure performance. The function records the internal time at execution of the tic command. Display the elapsed time with the toc function. If no name is given, the name will be assigned to __default__.

  Examples:

      tic()
      time.sleep(1)
      print(toc())

  Parameters

    - name – str, name to give timer to reference later

    - i – int, index if array of times need to be recorded

`satsim.util.timer.` `toc`(name=None, i=None)

  toc reads the elapsed time from the stopwatch timer started by the tic function. The function reads the internal time at the execution of the toc command, and returns the elapsed time since the most recent call to the tic function in seconds.

  Parameters

    - name – str, name to give timer to reference later

    - i – int, index if array of times need to be recorded

  Returns

    A float, seconds elapsed