def _plot_and_save_single_group_worker(i, group, filename, cfg, d_fits): set_style() # set style in child process # try: fig = plot_single_group(group, cfg, d_fits) filename = filename_to_tmp_file(filename) + f"__{i:06d}.pdf" utils.init_parent_folder(filename) fig.savefig(filename) return None
def save(self, df, filename, key, metadata=None): utils.init_parent_folder(filename) if metadata is None: metadata = {} with warnings.catch_warnings(): message = "object name is not a valid Python identifier" warnings.filterwarnings("ignore", message=message) with HDFStore(filename, mode="a") as hdf: hdf.append(key, df, format="table", data_columns=True) hdf.get_storer(key).attrs.metadata = metadata
def plot_fit_results(all_fit_results, cfg, N_alignments_mins=[-1]): if not isinstance(N_alignments_mins, (list, tuple)): N_alignments_mins = [N_alignments_mins] if not 0 in N_alignments_mins: N_alignments_mins = [0] + N_alignments_mins filename = cfg.filename_plot_fit_results if utils.is_pdf_valid(filename, cfg.force_plots, N_pages=len(N_alignments_mins)): logger.info(f"Plot of fit results already exist.") return None set_style() logger.info(f"Plotting fit results.") n_sigma_lim, D_max_lim = find_fit_results_limits(all_fit_results) utils.init_parent_folder(filename) with PdfPages(filename) as pdf: for N_alignments_min in N_alignments_mins: # break fig = plot_fit_results_single_N_aligment( all_fit_results, cfg, N_alignments_min=N_alignments_min, n_sigma_lim=n_sigma_lim, D_max_lim=D_max_lim, ) if fig: pdf.savefig(fig, bbox_inches="tight", pad_inches=0.1) # pdf.savefig(fig) d = pdf.infodict() d["Title"] = "Error Rate Distributions" d["Author"] = "Christian Michelsen" d["CreationDate"] = datetime.datetime.today()
def seriel_saving_of_error_rates(cfg, df_plot_sorted, filename, d_fits): groupby = df_plot_sorted.groupby("tax_id", sort=False, observed=True) task_id_status_plotting = progress.add_task( "task_status_plotting", progress_type="status", status="Plotting", name="Plots:", total=len(groupby), ) utils.init_parent_folder(filename) with PdfPages(filename) as pdf, progress: for tax_id, group in groupby: fig = plot_single_group(group, cfg, d_fits) pdf.savefig(fig, bbox_inches="tight", pad_inches=0.1) progress.advance(task_id_status_plotting) d = pdf.infodict() d["Title"] = "Error Rate Distributions" d["Author"] = "Christian Michelsen" d["CreationDate"] = datetime.datetime.today()
def save(self, df, metadata=None): utils.init_parent_folder(self.filename) table = self._df_to_table_with_metadata(df, metadata) # pq.write_to_dataset(table, self.filename, partition_cols=partition_cols) pq.write_table(table, self.filename, version="2.0")