[postprocessor] add namelist because we need it there
This commit is contained in:
+19
-5
@@ -42,6 +42,9 @@ from baseprocessor import (
|
||||
oct_vect_getter,
|
||||
)
|
||||
|
||||
from run_selector import NamelistRecursive
|
||||
import f90nml
|
||||
|
||||
|
||||
# Getters
|
||||
|
||||
@@ -340,7 +343,12 @@ class PostProcessor(HDF5Container):
|
||||
distance = self._radius
|
||||
|
||||
# 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
|
||||
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.lbox = self.lbox
|
||||
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:
|
||||
self.save.create_group("/", "maps", "2D maps")
|
||||
@@ -381,9 +389,7 @@ class PostProcessor(HDF5Container):
|
||||
else:
|
||||
self.fil = None
|
||||
|
||||
time_in_right_unit = self.info["time"] * self.info["unit_time"].express(
|
||||
unit_time
|
||||
)
|
||||
time_in_right_unit = self.time * self.info["unit_time"].express(unit_time)
|
||||
self.snapshot = Snapshot(
|
||||
name=str(self.num),
|
||||
description="",
|
||||
@@ -476,6 +482,14 @@ class PostProcessor(HDF5Container):
|
||||
del self.cells
|
||||
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):
|
||||
"""
|
||||
Returns the position in normalized and centered units
|
||||
|
||||
Reference in New Issue
Block a user