Commit 462a2832 authored by Simeon Doetsch's avatar Simeon Doetsch

Some more fixes

parent 35a98f0b
......@@ -67,9 +67,10 @@ class Grid:
def __getattr__(self, name):
try:
return object.__getattribute__(self, self.mappings[name])
mappings = object.__getattribute__(self, 'mappings')
return object.__getattribute__(self, mappings[name])
except KeyError:
raise AttributeError
raise AttributeError(f"{type(self)} has no attribute '{name}'")
def __str__(self):
return f"PLUTO Grid, Dimensions {self.dims}"
......
......@@ -29,10 +29,15 @@ class Simulation:
self.data_dir = sim_dir
elif os.path.exists(join(sim_dir, 'data', 'grid.out')):
self.data_dir = join(sim_dir, 'data')
elif os.path.exists(join(sim_dir, self.ini['Static Grid Output']['output_dir'], 'grid.out')):
self.data_dir = join(join(sim_dir, self.ini['Static Grid Output']['output_dir']))
else:
raise FileNotFoundError("Gridfile not found")
try:
from_ini = join(sim_dir, self.ini['Static Grid Output']['output_dir'], 'grid.out')
if os.path.exists(from_ini):
self.data_dir = join(sim_dir)
else:
raise FileNotFoundError()
except FileNotFoundError:
raise FileNotFoundError("Data directory with gridfile not found")
## Read grid ##
self.grid = Grid(join(self.data_dir, 'grid.out'))
......@@ -111,9 +116,10 @@ class Simulation:
# vars
try:
return getattribute(self[-1], name)
if name in self.vars:
return getattr(self[-1], name)
except AttributeError:
pass
raise
raise AttributeError(f"{type(self)} has no attribute '{name}'")
......@@ -183,7 +189,7 @@ class Simulation:
def plot(self, *args, n: int=-1, **kwargs):
"""Plot last data file, or data file n. All other arguments forwarded to PlutoData.plot()"""
self[n].plot(*args, **kwargs)
return self[n].plot(*args, **kwargs)
def __len__(self) -> int:
return self.n
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment