TopoPyScale
Perform topography-based downscaling of climate data to the hillslope scale.
https://github.com/ArcticSnow/TopoPyScale
Category: Climate Change
Sub Category: Climate Downscaling
Keywords
climate climate-science clustering dem downscaling era5 geoscience joss science timeseries xarray
Keywords from Contributors
pointcloud point-cloud avalanche caaml international-classification pit snow
Last synced: about 9 hours ago
JSON representation
Repository metadata
TopoPyScale: a Python library to perform simplistic climate downscaling at the hillslope scale
- Host: GitHub
- URL: https://github.com/ArcticSnow/TopoPyScale
- Owner: ArcticSnow
- License: mit
- Created: 2021-09-28T11:13:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-18T16:39:19.000Z (8 days ago)
- Last Synced: 2025-04-22T07:03:23.417Z (5 days ago)
- Topics: climate, climate-science, clustering, dem, downscaling, era5, geoscience, joss, science, timeseries, xarray
- Language: Python
- Homepage: https://topopyscale.readthedocs.io
- Size: 14.1 MB
- Stars: 44
- Watchers: 4
- Forks: 12
- Open Issues: 34
- Releases: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
Please follow these simple rules:
- a bug -> fix it!
- an idea or a bug you cannot fix? -> create a new issue if none doesn't already exist. If one exist, then add material to it.
- 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):
conda create -n downscaling python=3.9 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
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 [email protected]: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.ini
to fit your problem (seeconfig.yml
for an example) - Run TopoPyScale
import pandas as pd
from TopoPyScale import topoclass as tc
from matplotlib import pyplot as plt
# ========= STEP 1 ==========
# Load Configuration
config_file = './config.yml'
mp = tc.Topoclass(config_file)
# Compute parameters of the DEM (slope, aspect, sky view factor)
mp.compute_dem_param()
# ========== STEP 2 ===========
# Extract DEM parameters for points of interest (centroids or physical points)
mp.extract_topo_param()
# ----- Option 1:
# Compute clustering of the input DEM and extract cluster centroids
#mp.extract_dem_cluster_param()
# plot clusters
#mp.toposub.plot_clusters_map()
# plot sky view factor
#mp.toposub.plot_clusters_map(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.extract_pts_param(method='linear',index_col=0)
# ========= STEP 3 ==========
# compute solar geometry and horizon angles
mp.compute_solar_geometry()
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.downscaled_pts.t-mp.downscaled_pts.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 metadata
- Name: Simon Filhol
- Login: ArcticSnow
- Email:
- Kind: user
- Description:
- Website:
- Location: Norway
- Twitter:
- Company: University of Oslo
- Icon url: https://avatars.githubusercontent.com/u/2042458?u=27230ceb61694b53dc31cf2a45c56e8a16eb9cc4&v=4
- Repositories: 33
- Last ynced at: 2024-04-21T11:08:17.792Z
- Profile URL: https://github.com/ArcticSnow
GitHub Events
Total
- Create event: 1
- Commit comment event: 1
- Release event: 1
- Issues event: 3
- Watch event: 3
- Issue comment event: 13
- Member event: 1
- Push event: 17
- Pull request event: 2
- Fork event: 2
Last Year
- Create event: 1
- Commit comment event: 1
- Release event: 1
- Issues event: 3
- Watch event: 3
- Issue comment event: 13
- Member event: 1
- Push event: 17
- Pull request event: 2
- Fork event: 2
Committers metadata
Last synced: 4 days ago
Total Commits: 575
Total Committers: 8
Avg Commits per committer: 71.875
Development Distribution Score (DDS): 0.287
Commits in past year: 51
Committers in past year: 3
Avg Commits per committer in past year: 17.0
Development Distribution Score (DDS) in past year: 0.51
Name | Commits | |
---|---|---|
arcticsnow | s****l@p****m | 410 |
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 |
Committer domains:
- tudelft.nl: 1
- meteo.fr: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 83
Total pull requests: 15
Average time to close issues: 3 months
Average time to close pull requests: about 4 hours
Total issue authors: 8
Total pull request authors: 6
Average comments per issue: 2.46
Average comments per pull request: 0.6
Merged pull request: 15
Bot issues: 0
Bot pull requests: 0
Past year issues: 5
Past year pull requests: 1
Past year average time to close issues: 3 months
Past year average time to close pull requests: about 17 hours
Past year issue authors: 4
Past year pull request authors: 1
Past year average comments per issue: 4.6
Past year average comments per pull request: 2.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- ArcticSnow (51)
- joelfiddes (19)
- paswyss (4)
- NILICK (4)
- MatteaE (2)
- srinivas2036 (1)
- dvalters (1)
- mvantiggelen (1)
Top Pull Request Authors
- ArcticSnow (7)
- NILICK (3)
- joelfiddes (2)
- ealonsogzl (1)
- paswyss (1)
- hugoledoux (1)
Top Issue Labels
- enhancement (39)
- topo_scale (16)
- bug (13)
- topoClass (7)
- debug (6)
- topo_sub (4)
- dem (4)
- fetch_data (4)
- good first issue (3)
- parallelize (3)
- new feature (2)
- documentation (2)
- meteo_util (2)
- abandoned (1)
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 296 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 11
- Total maintainers: 1
pypi.org: topopyscale
TopoPyScale: A Python Package for Hillslope Climate Downscaling
- Homepage: https://github.com/ArcticSnow/TopoPyScale
- Documentation: https://topopyscale.readthedocs.io/en/latest/
- Licenses: MIT
- Latest release: 0.2.6 (published 3 months ago)
- Last Synced: 2025-04-25T13:04:35.738Z (1 day ago)
- Versions: 11
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 296 Last month
- Docker Downloads: 0
-
Rankings:
- Dependent packages count: 6.633%
- Downloads: 13.693%
- Stargazers count: 14.904%
- Average: 17.079%
- Forks count: 19.553%
- Dependent repos count: 30.611%
- 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
Score: 12.129882507172127