def grid_to_time(self, latitude, longitude, depth, dimension, option, wave, limit): self.stations_to_nll_v2(latitude, longitude, depth, limit) output = self.set_grid2time_template(latitude, longitude, depth, dimension, option, wave) self.__append_files(self.get_stations_template_file_path, output) output_path = Path(output) command = "{} {}".format(self.get_bin_file("Grid2Time"), output_path.name) exc_cmd(command, cwd=output_path.parent)
def open_solutions(self): output_path = os.path.join(ROOT_DIR, 'arrayanalysis', 'dataframe.csv') try: command = "{} {}".format('open', output_path) exc_cmd(command, cwd=ROOT_DIR) except: md = MessageDialog(self) md.set_error_message("Coundn't open solutions file")
def vel_to_grid(self, latitude, longitude, depth, x_node, y_node, z_node, dx, dy, dz, grid_type, wave_type, model): if model == "2D": x_node = 2 # mandatory for 2D models output = self.set_vel2grid_template(latitude, longitude, depth, x_node, y_node, z_node, dx, dy, dz, grid_type, wave_type) model_path = self.get_model_file_path(wave_type,model) self.__append_files(model_path, output) output_path = Path(output) command = "{} {}".format(self.get_bin_file("Vel2Grid"), output_path.name) exc_cmd(command, cwd=output_path.parent) elif model == "3D": self.__write_header(latitude, longitude, depth, x_node, y_node, z_node, dx, dy, dz, wave_type) self.grid3d(wave_type)
def get_NLL_scatter(self): location_file = os.path.join(self.get_loc_dir, "last") command = "{} {} {} {}".format(self.get_bin_file("scat2latlon"), 1, self.get_loc_dir, location_file) exc_cmd(command) location_file_check = os.path.join(self.get_loc_dir, "last.hyp.scat.xyz") if os.path.isfile(location_file_check): my_array = np.genfromtxt(location_file_check, skip_header=3) y = my_array[:, 0] x = my_array[:, 1] z = my_array[:, 2] pdf = my_array[:, 4] pdf = np.array(pdf) / np.max(pdf) return x, y, z, pdf else: raise FileNotFoundError("The file {} doesn't exist. Please, run location".format(location_file))
def run_nlloc(self, latitude, longitude, depth, transform): if transform == "SIMPLE": output = self.set_run_template(latitude, longitude, depth) output_path = Path(output) command = "{} {}".format(self.get_bin_file("NLLoc"), output_path.name) elif transform == "GLOBAL": self.stations_to_nll_v2(latitude, longitude, depth, limit = 20000, transform="GLOBAL") stations_path = os.path.join(self.get_stations_template_file_path) temp_path = self.get_temp_dir shutil.copy(stations_path, temp_path) output = self.set_run_template_global() output_path = Path(output) command = "{} {}".format(self.get_bin_file("NLLoc"), output_path.name) return exc_cmd(command, cwd=output_path.parent)
def __append_files(file_path_to_cat: str, file_path_to_append: str): command = "cat {}".format(file_path_to_cat) exc_cmd(command, stdout=open(file_path_to_append, 'a'), close_fds=True)