Return the variable converted to different units using a temperature conversion algorithm. Args: var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A variable. var_unit (:obj:`str`): The variable's current units. dest_unit (:obj:`str`): The des
(var, var_unit, dest_unit)
| 97 | |
| 98 | |
| 99 | def _apply_temp_conv(var, var_unit, dest_unit): |
| 100 | """Return the variable converted to different units using a temperature |
| 101 | conversion algorithm. |
| 102 | |
| 103 | Args: |
| 104 | |
| 105 | var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A |
| 106 | variable. |
| 107 | |
| 108 | var_unit (:obj:`str`): The variable's current units. |
| 109 | |
| 110 | dest_unit (:obj:`str`): The desired units. |
| 111 | |
| 112 | Returns: |
| 113 | |
| 114 | :class:`xarray.DataArray` or :class:`numpy.ndarray`: The variable in |
| 115 | the desired units. |
| 116 | |
| 117 | """ |
| 118 | if dest_unit == var_unit: |
| 119 | return var |
| 120 | |
| 121 | if var_unit != _BASE_UNITS["temp"]: |
| 122 | tk = _to_kelvin(var, var_unit) |
| 123 | if dest_unit == _BASE_UNITS["temp"]: |
| 124 | return tk |
| 125 | else: |
| 126 | return (_TEMP_CONV_METHODS[dest_unit])(tk) |
| 127 | else: |
| 128 | return (_TEMP_CONV_METHODS[dest_unit])(var) |
| 129 | |
| 130 | |
| 131 | # A mapping of unit names to their dictionary key names |
no test coverage detected