volkanozsarac / EzGM

Toolbox for ground motion record selection and processing
GNU General Public License v3.0
65 stars 25 forks source link

Issue in the 'hazard_curve' method in the 'utility' content #11

Closed wuch992006 closed 1 year ago

wuch992006 commented 1 year ago

Dear Volkan,

I met a problem when I runing the 'Example 3.ipynb'. This issue happens in the 'hazard_curve(poes, results_dir, post_dir)' commend, under the '2) Post-process PSHA results' session. The error message is: 'local variable 'inv_t' referenced before assignment.

I would appreciate it if you could figure it out.

Best, Chenhao

volkanozsarac commented 1 year ago

Hi @wuch992006, there was a minor issue (related to the OpenQuake update; the output format was changed a bit). Please re-install the tool. I released the new version. Let me know if it does not work. (You can, alternatively, replace the files within your EzGM folder with the ones in GitHub).

Cheers, Volkan

wuch992006 commented 1 year ago

Dear Volkan,

I found my problem come from that it creates no output in the 'OQ_Outputs'.

I expect it could run OpenQuake by excututing the 'os.system(oq + ' engine --run ' + oq_ini + ' --exports csv')'. Unfortunately, it produces nothing after this execution. (with no errors and warnings when running).

I suspect there is an issue in my Openquake configuration. But I followed what you did in your youtube video. So I would appreciate it if you could let me know hot to fix that.

Cheers, Chenhao

wuch992006 commented 1 year ago

@volkanozsarac

volkanozsarac commented 1 year ago

Dear Volkan,

I found my problem come from that it creates no output in the 'OQ_Outputs'.

I expect it could run OpenQuake by excututing the 'os.system(oq + ' engine --run ' + oq_ini + ' --exports csv')'. Unfortunately, it produces nothing after this execution. (with no errors and warnings when running).

I suspect there is an issue in my Openquake configuration. But I followed what you did in your youtube video. So I would appreciate it if you could let me know hot to fix that.

Cheers, Chenhao

Dear @wuch992006, this could be related to PSHA computation in OpenQuake. Could you please try this:

  1. Open the console
  2. Activate the environment EzGM is going to be run
  3. Head to the directory where the example hazard model is located. For example, in Github it is here.
  4. Run PSHA in OpenQuake using the console, in specific use the following: oq engine --run job.ini --exports csv

Please let me know if the analysis work. Then we can try to look for the errors. Please show the output. I noted that sometimes PSHA does not run in online services due to ram issues. I guess I need to re-configure OpenQuake settings for that

wuch992006 commented 1 year ago

@volkanozsarac Hello Volkan, You mean I directly try the OpenQuake desktop console (rather than implement that in jupyter), right? If so, why do I need to activate the EzGM environment?

volkanozsarac commented 1 year ago

@volkanozsarac

Hello Volkan,

You mean I directly try the OpenQuake desktop console (rather than implement that in jupyter), right?

If so, why do I need to activate the EzGM environment?

Yes. Because the tool is using OpenQuake, and it is in fact installed in the same environment (it must be). In Example 3, we first produce hazard curves using OpenQuake engine, without using EzGM. So it needs to be working. Then we process the outputs to use in record selection part.

wuch992006 commented 1 year ago

@volkanozsarac Hello Volkan, You mean I directly try the OpenQuake desktop console (rather than implement that in jupyter), right? If so, why do I need to activate the EzGM environment?

Yes. Because the tool is using OpenQuake, and it is in fact installed in the same environment (it must be). In Example 3, we first produce hazard curves using OpenQuake engine, without using EzGM. So it needs to be working. Then we process the outputs to use in record selection part.

Hello Volkan,

I run the OQ engine in the OQ console and it is not working. Please see the screenshot I attached below. It seems like an error happen in pandas?

image
wuch992006 commented 1 year ago

Hi Volkan,

When I try running openquake in its own environment (i.e., without activating the clean environment for EzGM), it works. So I guess there is an issue in the configuration of the clean environment.

volkanozsarac commented 1 year ago

Hi @wuch992006,

As you said, it is related to OpenQuake installation. I will note it for later. At the moment, apparently, the installation of the new OpenQuake version the way I suggested causes some issues. I've added an extra step. Please try the following:

1-) Create a virtual environment python -m venv /path/to/new/virtual/environment 2-) Activate the new environment /path/to/new/virtual/environment/Scripts/activate.bat 3-) Upgrade pip: python -m pip install --upgrade pip 4-) Clone OpenQuake repository git clone https://github.com/gem/oq-engine.git 5-) Change the current directory to the clone directory cd path/to/oq-engine 6-) Install OpenQuake engine requirements based on your version (py38, py39, win64, linux etc., see the clone directory) pip install -r requirements-py38-win64.txt 7-) Install OpenQuake engine pip install -e. 8-) Install EzGM pip install EzGM 9-) Make a test (check OpenQuake version) oq -v

wuch992006 commented 1 year ago

Hello @volkanozsarac,

After running all the procedures you mentioned above, it prompts the OQ Version, which is : (environment) (base) C:\Users\Chenhao\oq-engine>oq -v 3.17.0

what should I do next?

volkanozsarac commented 1 year ago

This proves that OpenQuake is installed correctly. Now you can run the examples without any issues, I believe. Also please make sure that you have installed the last version of EzGM, 1.6.6.3. (pip install EzGM==1.6.6.3). I have verified all, it works on my computer at the moment.

If you would like to run the examples in jupyter notebook of course you should install it as well (pip install notebook). Let me know if there are still issues.

wuch992006 commented 1 year ago

Hello @volkanozsarac

Though it can show the OQ version correctly, it still cannot produce any outputs when I run the ipynb locally. Here is the error message. Again I appreciate your help.

image
volkanozsarac commented 1 year ago

This is very odd. Could you try the installation without using Anaconda? I have not tested it with Anaconda (I know that OpenQuake installation is quite problematic in some cases). You may install Python from here: https://www.python.org/downloads/release/python-3810/

I will look into the issue more. If we cannot solve it, I will just make another video/gif showing the installation.

wuch992006 commented 1 year ago

Hi @volkanozsarac ,

You mean we directly use python to run it (without using conda)? Yes please make another video to show this. Appreciate it!

volkanozsarac commented 1 year ago

@wuch992006 I've made a video regarding the installation. You can find it on my channel.