# pygplates.GpmlConstantValue¶

class pygplates.GpmlConstantValue(property_value[, description])

Bases: pygplates.PropertyValue

The most basic case of a time-dependent property value is one that is constant for all time. The other two types are GpmlIrregularSampling and GpmlPiecewiseAggregation. The GPlates Geological Information Model (GPGIM) defines those properties that are time-dependent (see http://www.gplates.org/gpml.html) and those that are not. For example, a GpmlPlateId property value is used in gpml:reconstructionPlateId properties, of general feature types, and also in gpml:relativePlate properties of motion path features. In the former case it is expected to be wrapped in a GpmlConstantValue while in the latter case it is not.
reconstruction_plate_id = pygplates.Property(
pygplates.PropertyName.gpml_reconstruction_plate_id,
pygplates.GpmlConstantValue(pygplates.GpmlPlateId(701)))

relative_plate_id = pygplates.Property(
pygplates.PropertyName.gpml_relative_plate,
pygplates.GpmlPlateId(701))


If a property is created without a time-dependent wrapper where one is expected, or vice versa, then you can still save it to a GPML file and a subsequent read of that file will attempt to correct the property when it is created during the reading phase (by the GPML file format reader). This usually works for the simpler GpmlConstantValue time-dependent wrapper but does not always work for the more advanced GpmlIrregularSampling and GpmlPiecewiseAggregation time-dependent wrapper types.

__init__(property_value[, description])

Wrap a property value in a time-dependent wrapper that identifies the property value as constant for all time.

Parameters: property_value (PropertyValue) – arbitrary property value description (string or None) – description of this constant value wrapper

Optionally provide a description string. If description is not specified then get_description() will return None.

constant_property_value = pygplates.GpmlConstantValue(property_value)


Methods

 __init__(property_value, [description]) Wrap a property value in a time-dependent wrapper that identifies the property value as constant for all time. accept_visitor(visitor) Accept a property value visitor so that it can visit this property value. clone() Create a duplicate of this property value (derived) instance, including a recursive copy of any nested property values that this instance might contain. get_description() Returns the optional description of this constant value wrapper, or None. get_geometry() Extracts the geometry if this property value contains a geometry. get_value([time=0]) Extracts the constant value contained within. set_description([description]) Sets the description of this constant value wrapper, or removes it if none specified. set_value(property_value) Sets the property value of this constant value wrapper.
accept_visitor(visitor)

Accept a property value visitor so that it can visit this property value. As part of the visitor pattern, this enables the visitor instance to discover the derived class type of this property. Note that there is no common interface shared by all property value types, hence the visitor pattern provides one way to find out which type of property value is being visited.

Parameters: visitor (PropertyValueVisitor) – the visitor instance visiting this property value
clone()

Create a duplicate of this property value (derived) instance, including a recursive copy of any nested property values that this instance might contain.

Return type: PropertyValue
get_description()

Returns the optional description of this constant value wrapper, or None.

Return type: string or None
get_geometry()

Extracts the geometry if this property value contains a geometry.

Return type: GeometryOnSphere or None

This function searches for a geometry in the following standard geometry property value types:

If this property value does not contain a geometry then None is returned.

Time-dependent geometry properties are not yet supported, so the only time-dependent property value wrapper currently supported by this function is GpmlConstantValue.

To extract geometry from a specific feature property:

property_value = feature.get_value(pygplates.PropertyName.gpml_pole_position)
if property_value:
geometry = property_value.get_geometry()


...however Feature.get_geometry() provides an easier way to extract geometry from a feature with:

geometry = feature.get_geometry(pygplates.PropertyName.gpml_pole_position)


To extract all geometries from a feature (regardless of which properties they came from):

all_geometries = []
for property in feature:
property_value = property.get_value()
if property_value:
geometry = property_value.get_geometry()
if geometry:
all_geometries.append(geometry)


...however again Feature.get_geometry() does this more easily with:

all_geometries = feature.get_geometry(lambda property: True, pygplates.PropertyReturn.all)

get_value([time=0])

Extracts the constant value contained within.

Parameters: time (float or GeoTimeInstant) – the time to extract value (defaults to present day) PropertyValue or None

Since the contained property value is constant, the time parameter is ignored.

This method overrides PropertyValue.get_value().

set_description([description])

Sets the description of this constant value wrapper, or removes it if none specified.

Parameters: description (string or None) – description of this constant value wrapper
set_value(property_value)

Sets the property value of this constant value wrapper.

Parameters: property_value (PropertyValue) – arbitrary property value

This essentially replaces the previous property value. Note that an alternative is to directly modify the property value returned by get_value() using its property value methods.

#### Previous topic

pygplates.XsString

#### Next topic

pygplates.GpmlIrregularSampling