Skip to content

Commit 6efb563

Browse files
arbennettJoe Hamman
authored andcommitted
Release/1.1.0 (#133)
* Prepare for version bump * Update to version 1.1 * Update whats-new.rst and remove unused parameters * Update data.rst * Update setup.py
1 parent 14fe2e0 commit 6efb563

File tree

9 files changed

+47
-36
lines changed

9 files changed

+47
-36
lines changed

docs/configuration.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ account when simulating incoming shortwave radiation. Defaults to ``0``.
7676
``mtclim_swe_corr :: bool``: Whether to activate MtClim's SWE correction
7777
algorithm. Default to ``False``.
7878

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+
7984
``lw_cloud :: str``: Type of cloud correction to longwave radiation to apply.
8085
Can be either ``DEFAULT`` or ``CLOUD_DEARDORFF``. Defaults to
8186
``CLOUD_DEARDORFF``. Capitalization does not matter.

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/examples.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ contents are:
5151
prec = prec
5252
t_max = t_max
5353
t_min = t_min
54-
swe = swe
5554
5655
[domain_vars]
5756
lat = lat

docs/whats-new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Enhancements
2121
going to be used by MtClim. (:issue:`103`). By `Joe Hamman <https://github.com/jhamman>`_.
2222
- Added support for supplying a glob-like file path or multiple input forcing
2323
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>`_.
2427

2528
Bug fixes
2629
~~~~~~~~~
@@ -31,3 +34,6 @@ Bug fixes
3134
Added a clear error message explaining that subdaily timesteps must be evenly
3235
divisible into 24 hours and less than 6 hours in length. (:issue:`110`).
3336
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>`_.

environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ dependencies:
99
- numba
1010
- numpy=1.11.2
1111
- scipy=0.18.1
12+
- dask
13+
- toolz
File renamed without changes.

metsim/disaggregate.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ def disaggregate(df_daily: pd.DataFrame, params: dict,
3838
3939
Parameters
4040
----------
41-
df_daily: pd.DataFrame
41+
df_daily:
4242
Dataframe containing daily timeseries.
4343
Should be the result of one of the methods
4444
provided in the `methods` directory.
45-
params: dict
45+
params:
4646
A dictionary containing the class parameters
4747
of the MetSim object.
48-
solar_geom: dict
48+
solar_geom:
4949
A dictionary of solar geometry variables
50-
t_begin: list
50+
t_begin:
5151
List of t_min and t_max for day previous to the
5252
start of `df_daily`. None indicates no extension
5353
of the record.
54-
t_end: list
54+
t_end:
5555
List of t_min and t_max for day after the end
5656
of `df_daily`. None indicates no extension of
5757
the record.
@@ -119,16 +119,19 @@ def set_min_max_hour(tiny_rad_fract: np.array, yday: np.array, n_days: int,
119119
120120
Parameters
121121
----------
122-
disagg_rad:
123-
Shortwave radiation disaggregated
124-
to sub-daily timesteps.
122+
tiny_rad_fract:
123+
Array of fraction of shortwave radiation received
124+
at a shortened timestep. This should be calculated
125+
by `metsim.physics.solar_geom`.
126+
yday:
127+
Array of day of year for each simulated day.
125128
n_days:
126-
The number of days being disaggregated
129+
Number of days in run.
127130
ts:
128-
Timestep used for disaggregation
131+
Timestep of run.
129132
params:
130-
A dictionary of class parameters of
131-
the MetSim object.
133+
Dictionary of parameters to use. Must contain
134+
`utc_offset` and `tmax_daylength_fraction`.
132135
133136
Returns
134137
-------
@@ -173,11 +176,12 @@ def temp(t_min: np.array, t_max: np.array, out_len: int,
173176
174177
Parameters
175178
----------
176-
TODO: FIXME
177-
df_daily:
178-
A dataframe of daily values.
179-
df_disagg:
180-
A dataframe of sub-daily values.
179+
t_min:
180+
Timeseries of daily minimum temperatures.
181+
t_max:
182+
Timeseries of daily maximum temperatures.
183+
out_len:
184+
Length of the required output vector.
181185
t_t_min:
182186
Times at which minimum daily
183187
temperatures are reached.
@@ -186,11 +190,11 @@ def temp(t_min: np.array, t_max: np.array, out_len: int,
186190
temperatures are reached.
187191
ts:
188192
Timestep for disaggregation
189-
t_begin: list
193+
t_begin:
190194
List of t_min and t_max for day previous to the
191195
start of `df_daily`. None indicates no extension
192196
of the record.
193-
t_end: list
197+
t_end:
194198
List of t_min and t_max for day after the end
195199
of `df_daily`. None indicates no extension of
196200
the record.

metsim/metsim.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ class MetSim(object):
128128
"lw_type": 'prata',
129129
"tdew_tol": 1e-6,
130130
"tmax_daylength_fraction": 0.67,
131-
"snow_crit_temp": -6.0,
132-
"snow_melt_rate": 0.042,
133131
"rain_scalar": 0.75,
134132
"tday_coef": 0.45,
135133
"lapse_rate": 0.0065,

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
cmdclass=versioneer.get_cmdclass(),
1010
description='Meteorology Simulator',
1111
url='https://github.com/UW-Hydro/MetSim',
12-
download_url='https://github.com/UW-Hydro/MetSim/archive/v1.0.tar.gz',
1312
author='Andrew Bennett',
1413
author_email='[email protected]',
1514
packages=['metsim', 'metsim.methods', 'metsim.cli'],
1615
entry_points={
1716
'console_scripts': ['ms = metsim.cli.ms:main']},
18-
install_requires=['xarray', 'numba'],
17+
install_requires=['xarray', 'numba', 'numpy', 'pandas',
18+
'dask', 'toolz', 'netCDF4', 'scipy'],
1919
keywords=['meteorology', 'disaggregation', 'hydrology',
2020
'climate', 'mtclim'],
2121
tests_require=['pytest'],)

0 commit comments

Comments
 (0)