pysilcam/__main__.py
def adminSTATS(logger, settings, overwriteSTATS, datafilename, datapath):
    '''
    Administration of the -STATS.csv file

    Args:
        logger          (logger object) : logger object created using configure_logger()
        datafilename    (str)           : name of the folder containing the -STATS.csv
        datapath        (str)           : name of the path containing the data

    '''
    if (os.path.isfile(datafilename + '-STATS.csv')):
        if overwriteSTATS:
            logger.info('removing: ' + datafilename + '-STATS.csv')
            print('Overwriting ' + datafilename + '-STATS.csv')
            os.remove(datafilename + '-STATS.csv')
        else:
            logger.info('Loading old data from: ' + datafilename + '-STATS.csv')
            print('Loading old data from: ' + datafilename + '-STATS.csv')
            oldstats = pd.read_csv(datafilename + '-STATS.csv')
            logger.info('  OK.')
            print('  OK.')
            last_time = pd.to_datetime(oldstats['timestamp'].max())

            logger.info('Calculating spooling offset')
            print('Calculating spooling offset')

            # TODO: move this import to the top
            from pysilcam.fakepymba import silcam_name2time
            files = [f for f in sorted(os.listdir(datapath))
                     if (f.endswith('.silc') or f.endswith('.bmp'))]
            offsetcalc = pd.DataFrame(columns=['files', 'times'])
            offsetcalc['files'] = files
            for i, f in enumerate(files):
                offsetcalc['times'].iloc[i] = silcam_name2time(f)
            offset = int(min(np.argwhere(offsetcalc['times'] > last_time)))
            offset -= settings.Background.num_images  # subtract the number of background images, so we get data from the correct start point
            # and check offset is still positive
            if offset < 0:
                offset = 0
            offset = str(offset)
            os.environ['PYSILCAM_OFFSET'] = offset
            logger.info('PYSILCAM_OFFSET set to: ' + offset)
            print('PYSILCAM_OFFSET set to: ' + offset)

    Administration of the -STATS.csv file

    Args:
        logger          (logger object) : logger object created using configure_logger()
        datafilename    (str)           : name of the folder containing the -STATS.csv
        datapath        (str)           : name of the path containing the data

    
Administration of the -STATS.csv file
Administration of the - STATS . csv file
def adminSTATS(logger, settings, overwriteSTATS, datafilename, datapath):
    if (os.path.isfile(datafilename + '-STATS.csv')):
        if overwriteSTATS:
            logger.info('removing: ' + datafilename + '-STATS.csv')
            print('Overwriting ' + datafilename + '-STATS.csv')
            os.remove(datafilename + '-STATS.csv')
        else:
            logger.info('Loading old data from: ' + datafilename + '-STATS.csv')
            print('Loading old data from: ' + datafilename + '-STATS.csv')
            oldstats = pd.read_csv(datafilename + '-STATS.csv')
            logger.info('  OK.')
            print('  OK.')
            last_time = pd.to_datetime(oldstats['timestamp'].max())
            logger.info('Calculating spooling offset')
            print('Calculating spooling offset')
            from pysilcam.fakepymba import silcam_name2time
            files = [f for f in sorted(os.listdir(datapath))
                     if (f.endswith('.silc') or f.endswith('.bmp'))]
            offsetcalc = pd.DataFrame(columns=['files', 'times'])
            offsetcalc['files'] = files
            for i, f in enumerate(files):
                offsetcalc['times'].iloc[i] = silcam_name2time(f)
            offset = int(min(np.argwhere(offsetcalc['times'] > last_time)))
            offset -= settings.Background.num_images  
            if offset < 0:
                offset = 0
            offset = str(offset)
            os.environ['PYSILCAM_OFFSET'] = offset
            logger.info('PYSILCAM_OFFSET set to: ' + offset)
            print('PYSILCAM_OFFSET set to: ' + offset)
def adminSTATS ( logger , settings , overwriteSTATS , datafilename , datapath ) : if ( os . path . isfile ( datafilename + '-STATS.csv' ) ) : if overwriteSTATS : logger . info ( 'removing: ' + datafilename + '-STATS.csv' ) print ( 'Overwriting ' + datafilename + '-STATS.csv' ) os . remove ( datafilename + '-STATS.csv' ) else : logger . info ( 'Loading old data from: ' + datafilename + '-STATS.csv' ) print ( 'Loading old data from: ' + datafilename + '-STATS.csv' ) oldstats = pd . read_csv ( datafilename + '-STATS.csv' ) logger . info ( '  OK.' ) print ( '  OK.' ) last_time = pd . to_datetime ( oldstats [ 'timestamp' ] . max ( ) ) logger . info ( 'Calculating spooling offset' ) print ( 'Calculating spooling offset' ) from pysilcam . fakepymba import silcam_name2time files = [ f for f in sorted ( os . listdir ( datapath ) ) if ( f . endswith ( '.silc' ) or f . endswith ( '.bmp' ) ) ] offsetcalc = pd . DataFrame ( columns = [ 'files' , 'times' ] ) offsetcalc [ 'files' ] = files for i , f in enumerate ( files ) : offsetcalc [ 'times' ] . iloc [ i ] = silcam_name2time ( f ) offset = int ( min ( np . argwhere ( offsetcalc [ 'times' ] > last_time ) ) ) offset -= settings . Background . num_images if offset < 0 : offset = 0 offset = str ( offset ) os . environ [ 'PYSILCAM_OFFSET' ] = offset logger . info ( 'PYSILCAM_OFFSET set to: ' + offset ) print ( 'PYSILCAM_OFFSET set to: ' + offset )
Administration of the -STATS.csv file
Administration of the - STATS . csv file
'''
    Administration of the -STATS.csv file

    Args:
        logger          (logger object) : logger object created using configure_logger()
        datafilename    (str)           : name of the folder containing the -STATS.csv
        datapath        (str)           : name of the path containing the data

    ''' # TODO: move this import to the top # subtract the number of background images, so we get data from the correct start point # and check offset is still positive
logger
logger object created using configure_logger()
logger object created using configure_logger ()
settings
overwriteSTATS
datafilename
name of the folder containing the -STATS.csv
name of the folder containing the - STATS . csv
datapath
name of the path containing the data
name of the path containing the data