The ETS (TNO) CookBook of useful Python Scripts
Project description
ETS_CookBook
This repository contains the ETS CookBook, which is a collection of useful Python scripts used across ETS (a research group within TNO) models.
Authors and contact
Omar Usmani (Omar.Usmani@TNO.nl)
Licence
This cookbook is released under the Apache 2.0 licence. All accompanying documentation and manual are released under the Creative Commons BY-SA 4.0 license.
Libraries used and licensing
(See requirements.txt file for versions (corresponding to Python 3.11.1, which is the version used for developping and testing the model)) pip install -r requirements.txt
Included scripts/functions
- check_if_folder_exists: Checks if a folder exists. If it does not, it creates it.
- parameters_from_TOML: Reads a TOML parameters file name and returns a parameters dictionary.
- reference_scale: This function takes a list of numbers an returns a scale (lower and upper boundary) they are in.
- dataframe_from_Excel_table_name: This function looks up a given table name in an Excel file and returns a DataFrame containing the values of that table.
- dataframe_to_Excel: This function takes a DataFrame and puts it into a new sheet in an Excel workbook.
- get_extra_colors: This function gets the user-defined extra colors from a file.
- get_RGB_from_name: This function takes a color name and returns its RGB values (0 to 1).
- rgb_color_list: Gets a list of RGB codes for a list of color names.
- register_color_bars: This function reads the user-defined color bars in a parameter file, creates them and makes them available.
- get_season: This function takes a datetime timestamp and tells us in which season it is.
- save_figure: Saves a Matplotlib figure to a number of file formats set by the user.
- save_dataframe: Saves a pandas dataframe to a number of file formats set by the user.
- put_dataframe_in_sql_in_chunks: This function takes a Dataframe and writes it into the table of an SQL database. It does so in chunks to avoid memory issues.
- query_list_from_file: This returns a list of queries from an SQL file
- **dataframes_from_query_list:**This returns a list of dataframes, each obtained from a query in the list
- from_grib_to_dataframe: This function takes a grib file and converts it to a DataFrame.
- read_query_generator: This function returns an sql query string that can be used (for example) in Panda's read_sql.
- database_tables_columns: Returns a dictionary with the tables of a database as keys and their columns as values.
- download_and_save_file: Downloads a file from an URL and saves it
- string_to_float: Converts strings to floats, and to zero if the string is not a float.
- get_map_area_data: Gets area data into a Dataframe
- get_map_borders_data: Gets borders data into a Dataframe
- get_map_points_data: Gets points data into a Dataframe
- make_spider__chart: Makes a spider/radar chart
- update_database_table: This function updates the values of one row of a table in a database. If you want to change multiple rows (with a different value for each row), then you need to iterate over the rows.
- update_database_table: Returns a query filter stringthat can be used in an SQL query.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ets_cookbook-1.0.tar.gz
(16.7 kB
view hashes)
Built Distribution
ets_cookbook-1.0-py3-none-any.whl
(17.0 kB
view hashes)
Close
Hashes for ets_cookbook-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 956bc3f64c998be7913c91c17ca01f8519ff0f3158e9bdf7f1cb2230b95bfeeb |
|
MD5 | 9ab7f867d6709ece7ed047d351700372 |
|
BLAKE2b-256 | 9c525070978de2ec64311b8447b059fc889210b4277c1bc056d285f23160469b |