# Creating a New Result in a Dataset

This is an example of a `run(scenario)` script that loads coarse-graining (cg) dataset and creates a new result based on a existing result:

```python
'''This scripts loads the cg_dataset of a scenario. For each timestep in the dataset, it loads the solid fraction
 for a specific mesh and calculates the voidage percentage = (1 - Solid Fraction)*100 and adds it as a new result of that mesh.'''

import iota

def run(scenario):

    ## Settings for results ##
    mesh_name = 'Simulation_Domain'                           #Name of the mesh that contains the result

    res1_name = 'Solid Fraction'                              #Name of the result to operate with
    res1_analysis = 'none'                                    #Name of the analysis of the res1

    new_res_name = 'Voidage'                                  #Name for the new result
    new_res_analysis = 'none'                                 #Name of the analysis for the new result
    ########################################

    cg_dataset = scenario.get_cg_dataset()                    # Get the coarse-graining dataset of the scenario
    cg_data = cg.data()                                       # Load the data of the coarse-graining dataset
    NumberOfSteps = len(cg_data.timesteps())                  # Get the number of timesteps of the dataset

    for cont in range(0,NumberOfSteps):                                                     # For each step in the dataset                  
        res1_values = cg_data.get_result(cont, mesh_name, res1_name, res1_analysis)      # Get the values of the Solid Fraction                  
        array_of_ones = iota.ArrayFloat(len(res1_values),1)                                 # Create an array of ones of the same length of res1
        new_res_values = (array_of_ones - res1_values)*100                                  # Caculate the values of the Voidage
        cg_data.add_result(cont, mesh_name, new_res_name, new_res_analysis, new_res_values) # Add the voidage result to the step
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://particle-analytics-1.gitbook.io/iota-python-api/examples/creating-a-new-result.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
