Skip to content

Commit

Permalink
hotfix: renounce the kT field for non-weighted projection data objects
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 12, 2020
1 parent b3496a4 commit 0391e3a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion yt/fields/fluid_fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
from unyt.exceptions import UnitConversionError

from yt.funcs import mylog
from yt.geometry.geometry_handler import is_curvilinear
Expand Down Expand Up @@ -134,7 +135,16 @@ def _pressure(field, data):
)

def _kT(field, data):
return (pc.kboltz * data[ftype, "temperature"]).in_units("keV")
ret = pc.kboltz * data[ftype, "temperature"]
try:
return ret.in_units("keV")
except UnitConversionError as err:
# see GH PR 2897
raise NotImplementedError(
"Can not define a kT field if temperature can not be converted to 'K'. "
"Chances are this is a non-weighted projection object and the "
"'temperature' field is expressed in K*cm."
) from err

registry.add_field(
(ftype, "kT"),
Expand Down

0 comments on commit 0391e3a

Please sign in to comment.