Overloading EnzoStaticOutput causing problems with load
Hi, Everybody-- In order to get units to be converted properly for fields that do not have units information in the parameter file, I've been subclassing EnzoStaticOutput. However, for some reason this shorts out the load function. For instance merely subclassing EnzoStaticOutput as follows causes load to return None, instead of a parameter file. This changed some time ago, but I've been ignoring it. Is there a way I can continue subclassing the EnzoStaticOutput, so I have more control over my units and not lose the load function? Thanks, d. from yt.mods import * class FileStaticOutputFourPi(EnzoStaticOutput): def __init__(self,*args,**kwargs): fpi = na.sqrt(4*na.pi) EnzoStaticOutput.__init__(self,*args,conversion_override={'Density': 1, 'DivB': 1, 'x-velocity': 1, 'Total_Energy': 1}, parameter_override={'LengthUnits': 1,'LengthUnit': 1, 'Time': 1}, **kwargs)
pf = load(path) print pf None -- Sent from my computer.
Hi Dave, There's probably a way, but I don't know what it is. Feel free to dig in and look. If your debug level were set lower, such that "load(...)" actually printed information out (instead of, as it looks, set to something like 50) it would probably track things down. My guess is that the subclass allows for multiple candidates to return true for _is_valid, which leads to an ambiguity, which load uses as a reason not to return a value. The kwargs support for load was added to support the use case of supplying units as well as supplying additional information that is required for instantiated some parameter files. -Matt On Mon, Oct 24, 2011 at 12:15 PM, david collins <antpuncher@gmail.com> wrote:
Hi, Everybody--
In order to get units to be converted properly for fields that do not have units information in the parameter file, I've been subclassing EnzoStaticOutput. However, for some reason this shorts out the load function. For instance merely subclassing EnzoStaticOutput as follows causes load to return None, instead of a parameter file. This changed some time ago, but I've been ignoring it. Is there a way I can continue subclassing the EnzoStaticOutput, so I have more control over my units and not lose the load function?
Thanks, d.
from yt.mods import * class FileStaticOutputFourPi(EnzoStaticOutput): def __init__(self,*args,**kwargs): fpi = na.sqrt(4*na.pi) EnzoStaticOutput.__init__(self,*args,conversion_override={'Density': 1, 'DivB': 1, 'x-velocity': 1, 'Total_Energy': 1}, parameter_override={'LengthUnits': 1,'LengthUnit': 1, 'Time': 1}, **kwargs)
pf = load(path) print pf None -- Sent from my computer.
Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
The kwargs support for load was added to support the use case of supplying units as well as supplying additional information that is required for instantiated some parameter files.
Ah, so could I pass the same conversion_override and parameter_override arguments to load? That's an easy enough modification to make. d.
-Matt
On Mon, Oct 24, 2011 at 12:15 PM, david collins <antpuncher@gmail.com> wrote:
Hi, Everybody--
In order to get units to be converted properly for fields that do not have units information in the parameter file, I've been subclassing EnzoStaticOutput. However, for some reason this shorts out the load function. For instance merely subclassing EnzoStaticOutput as follows causes load to return None, instead of a parameter file. This changed some time ago, but I've been ignoring it. Is there a way I can continue subclassing the EnzoStaticOutput, so I have more control over my units and not lose the load function?
Thanks, d.
from yt.mods import * class FileStaticOutputFourPi(EnzoStaticOutput): def __init__(self,*args,**kwargs): fpi = na.sqrt(4*na.pi) EnzoStaticOutput.__init__(self,*args,conversion_override={'Density': 1, 'DivB': 1, 'x-velocity': 1, 'Total_Energy': 1}, parameter_override={'LengthUnits': 1,'LengthUnit': 1, 'Time': 1}, **kwargs)
pf = load(path) print pf None -- Sent from my computer.
Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
_______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
-- Sent from my computer.
participants (2)
-
david collins
-
Matthew Turk