Return the variable converted to different units. Args: var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A variable. vartype (:obj:`str`): The type of variable. Choices are: 'wind', 'pressure', 'temp', or 'height'. var_unit (:obj:`st
(var, vartype, var_unit, dest_unit)
| 335 | |
| 336 | |
| 337 | def do_conversion(var, vartype, var_unit, dest_unit): |
| 338 | """Return the variable converted to different units. |
| 339 | |
| 340 | Args: |
| 341 | |
| 342 | var (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A |
| 343 | variable. |
| 344 | |
| 345 | vartype (:obj:`str`): The type of variable. Choices are: 'wind', |
| 346 | 'pressure', 'temp', or 'height'. |
| 347 | |
| 348 | var_unit (:obj:`str`): The variable's current units. |
| 349 | |
| 350 | dest_unit (:obj:`str`): The desired units. |
| 351 | |
| 352 | Returns: |
| 353 | |
| 354 | :class:`xarray.DataArray` or :class:`numpy.ndarray`: The variable in |
| 355 | the desired units. |
| 356 | |
| 357 | """ |
| 358 | u_cleaned = dealias_and_clean_unit(dest_unit) |
| 359 | if vartype != "temp": |
| 360 | return _apply_conv_fact(var, vartype, var_unit.lower(), u_cleaned) |
| 361 | else: |
| 362 | return _apply_temp_conv(var, var_unit.lower(), u_cleaned) |
no test coverage detected