W2W
W2W: A Python package that injects WUDAPT's Local Climate Zone information in WRF - Published in JOSS (2022)
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 22 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: mdpi.com, joss.theoj.org -
✓Committers with academic emails
1 of 9 committers (11.1%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords from Contributors
Scientific Fields
Repository
A python tool that ingests WUDAPT information into WRF.
Basic Info
- Host: GitHub
- Owner: matthiasdemuzere
- License: mit
- Language: Jupyter Notebook
- Default Branch: main
- Size: 30.8 MB
Statistics
- Stars: 41
- Watchers: 4
- Forks: 17
- Open Issues: 9
- Releases: 8
Metadata Files
README.md
w2w.py
A WUDAPT-to-WRF python tool that injects WUDAPT's Local Climate Zone information into WRF.
Install
pip install w2w
Install from GitHub:
pip install git+https://github.com/matthiasdemuzere/w2w
Run the tool
- Check out its help:
sh w2w --help - Try with the provided sample:
Sample data used here can be downloaded from the repository in the sample_data folder. After clicking on the file you can download it.
sh
w2w ./sample_data lcz_zaragoza.tif geo_em.d04.nc
- Deploy using your own data:
sh w2w INPUT_DIRECTORY YOUR_LCZ.TIF YOUR_GEO_EM.dXX.NCOutput -------
The original files are not modified. Three new files are generated by w2w:
- geoem.d04NoUrban.nc: Urban areas are replaced with the dominant surrounding rural land use.
- geoem.d04LCZextent.nc: The extension of urban areas is updated using LCZ.
- geoem.d04LCZparams.nc: Urban areas are described using three different urban density categories.
Differences between the original file and the newly created files by w2w are shown below for the sample data provided.
Fig.1: w2w results on sample data. Land use categories from the original file (a), the params file (b), the extent file (d) and the NoUrban (f). Pixels replaced with respect to the original file in params (c), extent (e) and NoUrb (g).
A sample Jupyter notebook is provided to recreate this Figure but is not part of the package, thus additional modules are required to run it.
Requirements
A geo_em.dXX.nc file (produced by WRF's WPS geoegrid.exe), for the inner WRF model domain in which you would like to use the LCZ-based information.
A Local Climate Zone map (lcz.tif) that is slightly bigger than the domain of the geo_em.d0X.nc file. There are a number of ways to obtain an LCZ map for your region of interest:
- Extract your domain from the continental-scale LCZ maps for Europe (Demuzere et al., 2019) or the United States (Demuzere et al., 2020). For more information, see here. Make sure you use the version ending with _epsg4326.tif.
- Check if your region of interest is already covered by the many LCZ maps available in the LCZ Generator submission table.
- Use the LCZ Generator to make an LCZ map for your region of interest. In case the geo_em.d0X.nc domain is larger than ~ 2.5 x 2.5°, the LCZ Generator will fail. In that case, please contact Matthias Demuzere for support.
Important notes
- Your LCZ .tif and geoem*.dXX.nc files should both live in the INPUTDIRECTORY.
- Also, this INPUT_DIRECTORY should be writeable by the user.
- Also the geoem.d0[0 to X].nc file(s) of the parent domain(s) should be available in the INPUTDIRECTORY. This is needed because the
w2w.pyroutine will check whetherNUM_LAND_CATis set to 41 in all these parent domain files. If that is not the case, this will be fixed by writing out adjusted geoem.d0[0 to X]41.nc files. - In case you use an LCZ map produced by the LCZ Generator, by default
-lcz_band 1will be used, which is the best-quality gaussian filtered LCZ map (see Demuzere et al. (2021) for more info). - Once the adjusted geo_em.dXX.nc files are created (geoem.d0141.nc, ..., geoem.dXXNoUrban.nc, geoem.dXXLCZextent.nc, geoem.dXXLCZparams.nc), make sure to rename them (e.g. rename geoem.d0141.nc to geoem.d01.nc, or geoem.d04LCZparams.nc to geo_em.d04.nc) before using them as input to the metgrid.exe module. See documentation for more info.
- It is advised to use this tool with urban parameterization options BEP or BEP+BEM (
sf_urban_physics = 2 or 3, respectively). In case you use this tool with the SLUCM model (sf_urban_physics = 1), make sure your lowest model level is above the highest building height. If not, real.exe will provide the following error message:ZDC + Z0C + 2m is larger than the 1st WRF level - Stop in subroutine urban - change ZDC and Z0C. - At the end of running
W2W, a note is displayed that indicates thenbui_maxvalue, e.g. for the sample data:Set nbui_max to 5 during compilation, in order to optimize memory storage. This is especially relevant for users that work with the BEP or BEP+BEM urban parameterization schemes (sf_urban_physics = 2 or 3, respectively). See alsonum_urban_nbuiin WRF's README.namelist for more info. - Make sure to set
use_wudapt_lcz=1(default is 0) andnum_land_cat=41(default is 21) in WRF'snamelist.inputwhen using the LCZ-based urban canopy parameters. - The outputs of this tool have only been tested with the most recent WRF version 4.3.x. So we advise you to work with this version as well, which is now able to ingest the urban LCZ classes by default.
- It is possible to specify the number of nearest pixels (NPIXNLC) to determine the dominant natural landuse in the surroundings of each urban pixel. The most frequent landuse among those pixels is used to replace the urban pixels. The distance used to find the nearest pixels is based on the great circle arc length. For performance reasons, the nearest pixels are searched using a k-d tree algorithm, instead of brute forcing over all possible pixels. Because only land natural pixels are considered to calculate the most frequent land use, we need to filter out water and other urban pixels. Thus, we need to specify the initial number of pixels (NPIXAREA) that the k-d tree algorithm will select, which will be larger than NPIXNLC. By default, NPIXAREA = NPIXNLC**2 pixels will be selected and the nearest NPIXNLC (default is 45) pixels that are not water or urban will be drawn from that initial selection. Because it is actually an area around the urban pixel, it is referred to as NPIX_AREA.
Arguments
- Additional arguments to be used:
-b --built-lcz = LCZ classes considered as urban (DEFAULT: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
-l --lcz-band = Band to use from LCZ file (DEFAULT: 0). For maps produced with LCZ Generator, use 1
-f --frc-threshold = FRC_URB2D threshold value to assign pixel as urban (DEFAULT: 0.2)
-n --npix-nlc = Number of pixels to use for sampling neighbouring natural land cover (DEFAULT: 45)
-a --npix_area = Area in number of pixels to look for the NPIX_NLC nearest number of pixels for sampling neighbouring natural land cover (DEFAULT: NPIX_NLC**2)
--lcz-ucp = Specify a custom lookup table for the LCZ-based Urban Canopy Parameters
Using a custom lookup table for the LCZ-based urban canopy parameters
- you can create a custom csv-file based on this format and use it specifying it with the
--lcz-ucpflag. For the example:w2w ./sample_data lcz_zaragoza.tif geo_em.d04.nc --lcz-ucp path/to/custom_lcz_ucp.csv - A table must have this this format (indentation optional). The table displayed below is the default table.
- you can create a custom csv-file based on this format and use it specifying it with the
csv
,FRC_URB2D ,MH_URB2D_MIN ,MH_URB2D ,MH_URB2D_MAX ,BLDFR_URB2D ,H2W
1 ,0.95 ,25 ,50 ,75 ,0.5 ,2.5
2 ,0.9 ,10 ,17.5 ,25 ,0.55 ,1.25
3 ,0.85 ,3 ,6.5 ,10 ,0.55 ,1.25
4 ,0.65 ,25 ,50 ,75 ,0.3 ,1
5 ,0.7 ,10 ,17.5 ,25 ,0.3 ,0.5
6 ,0.6 ,3 ,6.5 ,10 ,0.3 ,0.5
7 ,0.85 ,4 ,5 ,6 ,0.75 ,1.5
8 ,0.85 ,3 ,6.5 ,10 ,0.4 ,0.2
9 ,0.3 ,3 ,6.5 ,10 ,0.15 ,0.15
10 ,0.55 ,5 ,10 ,15 ,0.25 ,0.35
11 ,0 ,0 ,0 ,0 ,0 ,0
12 ,0 ,0 ,0 ,0 ,0 ,0
13 ,0 ,0 ,0 ,0 ,0 ,0
14 ,0 ,0 ,0 ,0 ,0 ,0
15 ,0.95 ,0 ,0 ,0 ,0.05 ,0
16 ,0 ,0 ,0 ,0 ,0 ,0
17 ,0 ,0 ,0 ,0 ,0 ,0
Background context
An important objective of WUDAPT, the World Urban Database and Access Portals Tools community project, is to generate urban canopy information and provide the (open-source) tools to facilitate urban-focused modelling studies (Ching et al., 2018).
Since the work of Brousse et al. (2016), the level-0 WUDAPT information, the Local Climate Zone maps, have been used increasingly in WRF, the community “Weather Research and Forecasting” model. Their original guide and code on how to use WUDAPT information into WRF (originally designed for WRF v3.2) is available here. Note that this tool was first assigning the LCZ mode to each WRF grid cell, and only afterwards assigning corresponding morphological, radiative and thermal properties to this modal LCZ class. This is done differently in w2w, see below.
As of spring 2021, WRF v4.3.x is able to ingest LCZ information by default (previous versions required manual WRF code changes by the user). See more details on "Updates of WRF-urban in WRF 4.3: Local Climate Zones, Mitigation Strategies, building materials permeability and new buildings drag coefficient" here. Because of this, we decided to simultaneously built an improved WUDAPT-to-WRF routine, to make the translation of LCZ-based parameters better and simpler. As before, the LCZ-based urban canopy parameters generally follow the values provided by Stewart and Oke (2012) and Stewart et al. (2014).
The procedure in this new w2w tool is different from the former tool. Morphological parameters are assigned directly to the high-resolution LCZ map, and only afterwards aggregated to the WRF grid. In this way, the method produces a unique value of the different urban morphology parameters for each model cell. This was found to be more efficient in reproducing urban boundary layer features, especially in the outskirts of the city (Zonato et al., 2020), and is in line with the WUDAPT-to-COSMO routine (Varentsov et al., 2020). Other radiative and thermal parameters are for now still assigned to the modal LCZ class. More details on the procedure and its assumptions will soon be available here.
How to cite?
Demuzere, M., Argüeso, D., Zonato, A. and Kittner, J. (2022). W2W: A Python package that injects WUDAPT's Local Climate Zone information in WRF. Journal of Open Source Software, 7(76), 4432, DOI: 10.21105/joss.04432.
License
The project is licensed under the MIT license.
Contributing
Contributions to w2w are welcome! This is how:
Bugs: If you find a bug, please report it by opening an issue. if possible, please attach the complete error/Traceback, the
w2wversion used, and other details like theWRFversion.Fixing Issues: If you want to contribute by fixing an issue, please check the issues: contributions are welcome for all open issues especially those with labels
bug,help wantedorgood first issuefor easy contributions.Enhancement: New features and modules are welcome! You can check the issues: contributions are welcome for open issues with labels
enhancementandhelp wanted.
Running the tests
The project uses tox to check the package installs correctly and all tests pass on different versions of python. The tests can be run using:
- all tests against all supported python versions can be run using:
console tox - a specific test can be run by specifying the
pytesttest id. In this case we only test against python 3.9 (-e py39argument)console tox -e py39 tests/w2w_test.py::<name_of_the_test>
pytest can also be used directly:
- install the package in the current virtual environment (
-eeditable install)console pip install -e . - install the development dependencies
console pip install -r requirements-dev.txt - run pytest
console pytest
Artists
- Matthias Demuzere: Lead developer
- Daniel Argueso: WRF expert
- Andrea Zonato: WUDAPT-WRF expert and liaison
- Jonas Kittner: Python wizard
Credits
- We appreciate the feedback and suggestions provided by Alberto Martilli and Oscar Brousse, lead developers of the original Fortran-based WUDAPT-to-WRF fortran package.
- Thanks to Alberto Martilli and Alejandro Rodriguez Sanchez for allowing us to use of their Zaragoza case-study files as sample data.
Owner
- Name: Matthias Demuzere
- Login: matthiasdemuzere
- Kind: user
- Location: Bochum
- Company: Ruhr-University Bochum
- Website: http://www.climate.ruhr-uni-bochum.de/team/matthias-demuzere/
- Repositories: 13
- Profile: https://github.com/matthiasdemuzere
JOSS Publication
W2W: A Python package that injects WUDAPT's Local Climate Zone information in WRF
Authors
Urban Climatology Group, Department of Geography, Ruhr-University Bochum, Bochum, Germany
Tags
WUDAPT WRF Local Climate Zones Urban canopy parameters Climate modelingGitHub Events
Total
- Create event: 4
- Release event: 1
- Issues event: 8
- Watch event: 2
- Delete event: 3
- Issue comment event: 27
- Push event: 18
- Pull request event: 4
Last Year
- Create event: 4
- Release event: 1
- Issues event: 8
- Watch event: 2
- Delete event: 3
- Issue comment event: 27
- Push event: 18
- Pull request event: 4
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| matthiasdemuzere | m****e@g****m | 140 |
| Jonas Kittner | j****r@r****e | 64 |
| pre-commit-ci[bot] | 6****] | 19 |
| Daniel Argüeso | d****o@u****s | 15 |
| Daniel Argüeso | d****o@u****u | 9 |
| Jonas Kittner | 5****3 | 7 |
| andreazonato | 4****o | 5 |
| Lukas Pilz | m****l@l****e | 1 |
| erexer | 1****r | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 65
- Total pull requests: 60
- Average time to close issues: about 1 month
- Average time to close pull requests: about 1 month
- Total issue authors: 42
- Total pull request authors: 7
- Average comments per issue: 6.72
- Average comments per pull request: 2.45
- Merged pull requests: 53
- Bot issues: 0
- Bot pull requests: 13
Past Year
- Issues: 6
- Pull requests: 4
- Average time to close issues: 3 months
- Average time to close pull requests: 17 days
- Issue authors: 6
- Pull request authors: 2
- Average comments per issue: 3.67
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 3
Top Authors
Issue Authors
- matthiasdemuzere (8)
- fipoucat (6)
- sunqiccgk (4)
- Foxcrash2021 (4)
- yy522 (2)
- erexer (2)
- htan2013 (2)
- FloBre33 (2)
- VladimirSobral (2)
- LluisFB (1)
- icqqc (1)
- meteomanic (1)
- Liz490 (1)
- Hanfly96 (1)
- gagenallorin (1)
Pull Request Authors
- jkittner (24)
- matthiasdemuzere (19)
- pre-commit-ci[bot] (15)
- dargueso (4)
- lpilz (1)
- erexer (1)
- andreazonato (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 93 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 16
- Total maintainers: 2
proxy.golang.org: github.com/matthiasdemuzere/w2w
- Documentation: https://pkg.go.dev/github.com/matthiasdemuzere/w2w#section-documentation
- License: mit
-
Latest release: v0.4.2
published over 3 years ago
Rankings
pypi.org: w2w
A python tool that ingests WUDAPT's Local Climate Zone information into WRF.
- Homepage: https://github.com/matthiasdemuzere/w2w
- Documentation: https://w2w.readthedocs.io/
- License: MIT
-
Latest release: 0.6.0
published about 1 year ago
Rankings
Maintainers (2)
Dependencies
- covdefaults *
- coverage *
- pytest *
- actions/checkout v3 composite
- actions/setup-python v4 composite