UMEP-dev / UMEP

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

SOLWEIG run failing in processing/python but successful in conventional plugin #260

Closed bweeding closed 3 years ago

bweeding commented 3 years ago

I'm running SOLWEIG simulations, and while they work perfectly when using the point and click plugin, when I attempt the same task using the processing plugin or in python I receive an error: image

It may be useful to note that this has only started happening with v1.0 of the processing plugin, with which I see the following error on install: image

I have included the relevant files.

utas_solweig_run.zip

rarygit commented 3 years ago

Yes, it throws an error; expects an npz file.

'INPUT_ANISO' : '',

Should this be 'INPUT_ANISO' : None, ?

biglimp commented 3 years ago

I cannot replicate your error using SOLWEIG from the processing toolbox. Could you try executing from there instead from the Python Console and see if you get the same error. Also make sure that you have the latest version (1.2.1 development release).

image

rarygit commented 3 years ago

Re-installed UMEP Processing plugin using QGIS plugin manager. This installed version 1.0 : First official release. SUEWSAnalyzer and TreeGenerator added And SOLWEIG fails to run as described above.

Uninstalled UMEP Processing plugin and installed using zip file downloaded from GitHub. This installed version 1.2.1 : Response to #256 SOLWEIG now runs from the processing toolbox.

Need to remind users to first check and double check if they are running the latest version, regardless which version the QGIS plugin manager chooses.

biglimp commented 3 years ago

Yes. I will update in the QGIS plugin repository and also add info on version (somehow) when running tools in the toolbox. @bweeding , did the update solve your issue when running from the Python console?

rarygit commented 3 years ago

@biglimp, thanks! That was time-consuming to detect, because I automatically trusted the plugin manager.

bweeding commented 3 years ago

Hi all, thanks for the help. However, I'm unclear which files I need to download from github to install the processing tool as a .zip?

I had also trusted the QGIS plugin manager too!

Cheers Ben

On Tue, Mar 23, 2021 at 11:31 PM rarygit @.***> wrote:

@biglimp https://github.com/biglimp, thanks! That was time-consuming to detect, because I automatically trusted the plugin manager.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UMEP-dev/UMEP/issues/260#issuecomment-804864530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYGKRCEFKBSTEN2JIV3SULTFCCZXANCNFSM4ZUNAURA .

rarygit commented 3 years ago

https://github.com/UMEP-dev/UMEP-processing/archive/refs/heads/main.zip

Download the zip file using link above and save to your HDD. Uninstall your existing UMEP_processing plugin using the QGIS plugin manager. Then use the QGIS plugin manager to "install from zip" - i.e. the downloaded zip file saved to your HDD.

As a future precaution, check the metadata.txt file in your zip file to confirm that you have the correct version, e.g. 1.2.1 As shown here: https://github.com/UMEP-dev/UMEP-processing/blob/main/metadata.txt

bweeding commented 3 years ago

Ah cheers, will do!

On Wed, Mar 24, 2021 at 8:08 AM rarygit @.***> wrote:

https://github.com/UMEP-dev/UMEP-processing/archive/refs/heads/main.zip

Download the zip file using link above and save to your HDD. Uninstall your existing UMEP_processing plugin using the QGIS plugin manager. Then use the QGIS plugin manager to "install from zip" - i.e. the downloaded zip file saved to your HDD.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UMEP-dev/UMEP/issues/260#issuecomment-805261930, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYGKRCUJDNBOTQBNEPYCZ3TFD7OBANCNFSM4ZUNAURA .

bweeding commented 3 years ago

Is now working, via both the processing toolbox and the QGIS python environment. Will next test in standalone python.

bweeding commented 3 years ago

I have successfully run SOLWEIG in standalone python (using Spyder through Anaconda).

Having downloaded "UMEP-processing-main", I made a copy of this folder inside the plugins folder ('C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins'), and renamed it to UMEP_processing_main (as python won't accept the '-').

I then ran:

from UMEP_processing_main.processing_umep_provider import ProcessingUMEPProvider umep_provider = ProcessingUMEPProvider() QgsApplication.processingRegistry().addProvider(umep_provider)

and

processing.run("umep:Outdoor Thermal Comfort: SOLWEIG", {'INPUT_DSM':'C:/Users/weedingb/Desktop/utas_solweig_run/DSM_clipped_addDEM.tif', 'INPUT_SVF':'C:\\Users\\weedingb\\Desktop\\utas_solweig_run\\svfs.zip', 'INPUT_HEIGHT':'C:/Users/weedingb/Desktop/utas_solweig_run/height.tif', 'INPUT_ASPECT':'C:/Users/weedingb/Desktop/utas_solweig_run/aspect.tif', 'INPUT_CDSM':'C:/Users/weedingb/Desktop/utas_solweig_run/CDSM_clipped.tif', 'TRANS_VEG':3, 'INPUT_TDSM':None, 'INPUT_THEIGHT':25, 'INPUT_LC':None, 'USE_LC_BUILD':False, 'INPUT_DEM':'C:/Users/weedingb/Desktop/utas_solweig_run/DEM_clipped.tif', 'SAVE_BUILD':False, 'INPUT_ANISO':'', 'ALBEDO_WALLS':0.2, 'ALBEDO_GROUND':0.15, 'EMIS_WALLS':0.9, 'EMIS_GROUND':0.95, 'ABS_S':0.7, 'ABS_L':0.95, 'POSTURE':0, 'CYL':True, 'INPUTMET':'C:\\Users\\weedingb\\Desktop\\utas_solweig_run\\metfile_20190105_20190106_tester.txt', 'ONLYGLOBAL':False, 'UTC':0, 'POI_FILE':None, 'POI_FIELD':'', 'AGE':35, 'ACTIVITY':80, 'CLO':0.9, 'WEIGHT':75, 'HEIGHT':180, 'SEX':0, 'SENSOR_HEIGHT':10, 'OUTPUT_TMRT':True, 'OUTPUT_KDOWN':True, 'OUTPUT_KUP':False, 'OUTPUT_LDOWN':False, 'OUTPUT_LUP':False, 'OUTPUT_SH':True, 'OUTPUT_TREEPLANTER':False, 'OUTPUT_DIR':'C:\\Users\\weedingb\\Desktop\\utas_solweig_run\\solweig_output'})

Results were produced, however my python console also spat some errors at me along the way:

`runcell(13, 'C:/Users/weedingb/Documents/GitHub/phd/las_fusion_processing_draft3_uni.py')

C:\Users\weedingb\Anaconda3\envs\qgis_env\lib\site-packages\ipykernel\ipkernel.py:287: DeprecationWarning: should_run_async will not call transform_cell automatically in the future. Please pass the result to transformed_cell argument and any exception that happen during thetransform in preprocessing_exc_tuple in IPython 7.17 and above. and should_run_async(code) C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\UMEP_processing_main\functions\SOLWEIGpython\gvf_2018a.py:29: RuntimeWarning: invalid value encountered in true_divide sunwall = (wallsun / walls * buildings) == 1 # new as from 2015a C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\UMEP_processing_main\functions\SOLWEIGpython\Lside_veg_v2015a.py:10: RuntimeWarning: divide by zero encountered in log svfalfaE=np.arcsin(np.exp((np.log(1-svfE))/2)) C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\UMEP_processing_main\functions\SOLWEIGpython\Lside_veg_v2015a.py:11: RuntimeWarning: divide by zero encountered in log svfalfaS=np.arcsin(np.exp((np.log(1-svfS))/2)) C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\UMEP_processing_main\functions\SOLWEIGpython\Lside_veg_v2015a.py:12: RuntimeWarning: divide by zero encountered in log svfalfaW=np.arcsin(np.exp((np.log(1-svfW))/2)) C:\Users\weedingb\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\UMEP_processing_main\functions\SOLWEIGpython\Lside_veg_v2015a.py:13: RuntimeWarning: divide by zero encountered in log svfalfaN=np.arcsin(np.exp((np.log(1-svfN))/2)) C:\Users\weedingb\Anaconda3\envs\qgis_env\Library\python\plugins\processing\gui\AlgorithmExecutor.py:62: ResourceWarning: unclosed file <_io.TextIOWrapper name='C:\\Users\\weedingb\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\default\\python\\plugins\\UMEP_processing_main\\processor/landcoverclasses_2016a.txt' mode='r' encoding='cp1252'> results, ok = alg.run(parameters, context, feedback) ResourceWarning: Enable tracemalloc to get the object allocation traceback`

rarygit commented 3 years ago

As you can see below, hyphen "-" in the path to the plugin folder works ok in python. Path: /home/l1nux/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP-processing-main

foobar = __import__("UMEP-processing-main")

But you are correct with import UMEP-processing-main throwing an invalid syntax error.

conda environment (using miniconda3 with conda-forge as primary channel; avoid Anaconda channel i.e. conflicts) OS: Ubuntu 20.04

biglimp commented 3 years ago

Thanks, @bweeding . I will try to find a way so the Python ignores the error messages. They are actually not errors that affect the model.

bweeding commented 3 years ago

Ah ok cool! I'll get to work commenting the code so it can be turned into a tutorial as previously discussed

On Wed, 24 Mar 2021, 19:15 biglimp, @.***> wrote:

Thanks, @bweeding https://github.com/bweeding . I will try to find a way so the Python ignores the error messages. They are actually not errors that affect the model.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UMEP-dev/UMEP/issues/260#issuecomment-805597789, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYGKRDRIKUTR5EUZFL4QOLTFGNQRANCNFSM4ZUNAURA .

biglimp commented 3 years ago

Should be fixed now. I updated to 1.3. Will push it to QGIS repository. TO find version, hover over UMEP in the toolbox and then a tooltip should appear displaying version number,