Coverage for aixweather/definitions.py: 92%
13 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"""
2This module includes variables or functions which define central variables for the whole project.
3"""
5import os
7# format of the core_data
8# time of measurement is always at indicated time
9format_core_data = {
10 # from TMY3 https://www.nrel.gov/docs/fy08osti/43156.pdf
11 "DryBulbTemp": {"unit": "degC"},
12 "DewPointTemp": {"unit": "degC"},
13 "RelHum": {"unit": "percent"},
14 "ExtHorRad": {"unit": "Wh/m2"},
15 "ExtDirNormRad": {"unit": "Wh/m2"},
16 "HorInfra": {"unit": "Wh/m2"},
17 "GlobHorRad": {"unit": "Wh/m2"},
18 "DirNormRad": {"unit": "Wh/m2"},
19 "DirHorRad": {"unit": "Wh/m2"},
20 "DiffHorRad": {"unit": "Wh/m2"},
21 "GlobHorIll": {"unit": "lux"},
22 "DirecNormIll": {"unit": "lux"},
23 "DiffuseHorIll": {"unit": "lux"},
24 "ZenithLum": {"unit": "Cd/m2"},
25 "WindDir": {"unit": "deg"},
26 "WindSpeed": {"unit": "m/s"},
27 "TotalSkyCover": {"unit": "1tenth"},
28 "OpaqueSkyCover": {"unit": "1tenth"},
29 "Visibility": {"unit": "km"},
30 "CeilingH": {"unit": "m"},
31 "PrecWater": {"unit": "mm"},
32 "Aerosol": {"unit": "1thousandth"},
33 "LiquidPrecD": {"unit": "mm/h"},
34 # exception to TMY3 format as all TMY3 data file actually use "Pa" instead of mbar
35 "AtmPressure": {"unit": "Pa"},
36 # additional variables
37 "Soil_Temperature_5cm": {"unit": "degC"},
38 "Soil_Temperature_10cm": {"unit": "degC"},
39 "Soil_Temperature_20cm": {"unit": "degC"},
40 "Soil_Temperature_50cm": {"unit": "degC"},
41 "Soil_Temperature_1m": {"unit": "degC"},
42}
44# creates the path to the root directory to be used in other modules
45ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
47# local temporary folder
48local_folder_temp = os.path.join(ROOT_DIR, "temp_local")
50def result_folder_path() -> str:
51 """
52 Creates the path to the resultsfolder.
53 """
54 folder_path = os.path.join(f"{ROOT_DIR}", "results")
55 return folder_path
57def results_file_path(filename: str, folder_path: str = None) -> str:
58 """
59 create a path to a results file
61 Args:
62 filename: name of file
63 folder_path: path to result folder
65 Returns:
66 str: path to result file
67 """
68 # if required specify folder_path e.g. for Django WebApp
69 if folder_path is None:
70 folder_path = result_folder_path()
72 # Ensure that the results folder exists
73 os.makedirs(folder_path, exist_ok=True)
75 # create file path
76 filepath = os.path.join(folder_path, filename)
77 return filepath