PySCeS / pysces

The official PySCeS project source code repository.
https://pysces.github.io
Other
34 stars 10 forks source link

Make simulation results available as recarray with lazy loading #21

Closed jmrohwer closed 7 years ago

jmrohwer commented 7 years ago

I have implemented the simulation results as a recarray mod.sim (much in the same way as for the mod.scan recarray). This is with lazy loading so the object is only created when it is called. This allows the user to conveniently access the simulation time and values of the variables: mod.Simulate() mod.sim.Time mod.sim.S1 mod.sim.R1 etc.

These can then directly be used further in calculations or plotting. I have found this very useful in interactive work.

bgoli commented 7 years ago

Nice idea. I'll try it out asap, are there any other output arrays that would benefit from this?

bgoli commented 7 years ago

Seems to work, the only thing I might suggest is instead of:

self._sim = numpy.rec.fromrecords(self.data_sim.getAllSimData(lbls=True)[0], names=self.data_sim.getAllSimData(lbls=True)[1])'

doing something like:

data = self.data_sim.getAllSimData(lbls=True) self._sim = numpy.rec.fromrecords(data[0], names=data[1])'

as it saves a function call. Otherwise good to go.

jmrohwer commented 7 years ago

OK done and merged.