Loading etl/prs/prs_inspect_results.py +22 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,18 @@ def get_results( run_id: str, session: Session, is_isothermal: bool = False) -> Tuple[float, str, str, tuple, np.array]: """ Get results from the database, given the prameters of the model :param dust_temperature: the characteristic dust temperature :param gas_density: the characteristic number density of molecualar hydrogen :param lines: the lines used to compute the ratio :param run_id: the run_id of the model :param session: a session to query the database :param is_isothermal: whether the model is isothermal :return: a tuple containing the aggregated line ratios, the ratio map name, the fits grid name (for the number density), the scaling factor between the grid and image pixel (must be integer!), and the pixel-by-pixel measured line ratios """ # Select correct column for filtering if is_isothermal is True: dust_temperature_column = GridPars.dust_temperature Loading Loading @@ -105,6 +117,16 @@ def get_grid_values( run_id: str, session: Session, is_isothermal: bool = False) -> np.array: """ Retrieve the grid values, given the model parameters :param quantity_name: the quantity to extract :param dust_temperature: the characteristic dust temperature :param gas_density: the characteristic number density of molecular hydrogen :param run_id: the run_id to process :param session: a session to query the database :param is_isothermal: whether the model is isothermal :return: the array of grid values """ # Select correct column for filtering if is_isothermal is True: dust_temperature_column = GridPars.dust_temperature Loading Loading @@ -182,7 +204,6 @@ def main(run_id: str, run_id=run_id, is_isothermal=is_isothermal ) # density_correlation.loc[nh2] = np.nanmean(np.where(density_grid == 0, np.nan, density_grid)) avg_density_map = np.nansum(np.where(density_grid == 0, np.nan, density_grid ** 2), axis=2) / \ np.nansum(np.where(density_grid == 0, np.nan, density_grid), axis=2) avg_temperature_map = np.nansum(np.where(density_grid == 0, np.nan, temperature_grid * density_grid), Loading @@ -202,7 +223,6 @@ def main(run_id: str, results.plot(x='dust_temperature', y='gas_density', yscale='log') plt.savefig(os.path.join('prs', 'output', f'ratio_grid_lines_{"-".join(lines)}.png')) plt.clf() # df_list_concat = [] for (tdust, nh2) in product(dust_temperatures, central_densities): df_list = [] Loading @@ -211,7 +231,6 @@ def main(run_id: str, columns=['avg_nh2', 'avg_tdust', f'ratio_{"-".join(lines)}']) df_list.append(df.dropna()) df_tmp = pd.concat(df_list, axis=1) # df_tmp = df_tmp.loc[~df_tmp.index.duplicated(), :].copy() df_tmp = df_tmp.loc[:, ~df_tmp.columns.duplicated()].copy() df_tmp['nh2'] = nh2 df_tmp['tdust'] = tdust Loading Loading
etl/prs/prs_inspect_results.py +22 −3 Original line number Diff line number Diff line Loading @@ -65,6 +65,18 @@ def get_results( run_id: str, session: Session, is_isothermal: bool = False) -> Tuple[float, str, str, tuple, np.array]: """ Get results from the database, given the prameters of the model :param dust_temperature: the characteristic dust temperature :param gas_density: the characteristic number density of molecualar hydrogen :param lines: the lines used to compute the ratio :param run_id: the run_id of the model :param session: a session to query the database :param is_isothermal: whether the model is isothermal :return: a tuple containing the aggregated line ratios, the ratio map name, the fits grid name (for the number density), the scaling factor between the grid and image pixel (must be integer!), and the pixel-by-pixel measured line ratios """ # Select correct column for filtering if is_isothermal is True: dust_temperature_column = GridPars.dust_temperature Loading Loading @@ -105,6 +117,16 @@ def get_grid_values( run_id: str, session: Session, is_isothermal: bool = False) -> np.array: """ Retrieve the grid values, given the model parameters :param quantity_name: the quantity to extract :param dust_temperature: the characteristic dust temperature :param gas_density: the characteristic number density of molecular hydrogen :param run_id: the run_id to process :param session: a session to query the database :param is_isothermal: whether the model is isothermal :return: the array of grid values """ # Select correct column for filtering if is_isothermal is True: dust_temperature_column = GridPars.dust_temperature Loading Loading @@ -182,7 +204,6 @@ def main(run_id: str, run_id=run_id, is_isothermal=is_isothermal ) # density_correlation.loc[nh2] = np.nanmean(np.where(density_grid == 0, np.nan, density_grid)) avg_density_map = np.nansum(np.where(density_grid == 0, np.nan, density_grid ** 2), axis=2) / \ np.nansum(np.where(density_grid == 0, np.nan, density_grid), axis=2) avg_temperature_map = np.nansum(np.where(density_grid == 0, np.nan, temperature_grid * density_grid), Loading @@ -202,7 +223,6 @@ def main(run_id: str, results.plot(x='dust_temperature', y='gas_density', yscale='log') plt.savefig(os.path.join('prs', 'output', f'ratio_grid_lines_{"-".join(lines)}.png')) plt.clf() # df_list_concat = [] for (tdust, nh2) in product(dust_temperatures, central_densities): df_list = [] Loading @@ -211,7 +231,6 @@ def main(run_id: str, columns=['avg_nh2', 'avg_tdust', f'ratio_{"-".join(lines)}']) df_list.append(df.dropna()) df_tmp = pd.concat(df_list, axis=1) # df_tmp = df_tmp.loc[~df_tmp.index.duplicated(), :].copy() df_tmp = df_tmp.loc[:, ~df_tmp.columns.duplicated()].copy() df_tmp['nh2'] = nh2 df_tmp['tdust'] = tdust Loading