aboutsummaryrefslogtreecommitdiffstats
path: root/Commons
diff options
context:
space:
mode:
authorVolker Hoffmann <volker@cheleb.net>2013-08-30 10:23:02 +0200
committerVolker Hoffmann <volker@cheleb.net>2013-08-30 10:29:22 +0200
commit974070b84ababb3aa402a8fa2ad4db443bada2d7 (patch)
tree679b9e4ab36f31e4a51e445d9375f146ca0c1751 /Commons
parent214a7645f3182ca66708295bb60567a42f4c61bb (diff)
compute orbital ellipses during reduction or plotting
Diffstat (limited to 'Commons')
-rw-r--r--Commons/Loaders.py17
-rw-r--r--Commons/Structs.py1
2 files changed, 11 insertions, 7 deletions
diff --git a/Commons/Loaders.py b/Commons/Loaders.py
index 27a762e..41900b5 100644
--- a/Commons/Loaders.py
+++ b/Commons/Loaders.py
@@ -1,19 +1,20 @@
from Structs import Snapshot, Particle
class Loader():
- def __init__(self, nstep, fname):
+ def __init__(self, nstep, fname, ellipses):
self.nstep = nstep
self.fname = fname
self.snapshot = Snapshot()
self.snapshot.nstep = nstep
+ self.snapshot.ellipses = ellipses
class GengaIC(Loader):
pass
class GengaOut(Loader):
- def __init__(self, nstep=1):
+ def __init__(self, nstep=1, ellipses=False):
fname = "Outgasrun_%012d.dat" % nstep
- Loader.__init__(self, nstep, fname)
+ Loader.__init__(self, nstep, fname, ellipses)
def load(self):
with open(self.fname, 'r') as f:
@@ -37,14 +38,15 @@ class GengaOut(Loader):
particle.vy = float(line[8])
particle.vz = float(line[9])
particle.cart2kep()
- particle.compute_ellipse()
+ if self.snapshot.ellipses:
+ particle.compute_ellipse()
particles.append(particle)
self.snapshot.particles = particles
class SSAscii(Loader):
- def __init__(self, nstep=1):
+ def __init__(self, nstep=1, ellipses=False):
fname = "Out.%010d.dat" % nstep
- Loader.__init__(self, nstep, fname)
+ Loader.__init__(self, nstep, fname, ellipses)
def load(self):
with open(self.fname, 'r') as f:
@@ -68,7 +70,8 @@ class SSAscii(Loader):
particle.vy = float(line[8])
particle.vz = float(line[9])
particle.cart2kep()
- particle.compute_ellipse()
+ if self.snapshot.ellipses:
+ particle.compute_ellipse()
particles.append(particle)
self.snapshot.particles = particles
diff --git a/Commons/Structs.py b/Commons/Structs.py
index 3bccc5d..b7372e3 100644
--- a/Commons/Structs.py
+++ b/Commons/Structs.py
@@ -49,3 +49,4 @@ class Snapshot():
self.tout = None
self.nstep = None
self.nparticles = None
+ self.ellipses = None