Welcome to base_bah’s documentation!
base_bah contains basic functions used in Python software from the Büro für Angewandte Hydrologie, Berlin. This package needs no other “heavy” packages, like numpy or pandas.
Contents:
Installing base_bah
base_bah should work on Python 3.6 (or later) on Windows, Linux or OS X.
The following command will build and install base_bah:
python setup.py install
Installing binary wheels with pip
Binary wheel distributions of base_bah are hosted on Pypi <https://bitbucket.org/BAH_Berlin/base_bah>_.
pip install base_bah
base_bah reference documentation.
Read
Functions
Read ArcEGMO configuration files and output
|
Read the pegel.dbf, creates a relation between fgw and gauge in a dictionary. |
|
Read the pegel.dbf, returns the position of a FGW in the file |
|
Read the arc_egmo.ste into a dictionary. |
|
Read other configuration files from arc_egmo. |
|
Read the configuration file for MOO. |
|
Return the further path for MET and HYD input data. |
|
Read more or less the whole configuration. |
|
Read the simulation results in excel mode. |
|
Read the observation time series in excel mode. |
|
Return simulation and observation time series with the same starting and ending times. |
|
Find the correct file name or directory name in the folder ignoring the case. |
Classes
Parse the ArcEGMO configuration tree
|
Class that provides functionality to read the ArcEGMO confilguration file hierarchy. |
Write
|
saves the results or simulation dictionaries |
|
loads the results or simulation dictionaries |
|
Configures arc_EGMO configuration files with new parameter values, parameters are given for specific sections in the file |
|
writes the y_TX.txt file containing the objective function values and backup filename |
|
writes the log file for each thread |
|
ov3rride an arc_egmo.ste file to set another BERECHNUNGS_VARIANTE |
|
writes a dictionary back into a configuration file, uses a template of the file |
Format
Functions to format strings.
|
compile an time header for ArcEGMO and format string |
|
assures that month or day are returned as %mm and are string |
|
returns a string with a given length. |
|
generates an arcEGMO time entry for hourly data. |
|
prints a nice status bar and updates it, if called again. |
|
Add back the quotes around the date columns like "01.01.2018 00:15" to ArcEGMO files. |
|
strip leading and tailing slash and backslash from pathsegment |
|
returns a number from the beginning or ending of a string |
FTP
Class to handle downloads from a FTP-Server
|
Class to download from FTP servers. |
Download
Functions for downloading from the interwebs.
|
Download all files found in the given FTP-folder into a folder with a foldername derived from the ACC file in DWD forecast folder |
|
Download all files found in the given FTP-folder |
|
Download a file given the link. |
|
downloads a link to a file from a https site.. |
|
Create the file name for a DWD weather station with 2 parameter. |
|
get the folder contents --> get html file |
Output
Functions to handle command line outputs
|
prints a nice status bar and updates it, if called again. |
PKL
Functions to create and read (gzip compressed) pickle files
|
Saves a struct or list into a prickle binary file. |
|
Loads a prickle binary file. |
|
Save a struct or list into a prickle binary file. |
|
Load a prickle binary file. |
Utilities
Functions
Random stuff
|
Load and modify the source of a module. |
Classification
Classification of dates
|
Return the month as int, for names or abbreviations. |
|
Look up the time scale. |
Return the pandas period string for value in seconds |
|
Return the time in seconds for a pandas period string |
Other classifications
code_lookup
Date
Functions for dates
|
Round a datetime object to any time laps in seconds |
|
Add a lagtime to a list of dates. |
|
Return the number of months between date1 and date2 |
|
Return the number of days in the month |
|
Return a list of timesteps from <tstart> to <tend> of length <tdelta> |
|
JSON serializer for objects not serializable by default json code extended from here: https://stackoverflow.com/questions/11875770/how-to-overcome-datetime-datetime-not-json-serializable-in-python |
|
Class for JSON encodings of datetimes. |
|
Return the timestep as string for the given int in seconds |
|
Given year, month, day return day of year Astronomical Algorithms, Jean Meeus, 2d ed, 1998, chap 7 |
|
Given year = Y and day of year = N, return year, month, day Astronomical Algorithms, Jean Meeus, 2d ed, 1998, chap 7 |
|
Given a datetime or a list with doy and year, lookup the week of the year |
|
Calculate the timesteps in weeks, months and days between 2 dates. |
|
Return two list with months (seasons) such that ss is the beginning of the first season and se the end of the first season. |
|
If year is a leap year return True else return False |
License
Software
base_bah is licensed under the GNU General Public License, Version 3.0 or later.
Copyright (C) 2018-2020 Ruben Müller, Büro für Angewandte Hydrologie, Berlin
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Documentation
This documentation is licensed under the GNU Free Documentation License, Version 1.3 or later.
Copyright (C) 2018-2020 Ruben Müller, Büro für Angewandte Hydrologie, Berlin
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.