From 8371831de09b67aa06dcf2c5fb8f3d2f1954ec01 Mon Sep 17 00:00:00 2001 From: drotheram Date: Mon, 7 Feb 2022 11:56:49 -0800 Subject: [PATCH] Add dsra hexgrid indices (#166) * add additional ES indices for dsra/psra/exposure * run modified es index scripts * run dsra shkmap script + exposure script bug fix * add additional ES indices for dsra/psra/exposure * run modified es index scripts * run dsra shkmap script + exposure script bug fix * remove global fabric - null value bug --- python/add_data.sh | 24 +-- python/calculate_all_dsra_jenks.py | 44 ----- python/dsraShakemap_postgres2es.py | 189 ++++++++++++++++++++ python/dsra_postgres2es.py | 57 ------ python/exposure_postgres2es.py | 274 +++++++++++++++++++++-------- python/psra_postgres2es.py | 53 +++++- 6 files changed, 458 insertions(+), 183 deletions(-) delete mode 100644 python/calculate_all_dsra_jenks.py create mode 100644 python/dsraShakemap_postgres2es.py diff --git a/python/add_data.sh b/python/add_data.sh index 26e52b50..1fe5395b 100755 --- a/python/add_data.sh +++ b/python/add_data.sh @@ -892,16 +892,17 @@ export_to_elasticsearch() { # Load Deterministic Model Indicators # shellcheck disable=SC2154 if [[ "$loadDsraScenario" = true ]]; then -for eqscenario in "${EQSCENARIO_LIST[@]}"; do - LOG "Creating Elasticsearch indexes for DSRA" - #RUN python3 dsra_postgres2es.py --eqScenario="$eqscenario" --dbview="indicators" --idField="building" - RUN python3 dsra_postgres2es.py --eqScenario="$eqscenario" - - # LOG "Creating DSRA Kibana Index Patterns" - # Need to develop saved object workflow for automated index patern generation - # RUN curl -X POST -H "Content-Type: application/json" "${KIBANA_ENDPOINT}/s/gsc-cgc/api/saved_objects/index-pattern/opendrr_dsra_${eqscenario}_indicators_s" -H "kbn-xsrf: true" -d "{ 'attributes': { 'title':'opendrr_dsra_${eqscenario}_indicators_s'}}" - # RUN curl -X POST -H "Content-Type: application/json" "${KIBANA_ENDPOINT}/s/gsc-cgc/api/saved_objects/index-pattern/opendrr_dsra_${eqscenario}_indicators_b" -H "kbn-xsrf: true" -d "{ 'attributes': { 'title':'opendrr_dsra_${eqscenario}_indicators_b'}}" -done + for eqscenario in "${EQSCENARIO_LIST[@]}"; do + LOG "Creating Elasticsearch indexes for DSRA" + #RUN python3 dsra_postgres2es.py --eqScenario="$eqscenario" --dbview="indicators" --idField="building" + RUN python3 dsra_postgres2es.py --eqScenario="$eqscenario" + RUN python3 dsraShakemap_postgres2es.py --eqScenario="$eqscenario" + + # LOG "Creating DSRA Kibana Index Patterns" + # Need to develop saved object workflow for automated index patern generation + # RUN curl -X POST -H "Content-Type: application/json" "${KIBANA_ENDPOINT}/s/gsc-cgc/api/saved_objects/index-pattern/opendrr_dsra_${eqscenario}_indicators_s" -H "kbn-xsrf: true" -d "{ 'attributes': { 'title':'opendrr_dsra_${eqscenario}_indicators_s'}}" + # RUN curl -X POST -H "Content-Type: application/json" "${KIBANA_ENDPOINT}/s/gsc-cgc/api/saved_objects/index-pattern/opendrr_dsra_${eqscenario}_indicators_b" -H "kbn-xsrf: true" -d "{ 'attributes': { 'title':'opendrr_dsra_${eqscenario}_indicators_b'}}" + done RUN python3 dsraExtents_postgres2es.py fi @@ -921,8 +922,7 @@ done # shellcheck disable=SC2154 if [[ $loadPhysicalExposure = true ]]; then LOG "Creating Elasticsearch indexes for Physical Exposure" - RUN python3 exposure_postgres2es.py --aggregation="building" --geometry=geom_point - RUN python3 exposure_postgres2es.py --aggregation="sauid" --geometry=geom_poly + RUN python3 exposure_postgres2es.py LOG "Creating Exposure Kibana Index Patterns" RUN curl -X POST -H "Content-Type: application/json" "${KIBANA_ENDPOINT}/s/gsc-cgc/api/saved_objects/index-pattern/opendrr_nhsl_physical_exposure_indicators_s" -H "kbn-xsrf: true" -d '{ "attributes": { "title":"opendrr_nhsl_physical_exposure_indicators_s"}}' diff --git a/python/calculate_all_dsra_jenks.py b/python/calculate_all_dsra_jenks.py deleted file mode 100644 index 85fc8875..00000000 --- a/python/calculate_all_dsra_jenks.py +++ /dev/null @@ -1,44 +0,0 @@ -# ================================================================= -# -# Authors: Drew Rotheram -# -# ================================================================= - - -import os -import configparser - -from elasticsearch import Elasticsearch - -def get_config_params(args): - """ - Parse Input/Output columns from supplied *.ini file - """ - configParseObj = configparser.ConfigParser() - configParseObj.read(args) - return configParseObj - - - -for eqScenario in ['sim6p8_cr2022_rlz_1']: - for retrofitPrefix in ['b0','r1','r2']: - for view in ['casualties_agg_view', - 'damage_state_agg_view', - 'economic_loss_agg_view', - #'full_retrofit_agg_view', - 'functional_state_agg_view', - #'partial_retrofit_agg_view', - 'recovery_agg_view', - 'scenario_hazard_agg_view', - 'scenario_hazard_threat_agg_view', - 'scenario_rupture_agg_view', - 'social_disruption_agg_view']: - indexName = 'dsra_{eqScenario}_{retrofitPrefix}_{view}'.format(**{'eqScenario':eqScenario, 'retrofitPrefix':retrofitPrefix, 'view':view}) - viewIndex = es.indices.get(index=indexName) - list = [] - for field in viewIndex[indexName]['mappings']['properties']['properties']['properties']: - list.append(field) - for field in list: - print('Calculating break points for: '+'dsra_{eqScenario}_{retrofitPrefix}_{view}: {field}'.format(**{'eqScenario':eqScenario, 'retrofitPrefix':retrofitPrefix, 'view':view, 'field':field})) - try: - os.system('python3 caclulateJenks.py --eqScenario={eqScenario} --retrofitPrefix={retrofitPrefix} --dbview={view} --field={field} --bins=5'.format(**{'eqScenario':eqScenario, 'retrofitPrefix':retrofitPrefix, 'view':view})) \ No newline at end of file diff --git a/python/dsraShakemap_postgres2es.py b/python/dsraShakemap_postgres2es.py new file mode 100644 index 00000000..a510f746 --- /dev/null +++ b/python/dsraShakemap_postgres2es.py @@ -0,0 +1,189 @@ +#!/usr/bin/python3 +# ================================================================= +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2020-2021 Government of Canada +# +# Main Authors: Drew Rotheram +# Joost van Ulden +# ================================================================= + +import utils +import argparse + + +def main(): + args = parse_args() + + # Create shakemap object and load to ES + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'coordinates': { + 'type': 'geo_point' + }, + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap \ + ORDER BY dsra_{eqScenario}_shakemap."SiteID" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + # Create load 5km shakemap hexbin + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap_hexbin_5km".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap_hexbin_5km \ + ORDER BY dsra_{eqScenario}_shakemap_hexbin_5km."gridid_5" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + # Create load 10km shakemap hexbin + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap_hexbin_10km".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap_hexbin_10km \ + ORDER BY dsra_{eqScenario}_shakemap_hexbin_10km."gridid_10" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + # Create load 25km shakemap hexbin + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap_hexbin_25km".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap_hexbin_25km \ + ORDER BY dsra_{eqScenario}_shakemap_hexbin_25km."gridid_25" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + # Create load 50km shakemap hexbin + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap_hexbin_50km".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap_hexbin_50km \ + ORDER BY dsra_{eqScenario}_shakemap_hexbin_50km."gridid_50" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + # Create load 100km shakemap hexbin + dsraTable = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_dsra_{eqScenario}_shakemap_hexbin_100km".format(**{ + 'eqScenario': args.eqScenario}).lower(), + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap_hexbin_100km \ + ORDER BY dsra_{eqScenario}_shakemap_hexbin_100km."gridid_100" \ + LIMIT {{limit}} \ + OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) + ) + dsraTable.postgis2es() + + return + + +def parse_args(): + parser = argparse.ArgumentParser(description="script description") + parser.add_argument("--eqScenario", type=str, help="Earthquake scenario id", required=True) + args = parser.parse_args() + + return args + + +if __name__ == '__main__': + main() diff --git a/python/dsra_postgres2es.py b/python/dsra_postgres2es.py index d490d7c2..3dd97f59 100644 --- a/python/dsra_postgres2es.py +++ b/python/dsra_postgres2es.py @@ -96,63 +96,6 @@ def main(): ) dsraTable.postgis2es() - # Create shakemap object and load to ES - # dsraTable = utils.PostGISPointDataset( - # utils.PostGISConnection(), - # utils.ESConnection(settings={ - # 'settings': { - # 'number_of_shards': 1, - # 'number_of_replicas': 0 - # }, - # 'mappings': { - # 'properties': { - # 'coordinates': { - # 'type': 'geo_point' - # }, - # 'geometry': { - # 'type': 'geo_shape' - # } - # } - # } - # }), - # view = "opendrr_dsra_{eqScenario}_shakemap".format(**{ - # 'eqScenario': args.eqScenario}).lower(), - # sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ - # FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap \ - # ORDER BY dsra_{eqScenario}_shakemap."SiteID" \ - # LIMIT {{limit}} \ - # OFFSET {{offset}}'.format(**{ - # 'eqScenario': args.eqScenario}) - # ) - # dsraTable.postgis2es() - # Create shakemap object and load to ES - dsraTable = utils.PostGISdataset( - utils.PostGISConnection(), - utils.ESConnection(settings={ - 'settings': { - 'number_of_shards': 1, - 'number_of_replicas': 0 - }, - 'mappings': { - 'properties': { - 'coordinates': { - 'type': 'geo_point' - }, - 'geometry': { - 'type': 'geo_shape' - } - } - } - }), - view="opendrr_dsra_{eqScenario}_shakemap".format(**{ - 'eqScenario': args.eqScenario}).lower(), - sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ - FROM results_dsra_{eqScenario}.dsra_{eqScenario}_shakemap \ - ORDER BY dsra_{eqScenario}_shakemap."SiteID" \ - LIMIT {{limit}} \ - OFFSET {{offset}}'.format(**{'eqScenario': args.eqScenario}) - ) - dsraTable.postgis2es() return diff --git a/python/exposure_postgres2es.py b/python/exposure_postgres2es.py index 9a5b13c4..1139bdf9 100644 --- a/python/exposure_postgres2es.py +++ b/python/exposure_postgres2es.py @@ -26,87 +26,223 @@ # Main Function def main(): - args = parse_args() - - # index settings - if args.geometry == "geom_poly": - table = utils.PostGISdataset( - utils.PostGISConnection(), - utils.ESConnection(settings={ - 'settings': { - 'number_of_shards': 1, - 'number_of_replicas': 0 - }, - 'mappings': { - 'properties': { - 'geometry': { - 'type': 'geo_shape' - } + + # sauid level aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_s", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom_poly) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_s \ + ORDER BY nhsl_physical_exposure_indicators_s."Sauid" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + + # building level aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'coordinates': { + 'type': 'geo_point' + }, + 'geometry': { + 'type': 'geo_shape' } } - }), - view="opendrr_nhsl_physical_exposure_indicators_{agg}".format(**{ - 'agg': args.aggregation[0].lower()}), - sqlquerystring='SELECT *, ST_AsGeoJSON(geom_poly) \ - FROM \ - results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_{agg} \ - LIMIT {{limit}} \ - OFFSET {{offset}}'.format(**{ - 'agg': args.aggregation[0].lower()}) - ) - - elif args.geometry == "geom_point": - table = utils.PostGISdataset( - utils.PostGISConnection(), - utils.ESConnection(settings={ - 'settings': { - 'number_of_shards': 1, - 'number_of_replicas': 0 - }, - 'mappings': { - 'properties': { - 'coordinates': { - 'type': 'geo_point' - }, - 'geometry': { - 'type': 'geo_shape' - } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_b", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom_point) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_b \ + ORDER BY nhsl_physical_exposure_indicators_b."BldgID" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + + # hexbin 5km aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' } } - }), - view="opendrr_nhsl_physical_exposure_indicators_{agg}".format(**{ - 'agg': args.aggregation[0].lower()}), - sqlquerystring='SELECT *, ST_AsGeoJSON(geom_point) \ - FROM \ - results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_{agg} \ - LIMIT {{limit}} \ - OFFSET {{offset}}'.format(**{ - 'agg': args.aggregation[0].lower()}) - ) + } + }), + view="opendrr_nhsl_physical_exposure_indicators_hexbin_5km", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_5km \ + ORDER BY nhsl_physical_exposure_indicators_hexbin_5km."gridid_5" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + # hexbin 10km aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_hexbin_10km", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_10km \ + ORDER BY nhsl_physical_exposure_indicators_hexbin_10km."gridid_10" \ + LIMIT {limit} \ + OFFSET {offset}' + ) table.postgis2es() + # hexbin 25km aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_hexbin_25km", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_25km \ + ORDER BY nhsl_physical_exposure_indicators_hexbin_25km."gridid_25" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + + # hexbin 50km aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_hexbin_50km", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_50km \ + ORDER BY nhsl_physical_exposure_indicators_hexbin_50km."gridid_50" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + + # hexbin 100km aggregation + table = utils.PostGISdataset( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + }, + 'mappings': { + 'properties': { + 'geometry': { + 'type': 'geo_shape' + } + } + } + }), + view="opendrr_nhsl_physical_exposure_indicators_hexbin_100km", + sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + FROM \ + results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_100km \ + ORDER BY nhsl_physical_exposure_indicators_hexbin_100km."gridid_100" \ + LIMIT {limit} \ + OFFSET {offset}' + ) + table.postgis2es() + + # hexbin global fabric + # table = utils.PostGISdataset( + # utils.PostGISConnection(), + # utils.ESConnection(settings={ + # 'settings': { + # 'number_of_shards': 1, + # 'number_of_replicas': 0 + # }, + # 'mappings': { + # 'properties': { + # 'geometry': { + # 'type': 'geo_shape' + # } + # } + # } + # }), + # view="opendrr_nhsl_physical_exposure_indicators_hexbin_global_fabric", + # sqlquerystring='SELECT *, ST_AsGeoJSON(geom) \ + # FROM \ + # results_nhsl_physical_exposure.nhsl_physical_exposure_indicators_hexbin_global_fabric \ + # ORDER BY nhsl_physical_exposure_indicators_hexbin_global_fabric."gridid" \ + # LIMIT {limit} \ + # OFFSET {offset}' + # ) + # table.postgis2es() + return def parse_args(): parser = argparse.ArgumentParser(description="load exposure PostGIS to ES") - # parser.add_argument("--type", - # type=str, - # help="assets building(s) or people", - # required=True) - parser.add_argument("--aggregation", - type=str, - help="building or Sauid", - required=True) - parser.add_argument("--geometry", - type=str, - help="geom_point or geom_poly", - required=True) - # parser.add_argument("--idField", - # type=str, - # help="Field to use as Index ID. AssetID or Sauid", - # required=True) args = parser.parse_args() return args diff --git a/python/psra_postgres2es.py b/python/psra_postgres2es.py index e6e41edc..81d0820c 100644 --- a/python/psra_postgres2es.py +++ b/python/psra_postgres2es.py @@ -125,8 +125,59 @@ def main(): OFFSET {offset}' ) psraTable.postgis2es() - return + # psra Canada agg loss + psraTable = utils.PostGISTable( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + } + }), + view="opendrr_psra_canada_agg_loss", + sqlquerystring='SELECT * \ + FROM results_psra_canada.psra_canada_agg_loss \ + LIMIT {limit} \ + OFFSET {offset}' + ) + psraTable.postgis2es() + + # psra Canada expected loss + psraTable = utils.PostGISTable( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + } + }), + view="opendrr_psra_canada_expected_loss", + sqlquerystring='SELECT * \ + FROM results_psra_canada.psra_canada_expected_loss \ + LIMIT {limit} \ + OFFSET {offset}' + ) + psraTable.postgis2es() + + # psra Canada src loss + psraTable = utils.PostGISTable( + utils.PostGISConnection(), + utils.ESConnection(settings={ + 'settings': { + 'number_of_shards': 1, + 'number_of_replicas': 0 + } + }), + view="opendrr_psra_canada_src_loss", + sqlquerystring='SELECT * \ + FROM results_psra_canada.psra_canada_src_loss \ + LIMIT {limit} \ + OFFSET {offset}' + ) + psraTable.postgis2es() + + return if __name__ == '__main__': main()