SWDatabase
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Classes | Functions | Variables
database.database_timeserie Namespace Reference

Classes

class  DBTimeserieError
 Error returned by database_timeserie. More...
 

Functions

def create_table
 Create a timeserie table data in a database for all timeserie 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_timeserie
 For a given table_name, return the fetch level it should use. More...
 
def datetime2file
 Look for the corresponding timeserie file in table_name table. More...
 
def datetime2data
 Find in table the nearest date from given date. More...
 
def nearest_sup
 Find in table the nearest date and newer from given date. More...
 
def nearest_inf
 Find in table the nearest date and older from given date. More...
 
def build_db
 Build the SW database for all files available and for a given table. More...
 

Variables

tuple database_path = os.path.join(path_db,'timeserie.db')
 
list database_tables
 
list attributes = []
 

Function Documentation

def database.database_timeserie.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.

Here is the call graph for this function:

Here is the caller graph for this function:

def database.database_timeserie.build_db (   table_name,
  db_file,
  verbose = 1 
)

Build the SW database for all files available and for a given table.

Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
Will look into folder corresponding to fetch type

Here is the call graph for this function:

def database.database_timeserie.compare_element (   db1,
  db2 
)

Compare 2 db_elements.

For all attribute names (see database_timeserie_attributes), check if db1[attr_name] == db2[attr_name].

Returns
boolean True if identical
def database.database_timeserie.create_table (   connector,
  table_name 
)

Create a timeserie table data in a database for all timeserie files.

For a table name, create all the attributes.

Here is the caller graph for this function:

def database.database_timeserie.datetime2data (   table_name,
  datetime_in,
  fetch_level = -1,
  h_accuracy = 3,
  frame = None 
)

Find in table the nearest date from given date.

Parameters
[in]table_name
[in]datetime_in
[in]fetch_level
[in]h_accuracy
[in]frameOnly for OBS_INSITU_MAG_ACELV4. GSE or RNT.
Returns
Nearest date in timeserie, its corresponding tuple, name tuple and unit tuple.

Here is the call graph for this function:

def database.database_timeserie.datetime2file (   table_name,
  datetime_in,
  fetch_level = -1,
  h_accuracy = 3 
)

Look for the corresponding timeserie file in table_name table.

Look at the files in [datetime_in-h_accuracy,datetime_in+h_accuracy].

Returns
Corresponding element of the database.

Here is the call graph for this function:

Here is the caller graph for this function:

def database.database_timeserie.delete_element (   table_name,
  connector,
  cursor,
  element_id 
)

Delete an element in a table through its ID.

def database.database_timeserie.fetch_level_choice_timeserie (   table_name)

For a given table_name, return the fetch level it should use.

Todo:
Check input

Here is the caller graph for this function:

def database.database_timeserie.find_element (   table_names,
  connector,
  cursor,
  kwargs 
)

Find an element in 1 or multiple tables.

Parameters
[in]table_nameslist of 1 or multiple table names
[in]connector
[in]cursor
[in]kwargsoptional arguments corresponding to database_timeserie_attributes and their values
[out]resultslist DB element found

Here is the caller graph for this function:

def database.database_timeserie.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

Here is the call graph for this function:

def database.database_timeserie.nearest_inf (   table_name,
  datetime_in,
  fetch_level = -1,
  frame = None 
)

Find in table the nearest date and older from given date.

Parameters
[in]table_name
[in]datetime_in
[in]fetch_level
[in]frameOnly for OBS_INSITU_MAG_ACELV4. GSE or RNT.
Returns
Nearest date in timeserie and its corresponding tuple.

Here is the call graph for this function:

def database.database_timeserie.nearest_sup (   table_name,
  datetime_in,
  fetch_level = -1,
  frame = None 
)

Find in table the nearest date and newer from given date.

Parameters
[in]table_name
[in]datetime_in
[in]fetch_level
[in]frameOnly for OBS_INSITU_MAG_ACELV4. GSE or RNT.
Returns
Nearest date in timeserie and its corresponding tuple.

Here is the call graph for this function:

def database.database_timeserie.open_db (   db_filename)

Open DB in dictionnary mode.

Returns
conn,cur connector and cursor

Here is the caller graph for this function:

def database.database_timeserie.printdiff_element (   db1,
  db2 
)

Show differences between 2 db_elements.

For all attribute names (see database_timeserie_attributes), if db1[attr_name] != db2[attr_name] print their respective value.

def database.database_timeserie.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_timeserie.update_element (   table_name,
  connector,
  cursor,
  element_id,
  kwargs 
)

Update an element in a table through its ID.

Here is the caller graph for this function:

Variable Documentation

list database.database_timeserie.attributes = []
tuple database.database_timeserie.database_path = os.path.join(path_db,'timeserie.db')
list database.database_timeserie.database_tables
Initial value:
1 = [
2 'OBS_INSITU_VELOCITY_DISCOVER' ,\
3 'OBS_INSITU_MAG_DISCOVER' ,\
4 'OBS_INSITU_VELOCITY_STEREOA' ,\
5 'OBS_INSITU_MAG_STEREOA' ,\
6 'OBS_INSITU_MAG_ACELV1' ,\
7 'OBS_INSITU_MAG_ACELV4' ,\
8 'OBS_INSITU_VELOCITY_ACELV4' ,\
9 'OBS_INSITU_VELOCITY_PSP' ,\
10 'OBS_INSITU_MAG_PSP' ,\
11 'OBS_HELIOSPHERE_SPEED_AMDA_EARTH' ,\
12 'OBS_HELIOSPHERE_SPEED_AMDA_PSP' ,\
13 'OBS_HELIOSPHERE_SPEED_AMDA_STEREOA' ,\
14 ]