firefly.data_reader.TweenParams

class firefly.data_reader.TweenParams(coords=None, duration=5, loop=True, filename=None)[source]

Bases: object

A class to store tween parameters and make an output file

__init__(coords=None, duration=5, loop=True, filename=None)[source]
Create a new tween parameter object, allowing the user to press t from within

the webapp to move between keyframe camera locations smoothly and automatically.

Parameters
  • coords (list of float) – keyframe camera coordinates, list of positions that camera will move between. 3 acceptable input formats: * [x,y,z] single keyframe * [[x1,y1,z1],[x2,y2,z2],…] multiple keyframes * [x1,y1,z1,x2,y2,z2,…] multiple flattened keyframes, defaults to []

  • duration (float/list of float) –

    duration to approach keyframe in seconds. 3 acceptable input formats: * d single duration (will be repeated) * [d] single duration in list (will be repeated) * [d1,d2,…] multiple durations (corresponding to number of keyframes or

    raises an error),

    defaults to 5

  • loop (bool, optional) – flag to loop after reaching the last keyframe, defaults to True

  • filename (str, optional) – name of tween file .json file, defaults to 'TweenParams.json'

__weakref__

list of weak references to the object (if defined)

addKeyframe(coords, duration)[source]

Adds a new keyframe to an existing TweenParams object.

Parameters
  • coords (list of float) –

    keyframe camera coordinates, list of positions that camera will move between 3 acceptable input formats:

    • [x,y,z] single keyframe

    • [[x1,y1,z1],[x2,y2,z2],…] multiple keyframes

    • [x1,y1,z1,x2,y2,z2,…] multiple flattened keyframes

  • duration (float/list of float) –

    duration to approach keyframe, 3 acceptable input formats: * d single duration (will be repeated) * [d] single duration in list (will be repeated) * [d1,d2,…] multiple durations (corresponding to number of keyframes or

    raises an error)

Raises
  • np.AxisError – if len of coords is not divisible by 3

  • np.AxisError – if len of durations does not match len of coords

outputToDict()[source]

Converts stored data into a single python dictionary.

Returns

tween_params_dict

Return type

dict

outputToJSON(datadir, file_prefix='', loud=1, write_to_disk=True, not_reader=True)[source]

Saves the current tween parameters to a JSON file.

Parameters
  • datadir (str, optional) – the sub-directory that will contain your JSON files, relative to your $HOME directory. , defaults to $HOME/<file_prefix>

  • file_prefix (str, optional) – Prefix for any .json files created, .json files will be of the format: <file_prefix><self.filename>.json, defaults to ‘’

  • loud (bool, optional) – flag to print status information to the console, defaults to True

  • write_to_disk (bool, optional) – flag that controls whether data is saved to disk (True) or only converted to a string and returned (False), defaults to True

  • not_reader – flag for whether to print the Reader filenames.json warning, defaults to True

Returns

filename, JSON(tween_params_dict) (either a filename if written to disk or a JSON strs)

Return type

str, str