Exemplo n.º 1
0
    if opdict['verbose']:
        fig = plt.figure(figsize=(10, 5))
        fig.set_facecolor('white')
        ax1 = fig.add_subplot(121)
        ax1.hist(mags, 25)
        ax1.set_xlabel('Magnitude')

        ax2 = fig.add_subplot(122, title='Gutenberg Richter law')
        ax2.plot(r, logN)
        ax2.plot(r[i1:i2], np.polyval(p, r[i1:i2]), 'r')
        ax2.set_xlabel('Magnitude')
        ax2.set_ylabel('log N')
        plt.show()


# =======================================================
if __name__ == '__main__':

    from options import WavelocOptions
    logging.basicConfig(level=logging.INFO,
                        format='%(levelname)s : %(asctime)s : %(message)s')

    wo = WavelocOptions()
    args = wo.p.parse_args()

    wo.set_all_arguments(args)
    wo.verify_magnitude_options()

    do_comp_mag(wo.opdict)
Exemplo n.º 2
0
    def setUp(self):

        self.wo = WavelocOptions()
        self.wo.set_test_options()
        self.wo.verify_migration_options()
Exemplo n.º 3
0
    def test_dirac_migration(self):
        from locations_trigger import trigger_locations_inner
        from filters import smooth

        wo = WavelocOptions()
        wo.set_test_options()

        wo.opdict['outdir'] = 'TEST_Dirac'
        wo.opdict['search_grid'] = 'grid.Taisne.search.hdr'
        wo.opdict['loclevel'] = 10
        wo.opdict[
            'load_ttimes_buf'] = True  # Optimized in time, but you must be usre you're reading the right grid for the test
        wo.opdict['syn_addnoise'] = False
        wo.opdict['syn_amplitude'] = 1.0
        wo.opdict['syn_datalength'] = 20.0
        wo.opdict['syn_samplefreq'] = 100.0
        wo.opdict['syn_kwidth'] = 0.1
        wo.opdict['syn_otime'] = 6.0
        wo.opdict['syn_ix'] = 16
        wo.opdict['syn_iy'] = 8
        wo.opdict['syn_iz'] = 6
        wo.opdict['syn_filename'] = 'test_grid4D_hires.hdf5'

        wo.verify_migration_options()
        wo.verify_location_options()
        wo.verify_synthetic_options()

        ##########################
        # generate the test case and retrieve necessary information
        ##########################

        logging.info('Running synthetic test case generation...')
        test_info = generateSyntheticDirac(wo.opdict)
        logging.debug(test_info)

        # retrieve info
        grid_filename = test_info['dat_file']
        stack_filename = test_info['stack_file']
        nx, ny, nz, nt = test_info['grid_shape']
        dx, dy, dz, dt = test_info['grid_spacing']
        x_orig, y_orig, z_orig = test_info['grid_orig']
        ix_true, iy_true, iz_true, it_true = test_info['true_indexes']
        stack_start_time = test_info['start_time']

        # plot base filename
        base_path = wo.opdict['base_path']
        outdir = wo.opdict['outdir']

        # loclevel for triggers
        loclevel = wo.opdict['loclevel']

        # set up x, y, z, t arrays
        x = np.arange(nx) * dx
        y = np.arange(ny) * dy
        z = np.arange(nz) * dz
        t = np.arange(nt) * dt + stack_start_time

        # extract the max stacks
        f_stack = h5py.File(stack_filename, 'r')
        max_val = f_stack['max_val']
        max_x = f_stack['max_x']
        max_y = f_stack['max_y']
        max_z = f_stack['max_z']

        locs = trigger_locations_inner(max_val, max_x, max_y, max_z, loclevel,
                                       loclevel, stack_start_time, dt)

        self.assertTrue(len(locs) > 0)

        #print locs
        # This is a dirac test, so only have one element in locs
        imax = np.argmax([loc['max_trig'] for loc in locs])
        trig_loc = locs[imax]
        self.assertAlmostEqual(wo.opdict['syn_otime'], trig_loc['o_time'], 2)
        self.assertAlmostEqual(wo.opdict['syn_ix'] * dx + x_orig,
                               trig_loc['x_mean'])
        self.assertAlmostEqual(wo.opdict['syn_iy'] * dy + y_orig,
                               trig_loc['y_mean'])
        self.assertAlmostEqual(wo.opdict['syn_iz'] * dz + z_orig,
                               trig_loc['z_mean'])

        f_stack.close()
Exemplo n.º 4
0
    def setUp(self):

        self.wo = WavelocOptions()
        self.wo.set_test_options()
        self.wo.verify_SDS_processing_options()