From f640b03eeec8fd069c6ebe9759c2c9e8e073db05 Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Sat, 29 May 2021 00:28:26 +0200 Subject: [PATCH] [run_selector] Change load_info to use pymses one --- run_selector.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/run_selector.py b/run_selector.py index 9385b38..918c305 100644 --- a/run_selector.py +++ b/run_selector.py @@ -5,9 +5,10 @@ import glob import os from functools import partial +from pymses.sources.ramses.info import read_ramses_info_file import numpy as np -import yaml + import f90nml @@ -263,25 +264,8 @@ class RunSelector: return runs def load_info(self, run, num): - info_file = open( - self.path_in - + "/" - + run - + "/" - + "output_" - + str(num).zfill(5) - + "/" - + "info_" - + str(num).zfill(5) - + ".txt", - "r", - ) - info = {} - for line in info_file.readlines(): - parsed = yaml.safe_load(line.replace("=", ":")) - if type(parsed) == dict: - info.update(parsed) - info_file.close() + info_filename = f"{self.path_in}/{run}/output_{num:05}/info_{num:05}.txt" + info = read_ramses_info_file(info_filename) return info def get_nums( @@ -292,7 +276,7 @@ class RunSelector: try: self.info[run][num] = self.load_info(run, num) success = True - except IOError: + except (IOError, AttributeError): success = False else: success = True