Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 epic ths table overhaul versioning support plus arrow #62

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
6419fef
WIP on adapter and sqlite implementation
chrisbc Dec 13, 2023
1445c1e
sqlite adapter is progressing
chrisbc Dec 14, 2023
d0e2d8b
added exists(), delete_table to sqlite adapter;
chrisbc Dec 14, 2023
5d6784b
added save() to sqlite adapter;
chrisbc Dec 14, 2023
b6c9e5f
added save() & query();
chrisbc Dec 14, 2023
8a23e1f
refactor db_adapter packages;
chrisbc Dec 14, 2023
fde0e73
refactoring
chrisbc Dec 14, 2023
84e7259
clone all oq models for v2 extract testing;
chrisbc Dec 14, 2023
50543ac
working test 1;
chrisbc Dec 17, 2023
fa0b1c3
v2 realisations OK; added test script/ths_v2.py;
chrisbc Dec 18, 2023
9290e52
simplified adapter pattern; added tests for pynamodb vs sqlite
chrisbc Dec 19, 2023
f3a93ce
update test script
chrisbc Dec 19, 2023
9fb34b0
batch support for sqlite;
chrisbc Dec 20, 2023
d507227
get caching back together; update changelog
chrisbc Dec 21, 2023
d281655
Bump version: 0.7.7 → 0.8.0
chrisbc Dec 21, 2023
5efa553
fix caching imports;
chrisbc Dec 21, 2023
0c3ac60
fix imports; reduce bounds for randint in test;
chrisbc Dec 21, 2023
32f641d
fix imports
chrisbc Dec 21, 2023
b6447d3
more docs; test using tmp_path;
chrisbc Jan 8, 2024
1144e57
tweak sqlite adapter folder location
chrisbc Jan 8, 2024
8909765
get pytest and mocking pynamodb working on meta table;
chrisbc Jan 8, 2024
5781a96
detox
chrisbc Jan 8, 2024
5418d20
WIP on dynamic base classes
chrisbc Jan 9, 2024
3e55e5e
dynamic_base_class working on ToshiOpenquakeMeta
chrisbc Jan 10, 2024
b7c2dcb
WIP on dyanic_base_class setup
chrisbc Jan 10, 2024
9c240c0
OpenquakeRealization dynamic working
chrisbc Jan 10, 2024
850dcd1
WIP on refactoring tests
chrisbc Jan 11, 2024
e63c615
delete duplicated test
chrisbc Jan 14, 2024
cb58a74
realization tests passing with db_adapter
chrisbc Jan 14, 2024
b9e32bd
HazardAggregation tests working with db_adapter
chrisbc Jan 15, 2024
0ce29f8
caching tests fixed
chrisbc Jan 15, 2024
091f278
moved db_adapter package; dropped unuused v2 models;
chrisbc Jan 15, 2024
93d8a3e
solved PyanmodbAdapterInterface typing and inheritance configuration;…
chrisbc Jan 16, 2024
584eda6
WIP on transform + export
chrisbc Jan 16, 2024
981ccba
reproduced pickle.dump error n oq_rlz.
chrisbc Jan 16, 2024
31ab9fb
pickle error relates to rebase importing package instead of module
chrisbc Jan 16, 2024
0af7db7
all tests passing; store_hazard script workging with SqliteAdapter; d…
chrisbc Jan 17, 2024
1f89db0
make get_tables dynamic; add test showing how NOT to rebase models;
chrisbc Jan 17, 2024
85a5826
testing [sqlite] rlz with ths_testing script;
chrisbc Jan 17, 2024
c307e51
update cli docs;
chrisbc Jan 17, 2024
d8bfb96
update docs; add model digrams and outline of proposed changes.
chrisbc Jan 18, 2024
b1df4ae
get all tests running in tox; fix db_adapter pattern in hazard_query.…
chrisbc Jan 25, 2024
91377c0
reorg hazard_query; add scripts watch to mkdocs config; fix random ed…
chrisbc Jan 25, 2024
1298d40
minor docs updates;
chrisbc Feb 25, 2024
0ea15d1
updated black; simplify pyproject.toml so `poetry check` passes;
chrisbc Feb 25, 2024
35eedac
black formatting
chrisbc Feb 25, 2024
bf596e8
Merge remote-tracking branch 'origin/update-urllib3-dep' into feature…
chrisbc Feb 25, 2024
c5bf44f
full support for SS round-tripping in sqlite with test cover;
chrisbc Feb 26, 2024
df3323c
update openquake to 3.19 to get all the NSHM GSIMS; re-store test_tra…
chrisbc Feb 26, 2024
a0d8b12
update CHANGELOG
chrisbc Feb 26, 2024
8aac572
update changelog
chrisbc Feb 26, 2024
dac19d1
cleanup tweaks;
chrisbc Feb 26, 2024
632c1e0
add test cover for unique contraints; sqlite is incomplete;
chrisbc Feb 27, 2024
40399bb
WIP on unique constraint for sqlite;
chrisbc Feb 27, 2024
cfedbb0
add deduplication to sqlite adapter batch save;
chrisbc Feb 27, 2024
7b578cd
commenting
chrisbc Feb 27, 2024
40bff41
changelog
chrisbc Feb 27, 2024
0fd4e35
added python-dotenv; .env support; fixed tests to use tempfile properly;
chrisbc Feb 28, 2024
1280759
fix breaking cache put test; WIP;
chrisbc Feb 28, 2024
3e9ed96
update to pynamodb>=6;
chrisbc Feb 29, 2024
439b0d4
WIP on serialization improvements;
chrisbc Feb 29, 2024
d1ef3de
more serialisation WIP
chrisbc Mar 1, 2024
0707287
refactoring WIP;
chrisbc Mar 4, 2024
09e139e
test coverage on db_adapter for custom attributes;
chrisbc Mar 4, 2024
d223a55
more cover and fixes for custom attributes
chrisbc Mar 4, 2024
b4207fc
formatting
chrisbc Mar 4, 2024
fc0e2c8
detox; tests passing;
chrisbc Mar 4, 2024
65d6db4
format; log level tweak;
chrisbc Mar 5, 2024
6f347c9
updated docs
chrisbc Mar 6, 2024
9ee00df
resolved merge conflicts on main
chrisbc Mar 6, 2024
8697193
add auto-configuration
chrisbc Mar 6, 2024
7314c70
added rev4 table CompatibleHazardCalculation
chrisbc Mar 6, 2024
0e0c4ce
WIP on new tables
chrisbc Mar 6, 2024
6cb0296
WIP on adding support for renamed attributes;
chrisbc Mar 6, 2024
a3bb63e
added HazardRealizationCurve table;
chrisbc Mar 6, 2024
f0a53f6
HazardRealizationCurve is now LocationIndexedModel; basic test harness;
chrisbc Mar 7, 2024
be73bf1
formatting
chrisbc Mar 7, 2024
a5ec1ca
HazardRealizationCurve is now LocationIndexedModel; basic test harness;
chrisbc Mar 7, 2024
ce9d6fc
added export_rev4 and new user script;
chrisbc Mar 7, 2024
fae8f96
formatting; fix tests
chrisbc Mar 8, 2024
4df3c47
test script
chrisbc Mar 8, 2024
8cae1cc
configure logging and error handler for batch ops
chrisbc Mar 11, 2024
2899861
add cdc test with logging
chrisbc Mar 11, 2024
9307525
merge complete
chrisbc Mar 12, 2024
071112f
WIP on new models; new store_hazard_v4; detox;
chrisbc Mar 12, 2024
3a3aa45
WIP refactoring HazardRealizatioCurve model
chrisbc Mar 14, 2024
f264d39
detoxed; WIP on rev models
chrisbc Mar 15, 2024
6855a5a
WIP on THS_R4_import script
chrisbc Mar 19, 2024
20a802a
using local nzshm-model; reorg logging setup in new script; add loggi…
chrisbc Mar 20, 2024
bf07268
WIP on rev4 importing;
chrisbc Mar 21, 2024
2a639e7
WIP on producer_config keys;
chrisbc Mar 21, 2024
55dac7d
WIP on ProducerConfig table;
chrisbc Mar 21, 2024
acec559
1 failing test; WIP on versioning;
chrisbc Mar 24, 2024
46f1ec4
1 failing test; WIP on versioning;
chrisbc Mar 24, 2024
dfcc5db
remove version attribute from primary key;
chrisbc Mar 24, 2024
b0fffbc
WIP on version SQL;
chrisbc Mar 25, 2024
2156548
db_adapter tests working
chrisbc Mar 25, 2024
2dc549f
WIP on test fixes;
chrisbc Mar 25, 2024
4fc8271
all tests OK; pickling some attributes that should be (de)serialising;
chrisbc Mar 25, 2024
3305e24
new script thd_r4_query; import producers;
chrisbc Mar 27, 2024
59bb0bd
import rlzs with script
chrisbc Mar 27, 2024
134044f
detox
chrisbc Mar 30, 2024
040d25a
get vs30 from config;
chrisbc Mar 30, 2024
81421fd
update nzxshm-model; openquake rlz mappings;
chrisbc Mar 30, 2024
8130e48
WIP on hazard rev4 importer
chrisbc Mar 31, 2024
3b1a981
comparing v3 v4 import performance
chrisbc Apr 1, 2024
f2c9f9d
WIP on ths_r4_import
chrisbc Apr 3, 2024
9c8f5f6
WIP: migrate local->local working
chrisbc Apr 3, 2024
a4a39e3
migrate from cloud -> local
chrisbc Apr 4, 2024
943a565
added count to sqlite adapter;
chrisbc Apr 5, 2024
b13695b
WIP on importing; migrating; sanity checking;
chrisbc Apr 5, 2024
e4f5bee
add proper rebase roundtrip - this is asymetric;
chrisbc Apr 7, 2024
f56287b
count fixes
chrisbc Apr 7, 2024
4125ed9
WIP on import & sanity tests
chrisbc Apr 7, 2024
17924da
detox;
chrisbc Apr 8, 2024
1a4666a
T1 write with batched df tables
chrisbc Apr 8, 2024
82eb80b
tweaks to manage historic calculations;
chrisbc Apr 10, 2024
ebb1f5e
simplify R4 model to use singular hash_digest refs
chrisbc Apr 10, 2024
f9a2351
WIP on model migration and pyarrow!
chrisbc Apr 10, 2024
aaaec5b
as used to build & check dataset: pq-CDC2
chrisbc Apr 10, 2024
c6bc6c0
WIP
chrisbc Apr 11, 2024
fb76946
WIP produced sample sets for THP testing_
chrisbc May 4, 2024
7f8db01
migrate to nzshm-common#pre-release
chrisbc May 6, 2024
2ee22b9
add cli options; dont use get_secret() in scripts... too slow;
chrisbc May 7, 2024
39af4ed
refactoring module structure; detoxed;
chrisbc May 7, 2024
82985c7
added HazardAggregateCurve with datset helper;
chrisbc May 7, 2024
e707875
update workflow for pre-release
chrisbc May 7, 2024
ca7b9ca
add option to configure a pyarrow.fs.FileSystem to new dataset helper
chrisbc May 8, 2024
cb39ee9
use pre-release branch of nzshm-model
chrisbc May 9, 2024
5e792ec
update lock file
chrisbc May 9, 2024
3057e22
first working realisations test
chrisbc May 9, 2024
7943488
exploring the disagg hdf5 content
chrisbc May 9, 2024
68433c7
WIP on direct extraction
chrisbc May 10, 2024
68479cf
WIP on direct saving rlzs;
chrisbc May 11, 2024
4223af8
simplify and overhaul ths_r4_import script;
chrisbc May 11, 2024
2ff2a7b
WIP on disagg extracts hfd5 vs csv
chrisbc May 13, 2024
0c004cb
WIP on parquet validations. CDC4 sets have issues for non PGA curves.
chrisbc May 13, 2024
396c785
sanity test hdf5 vs csv
chrisbc May 13, 2024
e060bd2
import direct
chrisbc May 15, 2024
7eba91f
fix tests broken after module refactoring;
chrisbc May 24, 2024
0ce1424
added latest scripts: filter_datasets + ths_r4_sanity;
chrisbc May 24, 2024
1461058
detox; updated changelog;
chrisbc May 24, 2024
26e55ab
move v3 and older scripts into legacy package; add new script docs;
chrisbc May 27, 2024
e98430c
doc improvements; docs layout; theme switcher; update mkdocs libs;
chrisbc May 27, 2024
7299a39
simplify tagging in CHANGELOG;
chrisbc May 27, 2024
f3e1984
Bump version: 0.8.0 → 0.9.0
chrisbc May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.9
current_version = 0.9.0
commit = True
tag = True

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ name: dev workflow

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
branches: [ main, pre-release ]
pull_request:
branches: [ main ]
branches: [ main, pre-release ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
39 changes: 38 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
# Changelog

## [0.7.9] - 2024-02-26
## [0.9.0] - 2024-05-27

### Added
- V4 epic tables
- parquet support
- new scripts:
- ths_r4_filter_dataset
- ths_r4_import
- ths_r4_migrate
- ths_r4_query
- migration/ths_r4_sanity
- extract datasets directly from hdf5
- more documtention

### Changed
- switch to nzshm-common#pre-release branch
- switch to nzshm-model#pre-release branch
- move outdated scripts to scripts/legacy
- new documentation theme

## [0.8.0] - 2024-02
### Added
- db_adapter architecture
- sqlite3 as db_adapter for localstorage option
- new envionment varisbale for localstorage
- more documentation
- use tmp_path for new localstorage tests
- db_adapter supports SS field type
- dynamodb unique behaviour implement in sqlite
- support for .env configuration (using python-dotenv)

### Changed
- update openquake dependency for NSHM GSIMs
- drop python 3.8 and update deps for openquake
- more test coverage
- refactor tests to use temporary folders correctly
- migrated to pynamodb>=6.0

## [0.7.9] - 2024-02-26
### Changed
- dependencies for compatibility with openquake-engine v3.19

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
* PyPI: <https://pypi.org/project/toshi-hazard-store/>
* Free software: GPL-3.0-only


This library provides different hazard storage options used withon NSHM hazard pipelines. Third parties may wish to
process models based on, or similar in scale to the NZSHM 22.

## Features

* Main purpose is to upload Openquake hazard results to a DynamodDB tables defined herein.
* relates the results to the toshi hazard id identifying the OQ hazard job run.
* extracts metadata from the openquake hdf5 solution
* Extract realisations from PSHA (openquake) hazard calcs and store these in Parquet dataset.
* Manage Openquake hazard results in AWS DynamodDB tables defined herein (used by NSHM project).
* CLI tools for end users
* **Legacy features:**
* Option for caching using sqlite, See NZSHM22_HAZARD_STORE_LOCAL_CACHE environment variable.
* Option to use a local sqlite store instead of DynamoDB, see THS_USE_SQLITE_ADAPTER and THS_SQLITE_FOLDER variables.

## Credits

Expand Down
8 changes: 7 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
::: toshi_hazard_store
## Hazard Queries

::: toshi_hazard_store.query.hazard_query

## Gridded Hazard Queries

::: toshi_hazard_store.query.gridded_hazard_query
18 changes: 18 additions & 0 deletions docs/cli/legacy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CLI Reference (Legacy)

This page provides documentation for our command line tools.

These scripts relate to V3 and earlier THS dynamodDB models. These are
superceded by revision_4 for new hazard calculations from May 2024.

::: mkdocs-click
:module: scripts.legacy.ths_testing
:command: cli
:prog_name: ths_testing

::: mkdocs-click
:module: scripts.legacy.ths_cache
:command: cli
:prog_name: ths_cache

This module maybe deprecated
12 changes: 12 additions & 0 deletions docs/cli/store_hazard_v4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.store_hazard_v4
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.store_hazard_v4
:command: main
:prog_name: store_hazard_v4
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_defrag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_defrag
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_defrag
:command: main
:prog_name: ths_r4_defrag
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_filter_dataset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_filter_dataset
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_filter_dataset
:command: main
:prog_name: ths_r4_filter_dataset
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_import
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_import
:command: main
:prog_name: ths_r4_import
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_migrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_migrate
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_migrate
:command: main
:prog_name: ths_r4_migrate
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_query
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_query
:command: main
:prog_name: ths_r4_query
:depth: 1
12 changes: 12 additions & 0 deletions docs/cli/ths_r4_sanity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
::: scripts.ths_r4_sanity
:depth: 1
options:
members: no

# Click CLI documentation

::: mkdocs-click
:module: scripts.ths_r4_sanity
:command: main
:prog_name: ths_r4_sanity
:depth: 1
75 changes: 75 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Configuration


The toshi_hazard_store project was originally designed to support the AWS Dynamodb database service. It now provides an option
to use a local sqlite3 store as an alternative.

Caveats for local storage:

- a complete model (e.g. the NSHM_v1.0.4 dataset) will likely prove too large for this option.
- this is a single-user solution.
- we provide no way to migrate data between storage backends (although in principle this should be relatively easy)


Run-time options let you configure the library for your use-case. Settings are made using environment variables, and/or a local `.env` (dotenv) file see [python-dotenv](https://github.com/theskumar/python-dotenv).

The '.env' file should be created in the folder from where the python interpreter is invoked - typically the root folder of your project.


### General settings

| | Default | Description | for Cloud | for Local |
|---------|---------|-------------|-----------|-----------|
| **NZSHM22_HAZARD_STORE_STAGE** | None | descriminator for table names | Required | Required |
| **NZSHM22_HAZARD_STORE_NUM_WORKERS** | 1 | number of parallel workers for batch operations | Optional integer | NA (single worker only) |
| **THS_USE_SQLITE_ADAPTER** | FALSE | use local (sqlite) storage? | NA | TRUE |


### Cloud settings

The NZSHM toshi-hazard-store database is available for public, read-only access using AWS API credentials (contact via email: [email protected]).

- AWS credentials will be provided with so-called `short-term credentials` in the form of an `awx_access_key_id` and and `aws_access_key_secret`.

- Typically these are configured in your local credentials file as described in [Authenticate with short-term credentials](https://docs.aws.amazon.com/cli/v1/userguide/cli-authentication-short-term.html).

- An `AWS_PROFILE` environment variable determines the credentials used at run-time by THS.


| | Default | Description | for Cloud | for Local |
|---------|---------|-------------|-----------|-----------|
| **AWS_PROFILE** | None | Name of your AWS credentials | Required | N/A |
| **NZSHM22_HAZARD_STORE_REGION** | None | AWS regaion e.g us-east-1 | Required | N/A |
| **NZSHM22_HAZARD_STORE_LOCAL_CACHE** | None | folder for local cache | Optional (leave unset to disable caching)| N/A |



### Local (off-cloud) settings

| | Default | Description | for Cloud | for Local |
|---------|---------|-------------|-----------|-----------|
| **THS_SQLITE_FOLDER** | None | folder for local storage | N/A | Required


## Example .env file

```
# GENERAL settings
NZSHM22_HAZARD_STORE_STAGE=TEST
NZSHM22_HAZARD_STORE_NUM_WORKERS=4

# IMPORTANT !!
THS_USE_SQLITE_ADAPTER=TRUE

# CLOUD settings
AWS_PROFILE={YOUR AWS PROFILE}
NZSHM22_HAZARD_STORE_REGION={us-east-1)

# LOCAL Caching (Optional, cloud only)
NZSHM22_HAZARD_STORE_LOCAL_CACHE=/home/chrisbc/.cache/toshi_hazard_store

# LOCAL Storage settings
THS_SQLITE_FOLDER=/GNSDATA/LIB/toshi-hazard-store/LOCALSTORAGE
```

These settings can be overridden by specifiying values in the local environment.
62 changes: 62 additions & 0 deletions docs/domain_model/disaggregation_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
**Tables:**

- **DisaggAggregationExceedance** - Disaggregation curves of Probablity of Exceedance
- **DisaggAggregationOccurence** - Disaggregation curves of Probablity of Occurence

The base class **LocationIndexedModel** provides common attributes and indexing for models that support location-based indexing.

The base class **DisaggAggregationBase** defines attribtues common to both types of disaggregation curve.

```mermaid
classDiagram
direction TB

class LocationIndexedModel {

partition_key = UnicodeAttribute(hash_key=True) # For this we will use a downsampled location to 1.0 degree
sort_key = UnicodeAttribute(range_key=True)

nloc_001 = UnicodeAttribute() # 0.001deg ~100m grid
nloc_01 = UnicodeAttribute() # 0.01deg ~1km grid
nloc_1 = UnicodeAttribute() # 0.1deg ~10km grid
nloc_0 = UnicodeAttribute() # 1.0deg ~100km grid

version = VersionAttribute()
uniq_id = UnicodeAttribute()

lat = FloatAttribute() # latitude decimal degrees
lon = FloatAttribute() # longitude decimal degrees

vs30 = EnumConstrainedIntegerAttribute(VS30Enum)
site_vs30 = FloatAttribute(null=True)

created = TimestampAttribute(default=datetime_now)

}

class DisaggAggregationBase{
... fields from LocationIndexedModel
hazard_model_id = UnicodeAttribute()
imt = EnumConstrainedUnicodeAttribute(IntensityMeasureTypeEnum)

hazard_agg = EnumConstrainedUnicodeAttribute(AggregationEnum) # eg MEAN
disagg_agg = EnumConstrainedUnicodeAttribute(AggregationEnum)

disaggs = CompressedPickleAttribute() # a very compressible numpy array,
bins = PickleAttribute() # a much smaller numpy array

shaking_level = FloatAttribute()
probability = EnumAttribute(ProbabilityEnum) # eg TEN_PCT_IN_50YRS
}

class DisaggAggregationExceedance{
... fields from DisaggAggregationBase
}

class DisaggAggregationOccurence{
... fields from DisaggAggregationBase
}
LocationIndexedModel <|-- DisaggAggregationBase
DisaggAggregationBase <| -- DisaggAggregationExceedance
DisaggAggregationBase <| -- DisaggAggregationOccurence
```
25 changes: 25 additions & 0 deletions docs/domain_model/gridded_hazard_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**Tables:**

- **GriddedHazard** - Grid points defined in location_grid_id has a values in grid_poes.
- **HazardAggregation** - stores aggregate hazard curves [see ./openquake_models for details](./openquake_models.md)

```mermaid
classDiagram
direction LR

class GriddedHazard{
partition_key = UnicodeAttribute(hash_key=True)
sort_key = UnicodeAttribute(range_key=True)
version = VersionAttribute()
created = TimestampAttribute(default=datetime_now)
hazard_model_id = UnicodeAttribute()
location_grid_id = UnicodeAttribute()
vs30 = EnumConstrainedIntegerAttribute(VS30Enum)
imt = EnumConstrainedUnicodeAttribute(IntensityMeasureTypeEnum)
agg = EnumConstrainedUnicodeAttribute(AggregationEnum)
poe = FloatAttribute()
grid_poes = CompressedListAttribute()
}

GriddedHazard --> "1..*" HazardAggregation
```
Loading
Loading