Coverage for aixweather/transformation_functions/unit_conversions.py: 91%
35 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-01-06 16:01 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-01-06 16:01 +0000
1"""
2Includes functions to convert units in weather data.
3"""
4import logging
6import pandas as pd
8logger = logging.getLogger(__name__)
11def Jcm2_to_Whm2(radiation: pd.Series):
12 """convert radiance unit from J/cm^2 to Wh/m^2"""
13 radiation = radiation / 0.36
14 logger.debug("%s transformed from from J/cm2 to Wh/m2", radiation.name)
15 return radiation
18def Jm2_to_Whm2(radiation: pd.Series):
19 """convert radiance unit from J/m^2 to Wh/m^2"""
20 radiation = radiation / 3600
21 logger.debug("%s transformed from from J/m2 to Wh/m2", radiation.name)
22 return radiation
25def kJm2_to_Whm2(radiation: pd.Series):
26 """convert radiance unit from kJ/m^2 to Wh/m^2"""
27 radiation = radiation / 3.6
28 logger.debug("%s transformed from from kJ/m^2 to Wh/m^2", radiation.name)
29 return radiation
32def hPa_to_Pa(pressure: pd.Series):
33 """convert pressure unit from hPa to Pa"""
34 pressure = pressure * 100
35 logger.debug("%s transformed from from hPa to Pa", pressure.name)
36 return pressure
39def eigth_to_tenth(cloudgrade: pd.Series):
40 """convert cloudgrade from eighth to tenth"""
41 cloudgrade = cloudgrade * 10 / 8
42 logger.debug("%s transformed from from eighth to tenth", cloudgrade.name)
43 return cloudgrade
46def percent_to_tenth(cloudgrade: pd.Series):
47 """convert cloudgrade from percent to tenth"""
48 cloudgrade = cloudgrade / 10
49 logger.debug("%s transformed from from percent to tenth", cloudgrade.name)
50 return cloudgrade
53def kelvin_to_celcius(temperature: pd.Series):
54 """convert temperature from kelvin to celcius"""
55 temperature = temperature - 273.15
56 logger.debug("%s transformed from from kelvin to celcius", temperature.name)
57 return temperature
60def divide_by_1000(series: pd.Series):
61 """divide by 1000"""
62 series = series / 1000
63 logger.debug("%s transformed from x to x/1000", series.name)
64 return series