Esempio n. 1
0
parser.add_argument(
    'location',
    help='CABM site name. Options: Alert, ETL, Egbert, Resolute, Whistler ',
    type=str)
parser.add_argument('instr_number',
                    help='SP2 number. Options: 17, 44, 58 ',
                    type=int)
parser.add_argument('-bi',
                    '--binning_interval',
                    help='binning interval length in hours (default is 6)',
                    default=6,
                    type=int)
args = parser.parse_args()

#create db connection and cursor
database_connection = dbConnection('CABM_SP2')
cnx = database_connection.db_connection
cursor = database_connection.db_cur

#set inputs
start_analysis = args.start_time
end_analysis = args.end_time
instr_location_ID = CABM_utilities.getLocationID(args.location)
instr_ID = CABM_utilities.getInstrID(args.instr_number)
min_VED = 80  # in nm
max_VED = 220  # in nm
binning_increment = 20  # in nm
interval_length = args.binning_interval * 3600  # in seconds
database_name = 'CABM_SP2'

import os
import argparse
import SP2_utilities
import CABM_utilities
from mysql_db_connection import dbConnection

#set arguments
parser = argparse.ArgumentParser(description='''
	This script should be run once to modify the database when updating the CABM_sp2 code from version 1.0 to version 1.1
	This script will add columns "chamber_temp" and "chamber_pressure" to the housekeeping data tables.
	''')
args = parser.parse_args()
db_name = 'CABM_SP2'

#create db connection and cursor
database_connection = dbConnection(db_name)
cnx = database_connection.db_connection
cursor = database_connection.db_cur


def tableExists(location):
    table_name = 'sp2_hk_data_locn' + str(location)
    cursor.execute(
        '''SELECT TABLE_NAME 
		FROM information_schema.tables
		WHERE
		    TABLE_SCHEMA = %s 
		AND TABLE_NAME = %s''', (db_name, 'sp2_hk_data_locn' + str(location)))
    table_exists = cursor.fetchall()

    if table_exists == []: