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

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 = []
 

Function Documentation

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

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.

Here is the call graph for this function:

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!

Here is the call graph for this function:

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

Returns
boolean True if identical
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.

Here is the caller graph for this function:

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

Delete an element in a table through its ID.

Here is the caller graph for this function:

def database.database_map2D.fetch_level_choice_map (   table_name)

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

Todo:
Check input

Here is the caller graph for this function:

def database.database_map2D.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_map2D_attributes and their values
[out]resultslist DB element found

Here is the caller graph for this function:

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

Here is the call graph for this function:

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.

Returns
db_element Corresponding element of the database.

Here is the call graph for this function:

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.

Returns
db_element Corresponding element of the database.

Here is the call graph for this function:

def database.database_map2D.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_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.

Returns
Corresponding element of the database.
Todo:

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.

Here is the call graph for this function:

def database.database_map2D.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:

def database.database_map2D.view_db (   db_file,
  folder 
)

Show a view of the DB.

Parameters
[in]db_filePath of the map2D DB
[in]folderPath of the folder containing output images

Here is the call graph for this function:

Variable Documentation

list database.database_map2D.attributes = []
tuple database.database_map2D.database_path = os.path.join(path_db,'map2D.db')
list database.database_map2D.database_tables
Initial value:
1 = [
2 'OBS_MAPS_NSO' ,\
3 'OBS_MAPS_NSOZ' ,\
4 'OBS_MAPS_WSO_FILLED' ,\
5 'OBS_MAPS_WSO_ORIGIN' ,\
6 'OBS_MAPS_WSO_DATE' ,\
7 'OBS_MAPS_ADAPT40' ,\
8 'OBS_MAPS_ADAPT41' ,\
9 'OBS_MAPS_SDO_AIA_171' ,\
10 'OBS_MAPS_SDO_AIA_193' ,\
11 #'OBS_MAPS_SDO_HMI' ,\
12 'OBS_MAPS_SOHO_EIT_171' ,\
13 'OBS_MAPS_SOHO_EIT_195' ,\
14 'OBS_MAPS_EUV2CARMAP_SDOSTA_171',\
15 'OBS_MAPS_EUV2CARMAP_SDOSTA_193',\
16 'OBS_MAPS_EUV2CARMAP_SDOSTA_304',\
17 'OBS_MAPS_WL2CARMAP_SOHOLASCO_C2',\
18 'OBS_MAPS_SDO_AIAFD_171' ,\
19 'OBS_MAPS_SDO_AIAFD_193' ,\
20 'OBS_MAPS_SDO_AIAFD_304' ,\
21 'OBS_MAPS_SDO_AIAFDNRT_171' ,\
22 'OBS_MAPS_SDO_AIAFDNRT_193' ,\
23 'OBS_MAPS_SDO_AIAFDNRT_304' ,\
24 'OBS_MAPS_EUV2CARMAP_SDO360_171',\
25 'OBS_MAPS_EUV2CARMAP_SDO360_193',\
26 'OBS_MAPS_EUV2CARMAP_SDO360_304',\
27 ]