Skip to content
Snippets Groups Projects
Commit d2a66008 authored by Graeme Weatherill's avatar Graeme Weatherill
Browse files

Updates README to explain OQ v3.15 edits

parent b8619ee4
No related branches found
No related tags found
1 merge request!1Updates README to explain OQ v3.15 edits
# FrancePSHA
Project contains OpenQuake input model files implementing the Drouet et al. (2020) PSHA model for Metropolitan France and related codes to build the source model files and extract and interpret results
(c) Graeme Weatherill, GFZ German Research Centre for Geosciences, Potsdam, Germany
## Getting started
Email: [graeme.weatherill@gfz-potsdam.de](graeme.weatherill@gfz-potsdam.de)
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
The project `FrancePSHA` contains OpenQuake input model files implementing the Drouet et al. (2020) PSHA model for Metropolitan France and related codes to build the source model files and extract and interpret results
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
### Acknowledgement:
The implementation of the Drouet et al. (2020) model in OpenQuake was made possible with support and input from the following:
```
cd existing_repo
git remote add origin https://git.gfz-potsdam.de/gweather/francepsha.git
git branch -M main
git push -uf origin main
```
* Guillaume Daniel (EDF)
* Irmela Zentner (EDF)
* Stéphane Drout (FUGRO)
* Gabriele Ameri (SEISTER)
* David Baumont (SEISTER)
* Fabrice Cotton (GFZ)
## Integrate with your tools
- [ ] [Set up project integrations](https://git.gfz-potsdam.de/gweather/francepsha/-/settings/integrations)
The work is undertaken with funding from Électricité de France (EDF) as part of the [Sigma-2 Project](https://www.sigma-2.net/)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Installation
## Test and Deploy
The current version of the model operates on OpenQuake-engine >= 3.15. Owing to the need to make changes to the code (explained below) it is recommended to install OpenQuake from source to allow for editing.
Use the built-in continuous integration in GitLab.
For installation instructions please see [Installing from Sources](https://github.com/gem/oq-engine/blob/master/doc/installing/development.md)
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
## Changes to OpenQuake
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
Since OpenQuake v3.13 a maximum number of 183 branches per tectonic region type has been imposed on each of the source model and ground motion model logic trees. Unfortunately, this changesfollows the completion of the migration the Drouet et al. (2020) PSHA model for France to OpenQuake, wherein a total of 400 source branches are needed for the one tectonic region type. Therefore it is not possible to run the model in the recent version of OpenQuake without adjustment to the code base. The adjustments are minor, however, and require small edits to several functions in the code, which are explained below.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
<b>Please note:
## Name
Choose a self-explaining name for your project.
1) Local modifications to the code are not run under continuous integration and therefore it is not possible to know in advance when a breaking change is introduced into OpenQuake. The authors of the current FrancePSHA repository (Graeme Weatherill and GFZ) cannot guarantee functionality of these changes in future versions of OpenQuake and give no warranty of suitability of the code for purpose and for correctness of results
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
2) The modifications proposed here are done <u>without</u> the support or recommendation of GEM and the OpenQuake developers. Problems arising from implementations of these changes should therefore <u>not</u> be directed to OpenQuake's developers but instead to [Graeme Weatherill](mailto:graeme.weatherill@gfz-potsdam.de)
</b>
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
The following changes have been tested on the current (v3.15 and v3.16 master) releases of OpenQuake.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
### 1: Getting around the branch limit
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
The limit on the maximum number of branches can be overcome to <i>run the calculations</i>. The mean and quantile of the hazard (both curves and UHS) can be exported in the conventional manner. Export of the full set of hazard results for all the branches must be done through the datastore, which will be explained in due course.
Getting around the 183 branch limit requires several small changes to the code, which appear to be possible without impacting on the general hazard calculations
The changes are as follows:
1) In the file `openquake/hazardlib/gsim_lt.py` the function `keyno(...)` should be replaced with the following:
```python
def keyno(branch_id, bsno, brno, fname='', chars=BASE183):
"""
:param branch_id: a branch ID string
:param bsno: number of the branchset (starting from 0)
:param brno: number of the branch in the branchset (starting from 0)
:returns: a short unique alias for the branch_id
"""
n = len(chars)
return chars[brno // n] + chars[brno % n] + str(bsno)
```
This allows the code to generate 2-character short-form branch IDs, which raises the 183 branch limit from 183 to 183 * 183 = 33489 branches per source model and/or ground motion model.
2) In the file `openquake/baselib/general.py` we need to create a list of all of the possible 33489 branches. To do this look for the following line below the `import` statements:
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
```python
BASE183 = ("ABCDEFG ...")
```
and beneath it add the following:
```python
BASE33489 = [i + j for i in BASE183 for j in BASE183]
```
3) Finally, this new vector `BASE33489` should be called in place of `BASE183` when creating the short form id of the branch. Go to the file `openquake/hazardlib/lt.py` and add `BASE33489` to the imports:
```python
from openquake.baselib.general import CallableDict, BASE183, BASE33489
```
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
Then look for the function `add_path(...)` and change the line:
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
```python
br.short_id = BASE183[brno]
```
to
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
```python
br.short_id = BASE33489[brno]
```
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
### 2: Change in OQ 3.15 - No empty truncation level
## License
For open source projects, say how it is licensed.
In v3.15 of the engine empty truncation level is no longer permitted to specify no truncation. No truncation is now defaulted to truncation at 99 standard deviations.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
So change the job.ini config to:
```
truncation_level = 99.
```
\ No newline at end of file
......@@ -40,7 +40,7 @@ intensity_measure_types_and_levels = {"PGA": [1.0E-4, 1.57999995E-04, 2.50999990
"SA(1.0)": [1.0E-4, 1.57999995E-04, 2.50999990E-04, 3.98000004E-04, 6.30999974E-04, 1.00000005E-03, 1.58499996E-03, 2.51200004E-03, 3.98099981E-03, 6.31000008E-03, 9.99999978E-03, 1.58489998E-02, 2.51189992E-02, 3.98110002E-02, 6.30960017E-02, 0.100000001, 0.158489004, 0.251188993, 0.398106992, 0.630957007, 1.00000000, 1.58489299, 2.51188588, 3.98107195],
"SA(2.0)": [1.0E-4, 1.57999995E-04, 2.50999990E-04, 3.98000004E-04, 6.30999974E-04, 1.00000005E-03, 1.58499996E-03, 2.51200004E-03, 3.98099981E-03, 6.31000008E-03, 9.99999978E-03, 1.58489998E-02, 2.51189992E-02, 3.98110002E-02, 6.30960017E-02, 0.100000001, 0.158489004, 0.251188993, 0.398106992, 0.630957007, 1.00000000, 1.58489299, 2.51188588, 3.98107195],
"SA(3.0)": [1.0E-4, 1.57999995E-04, 2.50999990E-04, 3.98000004E-04, 6.30999974E-04, 1.00000005E-03, 1.58499996E-03, 2.51200004E-03, 3.98099981E-03, 6.31000008E-03, 9.99999978E-03, 1.58489998E-02, 2.51189992E-02, 3.98110002E-02, 6.30960017E-02, 0.100000001, 0.158489004, 0.251188993, 0.398106992, 0.630957007, 1.00000000, 1.58489299, 2.51188588, 3.98107195]}
truncation_level =
truncation_level = 99
maximum_distance = 200
pointsource_distance = 80
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment