Giter Site home page Giter Site logo

inkenbrandt / peeters_piper Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 6.0 2.99 MB

From Peeters 2014 in Groundwater; ArcGIS Python Toolbox; Piper Diagram; Water Chemistry

Python 99.85% Jupyter Notebook 0.15%
piper plot groundwater chemistry trilinear hydrology hydrogeology arcgis arcgis-desktop

peeters_piper's Introduction

THIS LIBRARY IS NOW OUT OF DATE. PLEASE USE WQChartPy AS IT IS BY THE ORIGINAL AUTHOR AND MUCH MORE ROBUST.

Peeters_Piper

This script plots a piper diagram of water chemisty. It includes an ArcGIS Toolbox for use in ArcGIS Pro.

Reference

This script was taken from Peeters 2014 in Groundwater

@article {GWAT:GWAT12118,
author = {Peeters, Luk},
title = {A Background Color Scheme for Piper Plots to Spatially Visualize Hydrochemical Patterns},
journal = {Groundwater},
volume = {52},
number = {1},
publisher = {Blackwell Publishing Ltd},
issn = {1745-6584},
url = {http://dx.doi.org/10.1111/gwat.12118},
doi = {10.1111/gwat.12118},
pages = {2--6},
year = {2014},
}

Please refer to the original publication for licensing guidelines.

Installation

pip install https://github.com/inkenbrandt/Peeters_Piper/zipball/master 

Example

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from peeters_piper.peeter_piper import piper

filename = "examples/GW20130314-0057-s02_additional_field.csv"

df = pd.read_csv(filename)

# Plot example data
# Piper plot
fig = plt.figure()
markers = ["s", "o", "^", "v", "+", "x"]
arrays = []
for i, (label, group_df) in enumerate(df.groupby("additional-field")):
    arr = group_df.iloc[:, 2:10].values
    arrays.append(
        [
            arr,
            {
                "label": label,
                "marker": markers[i],
                "edgecolor": "k",
                "linewidth": 0.3,
                "facecolor": "none",
            },
        ]
    )

rgb = piper(arrays, "title", use_color=True, fig=fig)
plt.legend()
fig.savefig(filename + "_piper_plot.png", dpi=120)

Example Piper Output

peeters_piper's People

Contributors

ekortunov avatar inkenbrandt avatar kinverarity1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

peeters_piper's Issues

Add tests

Add some tests to ensure functions are working properly.

Make Piper from layer tool

Essentially the same functionality except with existing layer.

Probably Use this:

def table_to_pandas_dataframe(table, field_names=None, query=None, sql_sn=(None, None)):
    """
    Load data into a Pandas Data Frame for subsequent analysis.
    :param table: Table readable by ArcGIS.
    :param field_names: List of fields.
    :return: Pandas DataFrame object.
    """
    # if field names are not specified
    if not field_names:
        field_names = get_field_names(table)
    # create a pandas data frame
    df = pd.DataFrame(columns=field_names)

    # use a search cursor to iterate rows
    with arcpy.da.SearchCursor(table, field_names, query, sql_clause=sql_sn) as search_cursor:
        # iterate the rows
        for row in search_cursor:
            # combine the field names and row items together, and append them
            df = df.append(dict(zip(field_names, row)), ignore_index=True)

    # return the pandas data frame
    return df

Also check out this:
https://gis.stackexchange.com/questions/161933/how-to-pass-only-selected-features-in-python-toolbox?noredirect=1&lq=1

TDS stuff

Issues:
TDScalc is incorrect (maybe you multiplied instead of added somewhere)
Illustrator produces errors when opening svg (font related).
Text in SVG comes thru as vector text but is impractical to edit and contains errors (e.g., HCO3- comes thru as four units: H, C, O, 3 and an upside down !)

Suggestions:
In tool, add check box to allow marker size to vary with TDS.
In tool, add min and max fields to control range of TDS marker sizes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.