cinemaIO.cinema_store Module

Module defining classes and methods for managing cinema data storage.

class paraview.cinemaIO.cinema_store.Document(descriptor, data=None)[source]

Bases: object

This refers to a document in the cinema data storage. A document is uniquely identified by a ‘descriptor’. A descriptor is a dictionary with key-value pairs, where key is a parameter name and value is the value for that particular parameter. TODO: A document can have arbitrary data (as ‘data’) and meta-data (as ‘attributes’) associated with it. At the moment we are ignoring the attributes.

attributes

Attributes are arbitrary meta-data associated with the document. If no attributes are present, it is set to None. When present, attributes are a dict with arbitrary meta-data relevant to the application.

data

Data associated with the document.

descriptor

A document descriptor is a unique identifier for the document. It is a dict with key value pairs. The descriptor cannot be changed once the document has been instantiated.

class paraview.cinemaIO.cinema_store.FileStore(dbfilename=None)[source]

Bases: paraview.cinemaIO.cinema_store.Store

Implementation of a store based on named files and directories.

create()[source]

creates a new file store

filename_pattern

Files corresponding to Documents are arranged on disk according the the directory and filename structure described by the filename_pattern. The format is a regular expression consisting of parameter names enclosed in ‘{‘ and ‘}’ and separated by spacers. “/” spacer characters produce sub directories.

Composite type stores ignore the file name pattern other than the extension.

find(q=None)[source]

overridden to implement parent API with files

get(q)[source]

optimization of find()[0] for an important case where caller knows exactly what to retrieve.

get_default_type()[source]

overridden to use the filename pattern to determine default type

insert(document)[source]

overridden to write file for the document after parent makes a record of it in the store

load()[source]

loads an existing filestore

save()[source]

writes out a modified file store

class paraview.cinemaIO.cinema_store.SingleFileStore(dbfilename=None)[source]

Bases: paraview.cinemaIO.cinema_store.Store

Implementation of a store based on a single volume file (image stack). NOTE: This class is limited to parametric-image-stack type stores, currently unmaintained and may go away in the near future.

create()[source]

creates a new file store

find(q=None)[source]

Overridden to search for documentts withing the stack. TODO: algorithm is dumb, but consisent with compute_sliceindex (which is also dumb)

get_sliceindex(document)[source]

returns the location of one document within the stack

insert(document)[source]

overridden to store data within a volume after parent makes a note of it

load()[source]

loads an existing filestore

save()[source]

writes out a modified file store

class paraview.cinemaIO.cinema_store.Store[source]

Bases: object

API for cinema stores. A store is a collection of Documents, with API to add, find, and access them. This class is an abstract class defining the API and storage independent logic. Storage specific subclasses handle the ‘database’ access.

The design of cinema store is based on the following principles:

The store comprises of documents (Document instances). Each document has a unique set of parameters, aka a “descriptor” associated with it. This can be thought of as the ‘unique key’ in database terminology.

One defines the parameters (contents of the descriptor) for documents on the store itself. The set of them is is referred to as ‘parameter_list’. One uses ‘add_parameter()’ calls to add new parameter definitions for a new store instance.

Users insert documents in the store using ‘insert’. One can find document(s) using ‘find’ which returns a generator (or cursor) allow users to iterate over all match documents.

add_control(name, properties)[source]

A control is a togglable parameter for a filter. Examples include: isovalue, offset.

add_field(name, properties, parent_layer, parents_values)[source]

A field is a component of the final color for a layer. Examples include: depth, normal, color, scalar values.

add_layer(name, properties)[source]

A Layer boils down to an image of something in the scene, and only that thing, along with the depth at each pixel. Layers (note the plural) can be composited back together by a viewer.

add_metadata(keyval)[source]
add_parameter(name, properties)[source]

Add a parameter. :param name: Name for the parameter. :param properties: Keyword arguments can be used to associate miscellaneous meta-data with this parameter.

assign_parameter_dependence(dep_param, param, on_values)[source]

mark a particular parameter as being explorable only for a subset of the possible values of another.

For example given parameter ‘appendage type’ which might have value ‘foot’ or ‘flipper’, a dependent parameter might be ‘shoe type’ which only makes sense for ‘feet’. More to the point we use this for ‘layers’ and ‘fields’ in composite rendering of objects in a scene and the color settings that each object is allowed to take.

create()[source]

Creates an empty store. Subclasses must extend this.

dependencies_satisfied(dep_param, descriptor)[source]

Check if the values in decriptor satisfy all of the dependencies of dep_param. Return true if no dependencies to satisfy. Return false if dependency of dependency fails.

determine_type(desc)[source]

Given a descriptor this figures out what type of data it holds. It works by first looking into the __type_specs for registered relationships and if that fails returning the registered default type for the store.

find(q=None)[source]

Return iterator to all documents that match query q. Should support empty query or direct values queries e.g.

for doc in store.find({‘phi’: 0}):
print (doc.data)
for doc in store.find({‘phi’: 0, ‘theta’: 100}):
print (doc.data)
getDependeeValue(depender, dependee)[source]

Return the required value of a dependee to fulfill a dependency.

getRelatedField(parameter)[source]

Returns the ‘field’ argument related to a ‘parameter’.

get_camera_model()[source]

return the camera model that the raster images in the store correspond to

get_complete_descriptor(partial_desc)[source]

Convenience method that expands an incomplete list of parameters into the full set using default values for the missing variables. TODO: doesn’t make sense with bifurcation (dependencies), when SFS supports them remove

get_default_type()[source]

subclasses override this if they know more

get_parameter(name)[source]
get_version_major()[source]

major version information corresponds with store type

get_version_minor()[source]

minor version information corresponds to larger changes in a store type

get_version_patch()[source]

patch version information corresponds to slight changes in a store type

getdependees(depender)[source]

return a list of all the parameters that ‘depender’ depends on

getdependers(name)[source]

return a list of all the parameters that depend on the given one

hasRelatedParameter(fieldName)[source]

Predicate to know if a field has a related ‘parameter’ argument.

insert(document)[source]

Inserts a new document. Subclasses must extend this.

iscontrol(name)[source]
isdependee(name)[source]

check if the named parameter has others that depend on it

isdepender(name)[source]

check if the named parameter depends on any others

isfield(name)[source]
islayer(name)[source]
iterate(parameters=None, fixedargs=None)[source]

Run through all combinations of parameter/value pairs without visiting any combinations that do not satisfy dependencies among them. Parameters, if supplied, is a list of parameter names to enforce an ordering. Fixed arguments, if supplied, are parameter/value pairs that we want to hold constant in the exploration.

load()[source]

Loads contents on the store (but not the documents). Subclasses must extend this.

metadata

Auxiliary data about the store itself. An example is hints that help the viewer app know how to interpret this particular store.

parameter_associations

paremeter associations establish a dependency relationship between different parameters.

parameter_list

The parameter list is the set of variables and their values that the documents in the store vary over.

parameters_for_object(obj)[source]

Given <obj>, an element of the layer <vis>, this method returns: 1. the names of independent parameters (t, theta, etc) that affect it 2. the name of its associated field 3. the names of the controls that affect it

paraview.cinemaIO.cinema_store.make_field(name, _values, **kwargs)[source]

specialization of make_parameters for parameters that define fields(aka color inputs). In this case the values is a list of name, type pairs where types must be one of ‘rgb’, ‘depth’, ‘value’, or ‘luminance’ May also be given an set of valueRanges, which have min and max values for named ‘value’ type color selections.

paraview.cinemaIO.cinema_store.make_parameter(name, values, **kwargs)[source]

define a new parameter that will be added to a store. Primarily takes a name and an array of potential values. May also be given a default value from inside the array. May also be given a typechoice to help the UI which is required to be one of ‘list’, ‘range’, ‘option’ or ‘hidden’. May also bve given a user friendly label.