Skip to content

Commit 2d91edd

Browse files
authored
Merge pull request #137 from UW-Hydro/develop
release 1.1
2 parents b1dd17c + 6efb563 commit 2d91edd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3067
-525
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metsim/_version.py export-subst

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include versioneer.py
2+
include metsim/_version.py

ci/requirements-3.5.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
- pandas
88
- netcdf4
99
- numba
10+
- bottleneck
1011
- numpy
1112
- scipy
1213
- pytest

ci/requirements-3.6.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies:
66
- xarray
77
- pandas
88
- netcdf4
9+
- bottleneck
910
- numba
1011
- numpy
1112
- scipy

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#
2020
import os
2121
import sys
22+
2223
import sphinx_rtd_theme
2324

2425
sys.path.insert(0, os.path.abspath('.'))
@@ -34,11 +35,16 @@
3435
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3536
# ones.
3637
extensions = ['sphinx.ext.autodoc',
38+
'sphinx.ext.extlinks',
3739
'sphinx.ext.mathjax',
3840
'sphinx.ext.viewcode',
3941
'sphinx.ext.napoleon',
4042
'sphinx.ext.autosummary']
4143

44+
extlinks = {'issue': ('https://github.com/UW-Hydro/MetSim/issues/%s', 'GH'),
45+
'pull': ('https://github.com/UW-Hydro/MetSim/pull/%s', 'PR'),
46+
}
47+
4248
napoleon_google_docstring = False
4349
napoleon_use_param = False
4450
napoleon_use_ivar = True

docs/configuration.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ current implementation only supports ``mtclim``.
5757
``out_precision :: str``: Precision to use when writing output. Defaults to
5858
``f8``. Can be either ``f4`` or ``f8``.
5959

60-
``annual :: bool``: Whether to chunk up the timeseries into years for
60+
``time_grouper :: str``: Whether to chunk up the timeseries into pieces for
6161
processing. This option is useful to set for when you are limited on
62-
memory. Each year of output is written as ``{out_prefix}_{year}`` when
63-
active.
62+
memory. Each chunk of output is written as ``{out_prefix}_{date_range}`` when
63+
active. Any valid ``pandas.TimeGrouper`` string may be used (e.g. use '10AS'
64+
for 10 year chunks).
6465

6566
``iter_dims :: list``: The dimensions of input data to iterate over to
6667
accumulate sites. Defaults to ``['lat', 'lon']``.
@@ -75,6 +76,11 @@ account when simulating incoming shortwave radiation. Defaults to ``0``.
7576
``mtclim_swe_corr :: bool``: Whether to activate MtClim's SWE correction
7677
algorithm. Default to ``False``.
7778

79+
``utc_offset :: bool``: Whether to use UTC timecode offsets for shifting
80+
timeseries. Without this option all times should be considered local to
81+
the gridcell being processed. Large domain runs probably want to set this
82+
option to ``True``.
83+
7884
``lw_cloud :: str``: Type of cloud correction to longwave radiation to apply.
7985
Can be either ``DEFAULT`` or ``CLOUD_DEARDORFF``. Defaults to
8086
``CLOUD_DEARDORFF``. Capitalization does not matter.
@@ -109,7 +115,7 @@ Defaults to ``0.45``, range should be between ``0`` and ``1``.
109115
``out_vars :: list`` : List of variables to write to output. Should be a list
110116
containing valid variables. The list of valid variables is dependent on which
111117
simulation method is used, as well as whether disaggregation is used. Defaults
112-
to ``['temp', 'prec', 'shortwave', 'longwave', 'vapor_pressure', 'red_humid']``.
118+
to ``['temp', 'prec', 'shortwave', 'longwave', 'vapor_pressure', 'rel_humid']``.
113119
For more information about input and output variables see the :ref:`data` page.
114120

115121
forcing_vars and state_vars section
@@ -126,7 +132,7 @@ netcdf and data
126132
The ``in_vars`` section for NetCDF and xarray input acts as a mapping between the variable
127133
names in the input dataset to the variable names expected by MetSim. The format
128134
is given as ``netcdf_varname = metsim_varname``. The minimum required variables
129-
given have ``metsim_varname``s corresponding to ``t_min``, ``t_max``, and
135+
given have ``metsim_varname``\s corresponding to ``t_min``, ``t_max``, and
130136
``prec``; these variable names correspond to minimum daily temperature (Celcius),
131137
maximum daily temperature (Celcius), and precipitation (mm/day).
132138

@@ -148,7 +154,7 @@ input style. Each line is specified as ``varname = scale cdatatype``, where
148154
floating point scaling factor that should be applied after conversion from
149155
binary to floating point; the conversion applied by the ``scale`` is applied
150156
after the value in the input is converted from binary to the ``cdatatype``
151-
specified for each variable. Valid ``cdatatype``s are ``signed`` and
157+
specified for each variable. Valid ``cdatatype``\s are ``signed`` and
152158
``unsigned``. ``signed`` values are interpreted as values which can be positive
153159
or negative, whereas ``unsigned`` values are interpreted as values that can only
154160
be greater than or equal to zero.
@@ -159,6 +165,6 @@ The ``domain_vars`` section is where information about the domain file is given.
159165
Since the domain file is given as a NetCDF file this section has a similar
160166
format to that of the NetCDF input file format described above. That is,
161167
entries should be of the form ``netcdf_varname = metsim_varname``. The minimum
162-
required variables have ``metsim_varname``s corresponding to ``lat``, ``lon``,
168+
required variables have ``metsim_varname``\s corresponding to ``lat``, ``lon``,
163169
``mask``, and ``elev``; these variable names correspond to latitude, longitude,
164170
a mask of valid cells in the domain, and the elevation given in meters.

docs/data.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,26 @@ Second, is the ``elev`` variable. This provides elevation data used for
3535
calculation of solar geometry. It should be specified in meters, and only needs
3636
to be given at sites which are marked to be processed via the ``mask`` variable.
3737

38-
It is important to ensure that all valid locations in ``mask`` have data in
38+
It is important to ensure that all valid locations in ``mask`` have data in
3939
``elev``. Failure to ensure this will result in errors during runtime.
4040

4141
State file
4242
----------
4343
The state file provides information about the history of each of the grid cells
4444
to be processed. There are four required variables.
4545

46-
The first two are daily minimum and daily maximum temperatures for the 90 days
47-
preceeding the start date specified in the configuration file. They should be
48-
specified as ``t_min`` and ``t_max`` respectively. Similarly precipitation
49-
should be given as ``prec``. These variables are used to generate seasonal
46+
The first two are daily minimum and daily maximum temperatures for the 90 days
47+
preceeding the start date specified in the configuration file. They should be
48+
specified as ``t_min`` and ``t_max`` respectively. Similarly precipitation
49+
should be given as ``prec``. These variables are used to generate seasonal
5050
averages which are used in the calculation of shortwave and longwave radiation.
5151

52-
The final required variable is the initial snow water equivalent (SWE) for each
53-
grid cell. It should be named ``swe`` in the file.
54-
5552
Output Specifications
5653
=====================
5754
.. ATTENTION::
58-
The ``time`` coordinate in MetSim's output is local to the location of each
59-
cell! This means that for a single time slice in the NetCDF file all locations
60-
along a parallel (same latitude) will have the same solar geometry at that time.
55+
The ``time`` coordinate in MetSim's output is local to the location of each cell unless the ``utc_offset`` is set to
56+
``True``! This means that for a single time slice in the NetCDF file all locations along a parallel (same latitude)
57+
will have the same solar geometry at that time.
6158

6259
The output variables that are available are dependent on the time step being used. There are two cases:
6360

@@ -71,11 +68,11 @@ step:
7168
* ``t_min`` : Minimum temperature (also a required input value) (C)
7269
* ``t_max`` : Maximum temperature (also a required input value) (C)
7370
* ``prec`` : Precipitation (also a required input value) (mm/day)
74-
* ``swe`` : Snow water equivalent (mm)
7571
* ``vapor_pressure`` : Vapor pressure (kPa)
7672
* ``shortwave`` : Shortwave radiation (W/m^2)
7773
* ``tskc`` : Cloud cover fraction
7874
* ``pet`` : Potential evapotranpiration (mm/day)
75+
* ``wind`` : Wind speed (only if given as an input) (m/s)
7976

8077
Sub-daily Output
8178
----------------

docs/index.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ VIC_ hydrologic model.
1616
.. _MtClim: http://www.ntsg.umt.edu/project/mtclim
1717
.. _VIC: https://github.com/UW-Hydro/VIC
1818

19-
MetSim consists of 3 main modules that govern the operation of 3
19+
MetSim consists of 3 main modules that govern the operation of 3
2020
major aspects of its operation:
2121

2222
**1. Management of dataset preprocessing and IO**
2323

2424
The MetSim object provides high level support for setting up jobs
2525
and infrastructure for running simulation/disaggregation
2626
steps. It is the main interface through which the other modules
27-
are accessed.
27+
are accessed.
2828

2929
**2. Simulation of meteorological forcings**
3030

3131
The base implementation of the meteorological simulator is
3232
based off of the algorithms described in [1]_. This component
33-
has been designed to be flexible in allowing for alternative
33+
has been designed to be flexible in allowing for alternative
3434
implementations which may be specified during the setup of the
35-
MetSim object. The default implementation allows for the
35+
MetSim object. The default implementation allows for the
3636
daily simulation of:
3737

3838
* Mean daily temperature
@@ -46,11 +46,11 @@ daily simulation of:
4646

4747
Daily data from given input or simulated via the forcings generation
4848
component of MetSim can be disaggregated down to sub-daily values at
49-
intervals specified in minutes (provided they divide evenly into 24
49+
intervals specified in minutes (provided they divide evenly into 24
5050
hours). The operation of these algorithms is also described in [1]_.
5151

5252
This documentation is a work in progress.
53-
If you don't find what you're looking for here, check out MetSim's Github page.
53+
If you don't find what you're looking for here, check out MetSim's Github page.
5454

5555
Getting Started
5656
===============
@@ -64,7 +64,7 @@ ensure that you have all of the required dependencies:
6464
- `xarray <http://xarray.pydata.org/>`__ (0.9.1 or later)
6565
- `pandas <http://pandas.pydata.org/>`__ (0.19.0 or later)
6666
- `numba <http://numba.pydata.org/>`__ (0.31.0 or later)
67-
- `netCDF4 <https://github.com/Unidata/netcdf4-python>`__
67+
- `netCDF4 <https://github.com/Unidata/netcdf4-python>`__
6868
- `scipy <http://scipy.org/>`__
6969

7070

@@ -86,18 +86,18 @@ Finally, you can install MetSim directly from the source if you desire to::
8686

8787
Basic Usage
8888
-----------
89-
MetSim provides a simple command line interface which is primarily operated via
89+
MetSim provides a simple command line interface which is primarily operated via
9090
configuration files. For more information about the options available to be set
9191
in the configuration files see the :ref:`configuration` page.
9292

9393
Once installed, MetSim can be used from the command line via:
9494

9595
``ms /path/to/configuration [-v] [-n #]``
9696

97-
Bracketed flags are optional; ``-v`` activates verbose mode to print messages
98-
about the status of a run, and ``-n`` activates parallelism. The number given
97+
Bracketed flags are optional; ``-v`` activates verbose mode to print messages
98+
about the status of a run, and ``-n`` activates parallelism. The number given
9999
after the ``-n`` flag is the number of processes to run. A good rule of thumb is
100-
to use one less process than the number of processsors (or threads) that the
100+
to use one less process than the number of processsors (or threads) that the
101101
machine you are running on has.
102102

103103
References
@@ -139,3 +139,4 @@ Sitemap
139139
data
140140
configuration
141141
api
142+
whats-new

docs/release-proceedure.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Making a new release of Metsim is easy. Just follow the following steps:
2+
3+
Release per project:
4+
5+
* Update release notes in docs/whats-new.rst
6+
7+
* Tag commit
8+
9+
git tag -a x.x.x -m 'Version x.x.x'
10+
11+
* and push to github
12+
13+
git push upstream master --tags
14+
15+
* Upload to PyPI
16+
17+
git clean -xfd
18+
python setup.py sdist bdist_wheel --universal
19+
twine upload dist/*
20+
21+
* Update conda recipe feedstocks on `conda-forge <https://conda-forge.github.io/>`_.
22+
23+
* Update conda-smithy and run conda-smithy rerender
24+
25+
git clone [email protected]:conda-forge/metsim-feedstock
26+
cd metsim-feedstock
27+
conda install conda-smithy
28+
conda-smithy rerender
29+
30+
* Get sha256 hash from pypi.org
31+
* Update version number and hash in recipe
32+
* Check dependencies

docs/whats-new.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. currentmodule:: MetSim
2+
3+
What's New
4+
==========
5+
6+
.. _whats-new.1.1.0:
7+
8+
v1.1.0 (unreleased)
9+
-------------------
10+
11+
Enhancements
12+
~~~~~~~~~~~~
13+
14+
- Added option to use forcing start/stop dates to define run length (:issue:`93`).
15+
By `Joe Hamman <https://github.com/jhamman>`_.
16+
- Added option a flexible time grouper when chunking MetSim runs (:issue:`93`).
17+
By `Joe Hamman <https://github.com/jhamman>`_.
18+
- Improved configuration validation by checking for correctness of output variables (:issue:`96`)
19+
By `Andrew Bennett <https://github.com/arbennett>`
20+
- Added option to skip reading ``swe`` variable from state file if it is not
21+
going to be used by MtClim. (:issue:`103`). By `Joe Hamman <https://github.com/jhamman>`_.
22+
- Added support for supplying a glob-like file path or multiple input forcing
23+
files (netCDF) (:issue:`126`). By `Joe Hamman <https://github.com/jhamman>`_.
24+
- Refactored ``mtclim`` and ``disaggregate`` functions to reduce interdependency and
25+
increase modularity. By `Andrew Bennett <https://github.com/arbennett>`_.
26+
- Removed ``swe`` calculations. By `Andrew Bennett <https://github.com/arbennett>`_.
27+
28+
Bug fixes
29+
~~~~~~~~~
30+
- Fixed bug where output files were not written with the appropriate calendar
31+
encoding attribute (:issue:`97`).
32+
By `Joe Hamman <https://github.com/jhamman>`_.
33+
- Fixed a bug where invalid timesteps were used in subdaily disaggregation.
34+
Added a clear error message explaining that subdaily timesteps must be evenly
35+
divisible into 24 hours and less than 6 hours in length. (:issue:`110`).
36+
By `Joe Hamman <https://github.com/jhamman>`_.
37+
- Fixed a bug during disaggregation when ``t_min > t_max``. This now raises
38+
an exception.
39+
By `Andrew Bennett <https://github.com/arbennett>`_.

0 commit comments

Comments
 (0)