<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Fabian,<div class=""><br class=""></div><div class="">OK—we now know exactly what is going on. </div><div class=""><br class=""></div><div class="">First, some background on some changes to the way units in general (and electromagnetic units in particular) are handled in yt:</div><div class=""><br class=""></div><div class="">Even though superficially 1 G ~ 1.0e-4 T, it is not strictly true because</div><div class=""><br class=""></div><div class="">1 G = 1 sqrt(g)/(sqrt(cm)*s) —> dimensions of sqrt(mass)/(sqrt(length)*time)</div><div class=""><br class=""></div><div class="">1 T = 1 kg/(A*s**2) —> dimensions mass/(current*time**2)</div><div class=""><br class=""></div><div class="">since SI has a fundamental unit of current and CGS does not, it means that you cannot strictly convert between the two since yt unit conversions are based on converting between objects with the same dimensions. </div><div class=""><br class=""></div><div class="">We ignored this discrepancy in previous versions of yt, and simply allowed conversions between G and T, but in order to make things more self-consistent and better support MKS units we have now implemented the notion of separate unit systems, which means that you cannot convert directly between G and T anymore since they are not the same dimensions. </div><div class=""><br class=""></div><div class="">However, you can associate a specific set of units (such as MKS/SI) with a particular frontend, by adding this keyword in the call to __init__ like this:</div><div class=""><br class=""></div><div class="">class openPMDDataset(Dataset):</div><div class=""> def __init__(self, filename, …, unit_system=“mks”)</div><div class=""><br class=""></div><div class="">However, as Nathan has pointed out to me, though this is supposed to work it won’t because we need to make sure the dataset’s unit registry itself has a unit system. This will require a patch, which we are happy to do and provide for you to test to make sure we can get this to work for you. </div><div class=""><br class=""></div><div class="">I should note that regardless of what units your magnetic field is in you can make conversions between MKS/SI and CGS EM units using the to_equivalent() method for YTArrays and YTQuantities:</div><div class=""><br class=""></div><div class="">B = YTQuantity(1.0,"T") # magnetic field in Tesla<br class="">print (B, B.to_equivalent("gauss","CGS")) # convert to Gauss<br class=""><br class=""></div><div class="">There is more information about this here:</div><div class=""><br class=""></div><div class=""><a href="http://yt-project.org/docs/dev/analyzing/units/unit_equivalencies.html#Electromagnetic-Equivalencies" class="">http://yt-project.org/docs/dev/analyzing/units/unit_equivalencies.html#Electromagnetic-Equivalencies</a></div><div class=""><br class=""></div><div class="">You can see the rationale for the new unit system setup here:</div><div class=""><br class=""></div><div class=""><a href="http://ytep.readthedocs.io/en/latest/YTEPs/YTEP-0028.html" class="">http://ytep.readthedocs.io/en/latest/YTEPs/YTEP-0028.html</a></div><div class=""><br class=""></div><div class="">and, most relevant for you, the specific language on magnetic fields here:</div><div class=""><br class=""></div><div class=""><a href="http://ytep.readthedocs.io/en/latest/YTEPs/YTEP-0028.html#special-handling-for-magnetic-fields" class="">http://ytep.readthedocs.io/en/latest/YTEPs/YTEP-0028.html#special-handling-for-magnetic-fields</a></div><div class=""><br class=""></div><div class="">Let me know if you have any other questions about any of this, or if any of it is unclear—I think Nathan wants to work on this. </div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">John</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 26, 2016, at 1:59 PM, Fabian Koller <<a href="mailto:f.koller@hzdr.de" class="">f.koller@hzdr.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi there,<br class=""><br class="">I am currently trying to extend the WIP frontend for openPMD.<br class=""><br class="">Let me be more specific about the magnetic unit problem:<br class="">The already existing frontend was created on top of yt 3.2.1 and<br class="">appeared to work fine.<br class="">Recently, the code was migrated onto the yt_analysis/yt branch, which I<br class="">understand to be your dev version.<br class="">What appears to be the problem is this line of code in our<br class="">openPMDDataset class:<br class="">self.magnetic_unit = self.quan(1.0, "T")<br class=""><br class="">This worked with out noticeable problems with the old codebase.<br class="">After the migration, loading a oPMD file throws YTUnitsNotReducible:<br class=""><br class="">In [1]: import yt<br class="">In [2]: f =<br class="">yt.load('/data/home/koller47/openpmd/example-2d/hdf5/data00000100.h5')<br class="">Warning: Attribute author (recommended) does NOT exist in `/`!<br class="">Found 1 iteration(s)<br class="">Iteration 100 : found 4 meshes<br class="">Iteration 100 : found 2 particle species<br class="">Warning: Key particlePatches (recommended) does NOT exist in<br class="">`/data/100/particles/Hydrogen1+`!<br class="">Warning: Key particlePatches (recommended) does NOT exist in<br class="">`/data/100/particles/electrons`!<br class="">yt : [INFO ] 2016-05-26 19:22:56,315 openPMD: found 5 iterations in<br class="">directory<br class="">yt : [WARNING ] 2016-05-26 19:22:56,316 openPMD: only choose to load<br class="">the first iteration (100)<br class="">---------------------------------------------------------------------------<br class="">YTUnitsNotReducible Traceback (most recent call last)<br class=""><ipython-input-7-b3e410e545a5> in <module>()<br class="">----> 1 f =<br class="">yt.load('/data/home/koller47/openpmd/example-2d/hdf5/data00000100.h5')<br class=""><br class="">/data/home/koller47/openpmd/yt/convenience.pyc in load(*args, **kwargs)<br class=""> 84 candidates = find_lowest_subclasses(candidates)<br class=""> 85 if len(candidates) == 1:<br class="">---> 86 return candidates[0](*args, **kwargs)<br class=""> 87 if len(candidates) == 0:<br class=""> 88 if ytcfg.get("yt", "enzo_db") != '' \<br class=""><br class="">/data/home/koller47/openpmd/yt/frontends/openPMD/data_structures.pyc in<br class="">__init__(self, filename, dataset_type, storage_filename, units_override)<br class=""> 294 self._setBasePath(self._handle, self._filepath)<br class=""> 295 Dataset.__init__(self, filename, dataset_type,<br class="">--> 296 units_override=units_override)<br class=""> 297 self.storage_filename = storage_filename<br class=""> 298 self.fluid_types += ('openPMD',)<br class=""><br class="">/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in<br class="">__init__(self, filename, dataset_type, file_style, units_override,<br class="">unit_system)<br class=""> 235 self._create_unit_registry()<br class=""> 236 self._parse_parameter_file()<br class="">--> 237 self.set_units()<br class=""> 238 self._setup_coordinate_handler()<br class=""> 239<br class=""><br class="">/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in<br class="">set_units(self)<br class=""> 806 self.unit_registry.modify('a',<br class="">1/(1+self.current_redshift))<br class=""> 807<br class="">--> 808 self.set_code_units()<br class=""> 809<br class=""> 810 if getattr(self, "cosmological_simulation", False):<br class=""><br class="">/data/home/koller47/openpmd/yt/data_objects/static_output.pyc in<br class="">set_code_units(self)<br class=""> 843 # If we do not have this set, but some fields come in in<br class=""> 844 # "code_magnetic", this will allow them to remain in<br class="">that unit.<br class="">--> 845 self.unit_registry.modify("code_magnetic",<br class="">self.magnetic_unit)<br class=""> 846 vel_unit = getattr(<br class=""> 847 self, "velocity_unit", self.length_unit /<br class="">self.time_unit)<br class=""><br class="">/data/home/koller47/openpmd/yt/units/unit_registry.pyc in modify(self,<br class="">symbol, base_value)<br class=""> 107<br class=""> 108 if hasattr(base_value, "in_base"):<br class="">--> 109 base_value = base_value.in_base().value<br class=""> 110<br class=""> 111 self.lut[symbol] = (float(base_value), ) +<br class="">self.lut[symbol][1:]<br class=""><br class="">/data/home/koller47/openpmd/yt/units/yt_array.pyc in in_base(self,<br class="">unit_system)<br class=""> 559 >>> E_new = E.in_base(unit_system="galactic")<br class=""> 560 """<br class="">--> 561 return<br class="">self.in_units(self.units.get_base_equivalent(unit_system))<br class=""> 562<br class=""> 563 def in_cgs(self):<br class=""><br class="">/data/home/koller47/openpmd/yt/units/unit_object.pyc in<br class="">get_base_equivalent(self, unit_system)<br class=""> 421 if unit_system == "cgs":<br class=""> 422 if current_mks in self.dimensions.free_symbols:<br class="">--> 423 raise YTUnitsNotReducible(self, "cgs")<br class=""> 424 return yt_base_unit<br class=""> 425 else:<br class=""><br class="">YTUnitsNotReducible: The unit 'T' cannot be reduced to a single<br class="">expression within the cgs base system of units.<br class=""><br class="">With<br class="">self.magnetic_unit = self.quan(1.0, "gauss")<br class="">loading the file works fine and as expected.<br class=""><br class="">As for openPMD test data, you can get 2D and 3D ones from here:<br class=""><a href="https://github.com/openPMD/openPMD-example-datasets" class="">https://github.com/openPMD/openPMD-example-datasets</a><br class=""><br class="">On 24/05/16 18:54, John Zuhone wrote:<br class=""><blockquote type="cite" class="">The latest development version of yt now has “unit systems”:<br class=""><br class="">http://yt-project.org/docs/dev/analyzing/units/unit_systems.html<br class=""><br class="">But Nathan is correct—this doesn’t affect the Tesla unit per se—it<br class="">should be fine. If we could get a script and a more specific error<br class="">that you are seeing, that would help. <br class=""><br class=""><blockquote type="cite" class="">On May 24, 2016, at 12:30 PM, Huebl, Axel <a.huebl@hzdr.de<br class=""><mailto:a.huebl@hzdr.de>> wrote:<br class=""><br class="">Hi yt-devs,<br class=""><br class="">I am forwarding this conversation to the public list to keep it open for<br class="">others to join in and to build up a record that might help others.<br class=""><br class="">Our new student Fabian updated our frontend and implemented particle<br class="">readers. Unfortunately some details of the particle "fields" still cause<br class="">some bumps that we can not get our head around.<br class=""><br class="">We are now able to read fields and particles, even chunk-wise, and can<br class="">work with the data we read in python scripts via the all_data() method.<br class=""><br class="">Nevertheless, using the particle scatter plots such as yt.ParticlePlot<br class="">seems not to work. We have some problems with unions / the "all" group<br class="">and the fact that we have several particle species (e.g., "hot<br class="">electrons", "cold electrons", "helium ions", "nitrogen ions", etc.)<br class=""><br class="">Also since the last rebase: did someone recently change the unit system<br class="">in yt? T for "Tesla" seems not to be understood any more. Is there a<br class="">changelog somewhere available? Do we have to describe our data in cgs<br class="">/ mks?<br class=""><br class="">Would someone be interested for a quick heads up via e.g., skype /<br class="">web-rtc so we can ask specific questions?<br class=""><br class="">Fabian is around on Tuesdays and Fridays, something like early CA time,<br class="">and late GER time usually works great (e.g., 9pm-PDT / 6pm-CEST).<br class=""><br class="">Our current branch HEAD can be found here (->yt->frontends->openPMD):<br class=""> https://bitbucket.org/C0nsultant/openpmd/src?at=yt<br class=""><br class="">And an example script is attached.<br class=""><br class=""><br class="">Thanks a lot!<br class="">Axel<br class=""><read_openPMD.py>_______________________________________________<br class="">yt-dev mailing list<br class="">yt-dev@lists.spacepope.org <mailto:yt-dev@lists.spacepope.org><br class="">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org<br class=""></blockquote><br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></body></html>