Skip to content

Commit

Permalink
Second commit
Browse files Browse the repository at this point in the history
moved the two functions to the end of the file and fixed the indentation.
added"ridge_transforms" as property(return self.ridges + self.transforms), similar to this https://github.com/GPlates/gplately/blob/bea66aaff046fa7d08e33c94c41b63695f8ecbe9/gplately/plot.py#L383-L387
  • Loading branch information
Hojat-Shirmard committed Oct 31, 2024
1 parent bea66aa commit 286a896
Showing 1 changed file with 40 additions and 31 deletions.
71 changes: 40 additions & 31 deletions gplately/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ class PlotTopologies(object):
"""

def __init__(
self.ridge_transforms = [] # hjt: Initialize ridge_transforms
self,
plate_reconstruction,
coastlines=None,
Expand All @@ -308,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 @@ -1805,17 +1807,6 @@ def plot_unclassified_features(self, ax, color="black", **kwargs):
**kwargs,
)

@validate_reconstruction_time
@append_docstring(GET_DATE_DOCSTRING.format("topologies"))
@validate_reconstruction_time
@append_docstring(GET_DATE_DOCSTRING.format("ridge 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
def get_all_topologies(
self,
central_meridian=0.0,
Expand Down Expand Up @@ -1853,18 +1844,6 @@ def get_all_topologies(
)
return gdf

@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
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 @@ -1983,4 +1962,34 @@ def plot_topological_plate_boundaries(self, ax, color="black", **kwargs):
feature_name="topological plate boundaries",
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

0 comments on commit 286a896

Please sign in to comment.