コード例 #1
0
def create_event_set():
    """
    Create dummy event set.
    Uses the same technique from test_event_set 
    (Test_Event_Set.test_scenario_event_II)
    """

    eqrm_flags = DummyEventSet()
    eqrm_flags.scenario_latitude = [-30., -32.]
    eqrm_flags.scenario_longitude = [150., -151.]
    eqrm_flags.scenario_azimuth = [340, 330]
    eqrm_flags.dip = [37, 30]
    eqrm_flags.scenario_magnitude = [8, 7.5]
    eqrm_flags.scenario_max_width = [15, 7]
    eqrm_flags.scenario_depth = [11.5, 11.0]
    eqrm_flags.scenario_number_of_events = 1

    event_set = Event_Set.create_scenario_events(
        rupture_centroid_lat=[eqrm_flags.scenario_latitude],
        rupture_centroid_lon=[eqrm_flags.scenario_longitude],
        azimuth=[eqrm_flags.scenario_azimuth],
        dip=[eqrm_flags.dip],
        Mw=[eqrm_flags.scenario_magnitude],
        fault_width=eqrm_flags.scenario_max_width,
        depth=[eqrm_flags.scenario_depth],
        scenario_number_of_events=eqrm_flags.scenario_number_of_events)

    return event_set
コード例 #2
0
ファイル: test_filters.py プロジェクト: dynaryu/eqrm
def create_event_set():
    """
    Create dummy event set.
    Uses the same technique from test_event_set 
    (Test_Event_Set.test_scenario_event_II)
    """
    
    eqrm_flags = DummyEventSet()
    eqrm_flags.scenario_latitude = [-30., -32.]
    eqrm_flags.scenario_longitude = [150., -151.]
    eqrm_flags.scenario_azimuth = [340, 330]
    eqrm_flags.dip = [37, 30]
    eqrm_flags.scenario_magnitude = [8, 7.5]
    eqrm_flags.scenario_max_width = [15, 7]
    eqrm_flags.scenario_depth = [11.5, 11.0]
    eqrm_flags.scenario_number_of_events = 1
        
    event_set = Event_Set.create_scenario_events(
            rupture_centroid_lat=[eqrm_flags.scenario_latitude],
            rupture_centroid_lon=[eqrm_flags.scenario_longitude],
            azimuth=[eqrm_flags.scenario_azimuth],
            dip=[eqrm_flags.dip],
            Mw=[eqrm_flags.scenario_magnitude],
            fault_width=eqrm_flags.scenario_max_width,
            depth=[eqrm_flags.scenario_depth],
            scenario_number_of_events=eqrm_flags.scenario_number_of_events)
    
    return event_set
コード例 #3
0
ファイル: test_event_set_npy.py プロジェクト: dynaryu/eqrm
    def test_event_set_load_save(self):
        # Create a dummy event set
        event_set1 = test_event_set.event_from_csv_long()

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

        # Load the second event set from file
        event_set2 = Event_Set.load(self.data_dir)

        # Checking that event_set1.depth is not the same object
        # as event_set2.depth (as opposed to whether they are numerically
        # the same).
        assert event_set1.depth is not event_set2.depth
        assert event_set1.rupture_centroid_x is not event_set2.rupture_centroid_x

        # Testing that the values were saved with good precision
        assert allclose(event_set1.depth,
                        event_set2.depth)
        assert allclose(event_set1.rupture_centroid_lat,
                        event_set2.rupture_centroid_lat)
        assert allclose(event_set1.rupture_centroid_lon,
                        event_set2.rupture_centroid_lon)
        assert allclose(event_set1.azimuth,
                        event_set2.azimuth)
        assert allclose(event_set1.dip,
                        event_set2.dip)
        assert allclose(event_set1.trace_start_lat,
                        event_set2.trace_start_lat,
                        atol=0.01)
        assert allclose(event_set1.trace_start_lon,
                        event_set2.trace_start_lon,
                        atol=0.01)
        assert allclose(event_set1.dip,
                        event_set2.dip)
コード例 #4
0
def event_create(event_c):
    trace_start_lat = ones((event_c)) * -38.15
    trace_start_lon = ones((event_c)) * 146.5

    azimuth = ones((event_c)) * 217.2
    dip = ones((event_c)) * 60.2
    weight = ones((event_c)) * 18.1
    event_activity = ones((event_c)) * 0.1
    recurrence = ones((event_c)) * 5.3

    Mw = ones((event_c)) * 6.9
    lat0 = ones((event_c)) * -38.31
    lon0 = ones((event_c)) * 146.3

    depth = ones((event_c)) * 6.5
    rx = ones((event_c)) * 25.3
    ry = ones((event_c)) * 3.8

    length = ones((event_c)) * 50.6
    width = ones((event_c)) * 15.
    event_activity = ones((event_c)) * 9.

    event_set = Event_Set.create(depth=depth,
                                 rupture_centroid_lat=lat0,
                                 rupture_centroid_lon=lon0,
                                 azimuth=azimuth,
                                 dip=dip,
                                 ML=None,
                                 Mw=Mw,
                                 fault_width=15.0)
    event_set.event_activity = ones((event_c)) * 0.8
    pseudo_event_set = Pseudo_Event_Set.split_logic_tree(
        event_set, ['Gaull_1990_WA'], [1])
    pseudo_event_set.source_zone_id = ones((event_c)) * 9.
    return pseudo_event_set, event_activity
コード例 #5
0
ファイル: time_save_event_set.py プロジェクト: dynaryu/eqrm
def event_create(event_c):
    trace_start_lat = ones((event_c))* -38.15
    trace_start_lon = ones((event_c))* 146.5
   
    azimuth = ones((event_c))* 217.2
    dip = ones((event_c))* 60.2
    weight = ones((event_c))* 18.1
    event_activity = ones((event_c))* 0.1
    recurrence = ones((event_c))* 5.3
    
    Mw = ones((event_c))* 6.9
    lat0 = ones((event_c))* -38.31
    lon0 = ones((event_c))* 146.3
    
    depth = ones((event_c))* 6.5
    rx = ones((event_c))* 25.3
    ry = ones((event_c))* 3.8
    
    length = ones((event_c))* 50.6
    width = ones((event_c))* 15.
    event_activity = ones((event_c))* 9.

    event_set = Event_Set.create(depth=depth,rupture_centroid_lat=lat0,
                        rupture_centroid_lon=lon0,azimuth=azimuth,
                        dip=dip,ML=None,Mw=Mw,fault_width=15.0)
    event_set.event_activity =  ones((event_c))* 0.8
    pseudo_event_set = Pseudo_Event_Set.split_logic_tree(event_set,
                                                         ['Gaull_1990_WA'],
                                                         [1])
    pseudo_event_set.source_zone_id =  ones((event_c))* 9.
    return pseudo_event_set, event_activity
コード例 #6
0
    def test_event_set_load_save(self):
        # Create a dummy event set
        event_set1 = test_event_set.event_from_csv_long()

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

        # Load the second event set from file
        event_set2 = Event_Set.load(self.data_dir)

        # Checking that event_set1.depth is not the same object
        # as event_set2.depth (as opposed to whether they are numerically
        # the same).
        assert event_set1.depth is not event_set2.depth
        assert event_set1.rupture_centroid_x is not event_set2.rupture_centroid_x

        # Testing that the values were saved with good precision
        assert allclose(event_set1.depth, event_set2.depth)
        assert allclose(event_set1.rupture_centroid_lat,
                        event_set2.rupture_centroid_lat)
        assert allclose(event_set1.rupture_centroid_lon,
                        event_set2.rupture_centroid_lon)
        assert allclose(event_set1.azimuth, event_set2.azimuth)
        assert allclose(event_set1.dip, event_set2.dip)
        assert allclose(event_set1.trace_start_lat,
                        event_set2.trace_start_lat,
                        atol=0.01)
        assert allclose(event_set1.trace_start_lon,
                        event_set2.trace_start_lon,
                        atol=0.01)
        assert allclose(event_set1.dip, event_set2.dip)
コード例 #7
0
def create_event_set(event_num):        
        """
        Create an event set to investigate memory size.
        """
        
        fault_width = 5
        azi = array([90])
        dazi = array([2])
        fault_dip = array([35.0])
        prob_min_mag_cutoff = 1.0
        override_xml = True
        prob_number_of_events_in_zones = [event_num]
        handle, file_name = tempfile.mkstemp('.xml', __name__+'_')
        os.close(handle)
        handle = open(file_name,'w')
        
        # I don't know what this is A_min="1.0"
        # But I added it so the tests would pass
        # Another example file at
        # Q:\python_eqrm\implementation_tests\input\newc_source_polygon.xml
        #  polygon is a small square

        
        sample = """<Source_Model magnitude_type='Mw'>
<polygon area="5054.035">
  <boundary>-32.000 151.00 -32.0 151.05 -32.05 151.05 -32.05 151.0</boundary> 
  <recurrence distribution="bounded_gutenberg_richter" min_magnitude="3.3" max_magnitude="5.4" A_min="0.568" b="1" min_mag="4.5" depth="7" /> 
  </polygon>

</Source_Model>
"""
        handle.write(sample)
        handle.close()
        
        #file_name = os.path.join('..','implementation_tests','input','newc_source_polygon.xml')
        #return
        # need to fix
        events = Event_Set.generate_synthetic_events(
            file_name,
            fault_width,
            azi,
            dazi,
            fault_dip,
            prob_min_mag_cutoff,
            override_xml,
            prob_number_of_events_in_zones)
#        print "events.trace_start_lat", events.trace_start_lat
#         print " events.trace_start_lon", events.trace_start_lon
#         print "events.trace_end_lat", events.trace_end_lat
#         print "events.trace_end_lon", events.trace_end_lon
#         print "events.rupture_centroid_lat", events.rupture_centroid_lat
#         print "events.rupture_centroid_lon", events.rupture_centroid_lon
#         print "events.rupture_centroid_x", events.rupture_centroid_x
#         print "events.rupture_centroid_y", events.rupture_centroid_y

        os.remove(file_name)
コード例 #8
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)
コード例 #9
0
ファイル: test_postprocessing.py プロジェクト: dynaryu/eqrm
 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)