Bases: pygplates.PropertyValue
A sequence of property value elements.
GpmlArray behaves like a regular python list in that the following operations are supported:
Operation | Result |
---|---|
for x in s | iterates over the elements x of s |
x in s | True if x is an item of s |
x not in s | False if x is an item of s |
s += t | the GpmlArray instance s is extended by sequence t |
s + t | the concatenation of sequences s and t where either, or both, is a GpmlArray |
s[i] | the item of s at index i |
s[i] = x | replace the item of s at index i with x |
del s[i] | remove the item at index i from s |
s[i:j] | slice of s from i to j |
s[i:j] = t | slice of s from i to j is replaced by the contents of the sequence t (the slice and t can be different lengths) |
del s[i:j] | same as s[i:j] = [] |
s[i:j:k] | slice of s from i to j with step k |
del s[i:j:k] | removes the elements of s[i:j:k] from the list |
s[i:j:k] = t | the elements of s[i:j:k] are replaced by those of t (the slice and t must be the same length if k != 1) |
len(s) | length of s |
s.append(x) | add element x to the end of s |
s.extend(t) | add the elements in sequence t to the end of s |
s.insert(i,x) | insert element x at index i in s |
s.pop([i]) | removes the element at index i in s and returns it (defaults to last element) |
s.remove(x) | removes the first element in s that equals x (raises ValueError if not found) |
s.count(x) | number of occurrences of x in s |
s.index(x[,i[,j]]) | smallest k such that s[k] == x and i <= k < j (raises ValueError if not found) |
s.reverse() | reverses the items of s in place |
s.sort(key[,reverse]) | sort the items of s in place (note that key is not optional and, like python 3.0, we removed cmp) |
All elements should have the same type (such as GmlTimePeriod).
Create an array from a sequence of property value elements.
Parameters: | elements (Any sequence such as a list or a tuple) – A sequence of PropertyValue elements. |
---|---|
Raises: | RuntimeError if sequence is empty |
Note that all elements should have the same type (such as GmlTimePeriod).
Note
The sequence of elements must not be empty (for technical implementation reasons), otherwise a RuntimeError exception will be thrown.
array = pygplates.GpmlArray(elements)
Methods
__init__(elements) | Create an array from a sequence of property value elements. |
accept_visitor(visitor) | Accept a property value visitor so that it can visit this property value. |
append(x) | Add element x to the end. |
clone() | Create a duplicate of this property value (derived) instance, including a recursive copy of any nested property values that this instance might contain. |
count(x) | Number of occurrences of x. |
extend(t) | Add the elements in sequence t to the end. |
get_geometry() | Extracts the geometry if this property value contains a geometry. |
get_value([time=0]) | Extracts the value, of this possibly time-dependent property value, at the reconstruction time. |
index(x[,i[,j]]) | Smallest k such that the k th element equals x and i <= k < j (raises ValueError if not found). |
insert(i,x) | Insert element x at index i. |
pop([i]) | Removes the element at index i and returns it (defaults to last element). |
remove(x) | Removes the first element that equals x (raises ValueError if not found). |
reverse() | Reverses the items in place. |
sort(key[,reverse]) | Sort the items in place (note that key is not optional and, like python 3.0, we removed cmp). |
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 |
---|
Add element x to the end.
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 |
---|
Number of occurrences of x.
Add the elements in sequence t to the end.
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)
Extracts the value, of this possibly time-dependent property value, at the reconstruction time.
Parameters: | time (float or GeoTimeInstant) – the time to extract value (defaults to present day) |
---|---|
Return type: | PropertyValue or None |
If this property value is a time-dependent property (GpmlConstantValue, GpmlIrregularSampling or GpmlPiecewiseAggregation) then a nested property value is extracted at the reconstruction time and returned. Otherwise this property value instance is simply returned as is (since it’s not a time-dependent property value).
Returns None if this property value is a time-dependent property (GpmlConstantValue, GpmlIrregularSampling or GpmlPiecewiseAggregation) and time is outside its time range (of time samples or time windows).
Note that if this property value is a GpmlIrregularSampling instance then the extracted property value is interpolated (at reconstruction time) if property value can be interpolated (currently only GpmlFiniteRotation and XsDouble), otherwise None is returned.
The following example demonstrates extracting an interpolated finite rotation from a total reconstruction pole at time 20Ma:
gpml_finite_rotation_20Ma = total_reconstruction_pole.get_value(20)
if gpml_finite_rotation_20Ma:
print 'Interpolated finite rotation at 20Ma: %s' % gpml_finite_rotation_20Ma.get_finite_rotation()
Smallest k such that the k th element equals x and i <= k < j (raises ValueError if not found).
Insert element x at index i.
Removes the element at index i and returns it (defaults to last element).
Removes the first element that equals x (raises ValueError if not found).
Reverses the items in place.
Sort the items in place (note that key is not optional and, like python 3.0, we removed cmp).