cinema_python.adaptors

cinema_python.adaptors.explorers module

module for generating cinema databases from arbitrary codes. Essentially this provides a way to runs over all possible combinations of values in database and call out to arbitrary codes so that they have a chance to make corresponding changes before inserting the result into the database.

class cinema_python.adaptors.explorers.Explorer(store, parameters, tracks)[source]

Bases: object

Middleman that connects an arbitrary producing codes to the CinemaStore. The purpose of this class is to run through the parameter sets, and tell a set of tracks (in order) to do something with the parameter values it cares about.

execute(desc)[source]
explore(fixedargs=None, progressObject=None)[source]

Explore the problem space to populate the store being careful not to hit combinations where dependencies are not satisfied. Fixed arguments are the parameters that we want to hold constant in the exploration.

finish()[source]

Give tracks a chance to clean up after a run

insert(doc)[source]
list_parameters()[source]

parameters is an ordered list of parameters that the Explorer varies over

prepare()[source]

Give tracks a chance to get ready for a run

store
class cinema_python.adaptors.explorers.Layer(layer, objectlist)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a layer to the set of objects in the scene that it controls.

execute(doc)[source]
class cinema_python.adaptors.explorers.LayerControl(name, showFunc, hideFunc)[source]

Bases: object

Prototype for something that Layer track can control

class cinema_python.adaptors.explorers.Track[source]

Bases: object

abstract interface for things that can produce data

to use this: caller should set up some visualization then tie a particular set of parameters to an action with a track

execute(document)[source]

subclasses operate on parameters here

finish()[source]

subclasses cleanup after running here

prepare(explorer)[source]

subclasses get ready to run here

cinema_python.adaptors.vtk

cinema_python.adaptors.vtk.vtk_explorers module

Module consisting of explorers and tracks that connect arbitrary VTK pipelines to cinema stores.

class cinema_python.adaptors.vtk.vtk_explorers.ActorInLayer(parameter, actor)[source]

Bases: cinema_python.adaptors.explorers.LayerControl

A track that turns on and off an actor in a layer

hideme()[source]
showme()[source]
class cinema_python.adaptors.vtk.vtk_explorers.Camera(center, axis, distance, camera)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a VTK script’s camera to the phi and theta tracks. This allows the creation of spherical camera stores where the user can view the data from many points around it.

execute(document)[source]
static obtain_angles(angular_steps=[10, 15])[source]
class cinema_python.adaptors.vtk.vtk_explorers.Clip(argument, clip)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects clip filters to a scalar valued parameter.

execute(doc)[source]
prepare(explorer)[source]
class cinema_python.adaptors.vtk.vtk_explorers.Color(parameter, colorlist, actor)[source]

Bases: cinema_python.adaptors.vtk.vtk_explorers.ColorActors

class cinema_python.adaptors.vtk.vtk_explorers.ColorActors(parameter, colorlist, actors)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a parameter to a choice of surface rendered color maps.

execute(doc)[source]

tells VTK to color the object we’ve been assigned using the color definition we’ve been given that corresponds to the value we’ve been assigned to watch in the doc.descriptor

class cinema_python.adaptors.vtk.vtk_explorers.ColorList[source]

A helper that creates a dictionary of color controls for VTK. The Color track takes in a color name from the Explorer and looks up into a ColorList to determine exactly what needs to be set to apply the color.

AddDepth(name)[source]
AddLUT(name, lut, field, arrayname)[source]
AddLuminance(name)[source]
AddSolidColor(name, RGB)[source]
AddValueRender(name, field, arrayname, component, range)[source]
getColor(name)[source]
class cinema_python.adaptors.vtk.vtk_explorers.Contour(argument, filter, method)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects clip filters to a scalar valued parameter.

execute(doc)[source]
prepare(explorer)[source]
class cinema_python.adaptors.vtk.vtk_explorers.ImageExplorer(store, parameters, engines, rw)[source]

Bases: cinema_python.adaptors.explorers.Explorer

An explorer that connects a VTK program’s render window to a store and makes it save new images into the store.

insert(document)[source]

overridden to use VTK to generate an image and create a the document for it

setDrawMode(choice, **kwargs)[source]

helper for Color tracks so that they can cause ParaView to render in the right mode.

cinema_python.adaptors.paraview

cinema_python.adaptors.paraview.pv_explorers module

Module consisting of explorers and tracks that connect arbitrary paraview pipelines to cinema stores.

class cinema_python.adaptors.paraview.pv_explorers.Camera(center, axis, distance, view)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a ParaView script’s camera to the phi and theta tracks. This allows the creation of spherical camera stores where the user can view the data from many points around it.

execute(document)[source]

moves camera into position for the current phi, theta value

class cinema_python.adaptors.paraview.pv_explorers.Clip(argument, clip)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a clip filter to a scalar valued parameter.

execute(doc)[source]
prepare(explorer)[source]
class cinema_python.adaptors.paraview.pv_explorers.Color(parameter, colorlist, rep)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a parameter to color controls.

execute(doc)[source]

tells ParaView to color the object we’ve been assigned using the color definition we’ve been given that corresponds to the value we’ve been assigned to watch in the doc.descriptor

class cinema_python.adaptors.paraview.pv_explorers.ColorList[source]

A helper that creates a dictionary of color controls for ParaView. The Color track takes in a color name from the Explorer and looks up into a ColorList to determine exactly what needs to be set to apply the color.

AddDepth(name)[source]
AddLUT(field, name, comp)[source]
AddLuminance(name)[source]
AddSolidColor(name, RGB)[source]
AddValueRender(name, field, arrayname, component, range)[source]
getColor(name)[source]
class cinema_python.adaptors.paraview.pv_explorers.Contour(parameter, filt)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a contour filter to a scalar valued parameter.

execute(doc)[source]
prepare(explorer)[source]
class cinema_python.adaptors.paraview.pv_explorers.ImageExplorer(store, parameters, tracks, view=None, iSave=True)[source]

Bases: cinema_python.adaptors.explorers.Explorer

An Explorer that connects a ParaView script’s views to a store. Basically it iterates over the parameters and for each unique combination it tells ParaView to make an image and saved the result into the store.

captureWindowAsNumpy()[source]
captureWindowRGB()[source]
enableFloatValues(enable)[source]
finish()[source]
insert(document)[source]

overridden to use paraview to generate an image and create a the document for it

setDrawMode(choice, **kwargs)[source]

helper for Color tracks so that they can cause ParaView to render in the right mode.

updateRange(name, component, drange)[source]
class cinema_python.adaptors.paraview.pv_explorers.PoseCamera(view, camType, store)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a ParaView script’s pose track which has 3x3 camera orientations in it. Also takes in camera_eye, _at and _up arrays, which designate the initial position at each timestep, from which the camera moves according to each pose.

execute(document)[source]

moves camera into position for the current phi, theta value

class cinema_python.adaptors.paraview.pv_explorers.Slice(parameter, filt)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects a slice filter to a scalar valued parameter.

execute(doc)[source]
prepare(explorer)[source]
class cinema_python.adaptors.paraview.pv_explorers.SourceProxyInLayer(parameter, representation, proxy)[source]

Bases: cinema_python.adaptors.explorers.LayerControl

A track that turns on and off an source proxy in a layer

hideme()[source]
showme()[source]
class cinema_python.adaptors.paraview.pv_explorers.Templated(parameter, filt, methodName)[source]

Bases: cinema_python.adaptors.explorers.Track

A track that connects any type of filter to a scalar valued parameter. To use pass in a source proxy (aka filter) and the name of method (aka property) to be called on it.

execute(doc)[source]
class cinema_python.adaptors.paraview.pv_explorers.ValueMode[source]
FLOATING_POINT = 2
INVERTIBLE_LUT = 1
cinema_python.adaptors.paraview.pv_explorers.printView(view)[source]

For debugging/demonstrating frustums spits out the coordinates of the four camera near plane corners load them up in paraview

cinema_python.adaptors.paraview.pv_introspect module

Module that looks at a ParaView pipeline and automatically creates a cinema store that ranges over all of the variables that we know how to control and later show.

cinema_python.adaptors.paraview.pv_introspect.add_control_and_colors(name, cs, userDefined, arrayRanges, disableValues)[source]

add parameters that change the settings and color of a filter

cinema_python.adaptors.paraview.pv_introspect.add_customized_array_selection(sourceName, source, fields, userDefined, arrayRanges, disableValues)[source]
cinema_python.adaptors.paraview.pv_introspect.add_filter_value(name, cs, userDefinedValues)[source]

creates controls for the filters that we know how to manipulate

cinema_python.adaptors.paraview.pv_introspect.explore(cs, proxies, iSave=True, currentTime=None, userDefined={}, specLevel='A', camType='phi-theta', tracking={}, floatValues=True, arrayRanges={}, disableValues=False, progressObject=None)[source]

Runs a pipeline through all the changes we know how to make and saves off images into the store for each one.

cinema_python.adaptors.paraview.pv_introspect.explore_customized_array_selection(sourceName, source, colorList, userDefined, disableValues)[source]
cinema_python.adaptors.paraview.pv_introspect.export_scene(baseDirName, viewSelection, trackSelection, arraySelection)[source]

This explores a set of user-defined views and tracks. export_scene is called from vtkCinemaExport. The expected order of parameters is as follows:

  • viewSelection (following the format defined in Wrapping/Python/paraview/cpstate.py):

Directory of the form {‘ViewName’ : [parameters], ...}, with parameters defined in the order: Image filename, freq, fittoscreen, magnification, width, height, cinema).

  • trackSelection:

Directory of the form {‘FilterName’ : [v1, v2, v3], ...}

  • arraySelection:
Directory of the form {‘FilterName’ : [‘arrayName1’, ‘arrayName2’, ...],
... }

Note: baseDirName is used as the parent directory of the database generated for each view in viewSelection. ‘Image filename’ is used as the database directory name.

cinema_python.adaptors.paraview.pv_introspect.extend_range(arrayRanges, name, minmax)[source]

This updates the data ranges in the data base meta file. Throughout a time varying data export ranges will vary. Here we accumulate them as we go so that by the end we get the min and max values over for each array component over all time.

This version happens in catalyst, where we recreate the database file every timestep.

cinema_python.adaptors.paraview.pv_introspect.filter_has_parameters(name)[source]

see if this proxy is one we know how to make controls for

cinema_python.adaptors.paraview.pv_introspect.float_limiter(x)[source]

a shame, but needed to make sure python, javascript and (directory/file)name agree. TODO: This can go away now that we use name=index instead of name=value filenames.

cinema_python.adaptors.paraview.pv_introspect.get_pipeline()[source]

sanitizes the pipeline graph

cinema_python.adaptors.paraview.pv_introspect.inspect(skip_invisible=True)[source]

Produces a representation of the pipeline that is easier to work with. Thanks Scott Wittenburg and the pv mailing list for this gem

cinema_python.adaptors.paraview.pv_introspect.make_cinema_store(proxies, ocsfname, view, forcetime=False, userDefined={}, specLevel='A', camType='phi-theta', arrayRanges={}, extension='.png', disableValues=False)[source]

Takes in the pipeline, structured as a tree, and makes a cinema store definition containing all the parameters we will vary.

cinema_python.adaptors.paraview.pv_introspect.make_workspace_file(basedirname, cinema_dirs)[source]

This writes out the top level json file that says that there are child cinema stores inside. The viewer sees this and opens up in the children in separate panels.

cinema_python.adaptors.paraview.pv_introspect.max_bounds()[source]

returns conservative min and max (over x y and z) bounds

cinema_python.adaptors.paraview.pv_introspect.optimize_traversal_order(params)[source]

An optimization that reduces generation time by better amortizing setup costs. With this rendering state changes (cheap) are late and in particular camera (~free) is the innermost loop.

It also makes generation easier to watch. With camera innermost it iunderstand and prevents rapidly cycling between bright colors.

cinema_python.adaptors.paraview.pv_introspect.prepare_selection(trackSelection, arraySelection)[source]

The rest of pv_introspect expects to receive user-defined values in the structure:

{proxy_reference: {‘ControlName’: [value_1, value_2, ..., value_n],
‘arraySelection’: [‘ArrayName_1’, ..., ‘ArrayName_n’]}}

This structure is necessary for catalyst to correctly reference the created proxies. Although this is not necessary in the menu->export case (proxies could be accessed by name directly), we comply for compatibility.

cinema_python.adaptors.paraview.pv_introspect.project_to_at(eye, fp, cr)[source]

project center of rotation onto focal point to keep gaze direction the same while allowing both translate and zoom in and out to work

cinema_python.adaptors.paraview.pv_introspect.range_epsilon(minmax)[source]

ensure that min and max have some separation to assist rendering

cinema_python.adaptors.paraview.pv_introspect.record_visibility()[source]

at start of run, record the current paraview state so we can return to it

cinema_python.adaptors.paraview.pv_introspect.restore_visibility(proxies)[source]

at end of run, return to a previously recorded paraview state

cinema_python.adaptors.paraview.pv_introspect.track_source(proxy, eye, at, up)[source]

an animation mode that follows a specific object input camera position is in eye, at, up returns same, moved to follow the input proxy

cinema_python.adaptors.paraview.pv_introspect.update_all_ranges(cs, arrayRanges)[source]

This updates the data ranges in the data base meta file. Throughout a time varying data export ranges will vary. Here we accumulate them as we go so that by the end we get the min and max values over for each array component over all time.

This version happens in paraview export for time varying data where we recreate the database file once, and afterward only output new rasters.

cinema_python.adaptors.paraview.cinemareader module

cinemareader is used by vtkCinemaDatabaseReader.

class cinema_python.adaptors.paraview.cinemareader.FileStoreAPI(fs, qt)[source]

Bases: object

get_control_parameters(objectname)[source]

returns control paramater names for the given object

get_control_values(controlparametername)[source]

returns sorted list of available values for a control parameter

get_control_values_as_strings(controlparametername)[source]
get_field_name(objectname)[source]

return the field name associated with an object

get_field_valuerange(objectname, valueanme)[source]
get_field_values(objectname, valuetype)[source]

returns fields for a specific object

get_objects()[source]

returns a list of viewable objects in the scene

get_parents(objectname)[source]

returns a list of names of the objects that the given object’s parents

get_spec()[source]

returns current database spec

get_timesteps()[source]

returns a list of timesteps available in the store

get_visibility(object)[source]

returns an objects default visbility

translate_query(q)[source]
class cinema_python.adaptors.paraview.cinemareader.FileStoreSpecA(fs)[source]

Bases: cinema_python.adaptors.paraview.cinemareader.FileStoreAPI

get_cameras(ts)[source]

returns a list of camera positions timestep is ignored.

get_control_parameters(objectname)[source]

returns all parameters for this database

get_objects()[source]

returns a list of viewable objects in the scene

get_parents(objectname)[source]
get_spec()[source]
get_visibility(objectname)[source]

returns an objects default visbility

translate_query(q)[source]
class cinema_python.adaptors.paraview.cinemareader.FileStoreSpecB(fs)[source]

Bases: cinema_python.adaptors.paraview.cinemareader.FileStoreAPI

get_all_parents()[source]

builds a map with key is object name, and value is a list of objectname for its parents.

get_cameras(ts)[source]

returns a list of camera positions for a specific timestep. timestep is ignored if camera is not affected by time

get_control_parameters(objectname)[source]
get_field_name(objectname)[source]
get_field_valuerange(objectname, valuename)[source]
get_field_values(objectname, valuetype)[source]

returns fields for a specific object

get_objects()[source]
get_parents(objectname)[source]
get_spec()[source]
get_timesteps()[source]

returns a list of timesteps available in the store

get_visibility(objectname)[source]
translate_query(q)[source]
cinema_python.adaptors.paraview.cinemareader.layer2img(layer)[source]

converts a layer to vtkImageData.

cinema_python.adaptors.paraview.cinemareader.load(filename)[source]