[yt-dev] Issue #1229: Cannot set magnetic units to Tesla (yt_analysis/yt)
Nathan Goldbaum
issues-reply at bitbucket.org
Thu Jun 2 08:43:05 PDT 2016
New issue 1229: Cannot set magnetic units to Tesla
https://bitbucket.org/yt_analysis/yt/issues/1229/cannot-set-magnetic-units-to-tesla
Nathan Goldbaum:
This is easiest to trigger by applying the following patch to the FLASH frontend:
```
diff -r e5ad039158b8 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py Wed Jun 01 21:22:59 2016 -0500
+++ b/yt/frontends/flash/data_structures.py Thu Jun 02 10:41:24 2016 -0500
@@ -246,7 +246,7 @@ class FLASHDataset(Dataset):
else:
length_factor = 1.0
temperature_factor = 1.0
- self.magnetic_unit = self.quan(b_factor, "gauss")
+ self.magnetic_unit = self.quan(b_factor/1e5, "T")
self.length_unit = self.quan(length_factor, "cm")
self.mass_unit = self.quan(1.0, "g")
```
And then running the following snippet:
```
#!python
>>> import yt
>>> ds = yt.load('WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5')
yt : [INFO ] 2016-06-02 10:40:54,926 Particle file found: WDMerger_hdf5_chk_1000.hdf5
yt : [INFO ] 2016-06-02 10:40:54,932 integer runtime parameter checkpointfilenumber overwrites a simulation scalar of the same name
yt : [INFO ] 2016-06-02 10:40:54,932 integer runtime parameter forcedplotfilenumber overwrites a simulation scalar of the same name
yt : [INFO ] 2016-06-02 10:40:54,932 integer runtime parameter nbegin overwrites a simulation scalar of the same name
yt : [WARNING ] 2016-06-02 10:40:54,938 Extending theta dimension to 2PI + left edge.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/goldbaum/Documents/yt-hg/yt/convenience.py", line 86, in load
return candidates[0](*args, **kwargs)
File "/Users/goldbaum/Documents/yt-hg/yt/frontends/flash/data_structures.py", line 223, in __init__
unit_system=unit_system)
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/static_output.py", line 240, in __init__
self.set_units()
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/static_output.py", line 834, in set_units
self.set_code_units()
File "/Users/goldbaum/Documents/yt-hg/yt/frontends/flash/data_structures.py", line 259, in set_code_units
super(FLASHDataset, self).set_code_units()
File "/Users/goldbaum/Documents/yt-hg/yt/data_objects/static_output.py", line 862, in set_code_units
self._set_code_unit_attributes()
File "/Users/goldbaum/Documents/yt-hg/yt/frontends/flash/data_structures.py", line 256, in _set_code_unit_attributes
self.unit_registry.modify("code_magnetic", self.magnetic_unit)
File "/Users/goldbaum/Documents/yt-hg/yt/units/unit_registry.py", line 109, in modify
base_value = base_value.in_base().value
File "/Users/goldbaum/Documents/yt-hg/yt/units/yt_array.py", line 561, in in_base
return self.in_units(self.units.get_base_equivalent(unit_system))
File "/Users/goldbaum/Documents/yt-hg/yt/units/unit_object.py", line 423, in get_base_equivalent
raise YTUnitsNotReducible(self, "cgs")
yt.utilities.exceptions.YTUnitsNotReducible: The unit 'T' cannot be reduced to a single expression within the cgs base system of units.
```
This is a problem for the OpenPMD frontend, see http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/2016-May/006449.html
More information about the yt-dev
mailing list