def saveResult(self, folder=None, size=(16, 10), **kwargs): """Save all results in the specified folder. Saved items are: Inverted profile Resistivity vector Coverage vector Standardized coverage vector Mesh (bms and vtk with results) """ subfolder = self.__class__.__name__ path = getSavePath(folder, subfolder) pg.info('Saving resistivity data to: {}'.format(path)) np.savetxt(path + '/resistivity.vector', self.model) np.savetxt(path + '/resistivity-cov.vector', self.coverage()) np.savetxt(path + '/resistivity-scov.vector', self.standardizedCoverage()) m = pg.Mesh(self.paraDomain) m['Resistivity'] = self.paraModel(self.model) m['Resistivity (log10)'] = np.log10(m['Resistivity']) m['Coverage'] = self.coverage() m['S_Coverage'] = self.standardizedCoverage() m.exportVTK(os.path.join(path, 'resistivity')) m.saveBinaryV2(os.path.join(path, 'resistivity-pd')) self.fop.mesh().save(os.path.join(path, 'resistivity-mesh')) if self.paraDomain.dim() == 2: fig, ax = plt.subplots(figsize=size) self.showResult(ax=ax, coverage=self.coverage(), **kwargs) fig.savefig(path + '/resistivity.pdf', bbox_inches="tight") return path, fig, ax return path
def saveResult(self, folder=None, size=(16, 10), verbose=False, **kwargs): """Save the results in the specified folder. Saved items are: * Resulting inversion model * Velocity vector * Coverage vector * Standardized coverage vector * Mesh (bms and vtk with results) Args ---- path: str[None] Path to save into. If not set the name is automatic created size: (float, float) (16,10) Figure size. Keyword Args ------------ Will be forwardet to showResults Returns ------- str: Name of the result path. """ # TODO: How to extract the chi2 etc. from each iteration??? subfolder = self.__class__.__name__ path = getSavePath(folder, subfolder) if verbose: pg.info('Saving refraction data to: {}'.format(path)) np.savetxt(os.path.join(path, 'velocity.vector'), self.velocity) np.savetxt(os.path.join(path, 'velocity-cov.vector'), self.rayCoverage()) np.savetxt(os.path.join(path, 'velocity-scov.vector'), self.standardizedCoverage()) m = pg.Mesh(self.paraDomain) m['Velocity'] = self.paraModel(self.velocity) m['Coverage'] = self.rayCoverage() m['S_Coverage'] = self.standardizedCoverage() m.exportVTK(os.path.join(path, 'velocity')) m.saveBinaryV2(os.path.join(path, 'velocity-pd')) self.fop.mesh().save(os.path.join(path, 'velocity-mesh')) np.savetxt(os.path.join(path, 'chi.txt'), self.inv.chi2History) fig, ax = plt.subplots() self.showResult(ax=ax, cov=self.standardizedCoverage(), **kwargs) fig.set_size_inches(size) fig.savefig(os.path.join(path, 'velocity.pdf'), bbox_inches='tight') pg.plt.close(fig) return path