#!/usr/bin/python # # # 6/2/2022 Justin Stevens # # This script sets the correct mapping in Triplet Polarimeter signal channels after 3 channels were # moved prior to the Summer 2022 run # import sqlite3 as lite import sys import os import re import datetime if len(sys.argv) != 2: print "You must supply a SQLite DB file to modify!" sys.exit(0); # Connect to SQLite DB file db_filename = sys.argv[1] print "" print "opening SQLite DB file: %s" % db_filename print "---------------------------------------------" con = lite.connect(db_filename) with con: # Specify that next cursor should be "dictionary" # (i.e. python's hash map) so columns can be indexed # by name con.row_factory = lite.Row # Create Cursor cur = con.cursor() # get run range ID to add reference counters runrange_name = 'RunPeriod-2022-05-default' #2019-11+' cur.execute("SELECT runrangeid FROM RunRange WHERE name='%s'" % runrange_name) rows = cur.fetchall() if len(rows) == 0: print 'Unable to find id for run range with name "%s"!' % runrange_name sys.exit(-1) runrangeid = rows[0][0] # TPOL (chanid|moduleid|name|channel|system|col_name|enable) # Move 3 TPOL channels to new location in FADC board cur.execute("INSERT INTO TPOL Values (25, 0, 27131, %d)" % runrangeid) cur.execute("INSERT INTO TPOL Values (24, 0, 27132, %d)" % runrangeid) cur.execute("INSERT INTO TPOL Values (23, 0, 27133, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27131, 1022, 'TPOL-S25', 8, 'TPOL', 'adc_chanid', 1, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27132, 1022, 'TPOL-S24', 9, 'TPOL', 'adc_chanid', 1, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27133, 1022, 'TPOL-S23', 10, 'TPOL', 'adc_chanid', 1, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27123, 1022, 'TPOL-unused', 0, '', '', 0, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27124, 1022, 'TPOL-unused', 1, '', '', 0, %d)" % runrangeid) cur.execute("INSERT INTO Channel Values (27125, 1022, 'TPOL-unused', 2, '', '', 0, %d)" % runrangeid)