Classes | |
class | DBMap2DError |
Error returned by database_map2D. More... | |
Functions | |
def | create_table |
Create a map2D table in a database for all map2D files. More... | |
def | row2dict |
Classic SQLite routine for transforming a row of tuple into a dictionnary. More... | |
def | open_db |
Open DB in dictionnary mode. More... | |
def | init_db |
Initialise output database file. More... | |
def | find_element |
Find an element in 1 or multiple tables. More... | |
def | add_element |
Add an element in a table. More... | |
def | update_element |
Update an element in a table through its ID. More... | |
def | delete_element |
Delete an element in a table through its ID. More... | |
def | compare_element |
Compare 2 db_elements. More... | |
def | printdiff_element |
Show differences between 2 db_elements. More... | |
def | fetch_level_choice_map |
For a given table_name, return the map fetch level it should use. More... | |
def | time2map |
Look for the corresponding time maps in table_name table. More... | |
def | newest_map |
Look for the newest maps in table_name table. More... | |
def | oldest_map |
Look for the oldest maps in table_name table. More... | |
def | build_db |
Build the SW database for all files available and for a given table. More... | |
def | clean_db |
Clean all map2D files (in DB and physically) for all tables in the SW database. More... | |
def | check_db |
Check existing file and file present in DB. More... | |
def | clean_file |
Clean all map2D files for all tables in the SW database. More... | |
def | view_db |
Show a view of the DB. More... | |
Variables | |
tuple | database_path = os.path.join(path_db,'map2D.db') |
list | database_tables |
list | attributes = [] |
def database.database_map2D.add_element | ( | table_name, | |
connector, | |||
cursor, | |||
kwargs | |||
) |
Add an element in a table.
If found 0 corresponding element, just add it.
If found more than 1 corresponding element, raise DBTimeserieError.
def database.database_map2D.build_db | ( | table_name, | |
db_file, | |||
verbose = 0 |
|||
) |
Build the SW database for all files available and for a given table.
Important: a local_dir folder may have files from multiple table, that is why there all this possible Case.
Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
Will look into folder corresponding to fetch type
def database.database_map2D.check_db | ( | db_file | ) |
Check existing file and file present in DB.
Show file number in each fetch type for all tables.
Important: a local_dir folder may have files from multiple table, that is why there all this possible Case.
def database.database_map2D.clean_db | ( | db_file, | |
verbose = 0 |
|||
) |
Clean all map2D files (in DB and physically) for all tables in the SW database.
ACHTUNG! Remove physically files!
def database.database_map2D.clean_file | ( | db_file | ) |
Clean all map2D files for all tables in the SW database.
ACHTUNG! Not reversible!
def database.database_map2D.compare_element | ( | db1, | |
db2 | |||
) |
Compare 2 db_elements.
For all attribute names (see database_map2D_attributes), check if db1[attr_name] == db2[attr_name].
def database.database_map2D.create_table | ( | connector, | |
table_name | |||
) |
Create a map2D table in a database for all map2D files.
For a table name, create all the attributes.
def database.database_map2D.delete_element | ( | table_name, | |
connector, | |||
cursor, | |||
element_id | |||
) |
Delete an element in a table through its ID.
def database.database_map2D.fetch_level_choice_map | ( | table_name | ) |
For a given table_name, return the map fetch level it should use.
def database.database_map2D.find_element | ( | table_names, | |
connector, | |||
cursor, | |||
kwargs | |||
) |
Find an element in 1 or multiple tables.
[in] | table_names | list of 1 or multiple table names |
[in] | connector | |
[in] | cursor | |
[in] | kwargs | optional arguments corresponding to database_map2D_attributes and their values |
[out] | results | list DB element found |
def database.database_map2D.init_db | ( | db_file, | |
verbose_in | |||
) |
Initialise output database file.
If already exists, replace it. Old db kept into .old.
Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
def database.database_map2D.newest_map | ( | table_name | ) |
Look for the newest maps in table_name table.
Look at the newest Crmap and the newest Smap. Return the newest between both.
def database.database_map2D.oldest_map | ( | table_name | ) |
Look for the oldest maps in table_name table.
Look at the oldest Crmap and the oldest Smap. Return the oldest between both.
def database.database_map2D.open_db | ( | db_filename | ) |
Open DB in dictionnary mode.
def database.database_map2D.printdiff_element | ( | db1, | |
db2 | |||
) |
Show differences between 2 db_elements.
For all attribute names (see database_map2D_attributes), if db1[attr_name] != db2[attr_name] print their respective value.
def database.database_map2D.row2dict | ( | cursor, | |
row | |||
) |
Classic SQLite routine for transforming a row of tuple into a dictionnary.
Usage: conn comes from sqlite3.connect(db_file)
conn.row_factory = row2dict
IN FACT NO NEED FOR IT!!!
Just call conn.row_factory = sqlite3.Row
def database.database_map2D.time2map | ( | table_name, | |
time_in, | |||
h_accuracy = 6 , |
|||
flevel = None |
|||
) |
Look for the corresponding time maps in table_name table.
For smaps, look at the smaps in [time_in-h_acuracy,time_in+h_acuracy].
For crmaps, look at the crmap where cr = time_in.ncar.
Deal with data gap: return the nearest map in inside a data gap.
Deal with Extended mode: return the nearest and older map.
Deal with Forecast mode.
def database.database_map2D.update_element | ( | table_name, | |
connector, | |||
cursor, | |||
element_id, | |||
kwargs | |||
) |
Update an element in a table through its ID.
def database.database_map2D.view_db | ( | db_file, | |
folder | |||
) |
Show a view of the DB.
[in] | db_file | Path of the map2D DB |
[in] | folder | Path of the folder containing output images |
list database.database_map2D.attributes = [] |
tuple database.database_map2D.database_path = os.path.join(path_db,'map2D.db') |
list database.database_map2D.database_tables |