Skip to content

Conversation

@jordanplanders
Copy link
Contributor

This pull request adds support for adding Geologic Timescale to plots (Resolves #270) via util:

  • function in utils/datasets.py to pull information from url and return a dataframe (includes RDF graph operations).
  • function in utils/plotting.py to add a new annotation axis and plot the geologic timescale

Corrected the function name from 'hightlight_intervals' to 'highlight_intervals' and updated all references. Improved type checking for intervals, color, alpha, and labels to accept both lists and numpy arrays. Enhanced color handling to support named CSS4 colors and fixed logic for interval boundary checks.
Replaces legacy CSV-based GTS plotting with a new system that loads the ICS chart from RDF (Turtle) using rdflib, and provides robust DataFrame-based utilities for geologic time scale annotation. Adds functions to load and customize GTS data, determine label placement, and render colored interval bars with smart label fitting and abbreviation support. The new approach is more flexible, supports up-to-date ICS data, and improves maintainability.
Moved load_ics_chart_to_df and apply_custom_traits from plotting.py to the datasets module. Updated imports and function calls accordingly to improve code organization and modularity.
Introduces `load_ics_chart_to_df` to parse ICS stratigraphic charts in Turtle format into DataFrames, including robust namespace handling and rank normalization. Adds `apply_custom_traits` to allow custom overrides of DataFrame columns based on trait matching. These utilities facilitate integration and customization of geologic timescale data.
The load_ics_chart_to_df function now accepts a time_units argument to allow conversion of boundary values to different time units (Ma, ka, Ga, or years). This enhances flexibility for users needing geological time data in various units.
Introduces the add_GTS function to plot the Geologic Time Scale (GTS) on Matplotlib axes, with options for label preferences, time units, rank order, and improved font size handling. Refactors argument names for clarity, adds new parameters (e.g., zorder, reverse_rank_order), and improves axis handling and label fitting logic.
@jordanplanders jordanplanders requested a review from khider October 2, 2025 21:10
@jordanplanders jordanplanders linked an issue Oct 2, 2025 that may be closed by this pull request
jordanplanders and others added 5 commits October 2, 2025 14:11
Refactored load_ics_chart_to_df to import rdflib only within the function and handle ImportError by falling back to loading a local CSV. This improves compatibility for users without rdflib installed and avoids unnecessary imports when not needed.
Changed default reverse_rank_order to True and updated docstring to clarify rank ordering. Fixed duration calculation to use .values for numpy arrays. Modified rank iteration to follow the order in the ranks list. Adjusted y-axis inversion logic to depend on location instead of reverse_rank_order.
Added i-c-stratigraphy_2024_11_24.csv containing the International Chronostratigraphic Chart (ICS) with boundaries, colors, and abbreviations for geologic time units. Data is sourced from the ICS chart.ttl as of 2024-11-24.
Added a usage example in the plot method docstring demonstrating how to plot the CENOGRID d18O timeseries with Geologic Time Scale annotation using add_GTS.
@CommonClimate CommonClimate merged commit 7fb57bd into master Oct 6, 2025
1 check passed
@CommonClimate CommonClimate deleted the geol_ts branch October 6, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding geologic timescale to Series.plot()

4 participants