Skip to content

Commit

Permalink
Merge branch 'main' into demand
Browse files Browse the repository at this point in the history
  • Loading branch information
hboisgon committed Oct 15, 2024
2 parents 021f0f5 + b953441 commit 78a602e
Show file tree
Hide file tree
Showing 34 changed files with 500 additions and 258 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ jobs:
export PATH=/usr/share/miniconda3/bin:$PATH
mamba env update -n hydromt_wflow -f environment.yml
- name: Install HydroMT-core dev
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
mamba run -n hydromt_wflow python -m pip install git+https://github.com/Deltares/hydromt.git@main --user
# - name: Install HydroMT-core dev
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# mamba run -n hydromt_wflow python -m pip install git+https://github.com/Deltares/hydromt.git@main --user

- name: Generate dummy docs
if: ${{ github.event_name == 'pull_request' }}
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/test_conda_forge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test conda forge release

on:
schedule:
# At 00:00 UTC every Monday
- cron: "0 0 * * 1"
# on demand
workflow_dispatch:

jobs:
Test:
defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest" ] #, "macos-latest", "windows-latest"]
python-version: ['3.11']
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/hydromt_wflow

name: ${{ matrix.label }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ matrix.python-version }}-${{ github.ref }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
activate-environment: hydromt-wflow

- name: Install hydromt_wflow
run: mamba install -c conda-forge hydromt_wflow

- name: Install test dependencies
run: |
mamba install -c conda-forge pytest pytest-cov pytest-mock pytest-timeout
pip install gwwapi
- name: Conda info
run: |
conda info
conda list
- name: Run model build Tests
run: python -m pytest --verbose tests/test_model_class.py::test_model_build
148 changes: 74 additions & 74 deletions .github/workflows/test_dev.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
name: Test dev
# name: Test dev

on:
schedule:
- cron: 0 0 * * * # run on main everyday at 00:00
push:
branches: [ main ]
pull_request:
branches: [ main ]
# on:
# schedule:
# - cron: 0 0 * * * # run on main everyday at 00:00
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]

jobs:
Test:
defaults:
run:
shell: bash -l {0}
# jobs:
# Test:
# defaults:
# run:
# shell: bash -l {0}

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest" ] #, "macos-latest", "windows-latest"]
python-version: ['3.10', '3.11']
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/hydromt_wflow
# strategy:
# fail-fast: false
# matrix:
# os: ["ubuntu-latest" ] #, "macos-latest", "windows-latest"]
# python-version: ['3.10', '3.11']
# include:
# - os: ubuntu-latest
# label: linux-64
# prefix: /usr/share/miniconda3/envs/hydromt_wflow

name: ${{ matrix.label }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ matrix.python-version }}-${{ github.ref }}
cancel-in-progress: true
# name: ${{ matrix.label }} - py${{ matrix.python-version }}
# runs-on: ${{ matrix.os }}
# concurrency:
# group: ${{ github.workflow }}-${{ matrix.python-version }}-${{ github.ref }}
# cancel-in-progress: true

steps:
- name: Checkout source
uses: actions/checkout@v3
# steps:
# - name: Checkout source
# uses: actions/checkout@v3

- name: Generate env yaml
run: |
pip install tomli
python make_env.py test -p ${{ matrix.python-version}}.* -n hydromt_wflow
# - name: Generate env yaml
# run: |
# pip install tomli
# python make_env.py test -p ${{ matrix.python-version}}.* -n hydromt_wflow

- name: Load cache
id: cache
uses: actions/cache/restore@v3
with:
path: |
/usr/share/miniconda3
~/pycache
# the below two settings mean we'll alway srestore the cache
# but the cache hit output can tell us if we have to update afterwards
key: test-py${{ matrix.python-version }}-${{ hashFiles('environment.yml') }}
restore-keys: |
test-py${{ matrix.python-version }}
# - name: Load cache
# id: cache
# uses: actions/cache/restore@v3
# with:
# path: |
# /usr/share/miniconda3
# ~/pycache
# # the below two settings mean we'll alway srestore the cache
# # but the cache hit output can tell us if we have to update afterwards
# key: test-py${{ matrix.python-version }}-${{ hashFiles('environment.yml') }}
# restore-keys: |
# test-py${{ matrix.python-version }}

- name: Failed cache restore
if: steps.cache.outputs.cache-matched-key == ''
run: |
echo "Failed to restore any cache. exiting..."
exit 1
# - name: Failed cache restore
# if: steps.cache.outputs.cache-matched-key == ''
# run: |
# echo "Failed to restore any cache. exiting..."
# exit 1

# by avoiding the mamba setup stage by loading it from cache instead we save
# a lot of setup time, but we do have to do our own PATH management
# hence the exports
- name: Update environment
if: steps.cache.outputs.cache-hit != 'true'
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
mamba env update -n hydromt_wflow -f environment.yml
# # by avoiding the mamba setup stage by loading it from cache instead we save
# # a lot of setup time, but we do have to do our own PATH management
# # hence the exports
# - name: Update environment
# if: steps.cache.outputs.cache-hit != 'true'
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# mamba env update -n hydromt_wflow -f environment.yml

- name: Install HydroMT-core dev
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
mamba run -n hydromt_wflow python -m pip install git+https://github.com/Deltares/hydromt.git@main --user
# - name: Install HydroMT-core dev
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# mamba run -n hydromt_wflow python -m pip install git+https://github.com/Deltares/hydromt.git@main --user

- name: Conda info
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
conda info
conda list -n hydromt_wflow
# - name: Conda info
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# conda info
# conda list -n hydromt_wflow

- name: Run tests
run: |
export PATH=/usr/share/miniconda3/bin:$PATH
PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt_wflow python -m pytest --verbose --cov=hydromt_wflow --cov-report xml
# - name: Run tests
# run: |
# export PATH=/usr/share/miniconda3/bin:$PATH
# PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt_wflow python -m pytest --verbose --cov=hydromt_wflow --cov-report xml

- name: Upload code coverage
uses: codecov/codecov-action@v3
# - name: Upload code coverage
# uses: codecov/codecov-action@v3
35 changes: 33 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,42 @@ The format is based on `Keep a Changelog`_, and this project adheres to

Unreleased
==========
All the unreleased new features and bug fixes.

Added
-----
- To be Added
-

Changed
-------
-

Fixed
-----
- Error in computation of LAI values from mapping to landuse in **setup_laimaps**. PR #297
- IO error for write_states in write. PR #297
- Creating the staticgeoms folder if it does not already exist (eg when dir_input is provided). PR #297

v0.6.1 (16 September 2024)
==========================
This release mainly contains small bugfixes and limits xarray version to 2024.03.0

Added
-----
- Added "fillna_method" option for **setup_temp_pet_forcing** by @tnlim
- Output filenames can now be specified in the model.write function. More detailed arguments should still be specified in each individual write* methods. PR #286

Changed
-------
- Individual methods like write_forcing will not longer write the config file if config settings get updated. Always call write_config as the last write method. PR #286
- More uniform handling of the date typing when reading/writing dates from the wflow toml files. PR #286

Fixed
-----
- Wrong dtype for columns when reading a mapping table in **setup_laimaps_from_lulc_mapping** . PR #290
- Read/write staticgeoms if dir_input folder is present in the wflow toml file. PR #286
- Creating subfolders for the config file of wflow in **write_config**. PR #286
- Fixed access to functions in the **pcrm** module (read_staticmaps_pcr, write_staticmaps_pcr). PR #293
- Bug in **setup_pet_forcing** when doing time resampling. PR #294

v0.6.0 (7 June 2024)
====================
Expand Down
24 changes: 14 additions & 10 deletions docs/getting_started/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Building a Wflow model
To build a Wflow model, it is strongly recommended to use the ``basin`` or ``subbasin`` when defining your region of interest.
This ensures that all upstream contributing cells are well taken into account. Using other options might cause your Wflow model
run crash. If you are sure of what you are doing, you can optionnaly use the ``geom`` option and provide an exact shapefile of the
run crash. If you are sure of what you are doing, you can optionally use the ``geom`` option and provide an exact shapefile of the
basin/subbasins you want to derive, that was prepared using the same DEM source that you intend to use in the :py:func:`~WflowModel.setup_basemaps`
method.

| **Q**: Can I derive several sub-basins at the same time using a bounding box or a geometry instead of a list of point corrdinates?
| **Q**: Can I derive several sub-basins at the same time using a bounding box or a geometry instead of a list of point coordinates?
To derive subbasin with HydroMT, you also need to provide in your region options a snapping arguments so that HydroMT knows what type of
subbasin you want to create. You can use either streamorder *strord* or upstream area *uparea* type of snapping:
Expand All @@ -40,14 +40,13 @@ will do its resampling magic!
Sure! HydroMT allows you to use several times the same method in your configuration file. For this, you just need to start
enumerating the methods by adding a number to the end of the method name. For example:

.. code-block:: console
.. code-block:: yaml
[setup_gauges]
gauges_fn = my_gauges1
setup_gauges:
gauges_fn: my_gauges1
[setup_gauges2]
gauges_fn = my_gauges2
derive_outlets = False # To avoid deriving basin outlets twice
setup_gauges2:
gauges_fn: my_gauges2
Updating a Wflow model
----------------------
Expand All @@ -60,15 +59,20 @@ your new "local" input data!

| **Q**: Can I select a specific Wflow TOML config file when updating my model ?
It is possible. In that case, you need to start your HydroMT configuration with a :py:func:`~WflowModel.read_config` method
It is possible. In that case, you need to start your HydroMT configuration with a `global` section
where you can specify which TOML file to use using the *config_fn* argument.

.. code-block:: yaml
global:
config_fn: path/to/my_wflow_config.toml
Others
------

| **Q**: Can I convert my old Wflow python model to the new Wflow Julia version with HydroMT ?
HydroMT is still able to read the python PCRaster based maps of Wflow with the method :py:func:`~WflowModel.read_staticmaps_pcr`.
HydroMT is still able to read the python PCRaster based maps of Wflow with the method :py:func:`~pcrm.read_staticmaps_pcr`.
So actually just a read and write of your python model will do most of the job :) The intbl are however not taken into account so if
you have single values intbl, you can use the :py:func:`~WflowModel.setup_constant_pars` method. For lakes and reservoirs parameters,
the best is to use a shapefile of yours lakes and reservoirs with the right columns for each parameters (see previous question on updating
Expand Down
Loading

0 comments on commit 78a602e

Please sign in to comment.