{ "cells": [ { "cell_type": "markdown", "id": "1bb66c07-5ab9-4621-a531-75711a01452b", "metadata": {}, "source": [ "# `pystrat` Quickstart Guide" ] }, { "cell_type": "markdown", "id": "22517350-43ca-430a-aecc-35c74c3754be", "metadata": {}, "source": [ "This Jupyter notebook is intended to quickly demonstrate core `pystrat` functionality. \n", "\n", "The example data files used in this guide can be found [here](https://github.com/pystrat-maintainers/pystrat/tree/main/docs/example-data)." ] }, { "cell_type": "markdown", "id": "5077b685-adbf-42c3-9047-f6cacd41f0a8", "metadata": {}, "source": [ "## Installation" ] }, { "cell_type": "markdown", "id": "02c24d7c-0e44-45c8-a1fc-71d322c0aedd", "metadata": {}, "source": [ "To install `pystrat`, use `pip`:\n", "```bash\n", "pip install pystrat\n", "```" ] }, { "cell_type": "code", "execution_count": 1, "id": "faba2776-e571-4756-a459-215fba01d2d9", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import pystrat" ] }, { "cell_type": "markdown", "id": "461f09b6-2119-4320-a5db-3bed58a5b08c", "metadata": {}, "source": [ "## Input Data" ] }, { "cell_type": "markdown", "id": "4a17a80c-62eb-4557-a9c0-24b54c699662", "metadata": {}, "source": [ "To plot sections with `pystrat`, it is necessary to provide a spreadsheet for each section in which the rows (downwards) correspond to units/beds going stratigraphically upwards, and there are minimally the following columns (see [example](example-data/lithostratigraphy.csv)):\n", "- unit thickness (numeric)\n", "- facies (string)\n", "\n", "The facies column dictates how each unit will be visualized according to the styling." ] }, { "cell_type": "markdown", "id": "3b425e38-ad5d-41a9-88df-4510b7be00d1", "metadata": {}, "source": [ "The following code creates a `pystrat.Section`:" ] }, { "cell_type": "code", "execution_count": 2, "id": "5a888315-87f0-43b9-951c-a3c3c6c8c112", "metadata": {}, "outputs": [], "source": [ "# read in your lithostratigraphy data\n", "litho_df = pd.read_csv('example-data/lithostratigraphy.csv')\n", "\n", "# create a pystrat Section from the lithostratigraphy data\n", "section = pystrat.Section(litho_df['THICKNESS'], # unit thicknesses\n", " litho_df['FACIES']) # unit facies" ] }, { "cell_type": "markdown", "id": "6504cca1-8cf4-4c78-9ac2-08eeefede8ca", "metadata": {}, "source": [ "### Styling" ] }, { "cell_type": "markdown", "id": "8f265940-365a-4ea2-bdf6-4ffd8f15f1ab", "metadata": {}, "source": [ "Before plotting sections, it is necessary to define a `pystrat.Style` object. This object provides the styling information for widths, colors, and swatches for units within a section, as well as annotations that can be plotted alongside sections.\n", "\n", "The styling logic is based on the unit facies, whereby each facies has a unique style specified in `pystrat.Style`. " ] }, { "cell_type": "code", "execution_count": 3, "id": "36656870-06af-4346-b26b-e91739692cd3", "metadata": {}, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "facies", "rawType": "object", "type": "string" }, { "name": "R", "rawType": "int64", "type": "integer" }, { "name": "G", "rawType": "int64", "type": "integer" }, { "name": "B", "rawType": "int64", "type": "integer" }, { "name": "width", "rawType": "float64", "type": "float" }, { "name": "swatch", "rawType": "int64", "type": "integer" } ], "conversionMethod": "pd.DataFrame", "ref": "886029f4-2b21-4cdb-89fb-0594efdfcaed", "rows": [ [ "0", "cover", "255", "255", "255", "0.2", "0" ], [ "1", "grainstone", "248", "169", "85", "0.8", "627" ], [ "2", "intraclast breccia", "200", "100", "255", "1.0", "605" ], [ "3", "marl", "119", "136", "187", "0.4", "623" ], [ "4", "marl-ribbonite", "119", "136", "187", "0.4", "623" ] ], "shape": { "columns": 6, "rows": 5 } }, "text/html": [ "
| \n", " | facies | \n", "R | \n", "G | \n", "B | \n", "width | \n", "swatch | \n", "
|---|---|---|---|---|---|---|
| 0 | \n", "cover | \n", "255 | \n", "255 | \n", "255 | \n", "0.2 | \n", "0 | \n", "
| 1 | \n", "grainstone | \n", "248 | \n", "169 | \n", "85 | \n", "0.8 | \n", "627 | \n", "
| 2 | \n", "intraclast breccia | \n", "200 | \n", "100 | \n", "255 | \n", "1.0 | \n", "605 | \n", "
| 3 | \n", "marl | \n", "119 | \n", "136 | \n", "187 | \n", "0.4 | \n", "623 | \n", "
| 4 | \n", "marl-ribbonite | \n", "119 | \n", "136 | \n", "187 | \n", "0.4 | \n", "623 | \n", "