pysilcam/postprocess.py
def trim_stats(stats_csv_file, start_time, end_time, write_new=False, stats=[]):
    '''Chops a STATS.csv file given a start and end time

    Args:
        stats_csv_file              : filename of stats file
        start_time                  : start time of interesting window
        end_time                    : end time of interesting window
        write_new=False             : boolean if True will write a new stats csv file to disc
        stats=[]                    : pass stats DataFrame into here if you don't want to load the data from the stats_csv_file given.
                                      In this case the stats_csv_file string is only used for creating the new output datafilename.

    Returns:
        trimmed_stats       : pandas DataFram of particle statistics
        outname             : name of new stats csv file written to disc
    '''
    if len(stats)==0:
        stats = pd.read_csv(stats_csv_file)

    start_time = pd.to_datetime(start_time)
    end_time = pd.to_datetime(end_time)

    trimmed_stats = stats[
        (pd.to_datetime(stats['timestamp']) > start_time) & (pd.to_datetime(stats['timestamp']) < end_time)]

    if np.isnan(trimmed_stats.equivalent_diameter.max()) or len(trimmed_stats) == 0:
        logger.info('No data in specified time range!')
        outname = ''
        return trimmed_stats, outname

    actual_start = pd.to_datetime(trimmed_stats['timestamp'].min()).strftime('D%Y%m%dT%H%M%S.%f')
    actual_end = pd.to_datetime(trimmed_stats['timestamp'].max()).strftime('D%Y%m%dT%H%M%S.%f')

    path, name = os.path.split(stats_csv_file)

    outname = os.path.join(path, name.replace('-STATS.csv','')) + '-Start' + str(actual_start) + '-End' + str(
        actual_end) + '-STATS.csv'

    if write_new:
        trimmed_stats.to_csv(outname)

    return trimmed_stats, outname
Chops a STATS.csv file given a start and end time

    Args:
        stats_csv_file              : filename of stats file
        start_time                  : start time of interesting window
        end_time                    : end time of interesting window
        write_new=False             : boolean if True will write a new stats csv file to disc
        stats=[]                    : pass stats DataFrame into here if you don't want to load the data from the stats_csv_file given.
                                      In this case the stats_csv_file string is only used for creating the new output datafilename.

    Returns:
        trimmed_stats       : pandas DataFram of particle statistics
        outname             : name of new stats csv file written to disc
    
Chops a STATS.csv file given a start and end time
Chops a STATS . csv file given a start and end time
def trim_stats(stats_csv_file, start_time, end_time, write_new=False, stats=[]):
    if len(stats)==0:
        stats = pd.read_csv(stats_csv_file)
    start_time = pd.to_datetime(start_time)
    end_time = pd.to_datetime(end_time)
    trimmed_stats = stats[
        (pd.to_datetime(stats['timestamp']) > start_time) & (pd.to_datetime(stats['timestamp']) < end_time)]
    if np.isnan(trimmed_stats.equivalent_diameter.max()) or len(trimmed_stats) == 0:
        logger.info('No data in specified time range!')
        outname = ''
        return trimmed_stats, outname
    actual_start = pd.to_datetime(trimmed_stats['timestamp'].min()).strftime('D%Y%m%dT%H%M%S.%f')
    actual_end = pd.to_datetime(trimmed_stats['timestamp'].max()).strftime('D%Y%m%dT%H%M%S.%f')
    path, name = os.path.split(stats_csv_file)
    outname = os.path.join(path, name.replace('-STATS.csv','')) + '-Start' + str(actual_start) + '-End' + str(
        actual_end) + '-STATS.csv'
    if write_new:
        trimmed_stats.to_csv(outname)
    return trimmed_stats, outname
def trim_stats ( stats_csv_file , start_time , end_time , write_new = False , stats = [ ] ) : if len ( stats ) == 0 : stats = pd . read_csv ( stats_csv_file ) start_time = pd . to_datetime ( start_time ) end_time = pd . to_datetime ( end_time ) trimmed_stats = stats [ ( pd . to_datetime ( stats [ 'timestamp' ] ) > start_time ) & ( pd . to_datetime ( stats [ 'timestamp' ] ) < end_time ) ] if np . isnan ( trimmed_stats . equivalent_diameter . max ( ) ) or len ( trimmed_stats ) == 0 : logger . info ( 'No data in specified time range!' ) outname = '' return trimmed_stats , outname actual_start = pd . to_datetime ( trimmed_stats [ 'timestamp' ] . min ( ) ) . strftime ( 'D%Y%m%dT%H%M%S.%f' ) actual_end = pd . to_datetime ( trimmed_stats [ 'timestamp' ] . max ( ) ) . strftime ( 'D%Y%m%dT%H%M%S.%f' ) path , name = os . path . split ( stats_csv_file ) outname = os . path . join ( path , name . replace ( '-STATS.csv' , '' ) ) + '-Start' + str ( actual_start ) + '-End' + str ( actual_end ) + '-STATS.csv' if write_new : trimmed_stats . to_csv ( outname ) return trimmed_stats , outname
Chops a STATS.csv file given a start and end time
Chops a STATS . csv file given a start and end time
'''Chops a STATS.csv file given a start and end time

    Args:
        stats_csv_file              : filename of stats file
        start_time                  : start time of interesting window
        end_time                    : end time of interesting window
        write_new=False             : boolean if True will write a new stats csv file to disc
        stats=[]                    : pass stats DataFrame into here if you don't want to load the data from the stats_csv_file given.
                                      In this case the stats_csv_file string is only used for creating the new output datafilename.

    Returns:
        trimmed_stats       : pandas DataFram of particle statistics
        outname             : name of new stats csv file written to disc
    '''
trimmed_stats       : pandas DataFram of particle statistics
outname             : name of new stats csv file written to disc
trimmed_stats : pandas DataFram of particle statistics outname : name of new stats csv file written to disc
stats_csv_file
start_time
end_time
write_new
stats
stats_csv_file              
filename of stats file
filename of stats file
start_time                  
start time of interesting window
start time of interesting window
end_time                    
end time of interesting window
end time of interesting window
write_new=False             
boolean if True will write a new stats csv file to disc
boolean if True will write a new stats csv file to disc
stats=[]                    
pass stats DataFrame into here if you don't want to load the data from the stats_csv_file given.
In this case the stats_csv_file string is only used for creating the new output datafilename.
pass stats DataFrame into here if you don ' t want to load the data from the stats_csv_file given . In this case the stats_csv_file string is only used for creating the new output datafilename .