pyrokinetics.pyroscan.PyroScan#

class pyrokinetics.pyroscan.PyroScan(pyro, parameter_dict=None, p_prime_type=0, value_fmt='.2f', value_separator='_', parameter_separator='/', file_name=None, base_directory='.', load_default_parameter_keys=True, pyroscan_json=None)[source]#

Bases: object

Creates a dictionary of pyro objects in pyro_dict

Need a templates pyro object

Dict of parameters to scan through { param : [values], }

__init__(pyro, parameter_dict=None, p_prime_type=0, value_fmt='.2f', value_separator='_', parameter_separator='/', file_name=None, base_directory='.', load_default_parameter_keys=True, pyroscan_json=None)[source]#

Methods

__init__(pyro[, parameter_dict, ...])

add_parameter_func([parameter_key, ...])

Applies function parameter_func(pyro, **kwargs) on pyro object each time after parameter_key is set in a scan

add_parameter_key([parameter_key, ...])

parameter_key: string to access variable parameter_attr: string of attribute storing value in pyro parameter_location: lis of strings showing path to value in pyro

convert_gk_code(gk_code)

Converts all gyrokinetics codes to the code type 'gk_code'.

create_single_run(parameters)

Create a new Pyro instance from the PyroScan base with new run parameters

format_single_run_name(parameters)

Concatenate parameter names/values with separator

load_default_parameter_keys()

Loads default parameters name into parameter_map

load_gk_output()

Loads GKOutput as a xarray Sataset

outer_product()

Creates generator of outer product for all parameter permutations

write([file_name, base_directory, template_file])

Creates and writes GK input files for parameters in scan

Attributes

JSON_ATTRS

base_directory

file_name

gk_code

JSON_ATTRS = ['value_fmt', 'value_separator', 'parameter_separator', 'parameter_dict', 'file_name', 'base_directory', 'p_prime_type', 'parameter_map']#
add_parameter_func(parameter_key=None, parameter_func=None, parameter_kwargs=None)[source]#

Applies function parameter_func(pyro, **kwargs) on pyro object each time after parameter_key is set in a scan

parameter_key: string to access variable parameter_func: function that take in a pyro object applies modification parameter_kwargs: Dictionary of kwargs to apply to function

add_parameter_key(parameter_key=None, parameter_attr=None, parameter_location=None)[source]#

parameter_key: string to access variable parameter_attr: string of attribute storing value in pyro parameter_location: lis of strings showing path to value in pyro

property base_directory#
convert_gk_code(gk_code)[source]#

Converts all gyrokinetics codes to the code type ‘gk_code’. This can be any viable GKInput type (GS2, CGYRO, GENE,…)

Return type:

None

Parameters:

gk_code (str)

create_single_run(parameters)[source]#

Create a new Pyro instance from the PyroScan base with new run parameters

Parameters:

parameters (dict)

property file_name#
format_single_run_name(parameters)[source]#

Concatenate parameter names/values with separator

property gk_code#
load_default_parameter_keys()[source]#

Loads default parameters name into parameter_map

{param : [“attribute”, [“key_to_location_1”, “key_to_location_2” ]] }

for example

{‘electron_temp_gradient’: [“local_species”, [‘electron’,’inverse_lt’]] }

load_gk_output()[source]#

Loads GKOutput as a xarray Sataset

Returns:

self.gk_output

Return type:

xarray DataSet of data

outer_product()[source]#

Creates generator of outer product for all parameter permutations

write(file_name=None, base_directory=None, template_file=None)[source]#

Creates and writes GK input files for parameters in scan