UMEP-dev / UMEP

Urban Multi-scale Environmental Predictor
https://umep-docs.readthedocs.io/
62 stars 15 forks source link

Urban Heat Island: UWGPrepare missing local variable 'IMP_heights_mean' #634

Closed ccatter closed 2 months ago

ccatter commented 3 months ago

I got the following error while using Urban Heat Island: UWGPrepare:

-- QGIS version: 3.34.7-Prizren QGIS code revision: 6f7d735c Qt version: 5.15.13 Python version: 3.12.3 GDAL version: 3.9.0 GEOS version: 3.12.1-CAPI-1.18.1 PROJ version: Rel. 9.4.0, March 1st, 2024 PDAL version: 2.6.3 (git-version: b5523a) Algorithm 'Urban Heat Island: UWG Prepare' starting… Input parameters: { 'CLIMATEZONE' : 6, 'FILE_PREFIX' : 'x', 'ID_FIELD' : 'fid', 'INPUT_LC' : 'C:\Users\uu703\OneDrive - UCL\code\QGIS\LULC_fraction\lulc_LCFG_anisotropic_result_2.txt', 'INPUT_MORPH' : 'C:\Users\uu703\OneDrive - UCL\code\QGIS\morpho\morpho_IMPGrid_anisotropic_2.txt', 'INPUT_POLYGONLAYER' : 'C:/Users/uu703/OneDrive - UCL/code/QGIS/grid.gpkg|layername=grids', 'INPUT_POLYGONLAYERTYPOLOGY' : 'C:/Users/uu703/OneDrive - UCL/code/QGIS/UrbanWindField_URock/building_type.gpkg|layername=building_windfield', 'INPUT_RURAL' : 0.9, 'OUTPUT_DIR' : 'TEMPORARY_OUTPUT' }

Traceback (most recent call last): File "C:\Users/uu703/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\preprocessor\uwgprepare_algorithm.py", line 262, in processAlgorithm uwgDict['bldHeight'] = IMP_heights_mean # average building height (m) ^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'IMP_heights_mean' where it is not associated with a value

The issue is related to Urban Morphology, so I also describe it a bit here. I used Urban Morphology: Morphologic Calculator (Grid) with default parameters and input all the DSM/DEM I have (including CDSM) and get the txt results. I don't understand why the average building height was not produced. The files I used listed below: Vector polygon grid: grid.gpkg (ID field: fid) Building type polygon layer: building_type.gpkg Raster DSM (3D objects and ground): building_ground.tif Raster DEM (only ground): ground.tif Raster DSM (only 3D objects ): DSM-DTM_building.tif Raster vegetation DSM (CDSM): vegetation.tif Land Cover: LULC_UMEP_clipped.tif (value 1-7 represent Paved to Water, accordingly) files.zip

ccatter commented 3 months ago

I rerun the algorithm on another computer but didn't solve the problem. I still got the following error message:

QGIS version: 3.36.0-Maidenhead QGIS code revision: 09951dc0 Qt version: 5.15.3 Python version: 3.9.18 GDAL version: 3.8.4 GEOS version: 3.12.1-CAPI-1.18.1 PROJ version: Rel. 9.3.1, December 1st, 2023 PDAL version: 2.6.0 (git-version: 3fced5)

Traceback (most recent call last): File "C:\Users/yehuang/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\preprocessor\uwgprepare_algorithm.py", line 262, in processAlgorithm uwgDict['bldHeight'] = IMP_heights_mean # average building height (m) UnboundLocalError: local variable 'IMP_heights_mean' referenced before assignment

biglimp commented 2 months ago

Sorry for late reply. You are supposd to use the file ending with "isotrophic", not anisotrophic.

ccatter commented 2 months ago

Thanks for the instruction. I run it successfully and got the following files UWGPrepare.zip However, when I run the Urban Weather Generator, I got the following error message:

Traceback error message while caclulation grid: 9 Traceback (most recent call last): File "C:\Users/yehuang/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_umep\processor\uwg_algorithm.py", line 224, in processAlgorithm model.generate() File "C:\Users\yehuang\AppData\Roaming\Python\Python39\site-packages\uwg\uwg.py", line 1177, in generate self._read_epw() File "C:\Users\yehuang\AppData\Roaming\Python\Python39\site-packages\uwg\uwg.py", line 1523, in _read_epw self.lat = float(self._header[0][6]) IndexError: list index out of range

I supposed it was the meteorological data issue, but it still failed when I tried the tutorial data of Goteborg. I checked the line 1522 of uwg.py and it seems to read latitude and longitude of the meteorological data, which is not in mine nor the tutorial data of Goteborg. Does that mean I need to create these two columns by myself?

biglimp commented 2 months ago

Unfortunately we have not been able to write the tutorial for the UWG. The epw-file needs to be in the specific epw-format. I see that you use UMEP-formatted met-files. This cannot be used. Try to locate an epw-file from your area and then combine it with your metdata. We will try to get a working tutorial up for UWG soon.

ccatter commented 2 months ago

Many thanks for the explanation. I can run UWG with epw from https://climate.onebuilding.org/ . By the way, I got UMEP-formatted epw from https://www.ladybug.tools/epwmap/ suggested by a Youtube video https://youtu.be/bavT3RFvusE?t=192 . You can close this case now.