diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..85e6298e --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,19 @@ +name: Run all tests +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + architecture: x64 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + - run: pip install -r requirements.txt + - run: pytest tests diff --git a/.gitignore b/.gitignore index d12b09cb..79384561 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .ve *.swp *~ +tests/__pycache__ diff --git a/developer_docs.md b/developer_docs.md index 4b309d2e..cb16de5d 100644 --- a/developer_docs.md +++ b/developer_docs.md @@ -129,6 +129,34 @@ python -m http.server --directory _build/html ### Resolve check failures +#### tests + +If this check fails, review the output to identify which test failed: + +##### test_json.py::test_empty + +Review the warnings to identify the empty JSON files and remove the files. + +##### test_json.py::test_indent + +Run the following command to indent JSON files: + +```bash +ocdskit indent -r . +``` + +##### test_json.py::test_invalid_json + +Review the warnings to identify the invalid JSON files and correct the errors. + +##### test_schema.py (all tests) + +Review the warnings to identify and correct the errors. For more information on each test, see https://jscc.readthedocs.io/en/latest/api/testing/checks.html#module-jscc.testing.checks. + +#### test_csv.py + +Review the warnings to identify and correct the errors. + #### mdformat If this check fails, run the following command to fix markdown formatting: diff --git a/requirements.in b/requirements.in index 4ecd45d4..ab43ad1f 100644 --- a/requirements.in +++ b/requirements.in @@ -9,4 +9,8 @@ sphinx-intl #transifex-client sphinx_rtd_theme myst-parser -mdformat-myst +pytest +jscc +ocdskit +mdformat +jsonschema diff --git a/requirements.txt b/requirements.txt index 8cbc8e8d..2d4af5fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,10 +6,17 @@ # alabaster==0.7.12 # via sphinx +attrs==23.1.0 + # via + # cattrs + # jsonschema + # requests-cache babel==2.11.0 # via # sphinx # sphinx-intl +cattrs==22.2.0 + # via requests-cache certifi==2022.12.7 # via requests charset-normalizer==2.1.0 @@ -28,18 +35,35 @@ docutils==0.17.1 # sphinxcontrib-opendataservices-jsonschema idna==3.4 # via requests +ijson==3.2.0.post0 + # via ocdskit imagesize==1.4.1 # via sphinx +iniconfig==2.0.0 + # via pytest jinja2==3.1.2 # via # myst-parser # sphinx +jscc==0.2.2 + # via -r requirements.in +json-merge-patch==0.2 + # via + # jscc + # ocdsextensionregistry jsonpointer==2.3 # via # sphinxcontrib-opendataservices # sphinxcontrib-opendataservices-jsonschema jsonref==1.0.1 - # via sphinxcontrib-opendataservices-jsonschema + # via + # jscc + # ocdsextensionregistry + # ocdskit + # ocdsmerge + # sphinxcontrib-opendataservices-jsonschema +jsonschema==4.17.3 + # via -r requirements.in livereload==2.6.3 # via sphinx-autobuild markdown-it-py==2.1.0 @@ -72,24 +96,43 @@ myst-parser==0.18.1 # -r requirements.in # sphinxcontrib-opendataservices # sphinxcontrib-opendataservices-jsonschema +ocdsextensionregistry==0.2.0 + # via ocdskit +ocdskit==1.1.5 + # via -r requirements.in +ocdsmerge==0.6.6 + # via ocdskit packaging==22.0 - # via sphinx + # via + # pytest + # sphinx +platformdirs==3.5.1 + # via requests-cache +pluggy==1.0.0 + # via pytest pygments==2.13.0 # via sphinx +pyrsistent==0.19.3 + # via jsonschema +pytest==7.3.1 + # via -r requirements.in pytz==2022.6 # via babel pyyaml==6.0 # via myst-parser requests==2.28.1 - # via sphinx -ruamel-yaml==0.17.32 # via - # mdformat-frontmatter - # mdformat-myst -ruamel-yaml-clib==0.2.7 - # via ruamel-yaml + # jscc + # ocdsextensionregistry + # ocdsmerge + # requests-cache + # sphinx +requests-cache==1.0.1 + # via ocdsextensionregistry six==1.16.0 - # via livereload + # via + # livereload + # url-normalize snowballstemmer==2.2.0 # via sphinx sphinx==5.3.0 @@ -136,8 +179,12 @@ tornado==6.2 # via livereload typing-extensions==4.4.0 # via myst-parser +url-normalize==1.4.3 + # via requests-cache urllib3==1.26.11 - # via requests + # via + # requests + # requests-cache wheel==0.40.0 # via sphinx-togglebutton diff --git a/schema/rdl_schema_0.1.json b/schema/rdl_schema_0.1.json index 0d021e02..1ffc9368 100644 --- a/schema/rdl_schema_0.1.json +++ b/schema/rdl_schema_0.1.json @@ -1,1030 +1,1045 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "http://riskdatalibrary.org/schemas/rdl_schema_v0_1.json", - "title": "Risk Data Library Schema", - "type": "object", - "required": [ - "title", - "abstract", - "component", - "organization", - "model_source", - "model_date", - "geo_coverage", - "publish", - "license_code", - "resources" - ], - "properties": { - "title": { - "type": "string", - "description": "Title of the dataset" - }, - "abstract": { - "type": "string", - "description": "Short description of the resource" - }, - "component": { - "type": "string", - "description": "Univocal schema for this contribution (H, E, V or L)", - "enum": [ - "Hazard", - "Exposure", - "Vulnerability", - "Loss" - ] - }, - "organization": { - "type": "string", - "description": "Name of organization that published the dataset" - }, - "model_source": { - "type": "string", - "description": "Name of source model" - }, - "model_date": { - "type": "string", - "description": "Model release date", - "format": "date" - }, - "version": { - "type": "integer", - "description": "Version of the dataset" - }, - "purpose": { - "type": "string", - "description": "Purpose for what the data has been produced" - }, - "project": { - "type": "string", - "description": "Project under which data has been produced" - }, - "notes": { - "type": "string", - "description": "Additional details about the dataset" - }, - "biblio_title": { - "type": "string", - "description": "Authors/year/title of publication" - }, - "biblio_url": { - "type": "string", - "description": "URL of publication", - "format": "uri" - }, - "geo_coverage": { - "$ref": "#/definitions/common_iso", - "description": "ISO code(s) of countries covered by the dataset, comma-separated" - }, - "publish": { - "type": "boolean", - "description": "Flag to show/hide dataset from website" - }, - "license_code": { - "$ref": "#/definitions/common_license", - "description": "Type of license" - }, - "maintainer": { - "type": "string", - "description": "Who added the resource" - }, - "maintainer_email": { - "type": "string", - "description": "Contact email" - }, - "resources": { - "type": "array", - "items": { - "resource": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://riskdatalibrary.org/schemas/rdl_schema_v0_1.json", + "title": "Risk Data Library Schema", + "type": "object", + "required": [ + "common" + ], + "properties": { + "common": { + "type": "object", + "properties": { + "contribution": { "type": "object", "required": [ - "name", - "format", - "epsg", - "url" + "title", + "abstract", + "component", + "organization", + "model_source", + "model_date", + "geo_coverage", + "publish", + "license_code", + "resources" ], "properties": { - "name": { + "title": { "type": "string", - "description": "Name of linked resource" + "description": "Title of the dataset" }, - "aggregation_type": { + "abstract": { "type": "string", - "description": "Level of data representation" + "description": "Short description of the resource" }, - "format": { + "component": { "type": "string", - "description": "Format of resource" + "description": "Univocal schema for this contribution (H, E, V or L)", + "enum": [ + "Hazard", + "Exposure", + "Vulnerability", + "Loss" + ] }, - "h-res": { + "organization": { "type": "string", - "description": "Horizontal resolution in meters (raster data only)" + "description": "Name of organization that published the dataset" }, - "epsg": { + "model_source": { "type": "string", - "description": "Reference coordinate system (default: 4326)" + "description": "Name of source model" }, - "url": { + "model_date": { "type": "string", - "description": "URL of linked resource" + "description": "Model release date", + "format": "date" + }, + "version": { + "type": "integer", + "description": "Version of the dataset" + }, + "purpose": { + "type": "string", + "description": "Purpose for what the data has been produced" + }, + "project": { + "type": "string", + "description": "Project under which data has been produced" + }, + "notes": { + "type": "string", + "description": "Additional details about the dataset" + }, + "biblio_title": { + "type": "string", + "description": "Authors/year/title of publication" + }, + "biblio_url": { + "type": "string", + "description": "URL of publication", + "format": "uri" + }, + "geo_coverage": { + "$ref": "#/definitions/common_iso", + "description": "ISO code(s) of countries covered by the dataset, comma-separated" + }, + "publish": { + "type": "boolean", + "description": "Flag to show/hide dataset from website" + }, + "license_code": { + "$ref": "#/definitions/common_license", + "description": "Type of license" + }, + "maintainer": { + "type": "string", + "description": "Who added the resource" + }, + "maintainer_email": { + "type": "string", + "description": "Contact email" + } + } + }, + "resources": { + "type": "array", + "items": { + "resource": { + "type": "object", + "required": [ + "name", + "format", + "epsg", + "url" + ], + "properties": { + "name": { + "type": "string", + "description": "Name of linked resource" + }, + "aggregation_type": { + "type": "string", + "description": "Level of data representation" + }, + "format": { + "type": "string", + "description": "Format of resource" + }, + "h-res": { + "type": "string", + "description": "Horizontal resolution in meters (raster data only)" + }, + "epsg": { + "type": "string", + "description": "Reference coordinate system (default: 4326)" + }, + "url": { + "type": "string", + "description": "URL of linked resource" + } + } + } + } + } + } + } + }, + "anyOf": [ + { + "type": "object", + "title": "hazard", + "properties": { + "hazard": { + "type": "object", + "required": [ + "event_set", + "event", + "footprint_set" + ], + "properties": { + "event_set": { + "type": "object", + "required": [ + "hazard_type", + "analysis_type" + ], + "properties": { + "hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Type of hazard modelled" + }, + "analysis_type": { + "$ref": "#/definitions/common_analysis_type", + "description": "Type of analysis, probabilistic or deterministic" + }, + "geo_area": { + "type": "array", + "description": "The name of the geographic area covered by the hazard analysis. Comma-separated list of geographic names.", + "items": { + "type": "string" + } + }, + "time_start": { + "type": "string", + "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", + "format": "date" + }, + "time_end": { + "type": "string", + "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", + "format": "date" + }, + "time_span": { + "type": "string", + "description": "The extent of the time period covered by the events included in the current scenario hazard analysis [ISO 8601 format]" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + } + } + }, + "event": { + "type": "object", + "required": [ + "calculation_method", + "frequency_type" + ], + "properties": { + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of this event" + }, + "frequency_type": { + "$ref": "#/definitions/common_frequency_type", + "description": "Frequency representation type" + }, + "return_period": { + "type": "string", + "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" + }, + "occurence_time_start": { + "type": "string", + "description": "The start date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", + "format": "date-time" + }, + "occurence_time_end": { + "type": "string", + "description": "The end date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", + "format": "date-time" + }, + "occurence_time_span": { + "type": "string", + "description": "The duration (years) of the period used to specify either the frequency or the occurrence_probability" + }, + "trigger_hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Hazard type that triggered the event" + }, + "trigger_process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Process type that triggered the event" + }, + "description": { + "type": "string", + "description": "Provides additional information about this specific event" + } + } + }, + "footprint_set": { + "type": "object", + "properties": { + "process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Type of hazard process modelled" + }, + "imt": { + "$ref": "#/definitions/im_code", + "description": "Hazard intensity measure unit" + }, + "data_uncertainty": { + "type": "string", + "description": "Comments about the uncertainty of data" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "exposure", + "properties": { + "exposure": { + "type": "object", + "required": [ + "model", + "value" + ], + "properties": { + "model": { + "type": "object", + "required": [ + "category", + "occupancy" + ], + "properties": { + "category": { + "description": "Type of asset", + "$ref": "#/definitions/common_exp_category" + }, + "occupancy": { + "description": "Destination of use of the asset", + "$ref": "#/definitions/common_exp_occupancy" + }, + "occupancy_time": { + "description": "Period of occupancy, if appliable (e.g. Population)", + "$ref": "#/definitions/common_occupancy_time" + }, + "taxonomy_source": { + "type": "string", + "description": "Name of taxonomy source (default is GED4ALL)", + "default": "GED4ALL" + }, + "taxonomy_code": { + "type": "string", + "description": "Alphanumeric code for the taxonomy source (based on GED4ALL)" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + }, + "add_attributes": { + "type": "string", + "description": "List of key attributes included in the dataset" + } + } + }, + "value": { + "type": "object", + "properties": { + "val_type": { + "description": "Type of asset value", + "$ref": "#/definitions/common_exp_val_type" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "vulnerability", + "properties": { + "vulnerability": { + "type": "object", + "properties": { + "model": { + "type": "object", + "properties": { + "hazard_type_primary": { + "description": "Primary hazard involved", + "$ref": "#/definitions/common_hazard_type" + }, + "hazard_type_secondary": { + "description": "Secondary hazard involved", + "$ref": "#/definitions/common_hazard_type" + }, + "process_type_primary": { + "description": "Primary process involved", + "$ref": "#/definitions/common_process_type" + }, + "process_type_secondary": { + "description": "Secondary process involved", + "$ref": "#/definitions/common_process_type" + }, + "frequency_type": { + "description": "Frequency representation type", + "$ref": "#/definitions/common_frequency_type" + }, + "imt": { + "description": "Hazard intensity measure unit", + "$ref": "#/definitions/im_code" + }, + "category": { + "description": "Type of asset", + "$ref": "#/definitions/common_exp_category" + }, + "occupancy": { + "description": "Type of occupancy to which function applies", + "$ref": "#/definitions/common_exp_occupancy" + }, + "val_type": { + "description": "Type of asset value", + "$ref": "#/definitions/common_exp_val_type" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + }, + "taxonomy_source": { + "type": "string", + "description": "Source of taxonomy" + }, + "taxonomy_code": { + "type": "string", + "description": "Taxonomy code to which function applies" + }, + "impact_type": { + "description": "Type of impact", + "$ref": "#/definitions/common_impact_type" + }, + "scale_applicability": { + "description": "Administrative level of application", + "$ref": "#/definitions/common_aggregation_type" + }, + "country_tranferability": { + "description": "ISOa3 list of countries in which the model could be applied", + "$ref": "#/definitions/common_iso" + }, + "local_applicability": { + "type": "string", + "description": "Area within a country or region to wich the model specifically applies" + }, + "transferability_notes": { + "type": "string", + "description": "Details about applicability to different areas" + }, + "function_type": { + "$ref": "#/definitions/vulnerability_function_type", + "description": "Type of function" + }, + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of the function" + }, + "approach": { + "$ref": "#/definitions/vulnerability_f_subtype", + "description": "Type of methodological approach" + }, + "f_relationship": { + "$ref": "#/definitions/vulnerability_f_relationship", + "description": "Type of relationship: Mathematical or Discrete" + }, + "f_math": { + "$ref": "#/definitions/vulnerability_f_math", + "description": "Parametric or bespoke" + } + } + }, + "specifics": { + "type": "object", + "properties": { + "analysis_details": { + "description": "Description of analysis that produced the function", + "type": "string" + }, + "par_names": { + "type": "string", + "description": "Parameters considered by the function" + }, + "im_name": { + "type": "string", + "description": "Name of loss intensity measure" + }, + "im_units": { + "type": "string", + "description": "Unit of loss intensity measure" + }, + "n_events": { + "type": "integer", + "description": "Number of events the function has been built on" + }, + "n_assets": { + "type": "integer", + "description": "Number of assets the function has been built on" + }, + "is_fit_good": { + "type": "boolean", + "description": "Is the fit good overall?" + }, + "is_edp_thre": { + "type": "boolean", + "description": "Is the damage scale is associated to an engineered-design parameter threshold?" + }, + "is_dm_factor": { + "type": "boolean", + "description": "Is the damage scale is associated to a damage factor?" + }, + "is_casualties": { + "type": "boolean", + "description": "Is the damage scale is associated to a casualties estimation?" + }, + "is_downtime": { + "type": "boolean", + "description": "Is the damage scale is associated to a downtime estimation (e.g. service interruption)?" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "loss", + "properties": { + "loss": { + "type": "object", + "properties": { + "model": { + "type": "object", + "properties": { + "hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Type of hazard modelled" + }, + "process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Type of hazard process modelled" + }, + "time_start": { + "type": "string", + "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", + "format": "date" + }, + "time_end": { + "type": "string", + "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", + "format": "date" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + }, + "occupancy": { + "$ref": "#/definitions/common_exp_occupancy", + "description": "Destination of use of the asset" + }, + "category": { + "$ref": "#/definitions/common_exp_category", + "description": "Exposure category" + }, + "val_type": { + "$ref": "#/definitions/common_exp_val_type", + "description": "Element on which loss insist" + }, + "impact": { + "$ref": "#/definitions/common_impact_type", + "description": "Type of impact" + }, + "loss_type": { + "$ref": "#/definitions/loss_loss_type", + "description": "Type of loss" + }, + "frequency": { + "$ref": "#/definitions/common_frequency_type", + "description": "Frequency representation type" + }, + "return_period": { + "type": "string", + "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" + }, + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of this event" + }, + "metric": { + "$ref": "#/definitions/loss_metric", + "description": "Type of loss metric" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + }, + "hazard_link": { + "type": "string", + "description": "URL of source hazard data", + "format": "uri" + }, + "exposure_link": { + "type": "string", + "description": "URL of source exposure data", + "format": "uri" + }, + "vulnerability_link": { + "type": "string", + "description": "URL of source vulnerability data", + "format": "uri" + } + } } } } } } - }, - "anyOf": [ - { - "type": "object", - "title": "hazard", - "properties": { - "hazard": { - "type": "object", - "required": [ - "event_set", - "event", - "footprint_set" - ], - "properties": { - "event_set": { - "type": "object", - "required": [ - "hazard_type", - "analysis_type" - ], - "properties": { - "hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Type of hazard modelled" - }, - "analysis_type": { - "$ref": "#/definitions/common_analysis_type", - "description": "Type of analysis, probabilistic or deterministic" - }, - "geo_area": { - "type": "array", - "description": "The name of the geographic area covered by the hazard analysis. Comma-separated list of geographic names.", - "items": { - "type": "string" - } - }, - "time_start": { - "type": "string", - "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", - "format": "date" - }, - "time_end": { - "type": "string", - "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", - "format": "date" - }, - "time_span": { - "type": "string", - "description": "The extent of the time period covered by the events included in the current scenario hazard analysis [ISO 8601 format]" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - } - } - }, - "event": { - "type": "object", - "required": [ - "calculation_method", - "frequency_type" - ], - "properties": { - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of this event" - }, - "frequency_type": { - "$ref": "#/definitions/common_frequency_type", - "description": "Frequency representation type" - }, - "return_period": { - "type": "string", - "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" - }, - "occurence_time_start": { - "type": "string", - "description": "The start date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", - "format": "date-time" - }, - "occurence_time_end": { - "type": "string", - "description": "The end date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", - "format": "date-time" - }, - "occurence_time_span": { - "type": "string", - "description": "The duration (years) of the period used to specify either the frequency or the occurrence_probability" - }, - "trigger_hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Hazard type that triggered the event" - }, - "trigger_process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Process type that triggered the event" - }, - "description": { - "type": "string", - "description": "Provides additional information about this specific event" - } - } - }, - "footprint_set": { - "type": "object", - "properties": { - "process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Type of hazard process modelled" - }, - "imt": { - "$ref": "#/definitions/im_code", - "description": "Hazard intensity measure unit" - }, - "data_uncertainty": { - "type": "string", - "description": "Comments about the uncertainty of data" - } - } - } - } - } - } - }, - { - "type": "object", - "title": "exposure", - "properties": { - "exposure": { - "type": "object", - "required": [ - "model", - "value" - ], - "properties": { - "model": { - "type": "object", - "required": [ - "category", - "occupancy" - ], - "properties": { - "category": { - "description": "Type of asset", - "$ref": "#/definitions/common_exp_category" - }, - "occupancy": { - "description": "Destination of use of the asset", - "$ref": "#/definitions/common_exp_occupancy" - }, - "occupancy_time": { - "description": "Period of occupancy, if appliable (e.g. Population)", - "$ref": "#/definitions/common_occupancy_time" - }, - "taxonomy_source": { - "type": "string", - "description": "Name of taxonomy source (default is GED4ALL)", - "default": "GED4ALL" - }, - "taxonomy_code": { - "type": "string", - "description": "Alphanumeric code for the taxonomy source (based on GED4ALL)" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - }, - "add_attributes": { - "type": "string", - "description": "List of key attributes included in the dataset" - } - } - }, - "value": { - "type": "object", - "properties": { - "val_type": { - "description": "Type of asset value", - "$ref": "#/definitions/common_exp_val_type" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - } - } - } - } - } - } - }, - { - "type": "object", - "title": "vulnerability", - "properties": { - "vulnerability": { - "type": "object", - "properties": { - "model": { - "type": "object", - "properties": { - "hazard_type_primary": { - "description": "Primary hazard involved", - "$ref": "#/definitions/common_hazard_type" - }, - "hazard_type_secondary": { - "description": "Secondary hazard involved", - "$ref": "#/definitions/common_hazard_type" - }, - "process_type_primary": { - "description": "Primary process involved", - "$ref": "#/definitions/common_process_type" - }, - "process_type_secondary": { - "description": "Secondary process involved", - "$ref": "#/definitions/common_process_type" - }, - "frequency_type": { - "description": "Frequency representation type", - "$ref": "#/definitions/common_frequency_type" - }, - "imt": { - "description": "Hazard intensity measure unit", - "$ref": "#/definitions/im_code" - }, - "category": { - "description": "Type of asset", - "$ref": "#/definitions/common_exp_category" - }, - "occupancy": { - "description": "Type of occupancy to which function applies", - "$ref": "#/definitions/common_exp_occupancy" - }, - "val_type": { - "description": "Type of asset value", - "$ref": "#/definitions/common_exp_val_type" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - }, - "taxonomy_source": { - "type": "string", - "description": "Source of taxonomy" - }, - "taxonomy_code": { - "type": "string", - "description": "Taxonomy code to which function applies" - }, - "impact_type": { - "description": "Type of impact", - "$ref": "#/definitions/common_impact_type" - }, - "scale_applicability": { - "description": "Administrative level of application", - "$ref": "#/definitions/common_aggregation_type" - }, - "country_tranferability": { - "description": "ISOa3 list of countries in which the model could be applied", - "$ref": "#/definitions/common_iso" - }, - "local_applicability": { - "type": "string", - "description": "Area within a country or region to wich the model specifically applies" - }, - "transferability_notes": { - "type": "string", - "description": "Details about applicability to different areas" - }, - "function_type": { - "$ref": "#/definitions/vulnerability_function_type", - "description": "Type of function" - }, - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of the function" - }, - "approach": { - "$ref": "#/definitions/f_subtype", - "description": "Type of methodological approach" - }, - "f_relationship": { - "$ref": "#/definitions/vulnerability_f_relationship", - "description": "Type of relationship: Mathematical or Discrete" - }, - "f_math": { - "$ref": "#/definitions/vulnerability_f_math", - "description": "Parametric or bespoke" - } - } - }, - "specifics": { - "type": "object", - "properties": { - "analysis_details": { - "description": "Description of analysis that produced the function", - "type": "string" - }, - "par_names": { - "type": "string", - "description": "Parameters considered by the function" - }, - "im_name": { - "type": "string", - "description": "Name of loss intensity measure" - }, - "im_units": { - "type": "string", - "description": "Unit of loss intensity measure" - }, - "n_events": { - "type": "integer", - "description": "Number of events the function has been built on" - }, - "n_assets": { - "type": "integer", - "description": "Number of assets the function has been built on" - }, - "is_fit_good": { - "type": "boolean", - "description": "Is the fit good overall?" - }, - "is_edp_thre": { - "type": "boolean", - "description": "Is the damage scale is associated to an engineered-design parameter threshold?" - }, - "is_dm_factor": { - "type": "boolean", - "description": "Is the damage scale is associated to a damage factor?" - }, - "is_casualties": { - "type": "boolean", - "description": "Is the damage scale is associated to a casualties estimation?" - }, - "is_downtime": { - "type": "boolean", - "description": "Is the damage scale is associated to a downtime estimation (e.g. service interruption)?" - } - } - } - } - } - } - }, - { - "type": "object", - "title": "loss", - "properties": { - "loss": { - "type": "object", - "properties": { - "model": { - "type": "object", - "properties": { - "hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Type of hazard modelled" - }, - "process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Type of hazard process modelled" - }, - "time_start": { - "type": "string", - "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", - "format": "date" - }, - "time_end": { - "type": "string", - "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", - "format": "date" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - }, - "occupancy": { - "$ref": "#/definitions/common_exp_occupancy", - "description": "Destination of use of the asset" - }, - "category": { - "$ref": "#/definitions/common_exp_category", - "description": "Exposure category" - }, - "val_type": { - "$ref": "#/definitions/common_exp_val_type", - "description": "Element on which loss insist" - }, - "impact": { - "$ref": "#/definitions/common_impact_type", - "description": "Type of impact" - }, - "loss_type": { - "$ref": "#/definitions/loss_loss_type", - "description": "Type of loss" - }, - "frequency": { - "$ref": "#/definitions/common_frequency_type", - "description": "Frequency representation type" - }, - "return_period": { - "type": "string", - "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" - }, - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of this event" - }, - "metric": { - "$ref": "#/definitions/loss_metric", - "description": "Type of loss metric" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - }, - "hazard_link": { - "type": "string", - "description": "URL of source hazard data", - "format": "uri" - }, - "exposure_link": { - "type": "string", - "description": "URL of source exposure data", - "format": "uri" - }, - "vulnerability_link": { - "type": "string", - "description": "URL of source vulnerability data", - "format": "uri" - } - } - } - } - } - } - } - ], - "definitions": { - "common_aggregation_type": { - "type": "string", - "enum": [ - "Individual items", - "Aggregated to grid", - "Aggregated to boundaries", - "N/A" - ] - }, - "common_analysis_type": { - "type": "string", - "enum": [ - "Deterministic", - "Probabilistic" - ] - }, - "common_calc_method": { - "type": "string", - "enum": [ - "Inferred", - "Simulated", - "Observed" - ] - }, - "common_exp_category": { - "type": "string", - "enum": [ - "Buildings", - "Indicators", - "Infrastructures", - "Crops, livestock and forestry" - ] - }, - "common_exp_occupancy": { - "type": "string", - "enum": [ - "Residential", - "Commercial", - "Industrial", - "Infrastructure", - "Healthcare", - "Educational", - "Government", - "Crop", - "Livestock", - "Forestry", - "Mixed" - ] - }, - "common_exp_val_type": { - "type": "string", - "enum": [ - "Structure", - "Content", - "Product", - "Other" - ] - }, - "common_frequency_type": { - "type": "string", - "enum": [ - "Rate of Exceedence", - "Probability of Exceedence", - "Return Period" - ] - }, - "common_hazard_type": { - "type": "string", - "enum": [ - "CF", - "CS", - "DR", - "EQ", - "ET", - "FL", - "LS", - "MH", - "TS", - "VO", - "WF", - "WI" - ] - }, - "common_impact_type": { - "type": "string", - "enum": [ - "Direct", - "Indirect", - "Total" - ] - }, - "common_iso": { - "type": "string", - "enum": [ - "GLB", - "ABW", - "AFG", - "AGO", - "AIA", - "ALB", - "AND", - "ARE", - "ARG", - "ARM", - "ASM", - "ATG", - "AUS", - "AUT", - "AZE", - "BDI", - "BEL", - "BEN", - "BFA", - "BGD", - "BGR", - "BHR", - "BHS", - "BIH", - "BLM", - "BLR", - "BLZ", - "BMU", - "BOL", - "BRA", - "BRB", - "BRN", - "BTN", - "BWA", - "CAF", - "CAN", - "CHE", - "CHL", - "CHN", - "CIV", - "CMR", - "COD", - "COG", - "COK", - "COL", - "COM", - "CPV", - "CRI", - "CUB", - "CUW", - "CYM", - "CYP", - "CZE", - "DEU", - "DJI", - "DMA", - "DNK", - "DOM", - "DZA", - "ECU", - "EGY", - "ERI", - "ESP", - "EST", - "ETH", - "FIN", - "FJI", - "FLK", - "FRA", - "FRO", - "FSM", - "GAB", - "GBR", - "GEO", - "GGY", - "GHA", - "GIB", - "GIN", - "GMB", - "GNB", - "GNQ", - "GRC", - "GRD", - "GRL", - "GTM", - "GUM", - "GUY", - "HKG", - "HMD", - "HND", - "HRV", - "HTI", - "HUN", - "IDN", - "IMN", - "IND", - "IRL", - "IRN", - "IRQ", - "ISL", - "ISR", - "ITA", - "JAM", - "JEY", - "JOR", - "JPN", - "KAZ", - "KEN", - "KGZ", - "KHM", - "KIR", - "KNA", - "KOR", - "KWT", - "LAO", - "LBN", - "LBR", - "LBY", - "LCA", - "LIE", - "LKA", - "LSO", - "LTU", - "LUX", - "LVA", - "MAC", - "MAF", - "MAR", - "MCO", - "MDA", - "MDG", - "MDV", - "MEX", - "MHL", - "MKD", - "MLI", - "MLT", - "MMR", - "MNE", - "MNG", - "MNP", - "MOZ", - "MRT", - "MSR", - "MUS", - "MWI", - "MYS", - "NAM", - "NCL", - "NER", - "NFK", - "NGA", - "NIC", - "NIU", - "NLD", - "NOR", - "NPL", - "NRU", - "NZL", - "OMN", - "PAK", - "PAN", - "PCN", - "PER", - "PHL", - "PLW", - "PNG", - "POL", - "PRI", - "PRK", - "PRT", - "PRY", - "PSE", - "PYF", - "QAT", - "ROU", - "RUS", - "RWA", - "SAU", - "SDN", - "SEN", - "SGP", - "SGS", - "SHN", - "SLB", - "SLE", - "SLV", - "SMR", - "SOM", - "SPM", - "SRB", - "SSD", - "STP", - "SUR", - "SVK", - "SVN", - "SWE", - "SWZ", - "SXM", - "SYC", - "SYR", - "TCA", - "TCD", - "TGO", - "THA", - "TJK", - "TKM", - "TLS", - "TON", - "TTO", - "TUN", - "TUR", - "TUV", - "TZA", - "UGA", - "UKR", - "URY", - "USA", - "UZB", - "VAT", - "VCT", - "VEN", - "VGB", - "VIR", - "VNM", - "VUT", - "WLF", - "WSM", - "XXK", - "YEM", - "ZAF", - "ZMB", - "ZWE" - ] - }, - "common_license": { - "type": "string", - "enum": [ - "CC0-1.0", - "PDDL-1.0", - "CC-BY-4.0", - "ODC-By-1.0", - "CC-BY-SA-4.0", - "ODbL-1.0" - ] - }, - "common_occupancy_time": { - "type": "string", - "enum": [ - "Night", - "Day" - ] - }, - "common_process_type": { - "type": "string", - "enum": [ - "FCF", - "FSS", - "TOR", - "DTA", - "DTH", - "DTM", - "DTS", - "Q1R", - "Q2R", - "QGM", - "QLI", - "ECD", - "EHT", - "FFF", - "FPF", - "LAV", - "LSL", - "TSI", - "VAF", - "VBL", - "VFH", - "VLH", - "VLV", - "VPF", - "WFI", - "ETC", - "TCY" - ] - }, - "im_code": { - "type": "string", - "enum": [ - "PG+E47:E70A:g", - "PGA:m/s2", - "PGV:m/s", - "AvgSa:m/s2", - "Sd(T1):m", - "Sv(T1):m/s", - "PGDf:m", - "D:s", - "IA:m/s", - "Neq:-", - "EMS:-", - "MMI:-", - "CAV:m/s", - "D_B:s", - "fl_wd:m", - "fl_wv:m/s", - "v_ect(3s):km/h", - "v_ect(1m):km/h", - "v_etc(10m):km/h", - "PGWS_tcy:km/h", - "ls_fd:m", - "I_DF:m3/s2", - "v_lsl:m/s2", - "ls_mfd:m", - "SD_lsl:m", - "Rh_tsi:m", - "d_tsi:m", - "MMF:m4/s2", - "F_drag:kN", - "Fr:-", - "v_tsi:m/s", - "F_QS:kN", - "MF:m3/s2", - "h_tsi:m", - "Fh_tsi:m", - "h_vaf:m", - "L_vaf:kg/m2", - "CMI:-", - "PDSI:-", - "SPI:-" - ] - }, - "loss_loss_type": { - "type": "string", - "enum": [ - "Ground Up", - "Insured" - ] - }, - "loss_metric": { - "type": "string", - "enum": [ - "Annual Average Losses", - "Annual Average Loss Ratio", - "Probable Maximal Loss" - ] - }, - "vulnerability_function_type": { - "type": "string", - "enum": [ - "Fragility", - "Vulnerability", - "Damage-to-Loss" - ] - }, - "vulnerability_f_subtype": { - "type": "string", - "enum": [ - "Empirical", - "Analytical", - "Judgement", - "Hybrid" - ] - } - } + ], + "definitions": { + "common_aggregation_type": { + "type": "string", + "enum": [ + "Individual items", + "Aggregated to grid", + "Aggregated to boundaries", + "N/A" + ] + }, + "common_analysis_type": { + "type": "string", + "enum": [ + "Deterministic", + "Probabilistic" + ] + }, + "common_calc_method": { + "type": "string", + "enum": [ + "Inferred", + "Simulated", + "Observed" + ] + }, + "common_exp_category": { + "type": "string", + "enum": [ + "Buildings", + "Indicators", + "Infrastructures", + "Crops, livestock and forestry" + ] + }, + "common_exp_occupancy": { + "type": "string", + "enum": [ + "Residential", + "Commercial", + "Industrial", + "Infrastructure", + "Healthcare", + "Educational", + "Government", + "Crop", + "Livestock", + "Forestry", + "Mixed" + ] + }, + "common_exp_val_type": { + "type": "string", + "enum": [ + "Structure", + "Content", + "Product", + "Other" + ] + }, + "common_frequency_type": { + "type": "string", + "enum": [ + "Rate of Exceedence", + "Probability of Exceedence", + "Return Period" + ] + }, + "common_hazard_type": { + "type": "string", + "enum": [ + "CF", + "CS", + "DR", + "EQ", + "ET", + "FL", + "LS", + "MH", + "TS", + "VO", + "WF", + "WI" + ] + }, + "common_impact_type": { + "type": "string", + "enum": [ + "Direct", + "Indirect", + "Total" + ] + }, + "common_iso": { + "type": "string", + "enum": [ + "GLB", + "ABW", + "AFG", + "AGO", + "AIA", + "ALB", + "AND", + "ARE", + "ARG", + "ARM", + "ASM", + "ATG", + "AUS", + "AUT", + "AZE", + "BDI", + "BEL", + "BEN", + "BFA", + "BGD", + "BGR", + "BHR", + "BHS", + "BIH", + "BLM", + "BLR", + "BLZ", + "BMU", + "BOL", + "BRA", + "BRB", + "BRN", + "BTN", + "BWA", + "CAF", + "CAN", + "CHE", + "CHL", + "CHN", + "CIV", + "CMR", + "COD", + "COG", + "COK", + "COL", + "COM", + "CPV", + "CRI", + "CUB", + "CUW", + "CYM", + "CYP", + "CZE", + "DEU", + "DJI", + "DMA", + "DNK", + "DOM", + "DZA", + "ECU", + "EGY", + "ERI", + "ESP", + "EST", + "ETH", + "FIN", + "FJI", + "FLK", + "FRA", + "FRO", + "FSM", + "GAB", + "GBR", + "GEO", + "GGY", + "GHA", + "GIB", + "GIN", + "GMB", + "GNB", + "GNQ", + "GRC", + "GRD", + "GRL", + "GTM", + "GUM", + "GUY", + "HKG", + "HMD", + "HND", + "HRV", + "HTI", + "HUN", + "IDN", + "IMN", + "IND", + "IRL", + "IRN", + "IRQ", + "ISL", + "ISR", + "ITA", + "JAM", + "JEY", + "JOR", + "JPN", + "KAZ", + "KEN", + "KGZ", + "KHM", + "KIR", + "KNA", + "KOR", + "KWT", + "LAO", + "LBN", + "LBR", + "LBY", + "LCA", + "LIE", + "LKA", + "LSO", + "LTU", + "LUX", + "LVA", + "MAC", + "MAF", + "MAR", + "MCO", + "MDA", + "MDG", + "MDV", + "MEX", + "MHL", + "MKD", + "MLI", + "MLT", + "MMR", + "MNE", + "MNG", + "MNP", + "MOZ", + "MRT", + "MSR", + "MUS", + "MWI", + "MYS", + "NAM", + "NCL", + "NER", + "NFK", + "NGA", + "NIC", + "NIU", + "NLD", + "NOR", + "NPL", + "NRU", + "NZL", + "OMN", + "PAK", + "PAN", + "PCN", + "PER", + "PHL", + "PLW", + "PNG", + "POL", + "PRI", + "PRK", + "PRT", + "PRY", + "PSE", + "PYF", + "QAT", + "ROU", + "RUS", + "RWA", + "SAU", + "SDN", + "SEN", + "SGP", + "SGS", + "SHN", + "SLB", + "SLE", + "SLV", + "SMR", + "SOM", + "SPM", + "SRB", + "SSD", + "STP", + "SUR", + "SVK", + "SVN", + "SWE", + "SWZ", + "SXM", + "SYC", + "SYR", + "TCA", + "TCD", + "TGO", + "THA", + "TJK", + "TKM", + "TLS", + "TON", + "TTO", + "TUN", + "TUR", + "TUV", + "TZA", + "UGA", + "UKR", + "URY", + "USA", + "UZB", + "VAT", + "VCT", + "VEN", + "VGB", + "VIR", + "VNM", + "VUT", + "WLF", + "WSM", + "XXK", + "YEM", + "ZAF", + "ZMB", + "ZWE" + ] + }, + "common_license": { + "type": "string", + "enum": [ + "CC0-1.0", + "PDDL-1.0", + "CC-BY-4.0", + "ODC-By-1.0", + "CC-BY-SA-4.0", + "ODbL-1.0" + ] + }, + "common_occupancy_time": { + "type": "string", + "enum": [ + "Night", + "Day" + ] + }, + "common_process_type": { + "type": "string", + "enum": [ + "FCF", + "FSS", + "TOR", + "DTA", + "DTH", + "DTM", + "DTS", + "Q1R", + "Q2R", + "QGM", + "QLI", + "ECD", + "EHT", + "FFF", + "FPF", + "LAV", + "LSL", + "TSI", + "VAF", + "VBL", + "VFH", + "VLH", + "VLV", + "VPF", + "WFI", + "ETC", + "TCY" + ] + }, + "im_code": { + "type": "string", + "enum": [ + "PG+E47:E70A:g", + "PGA:m/s2", + "PGV:m/s", + "AvgSa:m/s2", + "Sd(T1):m", + "Sv(T1):m/s", + "PGDf:m", + "D:s", + "IA:m/s", + "Neq:-", + "EMS:-", + "MMI:-", + "CAV:m/s", + "D_B:s", + "fl_wd:m", + "fl_wv:m/s", + "v_ect(3s):km/h", + "v_ect(1m):km/h", + "v_etc(10m):km/h", + "PGWS_tcy:km/h", + "ls_fd:m", + "I_DF:m3/s2", + "v_lsl:m/s2", + "ls_mfd:m", + "SD_lsl:m", + "Rh_tsi:m", + "d_tsi:m", + "MMF:m4/s2", + "F_drag:kN", + "Fr:-", + "v_tsi:m/s", + "F_QS:kN", + "MF:m3/s2", + "h_tsi:m", + "Fh_tsi:m", + "h_vaf:m", + "L_vaf:kg/m2", + "CMI:-", + "PDSI:-", + "SPI:-" + ] + }, + "loss_loss_type": { + "type": "string", + "enum": [ + "Ground Up", + "Insured" + ] + }, + "loss_metric": { + "type": "string", + "enum": [ + "Annual Average Losses", + "Annual Average Loss Ratio", + "Probable Maximal Loss" + ] + }, + "vulnerability_function_type": { + "type": "string", + "enum": [ + "Fragility", + "Vulnerability", + "Damage-to-Loss" + ] + }, + "vulnerability_f_subtype": { + "type": "string", + "enum": [ + "Empirical", + "Analytical", + "Judgement", + "Hybrid" + ] + }, + "vulnerability_f_relationship": {}, + "vulnerability_f_math": {} + } } diff --git a/specs/DDH_compliant/rdl_schema_0_1.json b/specs/DDH_compliant/rdl_schema_0_1.json index 3ae03b2e..f83b40a4 100644 --- a/specs/DDH_compliant/rdl_schema_0_1.json +++ b/specs/DDH_compliant/rdl_schema_0_1.json @@ -1,653 +1,1043 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "http://riskdatalibrary.org/schemas/rdl_schema_v0_1.json", - "title": "Risk Data Library Schema", - "type": "object", - "required": [ - "common" - ], - "properties": { - "common": { - "type": "object", - "properties": { - "contribution": { - "type": "object", - "required": ["title", "abstract", "component", "organization", "model_source", "model_date", - "geo_coverage", "publish", "license_code", "resources"], - "properties": { - "title": { - "type": "string", - "description": "Title of the dataset" - }, - "abstract": { - "type": "string", - "description": "Short description of the resource" - }, - "component": { - "type": "string", - "description": "Univocal schema for this contribution (H, E, V or L)", - "enum": ["Hazard", "Exposure", "Vulnerability", "Loss"] - }, - "organization": { - "type": "string", - "description": "Name of organization that published the dataset" - }, - "model_source": { - "type": "string", - "description": "Name of source model" - }, - "model_date": { - "type": "string", - "description": "Model release date", - "format": "date" - }, - "version": { - "type": "integer", - "description": "Version of the dataset" - }, - "purpose": { - "type": "string", - "description": "Purpose for what the data has been produced" - }, - "project": { - "type": "string", - "description": "Project under which data has been produced" - }, - "notes": { - "type": "string", - "description": "Additional details about the dataset" - }, - "biblio_title": { - "type": "string", - "description": "Authors/year/title of publication" - }, - "biblio_url": { - "type": "string", - "description": "URL of publication", - "format": "uri" - }, - "geo_coverage": { - "$ref": "#/definitions/common_iso", - "description": "ISO code(s) of countries covered by the dataset, comma-separated" - }, - "publish": { - "type": "boolean", - "description": "Flag to show/hide dataset from website" - }, - "license_code": { - "$ref": "#/definitions/common_license", - "description": "Type of license" - }, - "maintainer": { - "type": "string", - "description": "Who added the resource" - }, - "maintainer_email": { - "type": "string", - "description": "Contact email" - } - } - }, - "resources": { - "type": "array", - "items": { - "resource": { - "type": "object", - "required": ["name", "format", "epsg", "url"], - "properties": { - "name": { - "type": "string", - "description": "Name of linked resource" - }, - "aggregation_type": { - "type": "string", - "description": "Level of data representation" - }, - "format": { - "type": "string", - "description": "Format of resource" - }, - "h-res": { - "type": "string", - "description": "Horizontal resolution in meters (raster data only)" - }, - "epsg": { - "type": "string", - "description": "Reference coordinate system (default: 4326)" - }, - "url": { - "type": "string", - "description": "URL of linked resource" - } - } - } - } - } - } - } - }, - "anyOf": [ - { - "type": "object", - "title": "hazard", - "properties": { - "hazard": { - "type": "object", - "required": ["event_set", "event", "footprint_set"], - "properties": { - "event_set": { - "type": "object", - "required": ["hazard_type", "analysis_type"], - "properties": { - "hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Type of hazard modelled" - }, - "analysis_type": { - "$ref": "#/definitions/common_analysis_type", - "description": "Type of analysis, probabilistic or deterministic" - }, - "geo_area": { - "type": "array", - "description": "The name of the geographic area covered by the hazard analysis. Comma-separated list of geographic names.", - "items": { - "type": "string" - } - }, - "time_start": { - "type": "string", - "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", - "format": "date" - }, - "time_end": { - "type": "string", - "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", - "format": "date" - }, - "time_span": { - "type": "string", - "description": "The extent of the time period covered by the events included in the current scenario hazard analysis [ISO 8601 format]" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - } - } - }, - "event": { - "type": "object", - "required": ["calculation_method","frequency_type"], - "properties": { - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of this event" - }, - "frequency_type": { - "$ref": "#/definitions/common_frequency_type", - "description": "Frequency representation type" - }, - "return_period": { - "type": "string", - "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" - }, - "occurence_time_start": { - "type": "string", - "description": "The start date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", - "format": "date-time" - }, - "occurence_time_end": { - "type": "string", - "description": "The end date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", - "format": "date-time" - }, - "occurence_time_span": { - "type": "string", - "description": "The duration (years) of the period used to specify either the frequency or the occurrence_probability" - }, - "trigger_hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Hazard type that triggered the event" - }, - "trigger_process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Process type that triggered the event" - }, - "description": { - "type": "string", - "description": "Provides additional information about this specific event" - } - } - }, - "footprint_set": { - "type": "object", - "properties": { - "process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Type of hazard process modelled" - }, - "imt": { - "$ref": "#/definitions/im_code", - "description": "Hazard intensity measure unit" - }, - "data_uncertainty": { - "type": "string", - "description": "Comments about the uncertainty of data" - } - } - - } - } - } - } - }, - { - "type": "object", - "title": "exposure", - "properties": { - "exposure": { - "type": "object", - "required": ["model", "value"], - "properties": { - "model": { - "type": "object", - "required": ["category", "occupancy"], - "properties": { - "category": { - "description": "Type of asset", - "$ref": "#/definitions/common_exp_category" - }, - "occupancy": { - "description": "Destination of use of the asset", - "$ref": "#/definitions/common_exp_occupancy" - }, - "occupancy_time": { - "description": "Period of occupancy, if appliable (e.g. Population)", - "$ref": "#/definitions/common_occupancy_time" - }, - "taxonomy_source": { - "type": "string", - "description": "Name of taxonomy source (default is GED4ALL)", - "default": "GED4ALL" - }, - "taxonomy_code": { - "type": "string", - "description": "Alphanumeric code for the taxonomy source (based on GED4ALL)" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - }, - "add_attributes": { - "type": "string", - "description": "List of key attributes included in the dataset" - } - } - }, - "value": { - "type": "object", - "properties": { - "val_type": { - "description": "Type of asset value", - "$ref": "#/definitions/common_exp_val_type" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - } - } - } - } - } - } - }, - { - "type": "object", - "title": "vulnerability", - "properties": { - "vulnerability": { - "type": "object", - "properties": { - "model": { - "type": "object", - "properties": { - "hazard_type_primary": { - "description": "Primary hazard involved", - "$ref": "#/definitions/common_hazard_type" - }, - "hazard_type_secondary": { - "description": "Secondary hazard involved", - "$ref": "#/definitions/common_hazard_type" - - }, - "process_type_primary": { - "description": "Primary process involved", - "$ref": "#/definitions/common_process_type" - - }, - "process_type_secondary": { - "description": "Secondary process involved", - "$ref": "#/definitions/common_process_type" - }, - "frequency_type": { - "description": "Frequency representation type", - "$ref": "#/definitions/common_frequency_type" - }, - "imt": { - "description": "Hazard intensity measure unit", - "$ref": "#/definitions/im_code" - }, - "category": { - "description": "Type of asset", - "$ref": "#/definitions/common_exp_category" - }, - "occupancy": { - "description": "Type of occupancy to which function applies", - "$ref": "#/definitions/common_exp_occupancy" - }, - "val_type": { - "description": "Type of asset value", - "$ref": "#/definitions/common_exp_val_type" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - }, - "taxonomy_source": { - "type": "string", - "description": "Source of taxonomy" - }, - "taxonomy_code": { - "type": "string", - "description": "Taxonomy code to which function applies" - }, - "impact_type": { - "description": "Type of impact", - "$ref": "#/definitions/common_impact_type" - }, - "scale_applicability": { - "description": "Administrative level of application", - "$ref": "#/definitions/common_aggregation_type" - }, - "country_tranferability": { - "description": "ISOa3 list of countries in which the model could be applied", - "$ref": "#/definitions/common_iso" - }, - "local_applicability": { - "type": "string", - "description": "Area within a country or region to wich the model specifically applies" - }, - "transferability_notes": { - "type": "string", - "description": "Details about applicability to different areas" - }, - "function_type": { - "$ref": "#/definitions/vulnerability_function_type", - "description": "Type of function" - }, - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of the function" - }, - "approach": { - "$ref": "#/definitions/f_subtype", - "description": "Type of methodological approach" - }, - "f_relationship": { - "$ref": "#/definitions/vulnerability_f_relationship", - "description": "Type of relationship: Mathematical or Discrete" - }, - "f_math": { - "$ref": "#/definitions/vulnerability_f_math", - "description": "Parametric or bespoke" - } - } - }, - "specifics": { - "type": "object", - "properties": { - "analysis_details": { - "description": "Description of analysis that produced the function", - "type": "string" - }, - "par_names": { - "type": "string", - "description": "Parameters considered by the function" - }, - "im_name": { - "type": "string", - "description": "Name of loss intensity measure" - }, - "im_units": { - "type": "string", - "description": "Unit of loss intensity measure" - }, - "n_events": { - "type": "integer", - "description": "Number of events the function has been built on" - }, - "n_assets": { - "type": "integer", - "description": "Number of assets the function has been built on" - }, - "is_fit_good": { - "type": "boolean", - "description": "Is the fit good overall?" - }, - "is_edp_thre": { - "type": "boolean", - "description": "Is the damage scale is associated to an engineered-design parameter threshold?" - }, - "is_dm_factor": { - "type": "boolean", - "description": "Is the damage scale is associated to a damage factor?" - }, - "is_casualties": { - "type": "boolean", - "description": "Is the damage scale is associated to a casualties estimation?" - }, - "is_downtime": { - "type": "boolean", - "description": "Is the damage scale is associated to a downtime estimation (e.g. service interruption)?" - } - } - } - } - } - } - }, - { - "type": "object", - "title": "loss", - "properties": { - "loss": { - "type": "object", - "properties": { - "model": { - "type": "object", - "properties": { - "hazard_type": { - "$ref": "#/definitions/common_hazard_type", - "description": "Type of hazard modelled" - }, - "process_type": { - "$ref": "#/definitions/common_process_type", - "description": "Type of hazard process modelled" - }, - "time_start": { - "type": "string", - "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", - "format": "date" - }, - "time_end": { - "type": "string", - "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", - "format": "date" - }, - "time_year": { - "type": "string", - "description": "General reference year to which the scenario refers to (e.g. '2050')" - }, - "occupancy": { - "$ref": "#/definitions/common_exp_occupancy", - "description": "Destination of use of the asset" - }, - "category": { - "$ref": "#/definitions/common_exp_category", - "description": "Exposure category" - }, - "val_type": { - "$ref": "#/definitions/common_exp_val_type", - "description": "Element on which loss insist" - }, - "impact": { - "$ref": "#/definitions/common_impact_type", - "description": "Type of impact" - }, - "loss_type": { - "$ref": "#/definitions/loss_loss_type", - "description": "Type of loss" - }, - "frequency": { - "$ref": "#/definitions/common_frequency_type", - "description": "Frequency representation type" - }, - "return_period": { - "type": "string", - "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" - }, - "calculation_method": { - "$ref": "#/definitions/common_calc_method", - "description": "The methodology used for the calculation of this event" - }, - "metric": { - "$ref": "#/definitions/loss_metric", - "description": "Type of loss metric" - }, - "val_unit": { - "type": "string", - "description": "Unit of measure" - }, - "hazard_link": { - "type": "string", - "description": "URL of source hazard data", - "format": "uri" - }, - "exposure_link": { - "type": "string", - "description": "URL of source exposure data", - "format": "uri" - }, - "vulnerability_link": { - "type": "string", - "description": "URL of source vulnerability data", - "format": "uri" - } - } - } - } - } - } - } - ], - "definitions": { - - "common_aggregation_type": { - "type": "string", - "enum": ["Individual items", "Aggregated to grid", "Aggregated to boundaries", "N/A"] - }, - "common_analysis_type": { - "type": "string", - "enum": ["Deterministic","Probabilistic"] - }, - "common_calc_method": { - "type": "string", - "enum": ["Inferred","Simulated","Observed"] - }, - "common_exp_category": { - "type": "string", - "enum": ["Buildings", "Indicators", "Infrastructures", "Crops, livestock and forestry"] - }, - "common_exp_occupancy": { - "type": "string", - "enum": ["Residential", "Commercial", "Industrial", "Infrastructure", "Healthcare", "Educational", - "Government", "Crop", "Livestock", "Forestry", "Mixed"] - }, - "common_exp_val_type": { - "type": "string", - "enum": ["Structure", "Content", "Product", "Other"] - }, - "common_frequency_type": { - "type": "string", - "enum": ["Rate of Exceedence","Probability of Exceedence","Return Period"] - }, - "common_hazard_type": { - "type": "string", - "enum": ["CF","CS","DR","EQ","ET","FL","LS","MH","TS","VO","WF","WI"] - }, - "common_impact_type": { - "type": "string", - "enum": ["Direct", "Indirect", "Total"] - }, - "common_iso": { - "type": "string", - "enum": ["GLB","ABW","AFG","AGO","AIA","ALB","AND","ARE","ARG","ARM","ASM","ATG","AUS", - "AUT","AZE","BDI","BEL","BEN","BFA","BGD","BGR","BHR","BHS","BIH","BLM","BLR", - "BLZ","BMU","BOL","BRA","BRB","BRN","BTN","BWA","CAF","CAN","CHE","CHL","CHN", - "CIV","CMR","COD","COG","COK","COL","COM","CPV","CRI","CUB","CUW","CYM","CYP", - "CZE","DEU","DJI","DMA","DNK","DOM","DZA","ECU","EGY","ERI","ESP","EST","ETH", - "FIN","FJI","FLK","FRA","FRO","FSM","GAB","GBR","GEO","GGY","GHA","GIB","GIN", - "GMB","GNB","GNQ","GRC","GRD","GRL","GTM","GUM","GUY","HKG","HMD","HND","HRV", - "HTI","HUN","IDN","IMN","IND","IRL","IRN","IRQ","ISL","ISR","ITA","JAM","JEY", - "JOR","JPN","KAZ","KEN","KGZ","KHM","KIR","KNA","KOR","KWT","LAO","LBN","LBR", - "LBY","LCA","LIE","LKA","LSO","LTU","LUX","LVA","MAC","MAF","MAR","MCO","MDA", - "MDG","MDV","MEX","MHL","MKD","MLI","MLT","MMR","MNE","MNG","MNP","MOZ","MRT", - "MSR","MUS","MWI","MYS","NAM","NCL","NER","NFK","NGA","NIC","NIU","NLD","NOR", - "NPL","NRU","NZL","OMN","PAK","PAN","PCN","PER","PHL","PLW","PNG","POL","PRI", - "PRK","PRT","PRY","PSE","PYF","QAT","ROU","RUS","RWA","SAU","SDN","SEN","SGP", - "SGS","SHN","SLB","SLE","SLV","SMR","SOM","SPM","SRB","SSD","STP","SUR","SVK", - "SVN","SWE","SWZ","SXM","SYC","SYR","TCA","TCD","TGO","THA","TJK","TKM","TLS", - "TON","TTO","TUN","TUR","TUV","TZA","UGA","UKR","URY","USA","UZB","VAT","VCT", - "VEN","VGB","VIR","VNM","VUT","WLF","WSM","XXK","YEM","ZAF","ZMB","ZWE" - ] - }, - "common_license": { - "type": "string", - "enum": ["CC0-1.0", "PDDL-1.0", "CC-BY-4.0", "ODC-By-1.0", "CC-BY-SA-4.0", "ODbL-1.0"] - }, - "common_occupancy_time": { - "type": "string", - "enum": ["Night","Day"] - }, - "common_process_type": { - "type": "string", - "enum": ["FCF","FSS","TOR","DTA","DTH","DTM","DTS","Q1R","Q2R","QGM", - "QLI","ECD","EHT","FFF","FPF","LAV","LSL","TSI","VAF","VBL", - "VFH","VLH","VLV","VPF","WFI","ETC","TCY"] - }, - "im_code": { - "type": "string", - "enum": ["PGA:g","PGA:m/s2","PGV:m/s","AvgSa:m/s2","Sd(T1):m","Sv(T1):m/s", - "PGDf:m","D:s","IA:m/s","Neq:-","EMS:-","MMI:-","CAV:m/s", "D_B:s", "fl_wd:m", - "fl_wv:m/s","v_ect(3s):km/h","v_ect(1m):km/h","v_etc(10m):km/h", - "PGWS_tcy:km/h","ls_fd:m","I_DF:m3/s2","v_lsl:m/s2","ls_mfd:m","SD_lsl:m","Rh_tsi:m", - "d_tsi:m","MMF:m4/s2","F_drag:kN","Fr:-","v_tsi:m/s","F_QS:kN","MF:m3/s2","h_tsi:m", - "Fh_tsi:m","h_vaf:m","L_vaf:kg/m2","CMI:-","PDSI:-","SPI:-"] - }, - "loss_loss_type": { - "type": "string", - "enum": ["Ground Up", "Insured"] - }, - "loss_metric": { - "type": "string", - "enum": ["Annual Average Losses", "Annual Average Loss Ratio", "Probable Maximal Loss"] - }, - "vulnerability_function_type": { - "type": "string", - "enum": ["Fragility", "Vulnerability", "Damage-to-Loss"] - }, - "vulnerability_f_subtype": { - "type": "string", - "enum": ["Empirical", "Analytical", "Judgement", "Hybrid"] - } - } -} +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://riskdatalibrary.org/schemas/rdl_schema_v0_1.json", + "title": "Risk Data Library Schema", + "type": "object", + "required": [ + "common" + ], + "properties": { + "common": { + "type": "object", + "properties": { + "contribution": { + "type": "object", + "required": [ + "title", + "abstract", + "component", + "organization", + "model_source", + "model_date", + "geo_coverage", + "publish", + "license_code", + "resources" + ], + "properties": { + "title": { + "type": "string", + "description": "Title of the dataset" + }, + "abstract": { + "type": "string", + "description": "Short description of the resource" + }, + "component": { + "type": "string", + "description": "Univocal schema for this contribution (H, E, V or L)", + "enum": [ + "Hazard", + "Exposure", + "Vulnerability", + "Loss" + ] + }, + "organization": { + "type": "string", + "description": "Name of organization that published the dataset" + }, + "model_source": { + "type": "string", + "description": "Name of source model" + }, + "model_date": { + "type": "string", + "description": "Model release date", + "format": "date" + }, + "version": { + "type": "integer", + "description": "Version of the dataset" + }, + "purpose": { + "type": "string", + "description": "Purpose for what the data has been produced" + }, + "project": { + "type": "string", + "description": "Project under which data has been produced" + }, + "notes": { + "type": "string", + "description": "Additional details about the dataset" + }, + "biblio_title": { + "type": "string", + "description": "Authors/year/title of publication" + }, + "biblio_url": { + "type": "string", + "description": "URL of publication", + "format": "uri" + }, + "geo_coverage": { + "$ref": "#/definitions/common_iso", + "description": "ISO code(s) of countries covered by the dataset, comma-separated" + }, + "publish": { + "type": "boolean", + "description": "Flag to show/hide dataset from website" + }, + "license_code": { + "$ref": "#/definitions/common_license", + "description": "Type of license" + }, + "maintainer": { + "type": "string", + "description": "Who added the resource" + }, + "maintainer_email": { + "type": "string", + "description": "Contact email" + } + } + }, + "resources": { + "type": "array", + "items": { + "resource": { + "type": "object", + "required": [ + "name", + "format", + "epsg", + "url" + ], + "properties": { + "name": { + "type": "string", + "description": "Name of linked resource" + }, + "aggregation_type": { + "type": "string", + "description": "Level of data representation" + }, + "format": { + "type": "string", + "description": "Format of resource" + }, + "h-res": { + "type": "string", + "description": "Horizontal resolution in meters (raster data only)" + }, + "epsg": { + "type": "string", + "description": "Reference coordinate system (default: 4326)" + }, + "url": { + "type": "string", + "description": "URL of linked resource" + } + } + } + } + } + } + } + }, + "anyOf": [ + { + "type": "object", + "title": "hazard", + "properties": { + "hazard": { + "type": "object", + "required": [ + "event_set", + "event", + "footprint_set" + ], + "properties": { + "event_set": { + "type": "object", + "required": [ + "hazard_type", + "analysis_type" + ], + "properties": { + "hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Type of hazard modelled" + }, + "analysis_type": { + "$ref": "#/definitions/common_analysis_type", + "description": "Type of analysis, probabilistic or deterministic" + }, + "geo_area": { + "type": "array", + "description": "The name of the geographic area covered by the hazard analysis. Comma-separated list of geographic names.", + "items": { + "type": "string" + } + }, + "time_start": { + "type": "string", + "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", + "format": "date" + }, + "time_end": { + "type": "string", + "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", + "format": "date" + }, + "time_span": { + "type": "string", + "description": "The extent of the time period covered by the events included in the current scenario hazard analysis [ISO 8601 format]" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + } + } + }, + "event": { + "type": "object", + "required": [ + "calculation_method", + "frequency_type" + ], + "properties": { + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of this event" + }, + "frequency_type": { + "$ref": "#/definitions/common_frequency_type", + "description": "Frequency representation type" + }, + "return_period": { + "type": "string", + "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" + }, + "occurence_time_start": { + "type": "string", + "description": "The start date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", + "format": "date-time" + }, + "occurence_time_end": { + "type": "string", + "description": "The end date (and possibly time) of the time period used to specify either the frequency or the occurrence_probability [ISO 8601 format]", + "format": "date-time" + }, + "occurence_time_span": { + "type": "string", + "description": "The duration (years) of the period used to specify either the frequency or the occurrence_probability" + }, + "trigger_hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Hazard type that triggered the event" + }, + "trigger_process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Process type that triggered the event" + }, + "description": { + "type": "string", + "description": "Provides additional information about this specific event" + } + } + }, + "footprint_set": { + "type": "object", + "properties": { + "process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Type of hazard process modelled" + }, + "imt": { + "$ref": "#/definitions/im_code", + "description": "Hazard intensity measure unit" + }, + "data_uncertainty": { + "type": "string", + "description": "Comments about the uncertainty of data" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "exposure", + "properties": { + "exposure": { + "type": "object", + "required": [ + "model", + "value" + ], + "properties": { + "model": { + "type": "object", + "required": [ + "category", + "occupancy" + ], + "properties": { + "category": { + "description": "Type of asset", + "$ref": "#/definitions/common_exp_category" + }, + "occupancy": { + "description": "Destination of use of the asset", + "$ref": "#/definitions/common_exp_occupancy" + }, + "occupancy_time": { + "description": "Period of occupancy, if appliable (e.g. Population)", + "$ref": "#/definitions/common_occupancy_time" + }, + "taxonomy_source": { + "type": "string", + "description": "Name of taxonomy source (default is GED4ALL)", + "default": "GED4ALL" + }, + "taxonomy_code": { + "type": "string", + "description": "Alphanumeric code for the taxonomy source (based on GED4ALL)" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + }, + "add_attributes": { + "type": "string", + "description": "List of key attributes included in the dataset" + } + } + }, + "value": { + "type": "object", + "properties": { + "val_type": { + "description": "Type of asset value", + "$ref": "#/definitions/common_exp_val_type" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "vulnerability", + "properties": { + "vulnerability": { + "type": "object", + "properties": { + "model": { + "type": "object", + "properties": { + "hazard_type_primary": { + "description": "Primary hazard involved", + "$ref": "#/definitions/common_hazard_type" + }, + "hazard_type_secondary": { + "description": "Secondary hazard involved", + "$ref": "#/definitions/common_hazard_type" + }, + "process_type_primary": { + "description": "Primary process involved", + "$ref": "#/definitions/common_process_type" + }, + "process_type_secondary": { + "description": "Secondary process involved", + "$ref": "#/definitions/common_process_type" + }, + "frequency_type": { + "description": "Frequency representation type", + "$ref": "#/definitions/common_frequency_type" + }, + "imt": { + "description": "Hazard intensity measure unit", + "$ref": "#/definitions/im_code" + }, + "category": { + "description": "Type of asset", + "$ref": "#/definitions/common_exp_category" + }, + "occupancy": { + "description": "Type of occupancy to which function applies", + "$ref": "#/definitions/common_exp_occupancy" + }, + "val_type": { + "description": "Type of asset value", + "$ref": "#/definitions/common_exp_val_type" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + }, + "taxonomy_source": { + "type": "string", + "description": "Source of taxonomy" + }, + "taxonomy_code": { + "type": "string", + "description": "Taxonomy code to which function applies" + }, + "impact_type": { + "description": "Type of impact", + "$ref": "#/definitions/common_impact_type" + }, + "scale_applicability": { + "description": "Administrative level of application", + "$ref": "#/definitions/common_aggregation_type" + }, + "country_tranferability": { + "description": "ISOa3 list of countries in which the model could be applied", + "$ref": "#/definitions/common_iso" + }, + "local_applicability": { + "type": "string", + "description": "Area within a country or region to wich the model specifically applies" + }, + "transferability_notes": { + "type": "string", + "description": "Details about applicability to different areas" + }, + "function_type": { + "$ref": "#/definitions/vulnerability_function_type", + "description": "Type of function" + }, + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of the function" + }, + "approach": { + "$ref": "#/definitions/f_subtype", + "description": "Type of methodological approach" + }, + "f_relationship": { + "$ref": "#/definitions/vulnerability_f_relationship", + "description": "Type of relationship: Mathematical or Discrete" + }, + "f_math": { + "$ref": "#/definitions/vulnerability_f_math", + "description": "Parametric or bespoke" + } + } + }, + "specifics": { + "type": "object", + "properties": { + "analysis_details": { + "description": "Description of analysis that produced the function", + "type": "string" + }, + "par_names": { + "type": "string", + "description": "Parameters considered by the function" + }, + "im_name": { + "type": "string", + "description": "Name of loss intensity measure" + }, + "im_units": { + "type": "string", + "description": "Unit of loss intensity measure" + }, + "n_events": { + "type": "integer", + "description": "Number of events the function has been built on" + }, + "n_assets": { + "type": "integer", + "description": "Number of assets the function has been built on" + }, + "is_fit_good": { + "type": "boolean", + "description": "Is the fit good overall?" + }, + "is_edp_thre": { + "type": "boolean", + "description": "Is the damage scale is associated to an engineered-design parameter threshold?" + }, + "is_dm_factor": { + "type": "boolean", + "description": "Is the damage scale is associated to a damage factor?" + }, + "is_casualties": { + "type": "boolean", + "description": "Is the damage scale is associated to a casualties estimation?" + }, + "is_downtime": { + "type": "boolean", + "description": "Is the damage scale is associated to a downtime estimation (e.g. service interruption)?" + } + } + } + } + } + } + }, + { + "type": "object", + "title": "loss", + "properties": { + "loss": { + "type": "object", + "properties": { + "model": { + "type": "object", + "properties": { + "hazard_type": { + "$ref": "#/definitions/common_hazard_type", + "description": "Type of hazard modelled" + }, + "process_type": { + "$ref": "#/definitions/common_process_type", + "description": "Type of hazard process modelled" + }, + "time_start": { + "type": "string", + "description": "The time at which the modelled scenario(s) starts [ISO 8601 format]", + "format": "date" + }, + "time_end": { + "type": "string", + "description": "The time at which the modelled scenario(s) ends [ISO 8601 format]", + "format": "date" + }, + "time_year": { + "type": "string", + "description": "General reference year to which the scenario refers to (e.g. '2050')" + }, + "occupancy": { + "$ref": "#/definitions/common_exp_occupancy", + "description": "Destination of use of the asset" + }, + "category": { + "$ref": "#/definitions/common_exp_category", + "description": "Exposure category" + }, + "val_type": { + "$ref": "#/definitions/common_exp_val_type", + "description": "Element on which loss insist" + }, + "impact": { + "$ref": "#/definitions/common_impact_type", + "description": "Type of impact" + }, + "loss_type": { + "$ref": "#/definitions/loss_loss_type", + "description": "Type of loss" + }, + "frequency": { + "$ref": "#/definitions/common_frequency_type", + "description": "Frequency representation type" + }, + "return_period": { + "type": "string", + "description": "Probability of occurrence expressed as return periods list (10, 100, 1000) or range (10-1000)" + }, + "calculation_method": { + "$ref": "#/definitions/common_calc_method", + "description": "The methodology used for the calculation of this event" + }, + "metric": { + "$ref": "#/definitions/loss_metric", + "description": "Type of loss metric" + }, + "val_unit": { + "type": "string", + "description": "Unit of measure" + }, + "hazard_link": { + "type": "string", + "description": "URL of source hazard data", + "format": "uri" + }, + "exposure_link": { + "type": "string", + "description": "URL of source exposure data", + "format": "uri" + }, + "vulnerability_link": { + "type": "string", + "description": "URL of source vulnerability data", + "format": "uri" + } + } + } + } + } + } + } + ], + "definitions": { + "common_aggregation_type": { + "type": "string", + "enum": [ + "Individual items", + "Aggregated to grid", + "Aggregated to boundaries", + "N/A" + ] + }, + "common_analysis_type": { + "type": "string", + "enum": [ + "Deterministic", + "Probabilistic" + ] + }, + "common_calc_method": { + "type": "string", + "enum": [ + "Inferred", + "Simulated", + "Observed" + ] + }, + "common_exp_category": { + "type": "string", + "enum": [ + "Buildings", + "Indicators", + "Infrastructures", + "Crops, livestock and forestry" + ] + }, + "common_exp_occupancy": { + "type": "string", + "enum": [ + "Residential", + "Commercial", + "Industrial", + "Infrastructure", + "Healthcare", + "Educational", + "Government", + "Crop", + "Livestock", + "Forestry", + "Mixed" + ] + }, + "common_exp_val_type": { + "type": "string", + "enum": [ + "Structure", + "Content", + "Product", + "Other" + ] + }, + "common_frequency_type": { + "type": "string", + "enum": [ + "Rate of Exceedence", + "Probability of Exceedence", + "Return Period" + ] + }, + "common_hazard_type": { + "type": "string", + "enum": [ + "CF", + "CS", + "DR", + "EQ", + "ET", + "FL", + "LS", + "MH", + "TS", + "VO", + "WF", + "WI" + ] + }, + "common_impact_type": { + "type": "string", + "enum": [ + "Direct", + "Indirect", + "Total" + ] + }, + "common_iso": { + "type": "string", + "enum": [ + "GLB", + "ABW", + "AFG", + "AGO", + "AIA", + "ALB", + "AND", + "ARE", + "ARG", + "ARM", + "ASM", + "ATG", + "AUS", + "AUT", + "AZE", + "BDI", + "BEL", + "BEN", + "BFA", + "BGD", + "BGR", + "BHR", + "BHS", + "BIH", + "BLM", + "BLR", + "BLZ", + "BMU", + "BOL", + "BRA", + "BRB", + "BRN", + "BTN", + "BWA", + "CAF", + "CAN", + "CHE", + "CHL", + "CHN", + "CIV", + "CMR", + "COD", + "COG", + "COK", + "COL", + "COM", + "CPV", + "CRI", + "CUB", + "CUW", + "CYM", + "CYP", + "CZE", + "DEU", + "DJI", + "DMA", + "DNK", + "DOM", + "DZA", + "ECU", + "EGY", + "ERI", + "ESP", + "EST", + "ETH", + "FIN", + "FJI", + "FLK", + "FRA", + "FRO", + "FSM", + "GAB", + "GBR", + "GEO", + "GGY", + "GHA", + "GIB", + "GIN", + "GMB", + "GNB", + "GNQ", + "GRC", + "GRD", + "GRL", + "GTM", + "GUM", + "GUY", + "HKG", + "HMD", + "HND", + "HRV", + "HTI", + "HUN", + "IDN", + "IMN", + "IND", + "IRL", + "IRN", + "IRQ", + "ISL", + "ISR", + "ITA", + "JAM", + "JEY", + "JOR", + "JPN", + "KAZ", + "KEN", + "KGZ", + "KHM", + "KIR", + "KNA", + "KOR", + "KWT", + "LAO", + "LBN", + "LBR", + "LBY", + "LCA", + "LIE", + "LKA", + "LSO", + "LTU", + "LUX", + "LVA", + "MAC", + "MAF", + "MAR", + "MCO", + "MDA", + "MDG", + "MDV", + "MEX", + "MHL", + "MKD", + "MLI", + "MLT", + "MMR", + "MNE", + "MNG", + "MNP", + "MOZ", + "MRT", + "MSR", + "MUS", + "MWI", + "MYS", + "NAM", + "NCL", + "NER", + "NFK", + "NGA", + "NIC", + "NIU", + "NLD", + "NOR", + "NPL", + "NRU", + "NZL", + "OMN", + "PAK", + "PAN", + "PCN", + "PER", + "PHL", + "PLW", + "PNG", + "POL", + "PRI", + "PRK", + "PRT", + "PRY", + "PSE", + "PYF", + "QAT", + "ROU", + "RUS", + "RWA", + "SAU", + "SDN", + "SEN", + "SGP", + "SGS", + "SHN", + "SLB", + "SLE", + "SLV", + "SMR", + "SOM", + "SPM", + "SRB", + "SSD", + "STP", + "SUR", + "SVK", + "SVN", + "SWE", + "SWZ", + "SXM", + "SYC", + "SYR", + "TCA", + "TCD", + "TGO", + "THA", + "TJK", + "TKM", + "TLS", + "TON", + "TTO", + "TUN", + "TUR", + "TUV", + "TZA", + "UGA", + "UKR", + "URY", + "USA", + "UZB", + "VAT", + "VCT", + "VEN", + "VGB", + "VIR", + "VNM", + "VUT", + "WLF", + "WSM", + "XXK", + "YEM", + "ZAF", + "ZMB", + "ZWE" + ] + }, + "common_license": { + "type": "string", + "enum": [ + "CC0-1.0", + "PDDL-1.0", + "CC-BY-4.0", + "ODC-By-1.0", + "CC-BY-SA-4.0", + "ODbL-1.0" + ] + }, + "common_occupancy_time": { + "type": "string", + "enum": [ + "Night", + "Day" + ] + }, + "common_process_type": { + "type": "string", + "enum": [ + "FCF", + "FSS", + "TOR", + "DTA", + "DTH", + "DTM", + "DTS", + "Q1R", + "Q2R", + "QGM", + "QLI", + "ECD", + "EHT", + "FFF", + "FPF", + "LAV", + "LSL", + "TSI", + "VAF", + "VBL", + "VFH", + "VLH", + "VLV", + "VPF", + "WFI", + "ETC", + "TCY" + ] + }, + "im_code": { + "type": "string", + "enum": [ + "PGA:g", + "PGA:m/s2", + "PGV:m/s", + "AvgSa:m/s2", + "Sd(T1):m", + "Sv(T1):m/s", + "PGDf:m", + "D:s", + "IA:m/s", + "Neq:-", + "EMS:-", + "MMI:-", + "CAV:m/s", + "D_B:s", + "fl_wd:m", + "fl_wv:m/s", + "v_ect(3s):km/h", + "v_ect(1m):km/h", + "v_etc(10m):km/h", + "PGWS_tcy:km/h", + "ls_fd:m", + "I_DF:m3/s2", + "v_lsl:m/s2", + "ls_mfd:m", + "SD_lsl:m", + "Rh_tsi:m", + "d_tsi:m", + "MMF:m4/s2", + "F_drag:kN", + "Fr:-", + "v_tsi:m/s", + "F_QS:kN", + "MF:m3/s2", + "h_tsi:m", + "Fh_tsi:m", + "h_vaf:m", + "L_vaf:kg/m2", + "CMI:-", + "PDSI:-", + "SPI:-" + ] + }, + "loss_loss_type": { + "type": "string", + "enum": [ + "Ground Up", + "Insured" + ] + }, + "loss_metric": { + "type": "string", + "enum": [ + "Annual Average Losses", + "Annual Average Loss Ratio", + "Probable Maximal Loss" + ] + }, + "vulnerability_function_type": { + "type": "string", + "enum": [ + "Fragility", + "Vulnerability", + "Damage-to-Loss" + ] + }, + "vulnerability_f_subtype": { + "type": "string", + "enum": [ + "Empirical", + "Analytical", + "Judgement", + "Hybrid" + ] + } + } +} diff --git a/specs/code-lists/CSV/IMT.csv b/specs/code-lists/CSV/IMT.csv index f13316a4..b7d8920e 100644 --- a/specs/code-lists/CSV/IMT.csv +++ b/specs/code-lists/CSV/IMT.csv @@ -1,47 +1,47 @@ -Code, Label, Definition -PGA_g, Peak ground acceleration in g, -PGA_gal, Peak ground acceleration in Gal (1 Gal equal to 0.01 m/s2), -PGA_m/s2, Peak ground acceleration in m/s2 (meters per second squared), -PGV_m/s, Peak ground velocity in m/s, -AvgSa_m/s2, Average spectral acceleration, -Sd(T1)_m, Spectral displacement, -Sv(T1)_m/s, Spectral velocity, -PGDf_m, Permanent ground deformation, -D_s, Significant duration, -IA_m/s, Arias intensity (Iα) or (IA) or (Ia), -Neq_-, Effective number of cycles, -EMS_-, European macroseismic scale, -MMI_-, Modified Mercalli Intensity, -CAV_m/s, Cumulative absolute velocity, -D_B_s, Bracketed duration, -fl_we, Flood water extent, -fl_wd_m, Flood water depth (m), -fl_wv_m/s, Flood flow velocity (m/s), -v_ect(3s)_km/h, 3-sec at 10m sustained wind speed (kph), -v_ect(1m)_km/h, 1-min at 10m sustained wind speed (kph), -v_etc(10m)_km/h, 10-min sustained wind speed (kph), -PGWS_tcy_km/h, Peak gust wind speed, -ls_fd_m, Landslide flow depth, -I_DF_m3/s2, Debris-flow intensity index, -v_lsl_m/s2, Landslide flow velocity, -ls_mfd_m, Maximum foundation displacement, -SD_lsl_m, Landslide displacement, -Rh_tsi_m, Tsunami wave runup height, -d_tsi_m, Tsunami inundation depth, -MMF_m4/s2, Modified momentum flux, -F_drag_kN, Drag force, -Fr_-, Froude number, -v_tsi_m/s, Tsunami velocity, -F_QS_kN, Quasi-steady force, -MF_m3/s2, Momentum flux, -h_tsi_m, Tsunami wave height, -Fh_tsi_m, Tsunami Horizontal Force, -h_vaf_m, Ash fall thickness, -L_vaf_kg/m2, Ash loading, -ASI, Agricultural Stress Index, -CMI, Crop Moisture Index, -PDSI, Palmer Drought Severity Index, -SPI, Standard Precipitation Index, -WBGT_c, Wet Bulb Globe Temperature in Celsius, -FWI, Fire Weather Index, -MHI, Multi-Hazard Index, \ No newline at end of file +Code,Label +PGA_g,Peak ground acceleration in g +PGA_gal,Peak ground acceleration in Gal (1 Gal equal to 0.01 m/s2) +PGA_m/s2,Peak ground acceleration in m/s2 (meters per second squared) +PGV_m/s,Peak ground velocity in m/s +AvgSa_m/s2,Average spectral acceleration +Sd(T1)_m,Spectral displacement +Sv(T1)_m/s,Spectral velocity +PGDf_m,Permanent ground deformation +D_s,Significant duration +IA_m/s,Arias intensity (Iα) or (IA) or (Ia) +Neq_-,Effective number of cycles +EMS_-,European macroseismic scale +MMI_-,Modified Mercalli Intensity +CAV_m/s,Cumulative absolute velocity +D_B_s,Bracketed duration +fl_we,Flood water extent +fl_wd_m,Flood water depth (m) +fl_wv_m/s,Flood flow velocity (m/s) +v_ect(3s)_km/h,3-sec at 10m sustained wind speed (kph) +v_ect(1m)_km/h,1-min at 10m sustained wind speed (kph) +v_etc(10m)_km/h,10-min sustained wind speed (kph) +PGWS_tcy_km/h,Peak gust wind speed +ls_fd_m,Landslide flow depth +I_DF_m3/s2,Debris-flow intensity index +v_lsl_m/s2,Landslide flow velocity +ls_mfd_m,Maximum foundation displacement +SD_lsl_m,Landslide displacement +Rh_tsi_m,Tsunami wave runup height +d_tsi_m,Tsunami inundation depth +MMF_m4/s2,Modified momentum flux +F_drag_kN,Drag force +Fr_-,Froude number +v_tsi_m/s,Tsunami velocity +F_QS_kN,Quasi-steady force +MF_m3/s2,Momentum flux +h_tsi_m,Tsunami wave height +Fh_tsi_m,Tsunami Horizontal Force +h_vaf_m,Ash fall thickness +L_vaf_kg/m2,Ash loading +ASI,Agricultural Stress Index +CMI,Crop Moisture Index +PDSI,Palmer Drought Severity Index +SPI,Standard Precipitation Index +WBGT_c,Wet Bulb Globe Temperature in Celsius +FWI,Fire Weather Index +MHI,Multi-Hazard Index diff --git a/specs/code-lists/CSV/data_formats.csv b/specs/code-lists/CSV/data_formats.csv index 75d9f0ef..656c0f96 100644 --- a/specs/code-lists/CSV/data_formats.csv +++ b/specs/code-lists/CSV/data_formats.csv @@ -1,11 +1,11 @@ -Code, Label, Definition -api, api, Application Programming Interface -csv, csv, Comma Separated Values -json, json, JavaScript Object Notation -geojson, geojson, Geographic JavaScript Object Notation -shp, shapefile, ESRI Shapefile -gpkg, geopackage, GeoPackage -geotiff, geotiff, GeoTiff -md, markdown, Markdown -pdf, pdf, Portable Document Format -website, website, External website \ No newline at end of file +Code,Label,Definition +api,api,Application Programming Interface +csv,csv,Comma Separated Values +json,json,JavaScript Object Notation +geojson,geojson,Geographic JavaScript Object Notation +shp,shapefile,ESRI Shapefile +gpkg,geopackage,GeoPackage +geotiff,geotiff,GeoTiff +md,markdown,Markdown +pdf,pdf,Portable Document Format +website,website,External website diff --git a/specs/code-lists/CSV/frequency_type.csv b/specs/code-lists/CSV/frequency_type.csv index 7b147379..365da92c 100644 --- a/specs/code-lists/CSV/frequency_type.csv +++ b/specs/code-lists/CSV/frequency_type.csv @@ -1,4 +1,4 @@ -Code, Label, Definition -Rate of Exceedence, Rate of Exceedence, -Probability of Exceedence, Probability of Exceedence, -Return Period, Return Period, \ No newline at end of file +Code,Label +Rate of Exceedence,Rate of Exceedence +Probability of Exceedence,Probability of Exceedence +Return Period,Return Period diff --git a/specs/code-lists/CSV/hazard_type.csv b/specs/code-lists/CSV/hazard_type.csv index b6fba5ef..d65b07a8 100644 --- a/specs/code-lists/CSV/hazard_type.csv +++ b/specs/code-lists/CSV/hazard_type.csv @@ -1,13 +1,13 @@ -Code, Label, Definition -CF, Coastal Flood, -CS, Convective Storm, -DR, Drought, -EQ, Earthquake, -ET, Extreme Temperature, -FL, Flood, -LS, Landslide, -MH, Multi-Hazard, -TS, Tsunami, -VO, Volcanic, -WF, Wildfire, -WI, Strong Wind, \ No newline at end of file +Code,Label +CF,Coastal Flood +CS,Convective Storm +DR,Drought +EQ,Earthquake +ET,Extreme Temperature +FL,Flood +LS,Landslide +MH,Multi-Hazard +TS,Tsunami +VO,Volcanic +WF,Wildfire +WI,Strong Wind diff --git a/specs/code-lists/CSV/occupancy.csv b/specs/code-lists/CSV/occupancy.csv index e47b3596..b961b4c6 100644 --- a/specs/code-lists/CSV/occupancy.csv +++ b/specs/code-lists/CSV/occupancy.csv @@ -1,12 +1,12 @@ -Code, Label, Definition -Residential,, -Commercial,, -Industrial,, -Infrastructure,, -Healthcare,, -Educational,, -Government,, -Crop,, -Livestock,, -Forestry,, -Mixed,, \ No newline at end of file +Code +Residential +Commercial +Industrial +Infrastructure +Healthcare +Educational +Government +Crop +Livestock +Forestry +Mixed diff --git a/specs/code-lists/CSV/process_type.csv b/specs/code-lists/CSV/process_type.csv index c90a25ec..884263ae 100644 --- a/specs/code-lists/CSV/process_type.csv +++ b/specs/code-lists/CSV/process_type.csv @@ -1,29 +1,29 @@ -Code, Label, Definition -FCF, Coastal Flood, -FSS, Storm Surge, -TOR, Tornado, -DTA, Agricultural Drought, -DTH, Hydrological Drought, -DTM, Meteorological Drought, -DTS, Socio-economic Drought, -Q1R, Primary Rupture, -Q2R, Secondary Rupture, -QGM, Ground Motion, -QLI, Liquefaction, -ECD, Extreme cold, -EHT, Extreme heat, -FFF, Fluvial Flood, -FPF, Pluvial Flood, -LAV, Snow Avalanche, -LSL, Landslide (general), -TSI, Tsunami, -VAF, Ashfall, -VBL, Ballistics, -VFH, Proximal hazards, -VLH, Lahar, -VLV, Lava, -VPF, Pyroclastic Flow, -WFI, Wildfire, -ETC, Extratropical cyclone, -TCY, Tropical cyclone, -MHC, Multi-Hazard combined, \ No newline at end of file +Code,Label +FCF,Coastal Flood +FSS,Storm Surge +TOR,Tornado +DTA,Agricultural Drought +DTH,Hydrological Drought +DTM,Meteorological Drought +DTS,Socio-economic Drought +Q1R,Primary Rupture +Q2R,Secondary Rupture +QGM,Ground Motion +QLI,Liquefaction +ECD,Extreme cold +EHT,Extreme heat +FFF,Fluvial Flood +FPF,Pluvial Flood +LAV,Snow Avalanche +LSL,Landslide (general) +TSI,Tsunami +VAF,Ashfall +VBL,Ballistics +VFH,Proximal hazards +VLH,Lahar +VLV,Lava +VPF,Pyroclastic Flow +WFI,Wildfire +ETC,Extratropical cyclone +TCY,Tropical cyclone +MHC,Multi-Hazard combined diff --git a/specs/code-lists/CSV/val_type.csv b/specs/code-lists/CSV/val_type.csv index 3dd63f8a..8fbc96ac 100644 --- a/specs/code-lists/CSV/val_type.csv +++ b/specs/code-lists/CSV/val_type.csv @@ -1,5 +1,5 @@ -Code, Label, Definition -Structure, Structure, -Content, Content, -Product, Product, -Others, Others, \ No newline at end of file +Code,Label +Structure,Structure +Content,Content +Product,Product +Others,Others diff --git a/specs/hazard-data-package/ex-valid-datapackage.json b/specs/hazard-data-package/ex-valid-datapackage.json index 947dc5c5..f03ef4bd 100644 --- a/specs/hazard-data-package/ex-valid-datapackage.json +++ b/specs/hazard-data-package/ex-valid-datapackage.json @@ -10,33 +10,39 @@ "path": "https://licenses.opendefinition.org/licenses/CC-BY-SA-4.0.json" } ], - "spatial": [ "..." ], + "spatial": [ + "..." + ], "eventset": { "hazard_type": "...", "analysis_type": "...", "id": "...", - "spatial": [ "..." ], + "spatial": [ + "..." + ], "start_date": "2021-04-01T20:20:39+00:00", "end_date": "2021-04-01T20:20:39+00:00", "year": "...", "time_span": "..." }, - "events": [{ - "id": "...", - "calculation_method": "...", - "frequency": "...", - "description": "", - "return_period": "...", - "occurrence": { - "start_date": "2021-04-01T20:20:39+00:00", - "end_date": "2021-04-01T20:20:39+00:00" - }, - "trigger": { - "hazard_type": "...", - "process_type": "...", - "event": "..." + "events": [ + { + "id": "...", + "calculation_method": "...", + "frequency": "...", + "description": "", + "return_period": "...", + "occurrence": { + "start_date": "2021-04-01T20:20:39+00:00", + "end_date": "2021-04-01T20:20:39+00:00" + }, + "trigger": { + "hazard_type": "...", + "process_type": "...", + "event": "..." + } } - }], + ], "resources": [ { "name": "fp1.tif", diff --git a/specs/hazard-data-package/schema.json b/specs/hazard-data-package/schema.json index 58aed514..c7ad1c86 100644 --- a/specs/hazard-data-package/schema.json +++ b/specs/hazard-data-package/schema.json @@ -44,239 +44,242 @@ "description": "A description of the dataset" }, "licenses": { - "title": "licenses", - "description": "The license(s) under which this package is published.", - "type": "array", - "minItems": 1, - "items": { - "title": "License", - "description": "A license for this descriptor.", - "type": "object", - "properties": { - "name": { - "title": "name", - "description": "MUST be an Open Definition license identifier, see http://licenses.opendefinition.org/", - "type": "string" - }, - "path": { - "title": "path", - "description": "A fully qualified URL, or a POSIX file path..", - "type": "string" - } - }, - "required": [ "name", "path"] - } - }, + "title": "licenses", + "description": "The license(s) under which this package is published.", + "type": "array", + "minItems": 1, + "items": { + "title": "License", + "description": "A license for this descriptor.", + "type": "object", + "properties": { + "name": { + "title": "name", + "description": "MUST be an Open Definition license identifier, see http://licenses.opendefinition.org/", + "type": "string" + }, + "path": { + "title": "path", + "description": "A fully qualified URL, or a POSIX file path..", + "type": "string" + } + }, + "required": [ + "name", + "path" + ] + } + }, "spatial": { - "title": "spatial", - "description": "spatial coverage of the datasets", - "minItems": 1, - "items": { - "type": "string" - } - }, + "title": "spatial", + "description": "spatial coverage of the datasets", + "minItems": 1, + "items": { + "type": "string" + } + }, "eventset": { - "title": "eventset", - "description": "An Event Set descriptor, that describes the circumstances in which a hazard occurs", - "type": "object", - "properties": { - "hazard_type": { - "title": "hazard_type", - "description": "Identifies the type of hazard. Valid values are defined by the RDL Hazard Type Code list", - "type": "string" - }, - "analysis_type": { - "title": "analysis_type", - "description": "Identifies the type of analysis used to generate the Footprints. Valid values are defined by the RDL Analysis Type Code List", - "type": "string" - }, - "id": { - "title": "id", - "description": "A globally unique identifier for the package, e.g. a UUID", - "type": "string" - }, - "spatial": { - "title": "spatial", - "description": "spatial coverage of the datasets", - "minItems": 1, - "items": { - "type": "string" + "title": "eventset", + "description": "An Event Set descriptor, that describes the circumstances in which a hazard occurs", + "type": "object", + "properties": { + "hazard_type": { + "title": "hazard_type", + "description": "Identifies the type of hazard. Valid values are defined by the RDL Hazard Type Code list", + "type": "string" + }, + "analysis_type": { + "title": "analysis_type", + "description": "Identifies the type of analysis used to generate the Footprints. Valid values are defined by the RDL Analysis Type Code List", + "type": "string" + }, + "id": { + "title": "id", + "description": "A globally unique identifier for the package, e.g. a UUID", + "type": "string" + }, + "spatial": { + "title": "spatial", + "description": "spatial coverage of the datasets", + "minItems": 1, + "items": { + "type": "string" + } + }, + "start_date": { + "title": "start date", + "description": "The datetime at which the modelled scenarios start", + "type": "string", + "format": "date-time" + }, + "end_date": { + "title": "end date", + "description": "The datetime at which the modelled scenarios end", + "type": "string", + "format": "date-time" + }, + "year": { + "title": "year", + "description": "The reference year to which the modelled scenario refers", + "type": "string" + }, + "time_span": { + "title": "time span", + "description": "The extent of the time period covered by the events included in the current scenario hazard analysis", + "type": "string" + } + }, + "required": [ + "hazard_type", + "process_type" + ] + }, + "events": { + "title": "events", + "description": "A list of Event descriptors", + "minItems": 1, + "items": { + "title": "Event", + "description": "An event", + "type": "object", + "properties": { + "id": { + "title": "id", + "description": "A globally unique identifier for the package, e.g. a UUID", + "type": "string" + }, + "calculation_method": { + "title": "calculation method", + "description": "A description of how this Event was generated, e.g. observed or simulated. Valid values are defined by the RDL Calculation Method Code List", + "type": "string" + }, + "frequency": { + "title": "frequency", + "description": "", + "type": "string" + }, + "description": { + "title": "description", + "type": "string", + "description": "A description of the dataset" + }, + "return_period": { + "title": "return period", + "type": "string", + "description": "The probability of the event occuring expressed as an array of return periods ('10', '100', '1000') or as a single String specifying a range (10-1000)" + }, + "occurence": { + "title": "occurence", + "type": "object", + "description": "", + "properties": { + "start_date": { + "title": "start date", + "description": "The datetime at which the modelled scenarios start", + "type": "string", + "format": "date-time" + }, + "end_date": { + "title": "end date", + "description": "The datetime at which the modelled scenarios end", + "type": "string", + "format": "date-time" + } } }, - "start_date": { - "title": "start date", - "description": "The datetime at which the modelled scenarios start", - "type": "string", - "format": "date-time" - }, - "end_date": { - "title": "end date", - "description": "The datetime at which the modelled scenarios end", - "type": "string", - "format": "date-time" - }, - "year": { - "title": "year", - "description": "The reference year to which the modelled scenario refers", - "type": "string" - }, - "time_span": { - "title": "time span", - "description": "The extent of the time period covered by the events included in the current scenario hazard analysis", - "type": "string" - } - }, - "required": [ - "hazard_type", - "process_type" - ] - }, - "events": { - "title": "events", - "description": "A list of Event descriptors", - "minItems": 1, - "items": { - "title": "Event", - "description": "An event", - "type": "object", - "properties": { - "id": { - "title": "id", - "description": "A globally unique identifier for the package, e.g. a UUID", - "type": "string" - }, - "calculation_method": { - "title": "calculation method", - "description": "A description of how this Event was generated, e.g. observed or simulated. Valid values are defined by the RDL Calculation Method Code List", - "type": "string" - }, - "frequency": { - "title": "frequency", - "description": "", - "type": "string" - }, - "description": { - "title": "description", - "type": "string", - "description": "A description of the dataset" - }, - "return_period": { - "title": "return period", - "type": "string", - "description": "The probability of the event occuring expressed as an array of return periods ('10', '100', '1000') or as a single String specifying a range (10-1000)" - }, - "occurence": { - "title": "occurence", - "type": "object", - "description": "", - "properties": { - "start_date": { - "title": "start date", - "description": "The datetime at which the modelled scenarios start", - "type": "string", - "format": "date-time" - }, - "end_date": { - "title": "end date", - "description": "The datetime at which the modelled scenarios end", - "type": "string", - "format": "date-time" - } - } - }, - "trigger": { - "title": "trigger", - "type": "object", - "description": "", - "properties": { - "hazard_type": { - "title": "hazard_type", - "description": "Identifies the type of hazard. Valid values are defined by the RDL Hazard Type Code list", - "type": "string" - }, - "process_type": { - "title": "process_type", - "description": "Identifies the type of analysis used to generate the Footprints. Valid values are defined by the RDL Process Type Code List", - "type": "string" - }, - "event": { - "title": "event", - "description": "Associates this event with another event. The value should match the value of an id attribute of in the event array.", - "type": "string" - } - } - } - }, - "required": [ - "id", - "calculation_method", - "frequency" - ] - } - }, - "resources": { - "title": "footprints", - "description": "A list of the Hazard Data Package Resources contained in the package. ", - "type": "array", - "minItems": 1, - "items": { - "title": "Footprint", - "description": "Data Resource.", - "type": "object", - "required": [ - "name", - "path" - ], - "properties": { - "name": { - "title": "name", - "description": "An identifier string. Lower case characters with `.`, `_`, `-` and `/` are allowed.", - "type": "string", - "pattern": "^([-a-z0-9._/])+$" - }, - "path": { - "title": "path", - "description": "Provides the file system path, or a remote URL, that provides a location for the resource", - "type": "string" - }, - "mediatype": { - "title": "media type", - "description": "The media type of this resource. Can be any valid media type listed with [IANA](https://www.iana.org/assignments/media-types/media-types.xhtml).", - "type": "string", - "pattern": "^(.+)/(.+)$" - }, - "process_type": { - "title": "process_type", - "description": "The type of hazard process modelled. Valid values for the process_type property are defined by the RDL Process Type Code List", - "type": "string" - }, - "imt": { - "title": "imt", - "description": "The intensity measure. Valid values are described in the RDL Intensity Measure code list", - "type": "string" - }, - "event": { - "title": "event", - "description": "Associates this resource with an event. The value should match the value of an id attribute of in the event array.", - "type": "string" - }, - "title": { - "title": "title", - "description": "A human-readable title.", - "type": "string" - }, - "epsg": { - "title": "epsg", - "description": "Describes the spatial reference used in the data.", - "type": "string" - }, - "data_uncertainty": { - "title": "data_uncertainty", - "description": "Comments about the uncertainty of the data", - "type": "string" + "trigger": { + "title": "trigger", + "type": "object", + "description": "", + "properties": { + "hazard_type": { + "title": "hazard_type", + "description": "Identifies the type of hazard. Valid values are defined by the RDL Hazard Type Code list", + "type": "string" + }, + "process_type": { + "title": "process_type", + "description": "Identifies the type of analysis used to generate the Footprints. Valid values are defined by the RDL Process Type Code List", + "type": "string" + }, + "event": { + "title": "event", + "description": "Associates this event with another event. The value should match the value of an id attribute of in the event array.", + "type": "string" + } } } + }, + "required": [ + "id", + "calculation_method", + "frequency" + ] + } + }, + "resources": { + "title": "footprints", + "description": "A list of the Hazard Data Package Resources contained in the package. ", + "type": "array", + "minItems": 1, + "items": { + "title": "Footprint", + "description": "Data Resource.", + "type": "object", + "required": [ + "name", + "path" + ], + "properties": { + "name": { + "title": "name", + "description": "An identifier string. Lower case characters with `.`, `_`, `-` and `/` are allowed.", + "type": "string", + "pattern": "^([-a-z0-9._/])+$" + }, + "path": { + "title": "path", + "description": "Provides the file system path, or a remote URL, that provides a location for the resource", + "type": "string" + }, + "mediatype": { + "title": "media type", + "description": "The media type of this resource. Can be any valid media type listed with [IANA](https://www.iana.org/assignments/media-types/media-types.xhtml).", + "type": "string", + "pattern": "^(.+)/(.+)$" + }, + "process_type": { + "title": "process_type", + "description": "The type of hazard process modelled. Valid values for the process_type property are defined by the RDL Process Type Code List", + "type": "string" + }, + "imt": { + "title": "imt", + "description": "The intensity measure. Valid values are described in the RDL Intensity Measure code list", + "type": "string" + }, + "event": { + "title": "event", + "description": "Associates this resource with an event. The value should match the value of an id attribute of in the event array.", + "type": "string" + }, + "title": { + "title": "title", + "description": "A human-readable title.", + "type": "string" + }, + "epsg": { + "title": "epsg", + "description": "Describes the spatial reference used in the data.", + "type": "string" + }, + "data_uncertainty": { + "title": "data_uncertainty", + "description": "Comments about the uncertainty of the data", + "type": "string" + } } } + } } } diff --git a/tests/test_csv.py b/tests/test_csv.py new file mode 100644 index 00000000..4090d285 --- /dev/null +++ b/tests/test_csv.py @@ -0,0 +1,85 @@ +import csv +import json +import os +import warnings +from io import StringIO + +import pytest +import requests +from jscc.schema import is_codelist +from jscc.testing.filesystem import walk_csv_data +from jscc.testing.util import warn_and_assert + +cwd = os.getcwd() +repo_name = os.path.basename(os.getenv('GITHUB_REPOSITORY', cwd)) + + +def formatwarning(message, category, filename, lineno, line=None): + return str(message).replace(cwd + os.sep, '') + + +warnings.formatwarning = formatwarning +pytestmark = pytest.mark.filterwarnings('always') + + +def test_valid(): + """ + Ensures all CSV files are valid: no empty rows or columns, no leading or trailing whitespace in cells, same number + of cells in each row. + """ + errors = 0 + + for path, name, text, fieldnames, rows in walk_csv_data(): + codelist = is_codelist(fieldnames) + width = len(fieldnames) + columns = [] + + duplicates = len(fieldnames) - len(set(fieldnames)) + if duplicates: + errors += 1 + warnings.warn(f'ERROR: {path} has {duplicates} duplicate column headers') + + for row_index, row in enumerate(rows, 2): + expected = len(row) + duplicates + if expected != width: + errors += 1 + warnings.warn(f'ERROR: {path} has {expected} not {width} columns in row {row_index}') + if not any(row.values()): + errors += 1 + warnings.warn(f'ERROR: {path} has empty row {row_index}') + else: + for col_index, (header, cell) in enumerate(row.items(), 1): + if col_index > len(columns): + columns.append([]) + + columns[col_index - 1].append(cell) + + # Extra cells are added to a None columns. + if header is None and isinstance(cell, list): + cells = cell + else: + cells = [cell] + + for cell in cells: + if cell is not None and cell != cell.strip(): + errors += 1 + warnings.warn(f'ERROR: {path} {header} "{cell}" has leading or trailing whitespace at ' + f'{row_index},{col_index}') + + for col_index, column in enumerate(columns, 1): + if not any(column) and codelist: + errors += 1 + warnings.warn(f'ERROR: {path} has empty column {col_index}') + + output = StringIO() + writer = csv.DictWriter(output, fieldnames=fieldnames, lineterminator='\n') + writer.writeheader() + writer.writerows(rows) + expected = output.getvalue() + + if text != expected and repo_name != 'sample-data': + errors += 1 + warnings.warn(f'ERROR: {path} is improperly formatted (e.g. missing trailing newline, extra quoting ' + f'characters, non-"\\n" line terminator):\n{text!r}\n{expected!r}') + + assert errors == 0, 'One or more codelist CSV files are invalid. See warnings below.' diff --git a/tests/test_json.py b/tests/test_json.py new file mode 100644 index 00000000..6816cdfd --- /dev/null +++ b/tests/test_json.py @@ -0,0 +1,35 @@ +from jscc.testing.checks import get_empty_files, get_misindented_files, get_invalid_json_files +from jscc.testing.util import warn_and_assert + +import os + + +this_dir = os.path.dirname(os.path.realpath(__file__)) +absolute_source_schema_dir = this_dir + '/../schema/' +absolute_source_codelist_dir = this_dir + '/../codelists/' + + +def test_empty(): + """Tests that files (JSON and other files) are not empty.""" + empty_files_paths = [path for path in get_empty_files() if "src/" not in path[0]] + warn_and_assert(empty_files_paths, "{0} is empty, run: rm {0}", "Files are empty. See warnings below.") + + +def test_indent(): + """ + Test that JSON files are indented properly. + Note this test can often fail on problems that are not to do with indents. + """ + misindented_files_paths = [path for path in get_misindented_files() if "src/" not in path[0]] + warn_and_assert( + misindented_files_paths, + "{0} is not indented as expected", + "Files are not indented as expected. See warnings below", + ) + + +def test_invalid_json(): + """Test whether all JSON files can be parsed.""" + warn_and_assert( + get_invalid_json_files(excluded=('.git', '.ve', '_static', 'build', 'fixtures', "_build")), "{0} is not valid JSON: {1}", "JSON files are invalid. See warnings below." + ) diff --git a/tests/test_schema.py b/tests/test_schema.py new file mode 100644 index 00000000..ae893048 --- /dev/null +++ b/tests/test_schema.py @@ -0,0 +1,58 @@ +from jscc.testing.filesystem import walk_json_data +from jscc.schema import is_json_schema +from jscc.testing.util import http_get +import jsonref +import pytest +from jscc.testing.checks import ( + validate_array_items, + validate_codelist_enum, + validate_deep_properties, + validate_items_type, + validate_letter_case, + validate_merge_properties, + validate_metadata_presence, + validate_null_type, + validate_object_id, + validate_ref, + validate_schema, +) +from jsonschema import FormatChecker +from jsonschema.validators import Draft202012Validator + +schemas = [(path, name, data) for path, name, _, data in walk_json_data(top='schema') if is_json_schema(data)] +metaschema = http_get('https://json-schema.org/draft/2020-12/schema').json() + +@pytest.mark.parametrize('path,name,data', schemas) +def test_schema_valid(path, name, data): + validate_json_schema(path, name, data, metaschema) + +validator = Draft202012Validator(Draft202012Validator.META_SCHEMA, format_checker=FormatChecker()) + +@pytest.mark.parametrize('path,name,data', schemas) +def test_schema_valid(path, name, data): + validate_json_schema(path, name, data, metaschema) + + +def validate_json_schema(path, name, data, schema): + errors = 0 + + errors += validate_schema(path, data, validator) + errors += validate_array_items(path, data) + errors += validate_items_type(path, data) + + # Codelist fields are not yet implemented + # errors += validate_codelist_enum(path, data) + + errors += validate_merge_properties(path, data) + errors += validate_ref(path, data) + + # Titles and descriptions are not yet added + # errors += validate_metadata_presence(path, data) + + errors += validate_object_id(path, jsonref.replace_refs(data)) + errors += validate_null_type(path, data, no_null=True) + + # Here, we don't add to `errors`, in order to not count these warnings as errors. + validate_deep_properties(path, data) + + assert not errors, 'One or more JSON Schema files are invalid. See warnings below.'