Open GLlorin opened 1 month ago
I am not sure why you're encountering the error, but your re-installation command does not work because the branch does not exist anymore.
Try this instead for the latest version on main
pip install --upgrade --force-reinstall git+https://github.com/matthiasdemuzere/w2w.git
or a version where we've made a few changes (which is not merged)
pip install --upgrade --force-reinstall git+https://github.com/matthiasdemuzere/w2w.git@add_wrf_version
If you're error still persists, you will probably have to provide your geo_em files, for someone to have a look.
Thank you so much for replying so quickly. It took me some time to apply both suggestions but essentially, while both suggested re-installation commands worked, I still encounter the same error message I posted about when the checks and cleaning are being made. For some reason, the LCZ data is not being incorporated into the new geo_em.d0X.nc files.
It may not have been seen but I do provide all files I have in this drive as the TIFF file was quite large: https://drive.google.com/drive/u/1/folders/1J6sm3QQZaSg0JaYaPG4mezDLTx_k7eA5
Please advise me on further courses of action I can take, thank you!
Hi @GLlorin,
Thanks for reporting this.
The first thing I noticed is the large size of your PAR.tif file, that seems to cover an area that is many times larger than your target WRF d02 domain. When using that file, my local machine actually did not have anough memory :)
So, I just cropped a smaller area out of the global LCZ map, using the code below (you can get v3 of global LCZ map here):
import rioxarray as rxr
import xarray as xr
fn_lcz = "/mnt/SSD2TB/data/ZENODO/LCZ_GLOBAL/v3/lcz_filter_v3.tif"
fn_geo = "/mnt/SSD2TB/data/w2w-debug/132_Manilla/geo_em.d02.nc"
lcz = rxr.open_rasterio(fn_lcz)
ds = xr.open_dataset(fn_geo)
dxy = 0.5
xmin= float(ds['XLONG_M'].min()) - dxy
xmax = float(ds['XLONG_M'].max()) + dxy
ymin = float(ds['XLAT_M'].min()) - dxy
ymax = float(ds['XLAT_M'].max()) + dxy
print(xmin, xmax, ymin, ymax)
# Crop LCZ map
lcz_sel = lcz.sel(x=slice(xmin, xmax), y=slice(ymax, ymin))
print(lcz_sel)
# Store to drive
fn_lcz_sel = "/mnt/SSD2TB/data/w2w-debug/132_Manilla/lcz.tif"
lcz_sel.rio.to_raster(fn_lcz_sel)
When I execute w2w with this smaller file, I can actually reproduce your error:
w2w . lcz.tif geo_em.d02.nc 'v4.3'
--> Set data, arguments and files
> Using layer 0 of the LCZ GeoTIFF. Can be changed with -l (--lcz-band)
--> Check LCZ integrity, in terms of class labels, projection and extent
> LCZ labels as expected (1 to 17)
> LCZ provided as WGS84 (EPSG:4326)
> LCZ domain is covering WRF domain
--> Replace WRF urban LC with surrounding natural LC
Looping through urban grid pixels: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 182/182 [00:00<00:00, 194.71it/s]
--> Create LCZ-based geo_em file
> Processing LP_URB2D ...
> Processing MH_URB2D ...
> Processing STDH_URB2D ...
> Processing HGT_URB2D ...
> Processing LB_URB2D ...
> Processing LF_URB2D ...
> Processing HI_URB2D ...
--> Create LCZ-based urban extent geo_em file (excluding other LCZ-based info)
--> Expanding land categories of parent domain(s) to 41
--> Start sanity check and clean-up ...
> Check 1: Urban class removed from geo_em.d02_NoUrban.nc? OK
> Check 2: LCZ Urban extent present in geo_em.d02_LCZ_extent.nc?
WARNING: LCZ-based urban extent missing
> Check 3: Urban LCZ classes exists in geo_em.d02_LCZ_params.nc? OK: LCZ Classes ([]) present
> Check 4: FRC_URB2D present in geo_em.d02_LCZ_params.nc? OK: FRC_URB2D values range between 0.00 and 0.00
> Check 5: URB_PARAMS matrix present in file geo_em.d02_LCZ_params.nc? OK
> Check 6: Do URB_PARAM variable values follow expected range in geo_em.d02_LCZ_params.nc?
+ OK for LP_URB2D
+ OK for MH_URB2D
+ OK for STDH_URB2D
+ OK for HGT_URB2D
+ OK for LB_URB2D
+ OK for LF_URB2D
Traceback (most recent call last):
File "/home/matthias/pyvens/w2w/bin/w2w", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/matthias/pyvens/w2w/lib/python3.11/site-packages/w2w/w2w.py", line 234, in main
checks_and_cleaning(
File "/home/matthias/pyvens/w2w/lib/python3.11/site-packages/w2w/w2w.py", line 1728, in checks_and_cleaning
if np.nanmax(np.abs((100 - hi_sum).values)) > 0.1:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matthias/pyvens/w2w/lib/python3.11/site-packages/numpy/lib/_nanfunctions_impl.py", line 495, in nanmax
res = np.fmax.reduce(a, axis=axis, out=out, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: zero-size array to reduction operation fmax which has no identity
I can also confirm to get this error in both these versions:
pip install --upgrade --force-reinstall git+https://github.com/matthiasdemuzere/w2w.git
pip install --upgrade --force-reinstall git+https://github.com/matthiasdemuzere/w2w.git@add_wrf_version
Based on the output, it seems to go wrong when introducing the LCZ labels into the LU_INDEX, because of:
WARNING: LCZ-based urban extent missing
At the same time, Check 3 seems also misleading: > Check 3: Urban LCZ classes exists in geo_em.d02_LCZ_params.nc? OK: LCZ Classes ([]) present
. The LCZ class array is empty, so this check should not be ok.
I'll try to look into this further ...
Describe your issue
Hello!
I am trying to use the global LCZ map produced by Demuzere et al. (2022), cut to the Philippines (~5-25N, 115-130E), in simulations over Metro Manila to test the performance of different urban canopy models. However, I am running into trouble at the first step of using the w2w python utility to incorporate the TIFF file into the prepared geo_em.d0X.nc files.
Following its recommended use, I run this line in the directory where I have my LCZ file (PAR.tif) and my two domain geo files:
> w2w ./ PAR.tif geo_em.d02.nc
It runs well until the check and cleaning starts, giving the following messages and ending in an error:
I know this error was already brought up in Issue #38, but when I tried to follow the recommended course of action from the thread by executing:
pip install --upgrade --force-reinstall git+https://github.com/matthiasdemuzere/w2w.git@add_tests
I run into this error:
I have uploaded my geo_em.d0X.nc files and the TIFF file I have cropped from the global map by Demuzere et al. (2022) in this GDrive. I've also included the produced geo_em.d02_LCZ_params.nc file which confirms that the LU_INDEX was not updated. Please advise me on my next steps.
Thank you very much!
w2w --version
w2w 0.5.0
nc-config --all
Installed Packages
Traceback
No response