[yt-dev] yt Particle Plots & openPMD Frontend

Fabian Koller f.koller at hzdr.de
Thu May 26 10:59:24 PDT 2016

Hi there,

I am currently trying to extend the WIP frontend for openPMD.

Let me be more specific about the magnetic unit problem:
The already existing frontend was created on top of yt 3.2.1 and
appeared to work fine.
Recently, the code was migrated onto the yt_analysis/yt branch, which I
understand to be your dev version.
What appears to be the problem is this line of code in our
openPMDDataset class:
self.magnetic_unit = self.quan(1.0, "T")

This worked with out noticeable problems with the old codebase.
After the migration, loading a oPMD file throws YTUnitsNotReducible:

In [1]: import yt
In [2]: f =
Warning: Attribute author (recommended) does NOT exist in `/`!
Found 1 iteration(s)
Iteration 100 : found 4 meshes
Iteration 100 : found 2 particle species
Warning: Key particlePatches (recommended) does NOT exist in
Warning: Key particlePatches (recommended) does NOT exist in
yt : [INFO     ] 2016-05-26 19:22:56,315 openPMD: found 5 iterations in
yt : [WARNING  ] 2016-05-26 19:22:56,316 openPMD: only choose to load
the first iteration (100)
YTUnitsNotReducible                       Traceback (most recent call last)
<ipython-input-7-b3e410e545a5> in <module>()
----> 1 f =

/data/home/koller47/openpmd/yt/convenience.pyc in load(*args, **kwargs)
     84     candidates = find_lowest_subclasses(candidates)
     85     if len(candidates) == 1:
---> 86         return candidates[0](*args, **kwargs)
     87     if len(candidates) == 0:
     88         if ytcfg.get("yt", "enzo_db") != '' \

/data/home/koller47/openpmd/yt/frontends/openPMD/data_structures.pyc in
__init__(self, filename, dataset_type, storage_filename, units_override)
    294         self._setBasePath(self._handle, self._filepath)
    295         Dataset.__init__(self, filename, dataset_type,
--> 296                          units_override=units_override)
    297         self.storage_filename = storage_filename
    298         self.fluid_types += ('openPMD',)

/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in
__init__(self, filename, dataset_type, file_style, units_override,
    235         self._create_unit_registry()
    236         self._parse_parameter_file()
--> 237         self.set_units()
    238         self._setup_coordinate_handler()

/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in
    806             self.unit_registry.modify('a',
--> 808         self.set_code_units()
    810         if getattr(self, "cosmological_simulation", False):

/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in
    843             # If we do not have this set, but some fields come in in
    844             # "code_magnetic", this will allow them to remain in
that unit.
--> 845             self.unit_registry.modify("code_magnetic",
    846         vel_unit = getattr(
    847             self, "velocity_unit", self.length_unit /

/data/home/koller47/openpmd/yt/units/unit_registry.pyc in modify(self,
symbol, base_value)
    108         if hasattr(base_value, "in_base"):
--> 109             base_value = base_value.in_base().value
    111         self.lut[symbol] = (float(base_value), ) +

/data/home/koller47/openpmd/yt/units/yt_array.pyc in in_base(self,
    559         >>> E_new = E.in_base(unit_system="galactic")
    560         """
--> 561         return
    563     def in_cgs(self):

/data/home/koller47/openpmd/yt/units/unit_object.pyc in
get_base_equivalent(self, unit_system)
    421         if unit_system == "cgs":
    422             if current_mks in self.dimensions.free_symbols:
--> 423                 raise YTUnitsNotReducible(self, "cgs")
    424             return yt_base_unit
    425         else:

YTUnitsNotReducible: The unit 'T' cannot be reduced to a single
expression within the cgs base system of units.

self.magnetic_unit = self.quan(1.0, "gauss")
loading the file works fine and as expected.

As for openPMD test data, you can get 2D and 3D ones from here:

On 24/05/16 18:54, John Zuhone wrote:
> The latest development version of yt now has “unit systems”:
> http://yt-project.org/docs/dev/analyzing/units/unit_systems.html
> But Nathan is correct—this doesn’t affect the Tesla unit per se—it
> should be fine. If we could get a script and a more specific error
> that you are seeing, that would help. 
>> On May 24, 2016, at 12:30 PM, Huebl, Axel <a.huebl at hzdr.de
>> <mailto:a.huebl at hzdr.de>> wrote:
>> Hi yt-devs,
>> I am forwarding this conversation to the public list to keep it open for
>> others to join in and to build up a record that might help others.
>> Our new student Fabian updated our frontend and implemented particle
>> readers. Unfortunately some details of the particle "fields" still cause
>> some bumps that we can not get our head around.
>> We are now able to read fields and particles, even chunk-wise, and can
>> work with the data we read in python scripts via the all_data() method.
>> Nevertheless, using the particle scatter plots such as yt.ParticlePlot
>> seems not to work. We have some problems with unions / the "all" group
>> and the fact that we have several particle species (e.g., "hot
>> electrons", "cold electrons", "helium ions", "nitrogen ions", etc.)
>> Also since the last rebase: did someone recently change the unit system
>> in yt? T for "Tesla" seems not to be understood any more. Is there a
>> changelog somewhere available? Do we have to describe our data in cgs
>> / mks?
>> Would someone be interested for a quick heads up via e.g., skype /
>> web-rtc so we can ask specific questions?
>> Fabian is around on Tuesdays and Fridays, something like early CA time,
>> and late GER time usually works great (e.g., 9pm-PDT / 6pm-CEST).
>> Our current branch HEAD can be found here (->yt->frontends->openPMD):
>>  https://bitbucket.org/C0nsultant/openpmd/src?at=yt
>> And an example script is attached.
>> Thanks a lot!
>> Axel
>> <read_openPMD.py>_______________________________________________
>> yt-dev mailing list
>> yt-dev at lists.spacepope.org <mailto:yt-dev at lists.spacepope.org>
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

More information about the yt-dev mailing list