A Python3 package to calculate thermal comfort indexes (such as the Wet Bulb Globe Temperature), from ECMWF-data (e.g. ERA5 or IFS).
This package is now able to calculate the following indexes
- Wind-Chill Equivalent Temperature
- Using the JAG/TI method (Osczevski & Bluestein 2005)
- Wet Bulb Globe Temperature
- Using the improved Argonne model (adapted from Liljegren et al. 2008). This method uses less approximations to solve the radiation balance as the Argonne model, using the skin temperature and albedo. These were not available in the data of Liljegren et al. 2008, but are available in the ECMWF datasets.
- Using the approximations by ACSM (1984), Bernard & Barrow (2013) and Dimiceli et al. (2013)
Tool
serves as the main entry point for this module. You can create a tool by calling
import tcitool
tool = tcitool.Tool()
The tool can than be used to load data, calculate indexes, and export data.
tool.data.load('./ECMWF_ERA5.nc')
tool.options.update({'radiation_cumulative': False,'radiation_integration_time': 3600})
tool.calculate('windchill_jagti')
All data can be accessed using the tool.data
interface. This interface is based on xarray
with a few extra functions.
The xarray.Dataset can be accessed using tool.data.ds
.
tool.data['wcet_jagit']
>>> <xarray.DataArray 'wcet_jagti' (time: 3, latitude: 3, longitude: 3)>
array([[[16. , 17.85, 18.3 ],
[17.83, 14.74, 12.9 ],
[14.44, 14.36, 12.19]],
[[16.03, 17.77, 18.05],
[17.61, 15.21, 15.27],
[14.39, 14.91, 13.94]],
[[19.36, 21.33, 20.75],
[21.22, 25.93, 27.53],
[26.35, 27.14, 26.68]]])
tool.data['wcet_jagti'].attrs
>>> {'units': 'deg C',
'long_name': 'Wind Chill Equivalent Temperature (using JAG/TI calculation method)',
'source': 'Eq. 2.3 in https://cdn.knmi.nl/system/downloads/files/000/000/016/original/gevoelstemperatuur.pdf?1433939065'}
The Tool interface also provides exporting capabilities.
tool.data.save('./ECMWF_ERA5_withWC.nc')
For more information, view the documentation using help(tool)
(or help(tool.data)
for more info about the data object, for example).
When diving in the source code of this package, it is usefull to keep the thing below in mind. This is the general setup of the package.
tool
provides the main interactions with the user.- The
func
module is used to preform simple operations (e.g. unit conversions, density, Reynold number), using only the data submitted to the function. These are used by the Generators and Calculators. Methods in this module do not run on the enitre dataset, but only work with the data given. Classes in this module only containclassmethod
-s and are a way to namespace the different operations. Generators
are classes that preform a operation to the data set, uppon request. For example, the user, or aCalculator
may require the wind speed, while this quantity is unavailable intool.data
. What is available, is the u and v components of the wind. In that case, the relevant Generator-method will start and use thetcitool.func.MeteoFuncs.wind_speed
-function to convert between these parameters, and store the result back intotool.data
.Calculators
are classes that provide the core functionality of this module. These are often longer running processes that will calculate many different parameters to be able to calculate the requested variable. Usingtool.require_data()
it will kick-off the nessesary Generator-methods. It may also use many differentfunc
-methods in its internals.- The
data
module is a wrapper for axarray.Dataset
, and is used to provide some handy functions to the Dataset.
Calculator
-classes need to be registerd into the tcitool.tool.Tool.calculators
-dictionary.
Generator
-methods also need to be registerd into the tcitool.gens.registery
-class to be able to automaticaly start, when a certain dataset is nessesary. Generators
may not invoke tool.require_data
.