Add a conversion tool to produce NRML files from a set of .csv + .mdata files

Bug #1226517 reported by Michele Simionato
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Natural hazards' Risk Markup Language (NRML)
Fix Committed
High
Michele Simionato

Bug Description

Editing XML files directly is a pain. The plan is to develop some desktop tools to generate the files needed for the engine starting from pre-existing .CSV files. This is possible if the user supplements the .CSV file with a .mdata file containing the additional info needed to generate the NRML file.
For instance, an exposure CSV file for population could be the following:

$ cat exposure_pop.csv
id,taxonomy,lon,lat,number
asset_01,IT-PV,9.15000,45.16667,7
asset_02,IT-CE,9.15333,45.12200,7

If we supplement it with the following file

$ cat exposure_pop.mdata
<?xml version="1.0" encoding="utf-8"?>
<exposureModel
category="population"
id="my_exposure_model_for_population"
taxonomySource="fake population datasource"
>
    <description>
        Sample population
    </description>
    <assets />
</exposureModel>

it is possible to generate a NRML files where the node <assets> is filled with the data from the CSV. The mechanism must work iteratively (i.e. do not keep the entire tree in memory). Moreover, it must be able to collect groups of CSV files. This is needed for vulnerability and fragility models, where there is a .CSV file for each set of functions, and all the sets belong to the same model. A simple idea is to use a common prefix. For instance the two pairs

  vulnerability-model__0.mdata
  vulnerability-model__0.csv
  vulnerability-model__1.mdata
  vulnerability-model__1.csv

can describe two vulnerability sets belonging to the same vulnerability model. The tool must be able to convert the four files into a single file named vulnerability-model.xml. This is the default output name. It must also be possible to specify a different output name, for instance to generate the output into a different directory.

Changed in oq-nrmllib:
assignee: nobody → Michele Simionato (michele-simionato)
importance: Undecided → High
status: New → In Progress
description: updated
description: updated
description: updated
description: updated
description: updated
Revision history for this message
Michele Simionato (michele-simionato) wrote :
Changed in oq-nrmllib:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.