Commit ec619dbb authored by Médéric Boquien's avatar Médéric Boquien

Adapt pcigale-mock and pcigale-plots to the fusion of the output files.

parent 40bc3747
...@@ -22,8 +22,8 @@ from pcigale.session.configuration import Configuration ...@@ -22,8 +22,8 @@ from pcigale.session.configuration import Configuration
__version__ = "0.1-alpha" __version__ = "0.1-alpha"
# Name of the file containing the best models information # Name of the file containing the best models information
BEST_MODEL_FILE = "best_models.txt" BEST_MODEL_FILE = "results.fits"
MOCK_OUTPUT_FILE = "analysis_mock_results.txt" MOCK_OUTPUT_FILE = "results_mock.fits"
# Directory where the output files are stored # Directory where the output files are stored
OUT_DIR = "out/" OUT_DIR = "out/"
...@@ -93,14 +93,14 @@ def mock(config, nologo): ...@@ -93,14 +93,14 @@ def mock(config, nologo):
""" """
try: try:
exact = Table.read(OUT_DIR + BEST_MODEL_FILE, format='ascii') exact = Table.read(OUT_DIR + BEST_MODEL_FILE)
except FileNotFoundError: except FileNotFoundError:
print("Best models file {} not found.".format(OUT_DIR + print("Best models file {} not found.".format(OUT_DIR +
BEST_MODEL_FILE)) BEST_MODEL_FILE))
sys.exit(1) sys.exit(1)
try: try:
estimated = Table.read(OUT_DIR + MOCK_OUTPUT_FILE, format='ascii') estimated = Table.read(OUT_DIR + MOCK_OUTPUT_FILE)
except FileNotFoundError: except FileNotFoundError:
print("Mock models file {} not found.".format(OUT_DIR + print("Mock models file {} not found.".format(OUT_DIR +
MOCK_OUTPUT_FILE)) MOCK_OUTPUT_FILE))
......
...@@ -30,7 +30,7 @@ __version__ = "0.1-alpha" ...@@ -30,7 +30,7 @@ __version__ = "0.1-alpha"
# Name of the file containing the best models information # Name of the file containing the best models information
BEST_MODEL_FILE = "best_models.txt" BEST_MODEL_FILE = "results.fits"
# Directory where the output files are stored # Directory where the output files are stored
OUT_DIR = "out/" OUT_DIR = "out/"
# Wavelength limits (restframe) when plotting the best SED. # Wavelength limits (restframe) when plotting the best SED.
...@@ -124,9 +124,9 @@ def _sed_worker(obs, mod, filters, sed_type, nologo): ...@@ -124,9 +124,9 @@ def _sed_worker(obs, mod, filters, sed_type, nologo):
obs_fluxes = np.array([obs[filt] for filt in filters.keys()]) obs_fluxes = np.array([obs[filt] for filt in filters.keys()])
obs_fluxes_err = np.array([obs[filt+'_err'] obs_fluxes_err = np.array([obs[filt+'_err']
for filt in filters.keys()]) for filt in filters.keys()])
mod_fluxes = np.array([mod[filt] for filt in filters.keys()]) mod_fluxes = np.array([mod["best."+filt] for filt in filters.keys()])
z = np.around(obs['redshift'], decimals=2) z = np.around(obs['redshift'], decimals=2)
DL = mod['universe.luminosity_distance'] DL = mod['best.universe.luminosity_distance']
if sed_type == 'lum': if sed_type == 'lum':
xmin = PLOT_L_MIN xmin = PLOT_L_MIN
...@@ -300,7 +300,7 @@ def _sed_worker(obs, mod, filters, sed_type, nologo): ...@@ -300,7 +300,7 @@ def _sed_worker(obs, mod, filters, sed_type, nologo):
figure.suptitle("Best model for {} at z = {}. Reduced $\chi^2$={}". figure.suptitle("Best model for {} at z = {}. Reduced $\chi^2$={}".
format(obs['id'], np.round(obs['redshift'], format(obs['id'], np.round(obs['redshift'],
decimals=3), decimals=3),
np.round(mod['reduced_chi_square'], np.round(mod['best.reduced_chi_square'],
decimals=2))) decimals=2)))
if nologo is False: if nologo is False:
image = plt.imread(pkg_resources.resource_filename(__name__, image = plt.imread(pkg_resources.resource_filename(__name__,
...@@ -348,7 +348,7 @@ def sed(config, sed_type, nologo): ...@@ -348,7 +348,7 @@ def sed(config, sed_type, nologo):
"""Plot the best SED with associated observed and modelled fluxes. """Plot the best SED with associated observed and modelled fluxes.
""" """
obs = read_table(config.configuration['data_file']) obs = read_table(config.configuration['data_file'])
mod = Table.read(OUT_DIR + BEST_MODEL_FILE, format='ascii') mod = Table.read(OUT_DIR + BEST_MODEL_FILE)
with Database() as base: with Database() as base:
filters = OrderedDict([(name, base.get_filter(name)) filters = OrderedDict([(name, base.get_filter(name))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment