Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Cabayol-Garcia committed Sep 30, 2024
1 parent e6ee47a commit 870ce3c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/plot_mpg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Import necessary modules
## General python modules
import numpy as np
import matplotlib
matplotlib.use('Agg') # Use a non-interactive backend for rendering plots
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import os
Expand Down Expand Up @@ -34,39 +36,43 @@ def test():
# Initialize a GadgetArchive instance for postprocessing data
archive = gadget_archive.GadgetArchive(postproc="Cabayol23")

for ii, sim in enumerate(archive.list_sim):
if sim=='mpg_central':
# Directory for saving plots
save_dir = f'{repo}data/validation_figures/{archive_name}/'
# Create the directory if it does not exist
os.makedirs(save_dir, exist_ok=True)

#for ii, sim in enumerate(archive.list_sim):
for ii, sim in enumerate(['mpg_central']):

if sim == 'mpg_central':
model_path_central = f'{repo}data/NNmodels/Cabayol23+/Cabayol23+.pt'

emulator = NNEmulator(
training_set=training_set,
emulator_label=emulator_label,
emu_params=emu_params,
model_path=model_path_central,
drop_sim=None,
train=False,
)
else:
emulator = NNEmulator(
training_set=training_set,
emulator_label=emulator_label,
emu_params=emu_params,
model_path=model_path+f'_{sim}.pt',
model_path=model_path + f'_{sim}.pt',
drop_sim=sim,
train=False,
)

# Get testing data for the current simulation
testing_data = archive.get_testing_data(sim_label=f'{sim}')
if sim!='nyx_central':
testing_data = [d for d in testing_data if d['val_scaling']==1]
if sim != 'nyx_central':
testing_data = [d for d in testing_data if d['val_scaling'] == 1]

# Plot and save the emulated P1D
plot_p1d_vs_emulator(
testing_data,
emulator,
save_path=f'{repo}data/validation_figures/{archive_name}/{sim}.png'
)
save_path = f'{save_dir}{sim}.png'
plot_p1d_vs_emulator(testing_data, emulator, save_path=save_path)

return

# Call the function to execute the test
Expand Down

0 comments on commit 870ce3c

Please sign in to comment.