Skip to content

Commit

Permalink
Merge pull request #55 from IMMM-SFA/speedtest
Browse files Browse the repository at this point in the history
migrate from numexpr to numba
  • Loading branch information
thurber authored Jul 12, 2021
2 parents 961fc4b + e84742b commit 00f8e6c
Show file tree
Hide file tree
Showing 49 changed files with 1,652 additions and 1,617 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: linux
name: build

on: [push]

Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/build_osx.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/build_windows.yml

This file was deleted.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[![linux](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_linux.yml/badge.svg)](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_linux.yml)
[![osx](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_osx.yml/badge.svg)](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_osx.yml)
[![windows](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_windows.yml/badge.svg)](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build_windows.yml)
[![build](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build.yml/badge.svg)](https://github.com/IMMM-SFA/mosartwmpy/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/IMMM-SFA/mosartwmpy/branch/main/graph/badge.svg?token=IPOY8984MB)](https://codecov.io/gh/IMMM-SFA/mosartwmpy)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.03221/status.svg)](https://doi.org/10.21105/joss.03221)
[![DOI](https://zenodo.org/badge/312114600.svg)](https://zenodo.org/badge/latestdoi/312114600)

## mosartwmpy
Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rm -f dist/*
python -m build
python -m twine upload dist/*
40 changes: 17 additions & 23 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ simulation:
# path to a directory for writing output files; will be created if doesn't exist
output_path: ./output
# date to begin the simulation
start_date: 1981-05-24
start_date: 1981-05-01
# date to end the simulation
end_date: 1981-05-26
end_date: 1981-05-30

# For example -- to change the input files, update the paths below:
grid:
path: ./input/domains/mosart.nc
land:
path: ./input/domains/land.nc

# grid:
# # path to the grid domain file; can be absolute or relative to the source code root
# path: /pic/projects/im3/iwmm/rof/mosart/MOSART_NLDAS_8th_20160426.nc
# land:
# # path to the land grid domain file; can be absolute or relative to the source code root
# path: /pic/projects/im3/iwmm/share/domains/domain.clm/domain.lnd.nldas2_0224x0464_c110415.nc
# runoff:
# # whether or not to read runoff input from file
# read_from_file: true
# # path to the runoff file; can be absolute or relative to the source code root
# path: /pic/projects/im3/iwmm/lnd/dlnd7/NLDAS/Livneh_NLDAS_1980_2011.nc
# water_management:
# # flag to turn this feature on or off
# enabled: true
# demand:
# # path to the demand file; can be absolute or relative to the source code root
# path: /pic/projects/im3/iwmm/input_data/demand/GCAM_waterdemand_nc/rcp8.5/RCP8.5_GCAM_water_demand_{year}_{month}.nc
# reservoirs:
# # path to the reservoir parameter file; can be absolute or relative to the source code root
# path: /pic/projects/im3/iwmm/input_data/runoff/US_reservoir_8th_NLDAS3_updated_20200421.nc
runoff:
read_from_file: true
path: ./input/runoff/runoff_1981_05.nc

water_management:
enabled: true
demand:
read_from_file: true
path: ./input/demand/demand_1981_05.nc
reservoirs:
path: ./input/reservoirs/reservoirs.nc
1 change: 1 addition & 0 deletions docs/_static/api.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_static/cognitive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_static/education.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_static/soccer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions docs/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Override some aspects of the pydata-sphinx-theme */

:root {
/* Use softer blue from bootstrap's default info color */
--pst-color-info: 23, 162, 184;
}

/* Main index page overview cards */

.intro-card {
background: #fff;
border-radius: 0;
padding: 30px 10px 20px 10px;
margin: 10px 0px;
}

.intro-card p.card-text {
margin: 0px;
}

.intro-card .card-img-top {
margin: 0px;
height: 52px;
}

.intro-card .card-header {
border: none;
background-color:white;
color: #150458 !important;
font-size: var(--pst-font-size-h5);
font-weight: bold;
padding: 0.5rem 0rem 0.5rem 0rem;
}

.intro-card .card-footer {
border: none;
background-color:white;
}

.intro-card .card-footer p.card-text{
max-width: 220px;
margin-left: auto;
margin-right: auto;
}

.card-body {
padding: 0.5rem;
}
17 changes: 12 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
# ones.
extensions = [
'nbsphinx',
'recommonmark',
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
'sphinx_rtd_theme'
'recommonmark',
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
'sphinx_panels',
'sphinx_rtd_theme'
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -57,4 +58,10 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ['_static']
html_css_files = ['style.css']

panels_delimiters = (r"^\>{3,}$", r"^\^{3,}$", r"^\+{3,}$")

import mosartwmpy
version = str(mosartwmpy.__version__)
101 changes: 80 additions & 21 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,89 @@
mosartwmpy
==========
:notoc:

Introduction
------------
.. toctree::
:maxdepth: 1
.. mosartwmpy documentation master file, created by
README.md
.. module:: mosartwmpy

Tutorial
--------
.. toctree::
:maxdepth: 1
************************
mosartwmpy documentation
************************

tutorial.ipynb
**Date**: |today| **Version**: |version|

Tips and Tricks
---------------
.. toctree::
:maxdepth: 1
**Useful links**:
`Source Repository <https://github.com/immm-sfa/mosartwmpy>`__ |
`Issues & Ideas <https://github.com/immm-sfa/mosartwmpy/issues>`__

`mosartwmpy` is a Python translation of MOSART-WM, a water routing and reservoir management model written in Fortran.


.. panels::
:card: + intro-card text-center
:column: col-lg-6 col-md-6 col-sm-6 col-xs-12 d-flex

>>>
:img-top: _static/cognitive.svg

Getting started
^^^

Get to know the *mosartwmpy* model.

+++
.. link-button:: README
:type: ref
:text: Getting started
:classes: btn-block btn-secondary stretched-link

>>>
:img-top: _static/education.svg

Tutorial
^^^

Follow along with this Jupyter notebook to learn the ropes of *mosartwmpy*.

+++
.. link-button:: tutorial
:type: ref
:text: Tutorial
:classes: btn-block btn-secondary stretched-link

>>>
:img-top: _static/soccer.svg

Tips & tricks
^^^

Learn about ways to manage Python virtual environments.

+++
.. link-button:: virtualenv
:type: ref
:text: Virtual environments
:classes: btn-block btn-secondary stretched-link

>>>
:img-top: _static/api.svg

API reference
^^^

A detailed description of the *mosartwmpy* API.

+++
.. link-button:: mosartwmpy
:type: ref
:text: API
:classes: btn-block btn-secondary stretched-link

virtualenv

Application Programming Interface
---------------------------------
.. toctree::
:maxdepth: 1
:maxdepth: 1
:hidden:
:titlesonly:

mosartwmpy
README.md
tutorial.ipynb
virtualenv
mosartwmpy
7 changes: 4 additions & 3 deletions docs/virtualenv.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Python Virtual Environments
===========================

Maintaining different versions of Python can be a chore, especially when ``mosartwmpy`` is forcing you to use Python 3.9+ 😈. There are many tools for managing Python environments, and many more will probably be developed after I write this, but at this moment in time my two recommendations are:
Maintaining different versions of Python can be a chore. Thankfully, there are many tools for managing Python environments; here are a few recommendations:

* `PyCharm <https://www.jetbrains.com/pycharm/>`_ IDE -- this is great for developing code in Python, and can automatically create virtual environments for a codebase by detecting versions and dependencies from the ``setup.py`` or ``setup.cfg``.
* `pyenv <https://github.com/pyenv/pyenv>`_ CLI -- this is a shell based tool for installing and switching between different versions of Python and dependencies. I will give a brief tutorial of using ``pyenv`` below, but recognize that the instructions may change over time so the ``pyenv`` documentation is the best place to look.
* `PyCharm <https://www.jetbrains.com/pycharm/>`_ IDE -- great for developing code in Python, and can automatically create virtual environments for a codebase by detecting versions and dependencies from the ``setup.py`` or ``setup.cfg``.
* `Conda <https://docs.conda.io>`_ package manager -- a Python package manager focused on scientific computing that can also manage virtual environments.
* `pyenv <https://github.com/pyenv/pyenv>`_ CLI -- a shell based tool for installing and switching between different versions of Python and dependencies. I will give a brief tutorial of using ``pyenv`` below, but recognize that the instructions may change over time so the ``pyenv`` documentation is the best place to look.

To create a Python 3.9 virtual environment, try the following steps:

Expand Down
1 change: 1 addition & 0 deletions mosartwmpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .model import Model
from ._version import __version__
1 change: 1 addition & 0 deletions mosartwmpy/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
6 changes: 3 additions & 3 deletions mosartwmpy/config/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ def __init__(self):
# minimum main channel slope (replaces 0s from grid file)
self.channel_slope_minimum = 0.0001
# kinematic wave condition # TODO what is it?
self.kinematic_wave_condition = 1.0e6
self.kinematic_wave_parameter = 1.0e6

# reservoir parameters # TODO better describe
self.reservoir_minimum_flow_condition = 0.05
self.reservoir_flood_control_condition = 1.0
self.reservoir_small_magnitude_difference = 0.01
self.reservoir_regulation_release_parameter = 0.85
self.reservoir_runoff_capacity_condition = 0.1
self.reservoir_runoff_capacity_parameter = 0.1
self.reservoir_flow_volume_ratio = 0.9

# number of supply iterations
self.reservoir_supply_iterations = 3

# minimum depth to perform irrigation extraction [m]
self.irrigation_extraction_condition = 0.1
self.irrigation_extraction_parameter = 0.1
# maximum fraction of flow that can be extracted from main channel
self.irrigation_extraction_maximum_fraction = 0.5

Expand Down
Loading

0 comments on commit 00f8e6c

Please sign in to comment.