GeoscienceAustralia / eqrm

Automatically exported from code.google.com/p/eqrm
Other
5 stars 4 forks source link

Vs30 values are not automatically calculated based on the site class. #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Remove the vs30 column in 
trunk\eqrm_core\implementation_tests\input\newc_par_site.csv
2. run check scenarios.

What is the expected output?
If vs30 values are not present, calculate them based on the site class.

 What do you see instead?
This is the error;
Running scenario TS_haz46.py
*******1142**********
Traceback (most recent call last):
  File "check_scenarios.py", line 650, in <module>
  File "check_scenarios.py", line 631, in check_scenarios_main
  File "check_scenarios.py", line 173, in run_scenarios
  File "/nas/gemd/georisk_models/earthquake/sandpits/duncan/EQRM/trunk/eqrm_core/eqrm_code/analysis.py", line 162, in main
    sites = load_data(eqrm_flags)
  File "/nas/gemd/georisk_models/earthquake/sandpits/duncan/EQRM/trunk/eqrm_core/eqrm_code/analysis.py", line 1081, in load_data
    sites = Sites.from_csv(name, SITE_CLASS=str, VS30=float)
  File "/nas/gemd/georisk_models/earthquake/sandpits/duncan/EQRM/trunk/eqrm_core/eqrm_code/sites.py", line 115, in from_csv
    sites_dict = csv_to_arrays(file, **attribute_conversions)
  File "/nas/gemd/georisk_models/earthquake/sandpits/duncan/EQRM/trunk/eqrm_core/eqrm_code/csv_interface.py", line 53, in csv_to_arrays
    answer = quick_convert_csv_to_arrays(f, **attributes)
  File "/nas/gemd/georisk_models/earthquake/sandpits/duncan/EQRM/trunk/eqrm_core/eqrm_code/csv_interface.py", line 84, in quick_convert_csv_to_arrays
    for row in reader]
KeyError: 'VS30'

_______________________
Maybe we are doing it for risk, but not hazard?
in analysis.py there is this section, which looks like it's doing what we want;
# Load the site_class 2 Vs30 mapping

Please use labels and text to provide additional information.

Original issue reported on code.google.com by duncan.g...@gmail.com on 8 Jun 2012 at 6:20

GoogleCodeExporter commented 9 years ago
The site file for run_type = risk does not contain a VS30 column and so is 
calculated as follows:

        # Load the site_class 2 Vs30 mapping
        amp_factor_file = 'site_class2vs30.csv'
        amp_factor_file = get_local_or_default(amp_factor_file,
                                               eqrm_flags.default_input_dir,
                                               eqrm_flags.input_dir)
        # Load Vs30 mapping
        site_class2Vs30 = load_site_class2Vs30(amp_factor_file)
        # Use the mapping to add Vs30 info to add Vs30 info to structures
        sites.set_Vs30(site_class2Vs30)

run_type = hazard, however, relies on the VS30 column in the site file and so 
the csv reader expects it to be present and populated.

There are two options here:
1. Remove VS30 from the site input file for all run_types and calculate based 
on site class defined in site_class2vs30.csv
2. Keep the files as is. If the VS30 column is present and populated use it. If 
not, calculate based on site class defined in site_class2vs30.csv

Original comment by b...@girorosso.com on 14 Jun 2012 at 2:00

GoogleCodeExporter commented 9 years ago
Option 2 is consistent with the original request. Currently testing an 
implementation of this which applies to all run_types.

- The sites csv file is loaded without VS30 as an attribute. This loads up the 
relevant attributes without failing completely if VS30 is not present.
- It will then inspect the VS30 attribute of the sites file.
-- If it works correctly then VS30 is used as the sites attribute.
-- If it throws an exception, catch and pass. The VS30 attribute is not added 
to sites.
- The load_data function of analysis checks for the presence of this attribute. 
If it is not present, load based on site class.

Original comment by b...@girorosso.com on 14 Jun 2012 at 5:07

GoogleCodeExporter commented 9 years ago
The changes in comment 2 are implemented in trunk revision 1156

Original comment by b...@girorosso.com on 14 Jun 2012 at 6:25