[postprocessor] add namelist because we need it there

This commit is contained in:
Noe Brucy
2021-06-17 11:02:28 +02:00
parent 3ef8542ef4
commit 74d588f02b
+19 -5
View File
@@ -42,6 +42,9 @@ from baseprocessor import (
oct_vect_getter, oct_vect_getter,
) )
from run_selector import NamelistRecursive
import f90nml
# Getters # Getters
@@ -340,7 +343,12 @@ class PostProcessor(HDF5Container):
distance = self._radius distance = self._radius
# Get time # Get time
time = self._ro.info["time"] # time in codeunits self.time = self._ro.info["time"]
# Get namelist
self.namelist = None
path_nml = path + "/" + self.pp_params.input.nml_filename
self.namelist = NamelistRecursive(f90nml.read(path_nml))
# Set post processing attributes # Set post processing attributes
self.save.root._v_attrs.dir = os.path.dirname(path) self.save.root._v_attrs.dir = os.path.dirname(path)
@@ -348,7 +356,7 @@ class PostProcessor(HDF5Container):
self.save.root._v_attrs.num = num self.save.root._v_attrs.num = num
self.save.root._v_attrs.lbox = self.lbox self.save.root._v_attrs.lbox = self.lbox
self.save.root._v_attrs.unit_length = self.info["unit_length"] self.save.root._v_attrs.unit_length = self.info["unit_length"]
self.save.root._v_attrs.time = time self.save.root._v_attrs.time = self.time
if "/maps" not in self.save: if "/maps" not in self.save:
self.save.create_group("/", "maps", "2D maps") self.save.create_group("/", "maps", "2D maps")
@@ -381,9 +389,7 @@ class PostProcessor(HDF5Container):
else: else:
self.fil = None self.fil = None
time_in_right_unit = self.info["time"] * self.info["unit_time"].express( time_in_right_unit = self.time * self.info["unit_time"].express(unit_time)
unit_time
)
self.snapshot = Snapshot( self.snapshot = Snapshot(
name=str(self.num), name=str(self.num),
description="", description="",
@@ -476,6 +482,14 @@ class PostProcessor(HDF5Container):
del self.cells del self.cells
self.cells_loaded = False self.cells_loaded = False
def get_nml(self, nml_key):
if self.namelist is not None:
value = self.namelist[nml_key]
else:
raise AttributeError("No namelist associated with this snapshot")
return value
def getter_pos_disk(self, dset): def getter_pos_disk(self, dset):
""" """
Returns the position in normalized and centered units Returns the position in normalized and centered units