Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-250-ridge-transforms #298

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions gplately/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,29 @@ def __init__(

self.base_projection = ccrs.PlateCarree()

# store these for when time is updated
# make sure these are initialised as FeatureCollection objects

# Initialize FeatureCollection objects for coastlines, continents, and COBs
self._coastlines = _load_FeatureCollection(coastlines)
self._continents = _load_FeatureCollection(continents)
self._COBs = _load_FeatureCollection(COBs)

# Initialize additional attributes
self.coastlines = None
self.continents = None
self.COBs = None
self._topological_plate_boundaries = None
self._topologies = None

# Set the anchor plate ID
self._anchor_plate_id = self._check_anchor_plate_id(anchor_plate_id)

# store topologies for easy access
# setting time runs the update_time routine
# Initialize ridges and transforms as empty lists
self.ridges = [] # Initialize ridges (assuming it’s needed)
self.transforms = [] # Initialize transforms (assuming it’s needed)

# Initialize time-related attributes, running `update_time` if `time` is provided
self._time = None
if time is not None:
self.time = time
self.time = time # Runs the update_time routine

def __getstate__(self):
filenames = self.plate_reconstruction.__getstate__()
Expand Down Expand Up @@ -430,6 +433,10 @@ def _check_anchor_plate_id(id):
return id

def update_time(self, time):
self.ridge_transforms = [
feature for feature in self.plate_reconstruction.topology_features
if feature.get_feature_type() == pygplates.FeatureType.gpml_transform
] # hjt: Update ridge_transforms based on current topology features
"""Re-reconstruct features and topologies to the time specified by the `PlotTopologies` `time` attribute
whenever it or the anchor plate is updated.

Expand Down Expand Up @@ -1800,8 +1807,6 @@ def plot_unclassified_features(self, ax, color="black", **kwargs):
**kwargs,
)

@validate_reconstruction_time
@append_docstring(GET_DATE_DOCSTRING.format("topologies"))
def get_all_topologies(
self,
central_meridian=0.0,
Expand Down Expand Up @@ -1839,8 +1844,6 @@ def get_all_topologies(
)
return gdf

@validate_topology_availability("all topologies")
@append_docstring(PLOT_DOCSTRING.format("topologies"))
def plot_all_topologies(self, ax, color="black", **kwargs):
"""Plot topological polygons and networks on a standard map projection."""
if "edgecolor" not in kwargs.keys():
Expand Down Expand Up @@ -1960,3 +1963,33 @@ def plot_topological_plate_boundaries(self, ax, color="black", **kwargs):
color=color,
**kwargs,
)

@validate_reconstruction_time
@append_docstring(GET_DATE_DOCSTRING.format("topologies"))
@validate_reconstruction_time
@append_docstring(GET_DATE_DOCSTRING.format("ridge transforms"))
def ridge_transforms(self):
"""Combine ridges and transforms into one feature set."""
return self.ridges + self.transforms

def get_ridge_transforms(self, central_meridian=0.0, tessellate_degrees=None):
"""Create a GeoDataFrame containing geometries of reconstructed ridge transforms."""
return self.get_feature(
self.ridge_transforms,
central_meridian=central_meridian,
tessellate_degrees=tessellate_degrees
)
# hjt: Added get_ridge_transforms method

@validate_topology_availability("all topologies")
@append_docstring(PLOT_DOCSTRING.format("topologies"))
@append_docstring(PLOT_DOCSTRING.format("ridge transforms"))
def plot_ridge_transforms(self, ax, color="black", **kwargs):
"""Plot reconstructed ridge transforms onto a map."""
return self.plot_feature(
ax,
self.ridge_transforms,
feature_name="ridge_transforms",
color=color,
**kwargs,
) # hjt: Added plot_ridge_transforms method