Beispiel #1
0
    def __init__(self, logfile='reduction.log'):
        '''
        Init
        '''
        #set up logger
        self.logfile = logfile
        self.log = lg.setUpLogger(self.logfile)

        #set up some booleans
        self.dataWeird = False
Beispiel #2
0
    def __init__(self, logfile='reduction.log'):
        '''
        Init
        '''
        #set up logger
        self.logfile = logfile
        self.log = lg.setUpLogger(self.logfile)

        #set up some booleans
        self.dataWeird = False
Beispiel #3
0
    def __init__(self, ycuts, logfile='splitting.log'):
        """
        Class constructor.

        :param ycuts: ycoordinate cut values
        :type ycuts: dictionary
        :param logfile: name of the log file
        :type logfile: string
        """
        self.ycuts = ycuts
        self.logfile = logfile
        self.log = lg.setUpLogger(self.logfile)
        #create index to make searching faster
        if file in 'halos.dat':
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id)' % (file[:-4], file[:-4])
        elif file in ['galphot.dat', 'galphotdust.dat']:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id, z)' % (file[:-4], file[:-4])
        elif file in 'galpropz.dat':
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id, zgal)' % (file[:-4], file[:-4])
        elif 'totals.dat' in file:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (z)' % (file[:-4], file[:-4])
        else:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id)' % (file[:-4], file[:-4])

        c.execute(indexString)
        log.info('%s', indexString)

        # Save (commit) the changes
        conn.commit()
        # We can also close the cursor if we are done with it
        c.close()
        #close the connection
        conn.close()

    log.info('All done, check out the DB')


if __name__ == '__main__':
    log_filename = 'insertSAMTablesToMySQL.log'
    log = lg.setUpLogger(log_filename)
    addToMySQLDBfromSAMTables()

Beispiel #5
0
        elif file in ['galphot.dat', 'galphotdust.dat']:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id, z)' % (
                file[:-4], file[:-4])
        elif file in 'galpropz.dat':
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id, zgal)' % (
                file[:-4], file[:-4])
        elif 'totals.dat' in file:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (z)' % (file[:-4],
                                                                    file[:-4])
        else:
            indexString = 'CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id)' % (
                file[:-4], file[:-4])

        c.execute(indexString)
        log.info('%s', indexString)

        # Save (commit) the changes
        conn.commit()
        # We can also close the cursor if we are done with it
        c.close()
        #close the connection
        conn.close()

    log.info('All done, check out the DB')


if __name__ == '__main__':
    log_filename = 'insertSAMTablesToMySQL.log'
    log = lg.setUpLogger(log_filename)
    addToMySQLDBfromSAMTables()