postprocess
This module provides functions to process and analyze simulation output data.
Functions:
| Name | Description |
|---|---|
get_particles_data |
|
add_parameters_from_config |
|
merge_and_group_by_parameters_of_interest |
|
aggregate_output_data |
|
fix_LHC_version |
|
add_parameters_from_config(l_df_output, dic_parameters_of_interest, default_path_template_parameters=False)
Adds parameters from the configuration to the output data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_df_output
|
list
|
List of DataFrames containing the output data. |
required |
dic_parameters_of_interest
|
dict
|
Dictionary of parameters of interest. |
required |
default_path_template_parameters
|
bool
|
Flag to indicate if the default path template parameters are used. If True, less caution is applied in the checking of the parameters. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[DataFrame]
|
A list of DataFrames with added parameters. |
Source code in study_da/postprocess/postprocess.py
aggregate_output_data(path_tree, l_group_by_parameters, function_to_aggregate=min, generation_of_interest=2, name_output='output_particles.parquet', write_output=True, path_output=None, only_keep_lost_particles=True, dic_parameters_of_interest=None, l_parameters_to_keep=None, name_template_parameters='parameters_lhc.yaml', path_template_parameters=None, force_overwrite=False)
Aggregates output data from simulation files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_tree
|
str
|
The path to the tree file. |
required |
l_group_by_parameters
|
list
|
List of parameters to group by. |
required |
function_to_aggregate
|
callable
|
Function to aggregate the grouped data. |
min
|
generation_of_interest
|
int
|
The generation of interest. Defaults to 2. |
2
|
name_output
|
str
|
The name of the output file. Defaults to "output_particles.parquet". |
'output_particles.parquet'
|
write_output
|
bool
|
Flag to indicate if the output should be written to a file. Defaults to True. |
True
|
path_output
|
str
|
The path to the output file. If not provided, the default output file will be in the study folder as 'da.parquet'. Defaults to None. |
None
|
only_keep_lost_particles
|
bool
|
Flag to indicate if only lost particles should be kept. Defaults to True. |
True
|
dic_parameters_of_interest
|
dict
|
Dictionary of parameters of interest. Defaults to None. |
None
|
l_parameters_to_keep
|
list
|
List of parameters to keep. Defaults to None. |
None
|
name_template_parameters
|
str
|
The name of the template parameters file associating each parameter to a list of keys. Defaults to "parameters_lhc.yaml", which is already contained in the study-da package, and includes the main usual parameters. |
'parameters_lhc.yaml'
|
path_template_parameters
|
str
|
The path to the template parameters file. Must be provided if a no template already contained in study-da is provided through the argument name_template_parameters. Defaults to None. |
None
|
force_overwrite
|
bool
|
Flag to indicate if the output file should be overwritten if it already exists. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The final aggregated DataFrame. |
Source code in study_da/postprocess/postprocess.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
fix_LHC_version(df)
Fixes the LHC version type in the DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The DataFrame to fix. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The fixed DataFrame. |
Source code in study_da/postprocess/postprocess.py
get_particles_data(dic_all_jobs, absolute_path_study, generation_of_interest=2, name_output='output_particles.parquet')
Retrieves particle data from simulation output files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic_all_jobs
|
dict
|
Dictionary containing all jobs and their details. |
required |
absolute_path_study
|
str
|
The absolute path to the study directory. |
required |
generation_of_interest
|
int
|
The generation of interest. Defaults to 2. |
2
|
name_output
|
str
|
The name of the output file. Defaults to "output_particles.parquet". |
'output_particles.parquet'
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[DataFrame]
|
A list of DataFrames containing the particle data. |
Source code in study_da/postprocess/postprocess.py
merge_and_group_by_parameters_of_interest(l_df_output, l_group_by_parameters, only_keep_lost_particles=True, l_parameters_to_keep=None, function_to_aggregate=min)
Merges and groups the output data by parameters of interest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_df_output
|
list
|
List of DataFrames containing the output data. |
required |
l_group_by_parameters
|
list
|
List of parameters to group by. |
required |
only_keep_lost_particles
|
bool
|
Flag to indicate if only lost particles should be kept. Defaults to True. |
True
|
l_parameters_to_keep
|
list
|
List of parameters to keep. Defaults to None. |
None
|
function_to_aggregate
|
callable
|
Function to aggregate the grouped data. Defaults to min. |
min
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The merged and grouped DataFrame. |