Skip to content

Commit

Permalink
Merge d072f1c into 8b65889
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthavens committed Sep 17, 2020
2 parents 8b65889 + d072f1c commit e2b0bce
Show file tree
Hide file tree
Showing 11 changed files with 4,569 additions and 8,575 deletions.
121 changes: 121 additions & 0 deletions notebooks/numpy_differences.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9-final"
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python_defaultSpec_1600360623664",
"display_name": "Python 3.6.9 64-bit ('.venv': virtualenv)"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"source": [
"# Numpy version\n",
"\n",
"Numpy version >1.19 makes some ever so small changes to the test data making them not pass. It appears to be the vapor pressure from HRRR because the air temperature is fine but not variables derived from vapor pressure like precip temperature and thermal.\n",
"\n",
"- air temperature is exactly the same from HRRR\n",
"- relative humidity is exactly the same from HRRR\n",
"- vapor pressure is float noise\n"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "array([0.])"
},
"metadata": {},
"execution_count": 2
}
],
"source": [
"# air temperature\n",
"old = pd.read_csv('../ta_old.csv', parse_dates=True, index_col='date_time')\n",
"new = pd.read_csv('../ta_new.csv', parse_dates=True, index_col='date_time')\n",
"d = old - new\n",
"np.unique(d)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "array([0.])"
},
"metadata": {},
"execution_count": 3
}
],
"source": [
"# relative humidity\n",
"old = pd.read_csv('../rh_old.csv', parse_dates=True, index_col='date_time')\n",
"new = pd.read_csv('../rh_new.csv', parse_dates=True, index_col='date_time')\n",
"d = old - new\n",
"np.unique(d)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": "array([-2.11303719e-04, -2.09472666e-04, -7.00683595e-05, -6.70166046e-05,\n -5.78613290e-05, -1.80358875e-05, 0.00000000e+00, 1.29699711e-04,\n 1.82006839e-04, 1.91406260e-04])"
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"# vapor pressure\n",
"old = pd.read_csv('../vp_old.csv', parse_dates=True, index_col='date_time')\n",
"new = pd.read_csv('../vp_new.csv', parse_dates=True, index_col='date_time')\n",
"d = old - new\n",
"np.unique(d)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
coloredlogs
Cython>=0.28.4
inicheck>=0.9.0,<0.10.0
netCDF4>=1.2.9
numpy>=1.14.0,<1.19.0
numpy>=1.14.0
pandas>=0.23.0
pytz==2017.3
scipy>=1.0.0,<1.5.0
Expand Down
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r requirements.txt
Cython
coveralls>=1.3.0
tox>=3.14.0
flake8>=3.5.0
Expand All @@ -9,4 +10,4 @@ pydata-sphinx-theme
sphinxcontrib-bibtex>=1.0
sphinxcontrib-websupport>=1.0.1
pygit2
git+https://github.com/USDA-ARS-NWRC/goldmeister.git@master
git+https://github.com/USDA-ARS-NWRC/goldmeister.git@main
51 changes: 35 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,40 @@

import os

import numpy
from Cython.Distutils import build_ext
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext as _build_ext

# Test if compiling with cython or using the C source
try:
from Cython.Distutils import build_ext as _build_ext
except ImportError:
USE_CYTHON = False
else:
USE_CYTHON = True

print('Using Cython {}'.format(USE_CYTHON))
ext = '.pyx' if USE_CYTHON else '.c'


def c_name_from_path(location, name):
return os.path.join(location, name).replace('/', '.')


with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())

with open('README.md') as readme_file:
readme = readme_file.read()

# Give user option to specify his local compiler name
if "CC" not in os.environ:
# force the compiler to use gcc
os.environ["CC"] = "gcc"


ext_modules = []
extension_params = dict(
include_dirs=[numpy.get_include()],
extra_compile_args=['-fopenmp', '-O3'],
extra_link_args=['-fopenmp', '-O3'],
)
Expand All @@ -37,7 +47,7 @@ def c_name_from_path(location, name):
Extension(
c_name_from_path(source_folder, 'detrended_kriging'),
sources=[os.path.join(source_folder, val) for val in [
"detrended_kriging.pyx",
"detrended_kriging" + ext,
"krige.c",
"lusolv.c",
"array.c"
Expand All @@ -52,7 +62,7 @@ def c_name_from_path(location, name):
Extension(
c_name_from_path(source_folder, 'envphys_c'),
sources=[os.path.join(source_folder, val) for val in [
"envphys_c.pyx",
"envphys_c" + ext,
"topotherm.c",
"dewpt.c",
"iwbt.c"
Expand All @@ -67,14 +77,24 @@ def c_name_from_path(location, name):
Extension(
c_name_from_path(source_folder, 'wind_c'),
sources=[os.path.join(source_folder, val) for val in [
"wind_c.pyx",
"wind_c" + ext,
"breshen.c",
"calc_wind.c"
]],
**extension_params
),
]

cmdclass = {}
if USE_CYTHON:
cmdclass = {'build_ext': build_ext}

with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()

with open('README.md') as readme_file:
readme = readme_file.read()

setup(
name='smrf-dev',
description="Distributed snow modeling for water resources",
Expand Down Expand Up @@ -110,9 +130,7 @@ def c_name_from_path(location, name):
],
test_suite='smrf.tests',
# tests_require=test_requirements,
cmdclass={
'build_ext': build_ext
},
cmdclass=cmdclass,
ext_modules=ext_modules,
scripts=[
'scripts/update_configs',
Expand All @@ -130,6 +148,7 @@ def c_name_from_path(location, name):
'local_scheme': 'node-and-date',
},
setup_requires=[
'setuptools_scm'
'setuptools_scm',
'numpy'
],
)

0 comments on commit e2b0bce

Please sign in to comment.