# Getting the Profile of Result along a Line

This is an example of a `run(scenario)` script that loads coarse-graining (cg) dataset and gets the profile of a result along a line. The data of the profile is saved into the scenario as graph (raw data is also saved into a CSV file) and the graph is exported into a interactive HTML file.

```python
'''This scripts loads the cg_dataset of a scenario. For a given timestep, mesh name and result, it gets the profile of 
    the result along a line. The data of the profile is saved into the scenario and into a CSV file, and the graph is 
    exported into a HTML file'''

import iota

def run(scenario):

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

    res_name = 'Velocity'                                     #Name of the result
    res_component = 3                                         #Component of the result (X=0, Y=1, Z=2, Magnitude=3)
    res_analysis = 'none'                                     #Name of the analysis of the result


    Start_point = [0,0,0]                                     #Start point for the line profile
    End_point = [0,0,1]                                       #End point for the line profile
    Npoints = 50                                              #Number of points to get for the line profile

    t = '2.5'                                                 #Value of the timestep to get line from.   
    ########################################

    #### Settings for graph saving ######
    Name_graph = 'Profile {} from {} to {} at {} s'.format(res_name, Start_point, End_point, t)    #Name for the graph
    Title_graph = 'Profile {} at {}'.format(res_name,t)                   #Title to shown in the graph
    xtitle = 'Distance (m)'                                               #Title for x-axis 
    ytitle = 'Velocity Magnitude [m/s]'                                   #Tile for y-axis
    legend = ['{} to {}'.format(Start_point, End_point)]                  #Name of the trace for the graph legend
    graph_file = '{}/graphs/{}'.format(scenario.directory,Name_graph)     #Output name and path for exporting graph
    ########################################     

    cg_dataset = scenario.get_cg_dataset()                    #Get the coarse-graining dataset of the scenario
    cg_data = cg_dataset.data()                                       #Load the data of the coarse-graining dataset
    ListOfTimesteps = cg_data.timesteps()                      #Get the list of time of the steps
    step = ListOfTimesteps.index(t)                           #Get the step for time t.

    x_data , y_data = cg_data.line_variation(step=step, mesh=mesh_name, 
        point_start=iota.Vector3d(Start_point), point_end=iota.Vector3d(End_point), num_points = Npoints, 
            result=res_name, analysis=res_analysis, component=res_component, x_type='dist')  #Get line profile data

    graph = scenario.add_graph(name=Name_graph, title=Title_graph, xdata=x_data, ydata=y_data, 
        xtitle=xtitle, ytitle=ytitle, legend=legend)        #Save the graph data to database (including raw data to csv file)

        graph.export_html(graph_file)                                #Export the graph into html format
```


---

# 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/19.2.1/examples/result-variation-line.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.
