MCPcopy Create free account
hub / github.com/NCAR/wrf-python / do_conversion

Function do_conversion

src/wrf/units.py:337–362  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

335
336
337def 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)

Callers 1

func_wrapperFunction · 0.85

Calls 3

dealias_and_clean_unitFunction · 0.85
_apply_conv_factFunction · 0.85
_apply_temp_convFunction · 0.85

Tested by

no test coverage detected