USDA-ARS-NWRC / smrf

SMRF was designed to increase the flexibility of taking measured weather data, or atmospheric models, and distributing the data across a watershed.
Other
12 stars 4 forks source link

169 numpy #187

Closed scotthavens closed 4 years ago

scotthavens commented 4 years ago

A 2 part PR.

Numpy version

Numpy > v1.19 made some underlying changes that made the vapor pressure calculation slightly different only from HRRR. Looking at the vapor pressure calculation, the air temperature and relative humidity were exactly the same. The differences in vapor pressure stem from the sati and satw with differences in the float tolerance range.

Added a few levels of tests. First still tests for exact match. If the arrays are not exact, then try allclose with relative tolerance of 1e-5 and 1e-4. Raise an exception if these are not met.

SMRF pip install

The setup.py imports numpy which will not work if numpy is not installed. Following steps here, moved the build_ext to a class so numpy is only imported if compiling the pyx files to C.

This does move away from using Cython build_ext but not fully sure that it is needed as setuptools will call gcc to compile.

scotthavens commented 4 years ago

Added Cython build_ext back in. If Cython is present, it will compile SMRF from the .pyx files. If not, it willl use the .c files to build the extensions.