Ejemplo n.º 1
0
    #=========== now add topo data, with or without air layers?
    # 1) the data file will be changed in 3 columns sxi, syi and szi meters
    # 2) The covariance file will be written.
    # 3) the model file not changed?? No air layers can be seen in the .ws file.

    # add topography, define an initial resistivity model, modify and re-write the data file, define covariance mask
    # dat file will be changed and rewritten,
    # grid centre is used as the new origin of coordinate system, topo data used in the elev column.

    # model.add_topography(topofile, interp_method='nearest')  # dat file will be written again as elevation updated

    model.add_topography_2mesh(
        topofile, interp_method='nearest'
    )  # dat file will be written again as elevation updated

    model.plot_topograph()  # plot the MT stations on topography elevation data

    print(
        "*** Re-writing model file after topo data and air layers are added - will include air sea-water resistivity"
    )
    model.write_model_file(save_path=model.save_path)
    # model.write_model_file(save_path='temp/')

    # make covariance (mask) file
    cov = Covariance(mask_arr=model.covariance_mask,
                     save_path=outputdir,
                     smoothing_east=0.3,
                     smoothing_north=0.3,
                     smoothing_z=0.3)

    cov.write_covariance_file(model_fn=model.model_fn)
Ejemplo n.º 2
0
    def run(self):
        # monkey patch plt.show() so the plot is not displayed in worker thread
        true_plt_show = plt.show
        plt.show = _fake_plt_show
        self._figures = []
        try:
            if not os.path.exists(self.output_dir):
                os.mkdir(self.output_dir)

            # get period_list list
            self.status_updated.emit("Selecting Periods...")
            period_list = EdiCollection(self._edi_list).select_periods(**self._select_period_kwargs)
            # save period plot for reference
            figure = plt.gcf()
            figure.savefig(os.path.join(self.output_dir, self._period_image_name))
            if self.show:
                self.figure_updated.emit('Period Distribution', figure)

            # data object
            self.status_updated.emit("Creating ModEM Data Object...")
            self._data_kwargs['period_list'] = period_list
            data = Data(edi_list=self._edi_list, **self._data_kwargs)
            # write data file
            self.status_updated.emit("Writing Initial ModEM Data File...")
            data.write_data_file()

            # create model
            self.status_updated.emit("Creating Mesh Model...")
            model = Model(data_object=data, **self._mesh_kwagrs)
            model.make_mesh()
            # plot mesh
            model.plot_mesh(fig_num=plt.gcf().number + 1)
            figure = plt.gcf()
            figure.savefig(os.path.join(self.output_dir, self._mesh_image_name))
            if self.show:
                self.figure_updated.emit("Mesh", figure)
                # model.plot_mesh_xy()
                # self.figure_updated.emit("Mesh XY", plt.gcf())
                # model.plot_mesh_xz()
                # self.figure_updated.emit("Mesh XZ", plt.gcf())
            model.write_model_file()

            # add topography
            self.status_updated.emit("Adding Topography...")
            model.add_topography_to_mesh(**self._topo_args)
            if self.show:
                model.plot_topograph()  # this is too slow so only plot and save image when asked
                figure = plt.gcf()
                figure.savefig(os.path.join(self.output_dir, self._topo_image_name))
                self.figure_updated.emit("Topography", figure)
            self.status_updated.emit("Updating Mesh Model...")
            model.write_model_file()

            # covariance
            self.status_updated.emit("Creating Covariance File...")
            self._covariance_kwargs['mask_arr'] = model.covariance_mask
            cov = Covariance(**self._covariance_kwargs)
            self.status_updated.emit("Writing Covariance File...")
            cov.write_covariance_file(model_fn=model.model_fn, sea_water=self._topo_args['sea_resistivity'],
                                      air=self._topo_args['air_resistivity'])

            self.status_updated.emit("Creating README File...")
            self.write_readme(os.path.join(self.output_dir, self._readme_name))
            # done
            self.status_updated.emit("Finishing...")

        except Exception as e:
            frm = inspect.trace()[-1]
            mod = inspect.getmodule(frm[0])
            self.export_error.emit("{}: {}".format(mod.__name__, e.message))

        # restore plt.show()
        plt.show = true_plt_show