Creating Multiple Screenshots of a Dataset

This is an example of a run(scenario) script that creates multiple screenshots of the results of the coarse-graining (cg) dataset of a scenario. The settings for the screenshots of the results is specified by a list of Particle Analytics Camera files (.pac) (see the following link on how export the .pac files: link)

''' This scripts loads the cg_dataset of a scenario and creates multiples screenshots of the results in the dataset
 based on the scene settings specified in a list of Particle Analytics Camera file (.pac). 
 Each screenshot generates an PNG file and is saved into the scenario'''

import iota

def run(scenario):

    ###Setting the list of pac files for the scene settings
    path_screenshots_config = 'C:/Users/stephen/pac_scene_settings/'  #Path to the folder that contains the .pac files
    ListOfScreenshots = ['Density_Min_0_Max_2100', 
        'Solid Fraction_Min_0_Max_0p75', 
            'Velocity_Mag_Min_0_Max_7p8']                       #List of the names of the .pac files with the config of the screenshots 
    t  = "2.501"                                                #Time value of the step
    #############################################

    cg_dataset = scenario.get_cg_dataset()                      #Load the cg dataset of the scenario
    cg_data = cg_dataset.data()                                 #Load the dataset data
    ListOfTimesteps = cg_data.timesteps()                       #List of timesteps
    step_index = ListOfTimesteps.index(t)                       #Get the step with the time value t

    for screenshot in ListOfScreenshots:                                             #For each screenshot in the list of Screenshots
        config_screenshot = path_screenshots_config + screenshot + '.pac'            #Build the path to the .pac file of the screenshot 
        output_file =  scenario.directory + '/screenshots/' + screenshot + '.png'    #Build the path for the output screenshot file 

        iota.render.generate_screenshots(dataset=cg_data, config=config_screenshot, destination=output_file, step=step_index)   #Generate the screenshot
        scenario.add_screenshot(screenshot, output_file)     #Save the screenshot in the scenario

Last updated

Was this helpful?