TopoPyScale
TopoPyScale: A Python Package for Hillslope Climate Downscaling - Published in JOSS (2023)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 10 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
1 of 10 committers (10.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
TopoPyScale: a Python library to perform simplistic climate downscaling at the hillslope scale
Basic Info
- Host: GitHub
- Owner: ArcticSnow
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://topopyscale.readthedocs.io
- Size: 14.9 MB
Statistics
- Stars: 50
- Watchers: 4
- Forks: 16
- Open Issues: 24
- Releases: 18
Topics
Metadata Files
README.md
TopoPyScale
Python version of Toposcale packaged as a Pypi library. Toposcale is an original idea of Joel Fiddes to perform topography-based downscaling of climate data to the hillslope scale.
Documentation avalaible: https://topopyscale.readthedocs.io

References:
- Filhol et al., (2023). TopoPyScale: A Python Package for Hillslope Climate Downscaling. Journal of Open Source Software, 8(86), 5059, https://doi.org/10.21105/joss.05059
And the original method it relies on: - Fiddes, J. and Gruber, S.: TopoSCALE v.1.0: downscaling gridded climate data in complex terrain, Geosci. Model Dev., 7, 387–405, https://doi.org/10.5194/gmd-7-387-2014, 2014. - Fiddes, J. and Gruber, S.: TopoSUB: a tool for efficient large area numerical modelling in complex topography at sub-grid scales, Geosci. Model Dev., 5, 1245–1257, https://doi.org/10.5194/gmd-5-1245-2012, 2012.
Kristoffer Aalstad has a Matlab implementation: https://github.com/krisaalstad/TopoLAB
Contribution Workflow
- All contribution welcome!
- Found a bug -> Check the issue page. If you have a solution let us know.
- No idea on moving furhter -> then create a new issue
- Wanna develop a new feature/idea? -> create a new branch. Go wild. Merge with main branch when accomplished.
- Create release version when significant improvements and bug fixes have been done. Coordinate with others on Discussions
Create a new release: Follow procedure and conventions described in: https://www.youtube.com/watch?v=Ob9llA_QhQY
Our forum is now on Github Discussions. Come visit!
Design
- Inputs
- Climate data from reanalysis (ERA5, etc)
- Climate data from future projections (CORDEX) (TBD)
- DEM from local source, or fetch from public repository: SRTM, ArcticDEM, ASTER
- Run TopoScale
- compute derived values (from DEM)
- toposcale (k-mean clustering)
- interpolation (bilinear, inverse square dist.)
- Output
- Cryogrid format
- FSM format
- CROCUS format
- Snowmodel format
- basic netcfd
- For each method, have the choice to output either the abstract cluster points, or the gridded product after interpolation
- Validation toolset
- validation to local observation timeseries
- plotting
- Gap filling algorithm
- random forest temporal gap filling (TBD)
Validation (4) and Gap filling (4) are future implementation.
Installation
We have now added an environments.yml file to handle versions of depencencies that are tested with the current codebase, to use this run:
conda env create -f environment.yml
Alternatively you can follow this method for dependencies (to be deprecated):
```bash conda create -n downscaling python ipython conda activate downscaling
Recomended way to install dependencies:
conda install -c conda-forge xarray matplotlib scikit-learn pandas numpy netcdf4 h5netcdf rasterio pyproj dask rioxarray
install forked version of Topocalc compatible with Python >3.9 (tested with 3.13)
pip install pip@git+https://github.com/ArcticSnow/topocalc ```
Then install the code:
```
OPTION 1 (Pypi release):
pip install TopoPyScale
OPTION 2 (development):
cd github # navigate to where you want to clone TopoPyScale git clone git@github.com:ArcticSnow/TopoPyScale.git pip install -e TopoPyScale #install a development version
----------------------------------------------------------
OPTIONAL: if using jupyter lab
add this new Python kernel to your jupyter lab PATH
python -m ipykernel install --user --name downscaling
Tool for generating documentation from code docstring
pip install lazydocs ```
Then you need to setup your cdsapi with the Copernicus API key system. Follow this tutorial after creating an account with Copernicus. On Linux, create a file nano ~/.cdsapirc with inside:
url: https://cds.climate.copernicus.eu/api/v2
key: {uid}:{api-key}
Basic usage
- Setup your Python environment
- Create your project directory
- Configure the file
config.inito fit your problem (seeconfig.ymlfor an example) - Run TopoPyScale
```python import pandas as pd from TopoPyScale import topoclass as tc from matplotlib import pyplot as plt
========= STEP 1 ==========
Load Configuration
configfile = './config.yml' mp = tc.Topoclass(configfile)
Compute parameters of the DEM (slope, aspect, sky view factor)
mp.getera5() mp.computedem_param()
========== STEP 2 ===========
Extract DEM parameters for points of interest (centroids or physical points)
mp.extracttopoparam()
----- Option 1:
Compute clustering of the input DEM and extract cluster centroids
mp.extractdemcluster_param()
plot clusters
mp.toposub.plotclustersmap()
plot sky view factor
mp.toposub.plotclustersmap(var='svf', cmap=plt.cm.viridis)
------ Option 2:
inidicate in the config file the .csv file containing a list of point coordinates (!!! must same coordinate system as DEM !!!)
mp.extractptsparam(method='linear',index_col=0)
========= STEP 3 ==========
compute solar geometry and horizon angles
mp.computesolargeometry() mp.compute_horizon()
========= STEP 4 ==========
Perform the downscaling
mp.downscale_climate()
========= STEP 5 ==========
explore the downscaled dataset. For instance the temperature difference between each point and the first one
(mp.downscaledpts.t-mp.downscaledpts.t.isel(point_id=0)).plot() plt.show()
========= STEP 6 ==========
Export output to desired format
mp.to_netcdf() ```
TopoClass will create a file structure in the project folder (see below). TopoPyScale assumes you have a DEM in GeoTiFF, and a set of climate data in netcdf (following ERA5 variable conventions).
TopoPyScale can easier segment the DEM using clustering (e.g. K-mean), or a list of predefined point coordinates in pts_list.csv can be provided. Make sure all parameters in config.ini are correct.
my_project/
├── inputs/
├── dem/
├── my_dem.tif
└── pts_list.csv (optional)
└── climate/
├── PLEV*.nc
└── SURF*.nc
├── outputs/
└── config.ini
Owner
- Name: Simon Filhol
- Login: ArcticSnow
- Kind: user
- Location: Norway
- Company: University of Oslo
- Repositories: 33
- Profile: https://github.com/ArcticSnow
JOSS Publication
TopoPyScale: A Python Package for Hillslope Climate Downscaling
Authors
Tags
climate science downscaling xarray dem segmentation snow permafrostGitHub Events
Total
- Create event: 2
- Commit comment event: 4
- Release event: 3
- Issues event: 17
- Watch event: 6
- Delete event: 3
- Issue comment event: 39
- Member event: 1
- Push event: 62
- Pull request event: 4
- Fork event: 6
Last Year
- Create event: 2
- Commit comment event: 4
- Release event: 3
- Issues event: 17
- Watch event: 6
- Delete event: 3
- Issue comment event: 39
- Member event: 1
- Push event: 62
- Pull request event: 4
- Fork event: 6
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| arcticsnow | s****l@p****m | 441 |
| Joel Fiddes | j****s@g****m | 127 |
| paswyss | p****s@p****m | 26 |
| FILHOL Simon | s****l@m****r | 6 |
| Nilick | 6****K | 3 |
| Kristoffer Aalstad | k****d@g****m | 1 |
| Hugo Ledoux | h****x@t****l | 1 |
| Esteban Alonso | e****l@g****m | 1 |
| Marco Mazzolini | m****z@n****3 | 1 |
| Joel Fiddes | j****l@j****e | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 87
- Total pull requests: 23
- Average time to close issues: 7 months
- Average time to close pull requests: about 7 hours
- Total issue authors: 10
- Total pull request authors: 6
- Average comments per issue: 2.44
- Average comments per pull request: 0.61
- Merged pull requests: 22
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 9
- Pull requests: 6
- Average time to close issues: about 2 months
- Average time to close pull requests: about 21 hours
- Issue authors: 5
- Pull request authors: 3
- Average comments per issue: 3.0
- Average comments per pull request: 1.17
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- ArcticSnow (53)
- joelfiddes (20)
- paswyss (4)
- NILICK (3)
- MatteaE (2)
- Giulia-cima (1)
- srinivas2036 (1)
- dvalters (1)
- mvantiggelen (1)
- bare92 (1)
Pull Request Authors
- ArcticSnow (12)
- joelfiddes (4)
- NILICK (3)
- mmazzolini (2)
- ealonsogzl (1)
- paswyss (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 266 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 51
- Total maintainers: 1
proxy.golang.org: github.com/ArcticSnow/TopoPyScale
- Documentation: https://pkg.go.dev/github.com/ArcticSnow/TopoPyScale#section-documentation
- License: mit
-
Latest release: v0.3.0
published 4 months ago
Rankings
proxy.golang.org: github.com/arcticsnow/topopyscale
- Documentation: https://pkg.go.dev/github.com/arcticsnow/topopyscale#section-documentation
- License: mit
-
Latest release: v0.3.0
published 4 months ago
Rankings
pypi.org: topopyscale
TopoPyScale, a Python package to perform simplistic climate downscaling at the hillslope scale.
- Homepage: https://topopyscale.readthedocs.io
- Documentation: https://topopyscale.readthedocs.io/en/latest/
- License: mit
-
Latest release: 0.3.1
published 4 months ago
Rankings
Maintainers (1)
Dependencies
- cdsapi *
- configobj *
- dask *
- matplotlib *
- munch *
- numpy *
- pandas *
- pvlib *
- pyproj *
- rasterio *
- scikit-learn *
- topocalc *
- xarray *
- actions/checkout v2 composite
- actions/upload-artifact v1 composite
- openjournals/openjournals-draft-action master composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- cdsapi ==0.6.1
- gitpython ==3.1.31
- munch ==2.5.0
- numba ==0.57.0
- numpy ==1.24.2
- pvlib ==0.9.5
- pyModis ==2.3.0
- pydap ==3.4.0
- requests ==2.30.0
- scipy ==1.10.1
- seaborn ==0.12.2
- topocalc ==0.5.0
