def interp_midMVq( Pk=5.0, kappa=np.inf, struct="pp", sampling=1, KDE_qz_sampling=101j, do_single_spec=True, KDE_pickle_loc=None, error=0.05, nproc=1, diags=["[NII]/[SII]+;[OIII]/[SII]+"], ): # 1: get the intermediate data points from the MV shell script # Zs are identical, but at least we have changed the Qs # Where are we ? this_dir = os.path.dirname(__file__) fn = os.path.join(this_dir, "grid_QZ_midQs_pp_GCZO_Pk50_kinf.csv") metadata = pyqz.pyqz_tools.get_MVphotogrid_metadata(fn) data = np.loadtxt(fn, comments="c", delimiter=",", skiprows=4) # Build 'Pseudo' line fluxes - and then assume a 10% error Hb = np.ones_like(data[:, 0]) Oiii = 10 ** data[:, metadata["columns"].index("[OIII]/Hb")] Oiip = 10 ** data[:, metadata["columns"].index("[OII]+/Hb")] Nii = Oiip * 10 ** data[:, metadata["columns"].index("[NII]/[OII]+")] Siip = 1.0 / 10 ** data[:, metadata["columns"].index("[NII]/[SII]+")] * Nii Ha = 1.0 / 10 ** data[:, metadata["columns"].index("[NII]/Ha")] * Nii all_fluxes = np.zeros((len(Hb), 12)) for i in range(len(Hb)): all_fluxes[i, 0] = 1.0 all_fluxes[i, 1] = all_fluxes[i, 0] * error all_fluxes[i, 2] = Oiii[i] all_fluxes[i, 3] = all_fluxes[i, 2] * error all_fluxes[i, 4] = Oiip[i] all_fluxes[i, 5] = all_fluxes[i, 4] * error all_fluxes[i, 6] = Nii[i] all_fluxes[i, 7] = all_fluxes[i, 6] * error all_fluxes[i, 8] = Siip[i] all_fluxes[i, 9] = all_fluxes[i, 8] * error all_fluxes[i, 10] = Ha[i] all_fluxes[i, 11] = all_fluxes[i, 10] * error # Launch the interpolation nspec = 16 # 16 on grid,14 = grid edge if do_single_spec: specs = np.reshape(all_fluxes[nspec, :], (1, 12)) else: specs = np.ones((24, 12)) * np.reshape(all_fluxes[nspec, :], (1, 12)) results = pyqz.get_global_qz( specs, [ "Hb", "stdHb", "[OIII]", "std[OIII]", "[OII]+", "std[OII]+", "[NII]", "std[NII]", "[SII]+", "std[SII]+", "Ha", "stdHa", ], diags, Pk=5.0, kappa=np.inf, struct="pp", KDE_pickle_loc=KDE_pickle_loc, sampling=sampling, KDE_qz_sampling=KDE_qz_sampling, KDE_method="multiv", srs=400, nproc=nproc, verbose=True, ) return ( np.abs(results[0][0, results[1].index("<LogQ>")] / data[nspec, metadata["columns"].index("LogQ")] - 1.0) < 0.01 and np.abs( results[0][0, results[1].index("<LogQ{KDE}>")] / data[nspec, metadata["columns"].index("LogQ")] - 1.0 ) < 0.01 and np.abs( results[0][0, results[1].index("<Tot[O]+12>")] / data[nspec, metadata["columns"].index("Tot[O]+12")] - 1.0 ) < 0.01 and np.abs( results[0][0, results[1].index("<Tot[O]+12{KDE}>")] / data[nspec, metadata["columns"].index("Tot[O]+12")] - 1.0 ) < 0.01 )
def get_bad_global_qz(Pk=5.0, kappa=np.inf, struct="pp", sampling=1, nproc=1, error=0.05, KDE_pickle_loc=None): # 1: get the intermediate data points from the MV shell script # Zs are identical, but at least we have chnaged the Qs # Where are we ? this_dir = os.path.dirname(__file__) fn = os.path.join(this_dir, "grid_QZ_midQs_pp_GCZO_Pk50_kinf.csv") metadata = pyqz.pyqz_tools.get_MVphotogrid_metadata(fn) data = np.loadtxt(fn, comments="c", delimiter=",", skiprows=4) # Build 'Pseudo' line fluxes Hb = np.ones_like(data[:, 0]) Oiii = 10 ** data[:, metadata["columns"].index("[OIII]/Hb")] Oiip = 10 ** data[:, metadata["columns"].index("[OII]+/Hb")] Nii = Oiip * 10 ** data[:, metadata["columns"].index("[NII]/[OII]+")] Siip = 1.0 / 10 ** data[:, metadata["columns"].index("[NII]/[SII]+")] * Nii Ha = 1.0 / 10 ** data[:, metadata["columns"].index("[NII]/Ha")] * Nii all_fluxes = np.zeros((len(Hb), 12)) for i in range(len(Hb)): all_fluxes[i, 0] = 1.0 all_fluxes[i, 1] = all_fluxes[i, 0] * error all_fluxes[i, 2] = Oiii[i] * 1e3 # Make this an obviously bad line. all_fluxes[i, 3] = all_fluxes[i, 2] * error all_fluxes[i, 4] = Oiip[i] / 1e3 # Idem all_fluxes[i, 5] = all_fluxes[i, 4] * error all_fluxes[i, 6] = Nii[i] all_fluxes[i, 7] = all_fluxes[i, 6] * error all_fluxes[i, 8] = Siip[i] all_fluxes[i, 9] = all_fluxes[i, 8] * error all_fluxes[i, 10] = Ha[i] all_fluxes[i, 11] = all_fluxes[i, 10] * error # Launch the interpolation nspec = 16 # 16 on grid,14 = grid edge results = pyqz.get_global_qz( np.reshape(all_fluxes[nspec, :], (1, 12)), [ "Hb", "stdHb", "[OIII]", "std[OIII]", "[OII]+", "std[OII]+", "[NII]", "std[NII]", "[SII]+", "std[SII]+", "Ha", "stdHa", ], ["[NII]/[SII]+;[OIII]/Hb", "[NII]/[OII]+;[OIII]/[SII]+"], Pk=5.0, kappa=np.inf, struct="pp", KDE_pickle_loc=KDE_pickle_loc, sampling=1, KDE_qz_sampling=201j, KDE_method="multiv", srs=400, nproc=nproc, verbose=True, ) return np.isnan(results[0][0, results[1].index("<LogQ>")])