Hi Lavie,
You can use either in any situation. It’s just that pygplates.TopologicalSnapshot is a more object-oriented approach, which has some benefits.
To compare, with pygplates.resolve_topologies() you could resolve some plate polygons to 10Ma and export to a Shapefile with something like:
# Resolve topologies and export in one go.
pygplates.resolve_topologies(
'dynamic_plate_polygons.gpml',
'rotations.rot',
'resolved_plate_polygons_10Ma.shp',
reconstruction_time=10)
…whereas the equivalent with pygplates.TopologicalSnapshot
would be:
# First resolve topologies (at 10Ma).
snapshot_10 = pygplates.TopologicalSnapshot(
'dynamic_plate_polygons.gpml',
'rotations.rot',
10)
# Then export (using the 'snapshot_10' object).
snapshot_10.export_resolved_topologies('resolved_plate_polygons_10Ma.shp')
But if you wanted to do more, then you might have to call pygplates.resolve_topologies()
twice (both calls at 10Ma). In the following example, we want to export resolved networks to a Shapefile and return them as a Python list so we can query/process them further. This requires resolving the topologies twice (at 10Ma):
# Resolve topologies and export only resolved networks in one go.
pygplates.resolve_topologies(
'plate_polygons_and_networks.gpml',
'rotations.rot',
'resolved_networks_10Ma.shp',
reconstruction_time=10,
resolve_topology_types=pygplates.ResolveTopologyType.network)
# Resolve topologies again and return only resolved networks (in a list) in one go.
resolved_networks = []
pygplates.resolve_topologies(
'plate_polygons_and_networks.gpml',
'rotations.rot',
resolved_networks,
reconstruction_time=10,
resolve_topology_types=pygplates.ResolveTopologyType.network)
…whereas with pygplates.TopologicalSnapshot
we only need to resolve topologies once (at 10Ma):
# Resolve topologies only once.
snapshot_10 = pygplates.TopologicalSnapshot(
'plate_polygons_and_networks.gpml',
'rotations.rot',
10)
# Then export (only resolved networks).
snapshot_10.export_resolved_topologies(
'resolved_networks_10Ma.shp',
pygplates.ResolveTopologyType.network)
# Then return resolved networks (in a list).
resolved_networks = snapshot_10.get_resolved_topologies(
pygplates.ResolveTopologyType.network)
Furthermore, multiple pygplates.TopologicalSnapshot
’s (one for each reconstruction time) can be generated from a single pygplates.TopologicalModel, like this:
# Topological model can be used for any reconstruction time.
topological_model = pygplates.TopologicalModel(
'plate_polygons_and_networks.gpml',
'rotations.rot')
# Iterate over reconstruction times [0, 1, ..., 100].
for reconstruction_time in range(100+1):
# Generate a snapshot at the current reconstruction time.
topological_snapshot = topological_model.topological_snapshot(reconstruction_time)
# Then export snapshot (only resolved networks).
snapshot.export_resolved_topologies(
'resolved_networks_{}Ma.shp'.format(reconstruction_time),
pygplates.ResolveTopologyType.network)
# Then get resolved networks (in a list) from snapshot.
resolved_networks = snapshot.get_resolved_topologies(
pygplates.ResolveTopologyType.network)