Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module for computing river flood footprints from GloFAS river dis…
…charge data (#64) * Add util functions for downloading GloFAS data Use cdsapi to download GloFAS data from Copernicus Data Store. So far, the actual download is not tested. * Add util functions for downloading data. * Add unit tests for request handling. * Add 'cdsapi' to requirements * Allow `date_to=None` to download only a single file * [draft] Add class for processing GloFAS river flood * Working on glofas flood stuff [revise!] * Add tests for dantro operations * Update operations to fix issues found when writing the tests. * Add unit test case for dantro operations. * Tweak CDS GloFAS downloader. * Add dantro to requirements * Update GloFAS river flood pipeline * Add option to set countries instead of lat/lon limits when downloading GloFAS data. * Return pandas Series of Hazards with multi index. * Use discharge dataset for lat/lon slicing of all other datasets. * Add unit tests. * Make CDS Downloader support skipping downloads Downloads will be skipped if the target file exists with the same request dict. * Place the request as YAML file next to the target file for request comparison. * Add option to control using the "cached" results or always downloading the data. * Update unit tests. * Explicitly list ruamel.yaml as requirement (already required by dantro). * Fix an issue where ruamel.yaml could not dump numbers * Add 'max_from_isel' operation NOTE: Commented code would be an alternative to define the select dimension based on values instead of indices. * Add operation * Add test case for operation * Handle NaNs in flood depth interpolation * Update unit tests accordingly. * Add core dimension checks to flood depth unit tests. * Add routines for computing default files for GloFAS flood module * Add operations and config for computing the GEV fits and merging flood maps, which are both used for computing a flood footprint. * Update affected operations and configs. * Remove GloFASRiverFlood class in favor of two functions. * Update tests * Overhaul GloFAS flood pipeline * Move respective files into their own subdirectory. * Adapt configuration files to latest dantro version. * Add 'transform_ops.py' containing only dantro transformations. * Expose user functions via dedicated __init__.py * Add option to run tasks in parallel * Rename 'test_glofas_rf.py' to 'rest_rf_glofas.py' * Rename 'rf_glofas_util.yml' to 'setup.yml' and expose dantro_transform function * Add rioxarray as dependency Used for reading GeoTIFF with xarray. * Update test_rf_glofas.py imports to new module structure * Rework user experience of rf_glofas module and write full documentation * Fix formatting in glofas_rf docs * Fix type hints and data manager container type * Add operation for including FLOPROS database * Add tutorial for GloFAS river flood module * WIP: Add bootstrap resampling to return period computation * Fix glofas_rf unit tests, formatting, and docstrings * Fix return period sampling and update tests * Add tests for 'save_file' and 'finalize' * Fix return period resampling Actually do the resampling instead of resampling once and copying the new value. Update tests accordingly. * Add module docstrings and fix linter warnings in rf_glofas * Improve docstrings and try to please linter * Add links to ETH research collection datasets * Update env_docs.yml * Fix env_docs.yml * Fix order in doc toctree * Upgrade matplotlib in doc environment * Revert "Upgrade matplotlib in doc environment" This reverts commit 94c210f. * Mock dantro when building docs * Comply to latest climada_python/develop * readthedocs: add glofas to tutorials section of the navigation bar * jenkinsfile: install new dependencies on the fly * fix error in jenkins file * Add xesmf regrid operation * Add 'xesmf' to requirements * Fix bug in test file * Add new requirements to Jenkinsfile * Mock modules when building docs to make the automated build succeed * Fix typos in linter instructions * Only use pip to install missing dependencies * Fix pip install in Jenkinsfile * conda-env: install xesmf * Try 'pip install --upgrade' in Jenkinsfile * Do not upgrade to matplotlib 3.6 in Jenkinsfile * Fix an issue where the GeoDataFrame loader is not available * Fix an issue where infinite return periods would lead to NaN flood depths * rf_glofas: try to circumvent "ImportError: The ESMFMKFILE environment variable is not available." * rf_glofas: try to circumvent "ImportError: The ESMFMKFILE environment variable is not available.", bis * Apply suggestions from code review Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Improve performance of inundation computation * Vectorize computations of return period and inundation. * Define maximum return period to avoid inf. * Return Hazard instead of RiverFlood instances. * Working on new version without dantro * Make parallelization of 'setup_gumbel_fit' external * Fix bug in calling 'download_glofas_discharge' * Make sure netcdf4 engine is used to store data * Various changes * Improve file opening and closing with custom context manager. * Set new default data directory. * Add option to download reanalysis. * Improve compute algorithm and add docstrings * Do not store everything, avoid zlib * Update transform operations tests * Remove unused 'finalize' function * Remove dantro pipeline config files * Remove dantro-related functions and classes * Rework tutorial, docstrings, improve usability * Rework tutorial, docstrings, improve usability * Remove pipeline config files for tutorial * Add 'xesmf' to conda environment specs * Update requirement handling in Jenkinsfile * RiverFlood.__init__: re-merge from dev * RiverFlood.__init__: re-merge from dev * Add ruamel.yaml to requirements * Move CDS downloader into rf_glofas folder Adapt imports, tests, docs * Update docs and docstrings * Fix logger for river_flood_computation.py * Fix name for _RiverFloodCachePaths * Fix linter issues * Add tests for RiverFloodInundation * Add cdsapi as dependency * env_docs: include additional dependencies * Add rioxarray to requirements * Apply suggestions for test_preprocess Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Update climada_petals/hazard/rf_glofas/test/test_river_flood_computation.py Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Apply suggestions for cds_glofas_downloader.py Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Revert changes to river_flood.py * Remove import mocking in doc/conf.py * Update climada_petals/hazard/rf_glofas/test/test_rf_glofas.py Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Make sure tests operate on floats * Avoid division by zero in return period computation Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Improve testing of return_period_resample * Rename test_rf_glofas.py to test_transform_ops.py * Add tests for rf_glofas.py * Fix a bug where unit tests were not executed if called directly * Clean up temporary directories explicitly * Update climada_petals/hazard/rf_glofas/setup.py Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Update climada_petals/hazard/rf_glofas/transform_ops.py Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * Only use dimensions with time information for events * Render docs with 'myst_nb' * Add myst-nb parser to doc requirements * Mock xesmf in sphinx build Installing xesmf would require to reload the environment, which does not happen online. * Avoid squeezing of 'time' dimension when opening discharge data * Use hashed download paths for CDS data This avoids overwriting data downloaded for the same day (forecast) or year (reanalysis/historical). * Update tutorial * Apply suggestions from code review Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> * update glofas tutorial after code review * update glofas tutorial to make selection in multiindex more stable * fix pylint * Update docstrings --------- Co-authored-by: Lukas Riedel <lukas.riedel@meteoswiss.ch> Co-authored-by: emanuel-schmid <schmide@ethz.ch> Co-authored-by: Thomas Vogt <57705593+tovogt@users.noreply.github.com> Co-authored-by: Thomas Roosli <thomas.roeoesli@meteoswiss.ch>
- Loading branch information