pysilcam/plotting.py
def summarise_fancy_stats(stats_csv_file, config_file, monitor=False,
        maxlength=100000, msize=2048, oilgas=sc_pp.outputPartType.all):
    '''
    Plots a summary figure of a dataset which shows
    the volume distribution, number distribution and a montage of randomly selected particles
    
    Args:
        stats_csv_file (str)            : path of the *-STATS.csv file created by silcam process
        config_file (str)               : path of the config ini file associated with the data
        monitor=False (Bool)            : if True then this function will run forever, continuously reading the stats_csv_file and plotting the data
                                          might be useful in monitoring the progress of processing, for example
        maxlength=100000 (int)          : particles longer than this number will not be put in the montage
        msize=2048 (int)                : the montage created will have a canvas size of msize x msize pixels
        oilgas=oc_pp.outputPartType.all : the oilgas enum if you want to just make the figure for oil, or just gas (defulats to all particles)
    '''
    sns.set_style('ticks')

    settings = PySilcamSettings(config_file)

    min_length = settings.ExportParticles.min_length + 1

    #f,a = plt.subplots(2,2)
    ax1 = plt.subplot2grid((2,2),(0, 0))
    ax2 = plt.subplot2grid((2,2),(1, 0))
    ax3 = plt.subplot2grid((2,2), (0, 1), rowspan=2)
    logger = logging.getLogger(__name__)

    while True:
        try:
            montage = sc_pp.make_montage(stats_csv_file,
                    settings.PostProcess.pix_size,
                    roidir=settings.ExportParticles.outputpath,
                    auto_scaler=msize*2, msize=msize,
                    maxlength=maxlength,
                    oilgas=oilgas)
        except:
            montage = np.zeros((msize, msize, 3), dtype=np.uint8) + 255
            logger.warning('Unable to make montage. Check: {0} folder for h5 files'.format(settings.ExportParticles.outputpath))
            logger.warning('  in config file ExportParticles.export_images is {0}'.format(settings.ExportParticles.export_images))

        stats = pd.read_csv(stats_csv_file)
        stats = stats[(stats['major_axis_length'] *
                settings.PostProcess.pix_size) < maxlength]

        # average numer and volume concentrations
        nc, vc, sv_total, junge = sc_pp.nc_vc_from_stats(stats,
                settings.PostProcess, oilgas=oilgas)

        # extract only wanted particle stats
        if oilgas==sc_pp.outputPartType.oil:
            from pysilcam.oilgas import extract_oil
            stats = extract_oil(stats)
        elif oilgas==sc_pp.outputPartType.gas:
            from pysilcam.oilgas import extract_gas
            stats = extract_gas(stats)

        d50 = sc_pp.d50_from_stats(stats, settings.PostProcess)
        total_measured_particles = len(stats['major_axis_length'])

        plt.sca(ax1)
        plt.cla()
        psd(stats, settings.PostProcess, plt.gca())
        plt.title('Volume conc.: {0:.2f}uL/L  d50: {1:.0f}um'.format(vc, d50))

        plt.sca(ax2)
        plt.cla()
        nd(stats, settings.PostProcess, plt.gca(), sample_volume=sv_total)
        plt.title('Number conc.: {0:.0f}#/L  Junge exp.: {1:.2f}'.format(nc,
            junge))

        plt.sca(ax3)
        plt.cla()
        montage_plot(montage, settings.PostProcess.pix_size)
        plt.title('Volume processed: {0:.1f}L  {1:.0f} particles measured'.format(sv_total,
            total_measured_particles))

        plt.draw()
        if monitor:
            plt.pause(1)
        else:
            break
    #plt.show()

    Plots a summary figure of a dataset which shows
    the volume distribution, number distribution and a montage of randomly selected particles
    
    Args:
        stats_csv_file (str)            : path of the *-STATS.csv file created by silcam process
        config_file (str)               : path of the config ini file associated with the data
        monitor=False (Bool)            : if True then this function will run forever, continuously reading the stats_csv_file and plotting the data
                                          might be useful in monitoring the progress of processing, for example
        maxlength=100000 (int)          : particles longer than this number will not be put in the montage
        msize=2048 (int)                : the montage created will have a canvas size of msize x msize pixels
        oilgas=oc_pp.outputPartType.all : the oilgas enum if you want to just make the figure for oil, or just gas (defulats to all particles)
    
Plots a summary figure of a dataset which shows
the volume distribution, number distribution and a montage of randomly selected particles
Plots a summary figure of a dataset which shows the volume distribution number distribution and a montage of randomly selected particles
def summarise_fancy_stats(stats_csv_file, config_file, monitor=False,
        maxlength=100000, msize=2048, oilgas=sc_pp.outputPartType.all):
    sns.set_style('ticks')
    settings = PySilcamSettings(config_file)
    min_length = settings.ExportParticles.min_length + 1
    ax1 = plt.subplot2grid((2,2),(0, 0))
    ax2 = plt.subplot2grid((2,2),(1, 0))
    ax3 = plt.subplot2grid((2,2), (0, 1), rowspan=2)
    logger = logging.getLogger(__name__)
    while True:
        try:
            montage = sc_pp.make_montage(stats_csv_file,
                    settings.PostProcess.pix_size,
                    roidir=settings.ExportParticles.outputpath,
                    auto_scaler=msize*2, msize=msize,
                    maxlength=maxlength,
                    oilgas=oilgas)
        except:
            montage = np.zeros((msize, msize, 3), dtype=np.uint8) + 255
            logger.warning('Unable to make montage. Check: {0} folder for h5 files'.format(settings.ExportParticles.outputpath))
            logger.warning('  in config file ExportParticles.export_images is {0}'.format(settings.ExportParticles.export_images))
        stats = pd.read_csv(stats_csv_file)
        stats = stats[(stats['major_axis_length'] *
                settings.PostProcess.pix_size) < maxlength]
        nc, vc, sv_total, junge = sc_pp.nc_vc_from_stats(stats,
                settings.PostProcess, oilgas=oilgas)
        if oilgas==sc_pp.outputPartType.oil:
            from pysilcam.oilgas import extract_oil
            stats = extract_oil(stats)
        elif oilgas==sc_pp.outputPartType.gas:
            from pysilcam.oilgas import extract_gas
            stats = extract_gas(stats)
        d50 = sc_pp.d50_from_stats(stats, settings.PostProcess)
        total_measured_particles = len(stats['major_axis_length'])
        plt.sca(ax1)
        plt.cla()
        psd(stats, settings.PostProcess, plt.gca())
        plt.title('Volume conc.: {0:.2f}uL/L  d50: {1:.0f}um'.format(vc, d50))
        plt.sca(ax2)
        plt.cla()
        nd(stats, settings.PostProcess, plt.gca(), sample_volume=sv_total)
        plt.title('Number conc.: {0:.0f}#/L  Junge exp.: {1:.2f}'.format(nc,
            junge))
        plt.sca(ax3)
        plt.cla()
        montage_plot(montage, settings.PostProcess.pix_size)
        plt.title('Volume processed: {0:.1f}L  {1:.0f} particles measured'.format(sv_total,
            total_measured_particles))
        plt.draw()
        if monitor:
            plt.pause(1)
        else:
            break
def summarise_fancy_stats ( stats_csv_file , config_file , monitor = False , maxlength = 100000 , msize = 2048 , oilgas = sc_pp . outputPartType . all ) : sns . set_style ( 'ticks' ) settings = PySilcamSettings ( config_file ) min_length = settings . ExportParticles . min_length + 1 ax1 = plt . subplot2grid ( ( 2 , 2 ) , ( 0 , 0 ) ) ax2 = plt . subplot2grid ( ( 2 , 2 ) , ( 1 , 0 ) ) ax3 = plt . subplot2grid ( ( 2 , 2 ) , ( 0 , 1 ) , rowspan = 2 ) logger = logging . getLogger ( __name__ ) while True : try : montage = sc_pp . make_montage ( stats_csv_file , settings . PostProcess . pix_size , roidir = settings . ExportParticles . outputpath , auto_scaler = msize * 2 , msize = msize , maxlength = maxlength , oilgas = oilgas ) except : montage = np . zeros ( ( msize , msize , 3 ) , dtype = np . uint8 ) + 255 logger . warning ( 'Unable to make montage. Check: {0} folder for h5 files' . format ( settings . ExportParticles . outputpath ) ) logger . warning ( '  in config file ExportParticles.export_images is {0}' . format ( settings . ExportParticles . export_images ) ) stats = pd . read_csv ( stats_csv_file ) stats = stats [ ( stats [ 'major_axis_length' ] * settings . PostProcess . pix_size ) < maxlength ] nc , vc , sv_total , junge = sc_pp . nc_vc_from_stats ( stats , settings . PostProcess , oilgas = oilgas ) if oilgas == sc_pp . outputPartType . oil : from pysilcam . oilgas import extract_oil stats = extract_oil ( stats ) elif oilgas == sc_pp . outputPartType . gas : from pysilcam . oilgas import extract_gas stats = extract_gas ( stats ) d50 = sc_pp . d50_from_stats ( stats , settings . PostProcess ) total_measured_particles = len ( stats [ 'major_axis_length' ] ) plt . sca ( ax1 ) plt . cla ( ) psd ( stats , settings . PostProcess , plt . gca ( ) ) plt . title ( 'Volume conc.: {0:.2f}uL/L  d50: {1:.0f}um' . format ( vc , d50 ) ) plt . sca ( ax2 ) plt . cla ( ) nd ( stats , settings . PostProcess , plt . gca ( ) , sample_volume = sv_total ) plt . title ( 'Number conc.: {0:.0f}#/L  Junge exp.: {1:.2f}' . format ( nc , junge ) ) plt . sca ( ax3 ) plt . cla ( ) montage_plot ( montage , settings . PostProcess . pix_size ) plt . title ( 'Volume processed: {0:.1f}L  {1:.0f} particles measured' . format ( sv_total , total_measured_particles ) ) plt . draw ( ) if monitor : plt . pause ( 1 ) else : break
Plots a summary figure of a dataset which shows
the volume distribution, number distribution and a montage of randomly selected particles
Plots a summary figure of a dataset which shows the volume distribution number distribution and a montage of randomly selected particles
'''
    Plots a summary figure of a dataset which shows
    the volume distribution, number distribution and a montage of randomly selected particles
    
    Args:
        stats_csv_file (str)            : path of the *-STATS.csv file created by silcam process
        config_file (str)               : path of the config ini file associated with the data
        monitor=False (Bool)            : if True then this function will run forever, continuously reading the stats_csv_file and plotting the data
                                          might be useful in monitoring the progress of processing, for example
        maxlength=100000 (int)          : particles longer than this number will not be put in the montage
        msize=2048 (int)                : the montage created will have a canvas size of msize x msize pixels
        oilgas=oc_pp.outputPartType.all : the oilgas enum if you want to just make the figure for oil, or just gas (defulats to all particles)
    ''' #f,a = plt.subplots(2,2) # average numer and volume concentrations # extract only wanted particle stats #plt.show()
stats_csv_file
path of the *-STATS.csv file created by silcam process
path of the * - STATS . csv file created by silcam process
config_file
path of the config ini file associated with the data
path of the config ini file associated with the data
monitor
maxlength
msize
oilgas
monitor=False
if True then this function will run forever, continuously reading the stats_csv_file and plotting the data
might be useful in monitoring the progress of processing, for example
if True then this function will run forever continuously reading the stats_csv_file and plotting the data might be useful in monitoring the progress of processing for example
maxlength=100000
particles longer than this number will not be put in the montage
particles longer than this number will not be put in the montage
msize=2048
the montage created will have a canvas size of msize x msize pixels
the montage created will have a canvas size of msize x msize pixels
oilgas=oc_pp.outputPartType.all 
the oilgas enum if you want to just make the figure for oil, or just gas (defulats to all particles)
the oilgas enum if you want to just make the figure for oil or just gas ( defulats to all particles )