Example #1
0
    def test_event_activity_load_save(self):
        # Event_Activity object based on Test_Event_Set.test_Event_Activity
        num_events = 3
        event_indexes = array([0, 2])
        event_activities = array([[10, 20], [30, 40]])

        # Create a dummy event activity object
        ea1 = Event_Activity(num_events)
        ea1.set_event_activity(event_activities, event_indexes)

        # Save it to the temporary dir
        ea1.save(self.data_dir)

        # Load the second event activity object from file
        ea2 = Event_Activity.load(num_events, self.data_dir)

        assert allclose(ea1.event_activity, ea2.event_activity)
Example #2
0
    def test_event_activity_load_save(self):
        # Event_Activity object based on Test_Event_Set.test_Event_Activity
        num_events = 3
        event_indexes = array([0, 2])
        event_activities = array([[10, 20], [30, 40]])

        # Create a dummy event activity object
        ea1 = Event_Activity(num_events)
        ea1.set_event_activity(event_activities, event_indexes)

        # Save it to the temporary dir
        ea1.save(self.data_dir)

        # Load the second event activity object from file
        ea2 = Event_Activity.load(num_events, self.data_dir)

        assert allclose(ea1.event_activity, ea2.event_activity)
Example #3
0
    def create_analysis_objects(self):
        # Parameters
        rupture_centroid_lat = asarray([-30])
        rupture_centroid_lon = asarray([150])
        length = asarray([1.0])
        azimuth = asarray([2.0])
        width = asarray([3.0])
        dip = asarray([4.0])
        depth = asarray([5.0])
        Mw = asarray([6.0])
        atten_models = asarray([
            'Allen', 'Toro_1997_midcontinent', 'Sadigh_97',
            'Youngs_97_interface', 'Youngs_97_intraslab'
        ])
        atten_model_weights = asarray([0.2, 0.2, 0.2, 0.2, 0.2])
        atten_periods = asarray([0, 1.0, 2.0])
        sites_lat = asarray([-31])
        sites_lon = asarray([150])

        # Event Set
        event_set = Event_Set.create(rupture_centroid_lat=rupture_centroid_lat,
                                     rupture_centroid_lon=rupture_centroid_lon,
                                     azimuth=azimuth,
                                     dip=dip,
                                     Mw=Mw,
                                     depth=depth,
                                     area=length * width,
                                     width=width,
                                     length=length)

        # Event Activity
        event_activity = Event_Activity(len(event_set))
        event_activity.set_scenario_event_activity()

        # Source Model
        source_model = Source_Model.create_scenario_source_model(
            len(event_set))
        source_model.set_attenuation(atten_models, atten_model_weights)
        source_model.set_ground_motion_calcs(atten_periods)
        event_set.scenario_setup()
        event_activity.ground_motion_model_logic_split(source_model, True)

        # Sites
        sites = Sites(sites_lat, sites_lon)

        # SA
        # Set up synthetic SA figures
        # Dimensions -  spawn, gmm, rm, sites, events, period
        motion = zeros((1, len(atten_models), 1, len(sites), len(event_set),
                        len(atten_periods)),
                       dtype=float)
        # Allen
        motion[:, 0, :, :, :, 0] = 0  # period 0
        motion[:, 0, :, :, :, 1] = 1  # period 1.0
        motion[:, 0, :, :, :, 2] = 2  # period 2.0
        # Toro_1997_midcontinent
        motion[:, 1, :, :, :, 0] = 3  # period 0
        motion[:, 1, :, :, :, 1] = 4  # period 1.0
        motion[:, 1, :, :, :, 2] = 5  # period 2.0
        # Sadigh_97
        motion[:, 2, :, :, :, 0] = 6  # period 0
        motion[:, 2, :, :, :, 1] = 7  # period 1.0
        motion[:, 2, :, :, :, 2] = 8  # period 2.0
        # Youngs_97_interface
        motion[:, 3, :, :, :, 0] = 9  # period 0
        motion[:, 3, :, :, :, 1] = 10  # period 1.0
        motion[:, 3, :, :, :, 2] = 11  # period 2.0
        # Young_97_intraslab
        motion[:, 4, :, :, :, 0] = 12  # period 0
        motion[:, 4, :, :, :, 1] = 13  # period 1.0
        motion[:, 4, :, :, :, 2] = 14  # period 2.0

        # A minimal set of eqrm_flags so create_parameter_data passes
        # We only care about atten_models -> everything else are dummy values
        eqrm_flags = {}
        eqrm_flags['run_type'] = 'hazard'
        eqrm_flags['is_scenario'] = True
        eqrm_flags['output_dir'] = self.dir
        eqrm_flags['input_dir'] = self.dir
        eqrm_flags['site_tag'] = 'different_to_function'
        eqrm_flags['return_periods'] = [0.0]
        eqrm_flags['use_amplification'] = False
        eqrm_flags['zone_source_tag'] = 'not_used'
        eqrm_flags['atten_periods'] = atten_periods
        eqrm_flags['atten_models'] = atten_models

        return (event_set, event_activity, source_model, sites, motion,
                eqrm_flags)
Example #4
0
 def create_analysis_objects(self):
     # Parameters
     rupture_centroid_lat = asarray([-30])
     rupture_centroid_lon = asarray([150])
     length = asarray([1.0])
     azimuth = asarray([2.0])
     width = asarray([3.0])
     dip = asarray([4.0])
     depth = asarray([5.0])
     Mw = asarray([6.0])
     atten_models = asarray(['Allen', 
                             'Toro_1997_midcontinent', 
                             'Sadigh_97', 
                             'Youngs_97_interface', 
                             'Youngs_97_intraslab'])
     atten_model_weights = asarray([0.2, 0.2, 0.2, 0.2, 0.2])
     atten_periods = asarray([0, 1.0, 2.0])
     sites_lat = asarray([-31])
     sites_lon = asarray([150])
     
     # Event Set
     event_set = Event_Set.create(rupture_centroid_lat=rupture_centroid_lat,
                                  rupture_centroid_lon=rupture_centroid_lon,
                                  azimuth=azimuth,
                                  dip=dip,
                                  Mw=Mw,
                                  depth=depth,
                                  area=length*width,
                                  width=width, 
                                  length=length)
     
     # Event Activity
     event_activity = Event_Activity(len(event_set))
     event_activity.set_scenario_event_activity()
     
     # Source Model
     source_model = Source_Model.create_scenario_source_model(len(event_set))
     source_model.set_attenuation(atten_models, atten_model_weights)
     source_model.set_ground_motion_calcs(atten_periods)
     event_set.scenario_setup()
     event_activity.ground_motion_model_logic_split(source_model, True)
     
     # Sites
     sites = Sites(sites_lat, sites_lon)
     
     # SA
     # Set up synthetic SA figures
     # Dimensions -  spawn, gmm, rm, sites, events, period
     motion = zeros((1, 
                     len(atten_models), 
                     1, 
                     len(sites), 
                     len(event_set),
                     len(atten_periods)), dtype=float)
     # Allen
     motion[:,0,:,:,:,0] = 0 # period 0
     motion[:,0,:,:,:,1] = 1 # period 1.0
     motion[:,0,:,:,:,2] = 2 # period 2.0
     # Toro_1997_midcontinent
     motion[:,1,:,:,:,0] = 3 # period 0
     motion[:,1,:,:,:,1] = 4 # period 1.0
     motion[:,1,:,:,:,2] = 5 # period 2.0
     # Sadigh_97
     motion[:,2,:,:,:,0] = 6 # period 0
     motion[:,2,:,:,:,1] = 7 # period 1.0
     motion[:,2,:,:,:,2] = 8 # period 2.0
     # Youngs_97_interface
     motion[:,3,:,:,:,0] = 9  # period 0
     motion[:,3,:,:,:,1] = 10 # period 1.0
     motion[:,3,:,:,:,2] = 11 # period 2.0
     # Young_97_intraslab
     motion[:,4,:,:,:,0] = 12 # period 0
     motion[:,4,:,:,:,1] = 13 # period 1.0
     motion[:,4,:,:,:,2] = 14 # period 2.0
     
     # A minimal set of eqrm_flags so create_parameter_data passes
     # We only care about atten_models -> everything else are dummy values
     eqrm_flags = {}
     eqrm_flags['run_type'] = 'hazard'
     eqrm_flags['is_scenario'] = True
     eqrm_flags['output_dir'] = self.dir
     eqrm_flags['input_dir'] = self.dir
     eqrm_flags['site_tag'] = 'different_to_function'
     eqrm_flags['return_periods'] = [0.0]
     eqrm_flags['use_amplification'] = False
     eqrm_flags['zone_source_tag'] = 'not_used'
     eqrm_flags['atten_periods'] = atten_periods
     eqrm_flags['atten_models'] = atten_models
     
     return (event_set, 
             event_activity, 
             source_model, 
             sites, 
             motion, 
             eqrm_flags)