Skip to content

Commit

Permalink
Revert "updated .py modules with additional help descriptions"
Browse files Browse the repository at this point in the history
This reverts commit 2c1d1a5.
  • Loading branch information
tyson-swetnam committed Jan 1, 2024
1 parent 2c1d1a5 commit 84197e3
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 336 deletions.
42 changes: 1 addition & 41 deletions dplpy/autoreg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -43,26 +43,6 @@
import warnings

def ar_func(data, max_lag=5):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#ar_func
Description: Contains methods that fit series to autoregressive models and perform functions
related to AR modeling.
NOTE: This function only accepts pandas series and dataframes as parameters.
**Required Inputs**
<data>["<series>"] - a data file (.CSV or .RWL), or an array imported from dpl.readers()
<series> - an individual series within a chronology file
<lag> - years, default 5
Example usage:
>>> import dplpy as dpl
>>> data = dpl.readers("../tests/data/csv/file.csv")
>>> dpl.ar_func(data['series name']) -> returns residuals plus mean of best fit
from AR models with max lag of either 5
(default) or specified number
"""
if isinstance(data, pd.DataFrame):
start_df = pd.DataFrame(index=pd.Index(data.index))
to_concat = [start_df]
Expand Down Expand Up @@ -99,26 +79,6 @@ def ar_func_series(data, max_lag):
# This method selects the best AR model with a specified maximum order
# The best model is selected based on AIC value
def autoreg(data: pd.Series, max_lag=5):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#autoreg
Description: Contains methods that fit series to autoregressive models and perform functions
related to AR modeling.
NOTE: This function only accepts pandas series and dataframes as parameters.
**Required Inputs**
<data>["<series>"] - a data file (.CSV or .RWL), or an array imported from dpl.readers()
<series> - an individual series within a chronology file
<lag> - years, default 5
Example usage:
>>> import dplpy as dpl
>>> data = dpl.readers("../tests/data/csv/file.csv")
>>> dpl.autoreg(data['series name']) -> returns parameters of best fit AR model
with maxlag of 5 (default) or other
specified number
"""
# validate data?
if not isinstance(data, pd.Series):
raise TypeError("Data argument should be pandas series. Received " + str(type(data)) + " instead.")
Expand Down
25 changes: 1 addition & 24 deletions dplpy/chron.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2021 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -48,29 +48,6 @@
# Main function for creating chronology of series. Formats input, prewhitens if necessary
# and produces output mean value chronology in a dataframe.
def chron(rwi_data: pd.DataFrame, biweight=True, prewhiten=False, plot=True):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#chron
Description: Creates a mean value chronology for a dataset, typically the ring width
indices of a detrended series. Takes three optional arguments 'biweight',
'prewhiten', and 'plot'. They determine whether to find means using Tukey's
bi-weight robust mean (default 'True'), whether to prewhiten data by fitting
to an AR model (default 'False'), and whether to plot the results of the
chronology (default 'True').
**Required Inputs**
<data> - a data frame loaded using readers
<prewhiten> - run pre-whitening on the time series, options: True or False, default is False
<biweight> - use Tukey's bi-weight robust mean, default True
<plot> - plot the results, default True
Example Usage:
>>> import dplpy as dpl
>>> data = dpl.readers("../tests/data/csv/file.csv")
>>> rwi_data = dpl.detrend(data)
>>> dpl.chron(rwi_data)
>>> dpl.chron(rwi_data, prewhiten=True)
>>> chron_data = dpl.chron(rwi_data, biweight=False, plot=False)
"""
if not isinstance(rwi_data, pd.DataFrame):
raise TypeError("Expected pandas dataframe as input, got " + str(type(rwi_data)) + " instead")

Expand Down
2 changes: 1 addition & 1 deletion dplpy/curvefit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
29 changes: 1 addition & 28 deletions dplpy/detrend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,33 +41,6 @@
import curvefit

def detrend(data: pd.DataFrame | pd.Series, fit="spline", method="residual", plot=True, period=None):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#detrend
Description: Detrends a given series or dataframe, first by fitting data to curve(s),
with 'spline' as the default, and then by calculating residuals
(default = 'residual') or differences ('difference') compared to the original data.
Other supported curve fitting methods are 'ModNegex' (modified negative exponential),
'Hugershoff', 'linear', 'horizontal'.
**Required Inputs**
<data> - a data frame loaded using dpl.readers()
<fit> - fitting method of curves, e.g., 'horizontal', 'Hugershoff', 'linear', 'ModNegex' (modified negative exponential), and 'spline', default 'spline'
<method> - intercomparison method, options: 'difference' or 'residual', default 'residual'
<plot> - plot the results, default 'True'
Example Usage:
# Detrend the entire dataframe
>>> dpl.detrend(<data>)
# Detrending a series part of the dataframe
>>> dpl.detrend(<data>["<series>"])
# Detrending function and its options
>>> dpl.detrend(<data>["<series>"], fit="<fitting method>", method="<comparison method>", plot=<True/False>)
"""
if isinstance(data, pd.DataFrame):
res = pd.DataFrame(index=pd.Index(data.index))
to_add = [res]
Expand Down
4 changes: 2 additions & 2 deletions dplpy/dplpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2021 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -91,7 +91,7 @@ def help_from_parser(args):
# Open the Website README (Manual documentation)
def readme():
try:
a = webbrowser.open("https://opendendro.org/python/", new=2)
a = webbrowser.open("https://opendendro.github.io/opendendro/python/", new=2)
print("Success: Check your web browser for a new tab")
if a == False:
print("Your computer does not use a monitor, and cannot display the webpages")
Expand Down
20 changes: 1 addition & 19 deletions dplpy/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,24 +41,6 @@
from stats import stats

def plot(inp: pd.DataFrame | str, type="seg"):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#plot
Description: Plots a given dataframe or series of a specific dataframe in either
line ('default'), spaghetti ('spag') or segment ('seg') plots.
**Reqired Inputs**
<data> - a data frame loaded using dpl.readers()
<series> - a single time series within the data array
<type> - type of plot to generate, e.g., line, spaghetti (spag), or segment (seg). default line
Example Usage:
# Plot entire data
>>> dpl.plot(<data>)
# Plot series subset of dataframe with a specified plot type
>>> dpl.plot(<data>["<series>"], type=<plot type>)
"""
if isinstance(inp, pd.DataFrame):
series_data = inp
elif isinstance(inp, str):
Expand Down
2 changes: 1 addition & 1 deletion dplpy/rbar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2023 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
37 changes: 13 additions & 24 deletions dplpy/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -46,18 +46,8 @@

def readers(filename: str, skip_lines=0, header=False):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#readers
Description: This function imports common ring width data files (.csv, .rwls) into Python as arrays
**Required Inputs**
<filename> - a file (.CSV or .RWL), or the full path and file name
Example usages:
>>> import dplpy as dpl
>>> data = dpl.readers('../tests/data/csv/filename.csv')
>>> data = dpl.readers('../tests/data/rwl/filename.rwl'), header=True
This function imports common ring width data files into Python as arrays
Accepted file types are CSV and RWL
"""
FORMAT = "." + filename.split(".")[-1]
print("\nAttempting to read input file: " + os.path.basename(filename) + " as " + FORMAT + " format\n")
Expand All @@ -69,23 +59,22 @@ def readers(filename: str, skip_lines=0, header=False):
series_data = process_rwl_pandas(filename, skip_lines, header)
else:
errorMsg = """
Error: Unsupported file type '{file_extension}'.
Unable to read file, please check that you're using a supported type
Accepted file types are .csv and .rwl
Example usages:
>>> import dplpy as dpl
>>> data = dpl.readers('../tests/data/csv/filename.csv')
>>> data = dpl.readers('../tests/data/rwl/filename.rwl'), header=True
"""
Unable to read file, please check that you're using a supported type
Accepted file types are .csv and .rwl
Example usages:
>>> import dplpy as dpl
>>> data = dpl.readers('../tests/data/csv/filename.csv')
>>> data = dpl.readers('../tests/data/rwl/filename.rwl'), header=True
"""

raise ValueError(errorMsg)

# If no data is returned, then an error was encountered when reading the file.
if series_data is None:
errorMsg = """
Error reading file contents. Check that file exists and file formatting is consistent with {format} format.
Error reading file. Check that file exists and that file formatting is consistent with {format} format.
If your file contains headers, run dpl.headers(file_path, header=True)
""".format(format=FORMAT)
raise ValueError(errorMsg)
Expand Down
22 changes: 1 addition & 21 deletions dplpy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -43,26 +43,6 @@
from statsmodels.tsa.ar_model import AutoReg

def report(inp: pd.DataFrame | str):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#report
Description: Generates a report about the input dataset that includes:
Number of dated series
Number of measurements
Avg series length (years)
Range (total years)
Span (start-end year)
Mean (Standard Deviation) series intercorrelation
Mean (Standard Deviation) AR1
Years with absent rings listed by series
**Required Inputs**
<data> - a data file (.CSV or .RWL), or an array imported from dpl.readers()
Example Usage:
>>> dpl.report(<data>)
"""
if isinstance(inp, pd.DataFrame):
series_data = inp
elif isinstance(inp, str):
Expand Down
21 changes: 1 addition & 20 deletions dplpy/series_corr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2023 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -46,25 +46,6 @@

# Analyzes the crossdating of one series compared to the master chronology
def series_corr(data: pd.DataFrame, series_name: str, prewhiten=True, corr="Spearman", seg_length=50, bin_floor=100, p_val=0.05):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#series_corr
Description: Crossdating function that focuses on the comparison of one series to the master chronology.
**Required Inputs**
<data> - a data file (.CSV or .RWL), or an array imported from dpl.readers()
<series> - a series name from the <data> array
<prewhiten> - run pre-whitening on the time series, options: 'True' or 'False', default is 'False'
<corr> - select correlation type if 'prewhiten=True', options: 'Pearson' or 'Spearman', default is 'Pearson'
<seg_length> - segment length (years), default '50'
<bin_floor> - select bin size, default '100'
<p_val> - select a p-value, e.g., '0.05', '0.01', '0.001', default '0.05'
<plot> - plot the output, default is 'True'
Example Usage:
>>> dpl.series_corr(ca533, "CAM191", prewhiten=False, corr="Pearson", bin_floor=10)
"""
# Check types of inputs
if not isinstance(data, pd.DataFrame):
errorMsg = "Expected dataframe input, got " + str(type(data)) + " instead."
Expand Down
16 changes: 1 addition & 15 deletions dplpy/stats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__copyright__ = """
dplPy for tree ring width time series analyses
Copyright (C) 2024 OpenDendro
Copyright (C) 2022 OpenDendro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -51,20 +51,6 @@
from statsmodels.tsa.ar_model import AutoReg

def stats(inp: pd.DataFrame | str):
"""
Online Documentation: https:/opendendro.org/dplpy-man/#stats
Description: Generates summary statistics for .RWL and .CSV format files.
It outputs a table with 'first', 'last', 'year', 'mean', 'median', 'stdev',
'skew', 'gini', 'ar1' for each series in data file.
**Required Inputs**
<data> - a data file (.CSV or .RWL), or an array imported from dpl.readers()
Example Usage:
>>> dpl.stats(<data>)
"""
if isinstance(inp, pd.DataFrame):
series_data = inp
elif isinstance(inp, str):
Expand Down
Loading

0 comments on commit 84197e3

Please sign in to comment.