Ejemplo n.º 1
0
 def setUp(self):
     #
     # set logging settings
     fname = './testcomputedoubletruncatedmfd.log'
     logging.basicConfig(filename=fname, level=logging.DEBUG)
     #
     # clear directory
     folder = os.path.join(BASE_DATA_PATH, './../../tmp/project_test')
     delete_and_create_project_dir(folder)
     #
     # set environment variable
     self.prj_path = os.path.join(BASE_DATA_PATH,
                                  './../../tmp/project_test/test.oqmbtp')
     os.environ["OQMBT_PROJECT"] = self.prj_path
     #
     # create the project
     path = './../data/project.ini'
     inifile = os.path.join(BASE_DATA_PATH, path)
     project_create([inifile, os.path.dirname(self.prj_path)])
     #
     # add to the model the name of the shapefile - the path is relative to
     # the position of the project file
     oqtkp = OQtProject.load_from_file(self.prj_path)
     model_id = 'model01'
     oqtkp.active_model_id = model_id
     model = oqtkp.models[model_id]
     path = './../../data/wf01/shapefiles/test_faults.shp'
     model.faults_shp_filename = path
     oqtkp.models[model_id] = model
     oqtkp.save()
 def setUp(self):
     #
     #
     fname = './testcomputedoubletruncatedGRfromseismicity.log'
     logging.basicConfig(filename=fname, level=logging.DEBUG)
     #
     # clear directory
     folder = os.path.join(self.BASE_DATA_PATH, './../../tmp/project_test')
     delete_and_create_project_dir(folder)
     #
     # set environment variable
     self.prj_path = os.path.join(self.BASE_DATA_PATH,
                                  './../../tmp/project_test/test.oqmbtp')
     os.environ["OQMBT_PROJECT"] = self.prj_path
     #
     # create the project
     path = './../data/project.ini'
     inifile = os.path.join(self.BASE_DATA_PATH, path)
     project_create([inifile, os.path.dirname(self.prj_path)])
     #
     # add to the model the name of the shapefile - the path is relative to
     # the position of the project file
     oqtkp = OQtProject.load_from_file(self.prj_path)
     model_id = 'model01'
     oqtkp.active_model_id = model_id
     model = oqtkp.models[model_id]
     #
     # set the shapefile with the geometry of area sources
     path = './../../notebooks/data/shapefiles/area_sources.shp'
     model.area_shapefile_filename = path
     #
     # set the catalogue name
     path = './../../notebooks/data/catalogue.csv'
     model.catalogue_csv_filename = path
     #
     # saving the project
     oqtkp.models[model_id] = model
     oqtkp.save()
Ejemplo n.º 3
0
    def test_create_01(self):
        """
        Create an oqmbt project
        """
        inifile = os.path.join(self.BASE_DATA_PATH, 'project.ini')
        argv = [inifile]
        project_create(argv)

        # files created with the construction of the project
        fles = [
            'eqk_rates.hdf5', 'hypo_close_to_faults.hdf5', 'test.oqmbtp',
            'hypo_depths.hdf5', 'completeness.hdf5'
        ]
        #
        # checking files existence
        folder = '/tmp/project_test'
        for fle in fles:
            tmp = os.path.join(folder, fle)
            print(tmp)
            assert os.path.isfile(tmp)

        # check that in the new folder there are no other files
        self.assertEqual(len(os.walk(folder).__next__()[2]), 5)
Ejemplo n.º 4
0
    def setUp(self):
        #
        #
        fname = './wf01.log'
        # logging.basicConfig(filename=fname, level=logging.DEBUG)
        logging.basicConfig(filename=fname, level=logging.WARN)
        #
        # clear directory where the project will be created
        folder = os.path.join(self.BASE_DATA_PATH, '..', 'tmp', 'project_test')
        delete_and_create_project_dir(folder)
        #
        # set environment variable
        self.prj_path = os.path.join(folder, 'test.oqmbtp')
        os.environ["OQMBT_PROJECT"] = self.prj_path
        #
        # create the project
        inifile = os.path.join(self.BASE_DATA_PATH, '..', 'data', 'wf01',
                               'project.ini')
        project_create([inifile, os.path.dirname(self.prj_path)])
        #
        # load the project just created
        oqtkp = OQtProject.load_from_file(self.prj_path)
        model_id = 'model01'
        oqtkp.active_model_id = model_id
        model = oqtkp.models[model_id]
        #
        # set the shapefile with the geometry of area sources [relative path
        # with origin the project folder]
        model.area_shapefile_filename = os.path.join('.', '..', '..', 'data',
                                                     'wf01', 'shapefiles',
                                                     'test_area.shp')
        #
        # set the shapefile with the geometry of fault sources [relative path
        # with origin the project folder]
        model.faults_shp_filename = os.path.join('.', '..', '..', 'data',
                                                 'wf01', 'shapefiles',
                                                 'test_faults.shp')
        #
        # set the shapefile withe the faults
        path = './../../data/wf01/shapefile/test_faults.csv'
        model.catalogue_csv_filename = path
        #
        # set the catalogue name
        path = './../../data/wf01/catalogue.csv'
        model.catalogue_csv_filename = path

        # required by imfd_double_truncated_from_slip_rate_SRC.ipynb
        model.default_bgr = 1.0

        model.strain_pickle_spatial_index_filename = (
            './../../data/wf01/strain/sample_average_strain')
        model.strain_rate_model_hdf5_filename = (
            './../../data/wf01/strain/sample_average_strain.hdf5')

        # required by compute_mo_from_strain.ipynb
        model.shear_modulus = 3.2e10

        # required by compute_mo_from_strain.ipynb
        model.coup_coef = 0.8

        # required by compute_mo_from_strain.ipynb
        model.coup_thick = 15.0

        # required by compute_mo_from_strain.ipynb
        model.strain_cell_dx = 0.250
        model.strain_cell_dy = 0.200

        # required by set_mfd_tapered_GR.ipynb
        model.m_min = 5.0

        # required by set_mfd_tapered_GR.ipynb
        model.bin_width = 0.1

        model.faults_lower_threshold_magnitude = 6.5
        model.msr = 'WC1994'
        #
        # create the hypo files - the folder hypo_depths is created by the
        # 'project_create' script
        folder = os.path.dirname(self.prj_path)
        for i in [1, 2, 3]:
            fname = 'hypo_depths-model01-{:d}.csv'.format(i)
            path = os.path.join(folder, 'hypo_depths', fname)
            f = open(path, 'w')
            f.write('depth,weight\n')
            f.write('10,0.6\n')
            f.write('20,0.4\n')
            f.close()
        model.hypo_dist_filename = 'model01_hypo_dist.hdf5'
        #
        # create the focal mechanism files
        for i in [1, 2, 3]:
            fname = 'focal_mechs-model01-{:d}.csv'.format(i)
            path = os.path.join(folder, 'focal_mechs', fname)
            f = open(path, 'w')
            f.write('strike,dip,rake,weight\n')
            f.write('0.00,90.00,0.00,1.00\n')
            f.close()
        model.nodal_plane_dist_filename = 'model01_focal_mech_dist.hdf5'
        #
        # saving the project
        oqtkp.models[model_id] = model
        oqtkp.save()