Giter Site home page Giter Site logo

papagaai35 / tcitool Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 121 KB

A Python3 module to calculate many different thermal comfort indicies

License: GNU General Public License v3.0

Python 100.00%
thermal-comfort heat-stress cold-stress wbgt wind-chill python3 xarray netcdf4 ecmwf-data

tcitool's Introduction

TCItool

A Python3 package to calculate thermal comfort indexes (such as the Wet Bulb Globe Temperature), from ECMWF-data (e.g. ERA5 or IFS).

Python v3.7 License Last commit Release v1.0

Supported indexes

This package is now able to calculate the following indexes

Using this package

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).

Development Outline

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 contain classmethod-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 a Calculator may require the wind speed, while this quantity is unavailable in tool.data. What is available, is the u and v components of the wind. In that case, the relevant Generator-method will start and use the tcitool.func.MeteoFuncs.wind_speed-function to convert between these parameters, and store the result back into tool.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. Using tool.require_data() it will kick-off the nessesary Generator-methods. It may also use many different func-methods in its internals.
  • The data module is a wrapper for a xarray.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.

tcitool's People

Contributors

papagaai35 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

tcitool's Issues

Files need refactoring

The files in the package are seen as modules, even though the extensive __init__.py. Therefore, some commands are quite case-sensitive and will generate a TypeError:

tool = tcitool.tool()
> TypeError: 'module' object is not callable

Correct usage:

tool = tcitool.Tool()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.