[run_selector] Change load_info to use pymses one
This commit is contained in:
+5
-21
@@ -5,9 +5,10 @@
|
|||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from pymses.sources.ramses.info import read_ramses_info_file
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import yaml
|
|
||||||
import f90nml
|
import f90nml
|
||||||
|
|
||||||
|
|
||||||
@@ -263,25 +264,8 @@ class RunSelector:
|
|||||||
return runs
|
return runs
|
||||||
|
|
||||||
def load_info(self, run, num):
|
def load_info(self, run, num):
|
||||||
info_file = open(
|
info_filename = f"{self.path_in}/{run}/output_{num:05}/info_{num:05}.txt"
|
||||||
self.path_in
|
info = read_ramses_info_file(info_filename)
|
||||||
+ "/"
|
|
||||||
+ 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()
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def get_nums(
|
def get_nums(
|
||||||
@@ -292,7 +276,7 @@ class RunSelector:
|
|||||||
try:
|
try:
|
||||||
self.info[run][num] = self.load_info(run, num)
|
self.info[run][num] = self.load_info(run, num)
|
||||||
success = True
|
success = True
|
||||||
except IOError:
|
except (IOError, AttributeError):
|
||||||
success = False
|
success = False
|
||||||
else:
|
else:
|
||||||
success = True
|
success = True
|
||||||
|
|||||||
Reference in New Issue
Block a user