Skip to content

Commit

Permalink
Merge pull request #1 from timcera/main
Browse files Browse the repository at this point in the history
Sync Forked Repo 2022/08/29
  • Loading branch information
tbongiov authored Aug 29, 2022
2 parents 8780e97 + 6dadf2f commit 8fd4ffa
Show file tree
Hide file tree
Showing 12 changed files with 1,738 additions and 163 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
- id: blacken-docs

- repo: https://github.com/asottile/pyupgrade
rev: v2.35.0
rev: v2.37.3
hooks:
- id: pyupgrade

Expand All @@ -70,13 +70,13 @@ repos:
# types_or: [python]
# args: ["--write","--no-fixers"]

- repo: https://github.com/regebro/pyroma
rev: "4.0"
hooks:
- id: pyroma
# - repo: https://github.com/regebro/pyroma
# rev: "4.0"
# hooks:
# - id: pyroma

- repo: https://github.com/commitizen-tools/commitizen
rev: v2.28.0
rev: v2.31.0
hooks:
- id: commitizen
stages: [commit-msg]
86 changes: 86 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,89 @@
[project]
name = "mettoolbox"
dynamic = ["readme", "version"]
description="mettoolbox is set of command line and Python tools for the analysis and reporting of meteorological data."
requires-python = ">=3.7.1"
dependencies = [
"toolbox_utils < 1.0.0",
"cltoolbox",
"solarpy",
"standard-precip",
"pydaymet",
"pyet",
]
license = {file = "LICENSE.txt"}
authors = [
{name = "Tim Cera", email = "[email protected]"}
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
"Environment :: Console",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]
keywords = ["time-series",
"cli-app",
"meteorology",
"evaporation",
"precipitation",
"climate",
"weather",
"climate-data",
"climate-data-analysis",
"climate-data-analysis-tools",
"temperature",
"humidity",
"wind",
]

[project.optional-dependencies]
dev = [
"black",
"cleanpy",
"twine",
"pytest",
"coverage",
"flake8",
"pytest-cov",
"pytest-mpl",
"pre-commit",
"black-nbconvert",
"blacken-docs",
"velin",
"isort",
"pyroma",
"pyupgrade",
"commitizen",
]

[project.scripts]
mettoolbox = "mettoolbox.mettoolbox:main"

[project_urls]
documentation = "https://timcera.bitbucket.io/mettoolbox/docs/index.html#mettoolbox-documentation"
github = "https://github.com/timcera/mettoolbox"
bitbucket = "https://bitbucket.org/timcera/mettoolbox/src/main/"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
readme = {file = "README.rst"}
version = {file = "VERSION"}

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["examples*", "tools*", "docs*", "mettoolbox.tests*"]

[tool.check-manifest]
ignore = [".travis.yml",
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg

This file was deleted.

71 changes: 4 additions & 67 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import subprocess
import sys

from setuptools import find_packages, setup
from setuptools import setup

pkg_name = "mettoolbox"

version = open("VERSION").readline().strip()
with open("VERSION", encoding="ascii") as version_file:
version = version_file.readline().strip()

if sys.argv[-1] == "publish":
subprocess.run(shlex.split("cleanpy ."), check=True)
Expand All @@ -18,68 +19,4 @@
)
sys.exit()

README = open("README.rst").read()

install_requires = [
# List your project dependencies here.
# For more details, see:
# http://packages.python.org/distribute/setuptools.html#declaring-dependencies
"tstoolbox > 103.18.4",
"solarpy",
"standard-precip",
"pydaymet",
"pyet",
]

extras_require = {
"dev": [
"black",
"cleanpy",
"twine",
"pytest",
"coverage",
"flake8",
"pytest-cov",
"pytest-mpl",
"pre-commit",
]
}

setup(
name=pkg_name,
version=version,
description="mettoolbox is set of command line and Python tools for the analysis and reporting of meteorological data.",
long_description=README,
classifiers=[
# Get strings from
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
"Environment :: Console",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords="time_series",
author="Tim Cera, PE",
author_email="[email protected]",
url=f"http://timcera.bitbucket.io/{pkg_name}/docs/index.html",
license="BSD",
packages=find_packages("src"),
package_dir={"": "src"},
include_package_data=True,
zip_safe=False,
install_requires=install_requires,
extras_require=extras_require,
entry_points={"console_scripts": [f"{pkg_name}={pkg_name}.{pkg_name}:main"]},
test_suite="tests",
python_requires=">=3.7.1",
)
setup()
35 changes: 26 additions & 9 deletions src/mettoolbox/disaggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import numpy as np
import pandas as pd
import typic
from tstoolbox import tstoolbox, tsutils
from toolbox_utils import tsutils
from tstoolbox import tstoolbox

from .melodist.melodist.humidity import (
calculate_month_hour_precip_mean,
Expand Down Expand Up @@ -95,7 +96,7 @@ def temperature(
tsutils.error_wrapper(
"""
The methods "mean_course_min", "mean_course_mean", or if `max_delta` is
True, or if `min_max_time` is "sun_loc_shift" require a HOURLY temperature
True, or if `min_max_time` is "sun_loc_shift" require a HOURLY temperature
values in the CSV file specified by the keyword `hourly`."""
)
)
Expand Down Expand Up @@ -710,17 +711,18 @@ def precipitation(
pd.options.display.width = 60

tsd = tsutils.common_kwds(
tsutils.read_iso_ts(
input_ts, skiprows=skiprows, names=names, index_type=index_type
),
input_tsd=tsutils.make_list(input_ts),
skiprows=skiprows,
index_type=index_type,
start_date=start_date,
end_date=end_date,
pick=columns,
round_index=round_index,
names=names,
dropna=dropna,
clean=clean,
source_units=source_units,
target_units=target_units,
clean=clean,
usecols=columns,
)

if method == "masterstation":
Expand All @@ -731,10 +733,25 @@ def precipitation(
# If masterstations_hour_col is a column number:
masterstation_hour_col = int(masterstation_hour_col) - 1

masterstation_hour_col = tsd.columns[masterstation_hour_col]
try:
mhour = tsd[masterstation_hour_col].to_frame()
except:
mhour = tsutils.common_kwds(
input_tsd=tsutils.make_list(input_ts),
skiprows=skiprows,
index_type=index_type,
start_date=start_date,
end_date=end_date,
round_index=round_index,
names=names,
dropna=dropna,
clean=clean,
source_units=source_units,
target_units=target_units,
usecols=columns,
)

# Should only be one hourly column in the input.
mhour = tsd[masterstation_hour_col].to_frame()
dsum = mhour.groupby(pd.Grouper(freq="D")).sum().asfreq("H", method="ffill")
master = mhour.join(dsum, rsuffix="sum")
mask = master.iloc[:, 0] > 0.0
Expand Down
2 changes: 1 addition & 1 deletion src/mettoolbox/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
import typic
from standard_precip.spi import SPI
from tstoolbox import tsutils
from toolbox_utils import tsutils


def _nlarge_nsmall(
Expand Down
Loading

0 comments on commit 8fd4ffa

Please sign in to comment.