Commit f71e8dc5 authored by Tara Evaz Zadeh's avatar Tara Evaz Zadeh
Browse files

Modified descriptions in manual.md and preprocessor.py

parent 7ac40395
Pipeline #26134 passed with stage
in 1 minute and 30 seconds
......@@ -31,7 +31,7 @@ Definitions in this terminology section are taken from the `Glossary` section of
To run the program please call:
`python3 damage_calculator.py [OPTIONS] -e filepath -f pathname -g filepath -p filepath -t filepath`
`python3 damage_calculator.py [OPTIONS] -e filepath -f pathname -g filepath -p filepath -t filepath`
Use
......@@ -92,7 +92,7 @@ Please note that the assets of the region of interest can be presented different
geometry of each tile.
building_id:
An ID code used to trace back each asset into its source building. In this case, if an asset originates from a tile (not coming from a building), `building_id` is set to `-1`. `building_id`s can be freely defined as long as they contain numbers, letters and `_` only.
An ID code used to trace back each asset into its source building. In this case, if an asset originates from a tile (not coming from a building), `building_id` is set to `-1`. `building_id`s can be freely defined as long as they contain numbers, letters and `_` only.
building_geometry:
Geometry of each building asset. In case of `building_id` being `-1`, the geometry is defined as `"POINT EMPTY"`.
......@@ -220,13 +220,13 @@ PoO[_complete_] = PoE[_complete_]
# Preprocessor
This program imports a CSV exposure model into a database for damage calculation using the `losscalculator`.
The `losscalculator` computes earthquake-related damage in a building-specific way. For a building-specific calculation, the exposure model needs to include both the geometries of tiles ( As explained above in the section `-e` input, each asset in an exposure model can be represented either by their exact locations or in center of a tile.) and the buildings in addition to the data provided by
an OpenQuake-compatible exposure model (An OpenQuake-compatible exposure model CSV file with minimum information provided, has the headers: `id,lon,lat,taxonomy,number,structural,night,occupancy`). In fact, this program puts the geometries of both tiles and buildings together along with the OpenQuake-compatible exposure model information in a database format.
In addition to the `import` command (which use is explained above), the `preprocessor.py` provides an `export` command, using which the database exposure model is written to an output CSV file format.
The `losscalculator` computes earthquake-related damage in a building-specific way. For a building-specific calculation, the exposure model needs to include both the geometries of tiles (As explained above in the section `-e` input, each asset in an exposure model can be represented either by their exact locations or in center of a tile.) and the buildings in addition to the data provided by
an OpenQuake-compatible exposure model (An OpenQuake-compatible exposure model CSV file, with minimum information provided, has the headers: `id,lon,lat,taxonomy,number,structural,night,occupancy`). In fact, this program puts the geometries of both tiles and buildings together along with the OpenQuake-compatible exposure model information in a database format.
In addition to the `import` command (which use is explained above), the `preprocessor.py` provides an `export` command for exporting the database exposure model to a CSV file.
## Usage
To import an input CSV exposure model file to database, execute:
To import an input CSV exposure model file to a database, execute:
`python3 preprocessor.py import -d ../example_preprocessor/augmented_exposure.db
-i ../example_preprocessor/data/exposure_*.csv
-g ../example_preprocessor/data/building_to_cellid_map.csv`
......@@ -238,7 +238,7 @@ To export a database to a CSV output exposure model, execute:
## Program input parameters
**`-i`, `--import-search-pattern`**: str, optional
Search pattern for the input CSV exposure model files (e.g. '*.csv').
Search pattern for the input CSV exposure model files (e.g. `*.csv`).
Each input CSV exposure model file should follow the format below:
`id,lon,lat,taxonomy,number,structural,night,occupancy,admin_name,admin_ID,origin_id`
Where `origin_id` is a unique ID which enables us to trace an asset back to either the tile or the building it is originated from.
......@@ -253,8 +253,6 @@ exposure file with header
tile_geometry, building_id ,building_geometry` is exported.
**`-g`, `--building-geometries`**: str, optional
Filepath of the geometry definitions.
OR
Defines the path to the file which maps building IDs (`origin-id` column in an input OpenQuake-compatible CSV exposure model file points to building IDs if the asset is originated from a building or tile IDs if the asset is defined by center of a tile) to both the building geometries and the tile IDs in which the building centroids are located.
Only required if there are building assets in the `-i` input file (the input OpenQuake-compatible CSV exposure model file).
Building geometries file example extract:
......@@ -273,22 +271,22 @@ Building geometries file example extract:
Please note that the delimiter is `;`.
**`-o`, `--export-filepath`**: str, optional
Defines the path to a file, to which, the database exposure model is exported in CSV format.
The exported CSV exposure model file, follows the format below:
Defines the path to a file, to which the database exposure model is exported in CSV format.
The exported CSV exposure model file follows the format below:
`id,lon,lat,taxonomy,number,structural,night,occupancy,admin_name,admin_ID, tile_id,
tile_geometry, building_id ,building_geometry`
Only required when using `export` module.
Only required when using the `export` module.
**`-s`, `--spatialite-extension`**: str, optional
Defines the file path of the spatialite extension. (default: mod_spatialite)
Defines the file path of the Spatialite extension. (default: mod_spatialite)
**`-w`** overwrite existing result file: optional
To overwrite an existing exposure model file.
In order to use this program, please note that:
The spacing of the grid is 10 arc-seconds. The tile ID starts from North-West corner of the
world, moves East by row, and finishes at the South-East corner of the world. First tile ID
is 0, last tile ID is 8,398,079,999 (total number of cells is 8,398,080,000).
In order to use this program, please note:
The spacing of the grid is 10 arc-seconds. The tile ID starts from the north-west corner of the
world, moves east per row, and finishes in the south-east corner of the world. First tile ID
is 0, last tile ID is 8,398,079,999 (total number of tiles is 8,398,080,000).
## Output
### Using import command
......@@ -297,7 +295,7 @@ The output using import command is a database exposure model file. An example of
### Using export command
A CSV exposure model file (OQ-compatible) exported from a database exposure model with headers as below:
The output using the export command is a CSV exposure model file (OQ-compatible) exported from a database exposure model with headers as below:
`id,lon,lat,taxonomy,number,structural,night,occupancy,admin_name,admin_ID, tile_id,
tile_geometry, building_id ,building_geometry`
Definition of each column of the header is defined above under `-e` input parameter `losscalculator` section.
......@@ -17,9 +17,7 @@
# along with this program. If not, see http://www.gnu.org/licenses/.
"""
TODO: Update description
Returns an exposure model along with the asset geometries as either a csv or database file.
Returns an exposure model along with the asset geometries as either a CSV or a database file.
Please use either `import` to import exposure data into the database or `export` to export to
an OpenQuake-compatible exposure CSV file.
......@@ -62,7 +60,7 @@ To overwrite an existing exposure model file.
In order to use this program, please note:
The spacing of the grid is 10 arc-seconds. The tile ID starts from the north-west corner of the
world, moves east per row, and finishes at the south-east corner of the world. First tile ID
is 0, last tile ID is 8,398,079,999 (total number of cells is 8,398,080,000).
is 0, last tile ID is 8,398,079,999 (total number of tiles is 8,398,080,000).
Execution examples:
......@@ -72,7 +70,7 @@ python3 preprocessor.py import -d ../example_preprocessor/augmented_exposure.db
-i ../example_preprocessor/data/exposure_*.csv
-g ../example_preprocessor/data/building_to_cellid_map.csv
Create a csv exposure model file:
Create a CSV exposure model file:
python3 preprocessor.py export -d ../example_preprocessor/augmented_exposure.db
-o ../example_preprocessor/augmented_exposure.csv
......@@ -93,7 +91,7 @@ logger.addHandler(logging.StreamHandler(sys.stdout))
def main():
"""
Returns an exposure model along with the asset geometries as either a csv or database file.
Returns an exposure model along with the asset geometries as either a CSV or database file.
"""
parser = argparse.ArgumentParser(
description="This program imports exposure data into an exposure database "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment