cinema_python.database¶
cinema_python.database.store module¶
Module defining classes and methods for managing cinema data storage.
-
class
cinema_python.database.store.Document(descriptor, data=None)[source]¶ Bases:
objectThis 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
cinema_python.database.store.Store[source]¶ Bases:
objectAPI 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_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.
-
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)
-
find_field_key(desc)[source]¶ Given a descriptor this finds the field value if any in the descriptor.
-
getDependeeValue(depender, dependee)[source]¶ Return the required value of a dependee to fulfill a dependency.
-
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) remove
-
get_parameter_values(name)[source]¶ Get all values of type value :param name: Name for the parameter.
-
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
-
hasRelatedParameter(fieldName)[source]¶ Predicate to know if a field has a related ‘parameter’ argument.
-
iterate(parameters=None, fixedargs=None, progressObject=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.
-
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.
-
-
cinema_python.database.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’, ‘lut’, ‘depth’, ‘value’, or ‘luminance’ May also be given an set of valueRanges, which have min and max values for named ‘value’ type color selections.
-
cinema_python.database.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.
cinema_python.database.file_store module¶
An implementation of the database API based on named files and directories.
-
class
cinema_python.database.file_store.FileStore(dbfilename=None)[source]¶ Bases:
cinema_python.database.store.StoreImplementation of a store based on named files and directories.
-
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.
-
get(q)[source]¶ optimization of find()[0] for an important case where caller knows exactly what to retrieve.
-
cinema_python.database.vti_store module¶
An implementation of the database API stored in one VTK .vti format file.
-
class
cinema_python.database.vti_store.VTIFileStore(dbfilename=None)[source]¶ Bases:
cinema_python.database.store.StoreImplementation 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.
cinema_python.database.raster_wrangler module¶
Module that uses one of the available back end libraries to write out image files for cinema’s file store class.
-
class
cinema_python.database.raster_wrangler.RasterWrangler[source]¶ Bases:
objectIsolates the specifics of raster file formats from the cinema store. In particular this delegates the task to one or more subsidiary modules. The choice of which is open to facilitate packaging in different places, i.e. PIL for desktop and small packages, VTK for HPC contexts.
-
valuereader(fname, shape=None)[source]¶ Opens a value image file and returns it as either a color buffer or a floating point array (depending on how the image was exported).
-
cinema_python.database.oexr_helper module¶
Interface to OpenEXR library. TODO: fold this into raster_wrangler.
-
class
cinema_python.database.oexr_helper.OexrCompression[source]¶ -
NONE= 0¶
-
PIZ= 4¶
-
PXR24= 5¶
-
RLE= 1¶
-
ZIP= 3¶
-
ZIPS= 2¶
-