firefly.data_reader.Settings

class firefly.data_reader.Settings(settings_filename='Settings.json', **kwargs)[source]

Bases: object

This is a class for organizing the various settings you can pass to Firefly to customize how the app is initialized and what features the user has access to.

It is easiest to use when instances of Settings are passed to a firefly.data_reader.Reader instance when it is initialized.

UI_settings(UI=True, UIfullscreen=True, UIsnapshot=True, UIreset=True, UIsavePreset=True, UIloadNewData=True, UIcameraControls=True, UIdecimation=True, **extra)[source]

Flags for enabling different elements of the UI

Parameters
  • UI (bool, optional) – flag to show the UI as a whole, defaults to True

  • UIfullscreen (bool, optional) – flag to show the fullscreen button, defaults to True

  • UIsnapshot (bool, optional) – flag to show the screenshot button, defaults to True

  • UIreset (bool, optional) – flag to show the “Default Settings” button, defaults to True

  • UIsavePreset (bool, optional) – flag to show the “Save Settings” button, defaults to True

  • UIloadNewData (bool, optional) – flag to show the “Load Data” button, defaults to True

  • UIcameraControls (bool, optional) – flag to show the camera controls pane, defaults to True

  • UIdecimation (bool, optional) – flag to show the decimation slider, defaults to True

__getitem__(key)[source]

Implementation of builtin function __getitem__

Parameters

key (str) – key to read

Returns

attr, the value from the settings dictionary

Return type

object

__init__(settings_filename='Settings.json', **kwargs)[source]
Base initialization method for Settings instances. A Settings will store

the app state and produce firefly compatible .json files.

accepts passthrough kwargs from:

firefly.data_reader.Settings.window_settings()

firefly.data_reader.Settings.UI_settings()

firefly.data_reader.Settings.particle_UI_settings()

firefly.data_reader.Settings.camera_settings()

firefly.data_reader.Settings.startup_settings()

firefly.data_reader.Settings.particle_startup_settings()

firefly.data_reader.Settings.particle_filter_settings()

firefly.data_reader.Settings.particle_colormap_settings()

Parameters

settings_filename (str, optional) – name of settings .json file, defaults to ‘Settings.json’

__setitem__(key, value)[source]

Implementation of builtin function __setitem__

Parameters
  • key (str) – key to set

  • value (object) – value to set to key

__weakref__

list of weak references to the object (if defined)

attachSettings(particleGroup)[source]

Adds a ParticleGroup’s settings to the relevant settings dictionaries.

Parameters

particleGroup (firefly.data_reader.ParticleGroup) – the ParticleGroup that you want to link to this Settings.

camera_settings(center=None, camera=None, cameraRotation=None, **extra)[source]

Settings that affect the position and orientation of the camera

Parameters
  • center (np.ndarray of shape (3), optional) – do you want to explicilty define the initial camera focus/ zero point (if not, the WebGL app will calculate the center as the mean of the coordinates of the first particle set loaded in), defaults to None

  • camera (np.ndarray of shape (3), optional) – initial camera location, NOTE: the magnitude must be >0 , defaults to None

  • cameraRotation (np.ndarray of shape (3), optional) – can set camera rotation in units of radians if you want, defaults to None

keys()[source]

Returns a list of keys for all the different settings sub-dictionaries

loadFromJSON(filename, loud=True)[source]

Replaces the current settings with those stored in a JSON file.

Parameters
  • filename (str) – full filepath to settings .json file

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

Raises

FileNotFoundError – if the specified filename does not exist

outputToDict()[source]

Concatenates all the settings dicts into a single dictionary.

Returns

all_settings_dict, concatenated settings dictionary

Return type

dict

outputToJSON(JSONdir, JSON_prefix='', filename=None, loud=True, write_jsons_to_disk=True, not_reader=True)[source]

Saves the current settings to a JSON file.

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

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

  • filename (str, optional) – name of settings .json file, defaults to self.settings_filename

  • JSON_prefix – string that is prepended to filename, defaults to ‘’

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

  • write_jsons_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(all_settings_dict) (either a filename if written to disk or a JSON strs)

Return type

str, str

particle_UI_settings(UIparticle=None, UIdropdown=None, UIcolorPicker=None, **extra)[source]

Flags that control how the UI for each particle group looks like

Parameters
  • UIparticle (dict of UIname:bool, optional) – do you want to show the particles in the user interface. This is a dict with keys of the particle UInames mapped to bools, defaults to dict([(UIname,True) for UIname in UInames])

  • UIdropdown (dict of UIname:bool, optional) – do you want to enable the dropdown menus for particles in the user interface. This is a dict with keys of the particle UInames mapped to bools, defaults to dict([(UIname,True) for UIname in UInames])

  • UIcolorPicker (dict of UIname:bool, optional) – do you want to allow the user to change the color. This is a dict with keys of the particle UInames mapped to bools, defaults to dict([(UIname,True) for UIname in UInames])

particle_colormap_settings(colormapLims=None, colormapVals=None, colormap=None, colormapVariable=None, showColormap=None, **extra)[source]

Settings that will define the initial values of the colormaps in the particle UI panes.

Parameters
  • colormapLims (dict of UIname:dict of field:[min,max] range, optional) – initial [min, max] limits to the colormaps. This is a nested dict of the particle UInames, then for each colormappable field the [min, max] range (e.g., {‘Gas’:{‘log10Density’:[0,1],’magVelocities’:[20, 100]}}), defaults to None and is set in the web app to [min, max] of that field

  • colormapVals (dict of UIname:dict of field:[min,max] range, optional) – initial location of the colormap slider handles. This is a nested dict of the particle UInames, then for each colormappable field the [min, max] range (e.g., {‘Gas’:{‘log10Density’:[.1,0.5],’magVelocities’:[50, 60]}}), defaults to None and is set in the web app to [min, max] of that field

  • colormap (dict of UIname:float, optional) – index of the colormap to use for each gas particle, defined by the grid of colors in firefly/static/textures/colormap.png TODO: (index + 0.5) * (8/256) This is a dict with keys of the particle UInames mapped to floats, (e.g. {‘Gas’:0.015625, ‘Stars’:0.015625}), defaults to first colormap

  • colormapVariable (dict of UIname:int, optional) – index in arrays_to_track of array to colormap by This is a dict with keys of the particle UInames mapped to ints, (e.g. {‘Gas’:0, ‘Stars’:0}), defaults to 0

  • showColormap – flags for whether the colormap should be initialized

at startup.

This is a dict with keys of the particle UInames mapped to bools, (e.g. {‘Gas’:False, ‘Stars’:False}), defaults to False

particle_filter_settings(filterLims=None, filterVals=None, **extra)[source]

Settings that will define the initial values of the filters in the particle UI panes and consequently what particles are filtered at startup.

Parameters
  • filterLims (dict of UIname:dict of field:[min,max] range, optional) – initial [min, max] limits to the filters. This is a nested dict of the particle UInames, then for each filterble field the [min, max] range (e.g., {‘Gas’:{‘log10Density’:[0,1],’magVelocities’:[20, 100]}}), defaults to None and is set in the web app to [min, max] of that field

  • filterVals (dict of UIname:dict of field:[min,max] range, optional) – initial location of the filter slider handles. This is a nested dict of the particle UInames, then for each filterble field the [min, max] range (e.g., {‘Gas’:{‘log10Density’:[.1,0.5],’magVelocities’:[50, 60]}}), defaults to None and is set in the web app to [min, max] of that field

particle_startup_settings(plotNmax=None, showVel=None, velType=None, color=None, sizeMult=None, showParts=None, **extra)[source]

Settings that will define the initial values of the particle UI panes

Parameters
  • plotNmax (int, optional) – maximum number of particles to plot This is a dict with keys of the particle UInames mapped to ints, defaults to all particles

  • showVel (dict of UIname:bool, optional) – flag to start showing the velocity vectors This is a dict with keys of the particle UInames mapped to bools, defaults to dict([(UIname,False) for UIname in UInames])

  • velType (dict of UIname:str, optional) – type of velocity vectors to plot. This is a dict with keys of the particle UInames mapped to strs that must be one of ‘line’, ‘arrow’, or ‘triangle’, defaults to dict([(UIname,’line’) for UIname in UInames])

  • color (dict of UIname:list of len = 4, optional) – the default colors for each particle group, This is a dict with keys of the particle UInames mapped to 4-element lists of rgba float values, defaults to random color with a = 1

  • sizeMult (dict of UIname:float, optional) – the default point size multiplier. This is a dict with keys of the particle UInames mapped to floats, defaults to dict([(UIname,1) for UIname in UInames])

  • showParts (dict of UIname:bool, optional) – show particles by default. This is a dict with keys of the particle UInames mapped to bools, defaults to dict([(UIname,True) for UIname in UInames])

printKeys(pattern=None, values=True)[source]

Prints keys (and optionally their values) to the console in an organized (and pretty) fashion.

Parameters
  • pattern (str, optional) – string that settings group must contain to be printed, defaults to None

  • values (bool, optional) – flag to print what the settings are set to, in addition to the key, defaults to True

startup_settings(maxVrange=2000.0, startFly=False, friction=0.1, stereo=False, stereoSep=0.06, decimate=None, start_tween=False, CDmin=0, CDmax=1, CDlognorm=0, columnDensity=0, **extra)[source]

General settings that affect the state app state

Parameters
  • maxVrange (float, optional) – maximum range in velocities to use in deciding the length of the velocity vectors (making maxVrange larger will enhance the difference between small and large velocities), defaults to 2000.

  • startFly (bool, optional) – flag to start in Fly controls (if False, then start in the default Trackball controls), defaults to False

  • friction (float, optional) – set the initial friction for the controls, defaults to 0.1

  • stereo (bool, optional) – flag to start in stereo mode, defaults to False

  • stereoSep (float, optional) – camera (eye) separation in the stereo mode (should be < 1), defaults to 0.06

  • decimate (int, optional) – set the initial global decimation (e.g, you could load in all the data by setting the decimation_factor to 1 for any individual firefly.data_reader.ParticleGroup, but only _display_ some fraction by setting decimate > 1 here). This is a single value (not a dict), defaults to None

  • start_tween (bool, optional) – flag to initialize the Firefly scene in tween mode, requires a valid tweenParams.json file to be present in the JSONdir, defaults to False

  • CDmin (float, optional) – bottom of the renormalization for the experimental column density projection mode, defaults to 0

  • CDmax (bool, optional) – top of the renormalization for the experimental column density projection mode, defaults to 1

  • CDlognorm – flag for whether renormalization should be done in log (CDlognorm=1) or linear (CDlognorm=0) space, defaults to 0

  • columnDensity – flag for whether the experimental column density projection mode should be enabled at startup. Toggle this mode by pressing ‘p’ on the keyboard, defaults to 0

window_settings(title='Firefly', annotation=None, showfps=False, **extra)[source]

Settings that affect the browser window

Parameters
  • title (str, optional) – the title of the webpage, shows up in browser tab, defaults to ‘Firefly’

  • annotation (str, optional) – text to include at the top of the Firefly window as an annotation, defaults to None

  • showfps (bool, optional) – flag to display the FPS (frames per second) of the Firefly scene, defaults to False