repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
cuihantao/andes
andes/utils/misc.py
get_log_dir
def get_log_dir(): """ Get a directory for logging On Linux or macOS, '/tmp/andes' is the default. On Windows, '%APPDATA%/andes' is the default. Returns ------- str Path to the logging directory """ PATH = '' if platform.system() in ('Linux', 'Darwin'): PATH = t...
python
def get_log_dir(): """ Get a directory for logging On Linux or macOS, '/tmp/andes' is the default. On Windows, '%APPDATA%/andes' is the default. Returns ------- str Path to the logging directory """ PATH = '' if platform.system() in ('Linux', 'Darwin'): PATH = t...
Get a directory for logging On Linux or macOS, '/tmp/andes' is the default. On Windows, '%APPDATA%/andes' is the default. Returns ------- str Path to the logging directory
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/misc.py#L42-L64
cuihantao/andes
andes/variables/varout.py
VarOut.store
def store(self, t, step): """ Record the state/algeb values at time t to self.vars """ max_cache = int(self.system.tds.config.max_cache) if len(self.vars) >= max_cache > 0: self.dump() self.vars = list() self.t = list() self.k = lis...
python
def store(self, t, step): """ Record the state/algeb values at time t to self.vars """ max_cache = int(self.system.tds.config.max_cache) if len(self.vars) >= max_cache > 0: self.dump() self.vars = list() self.t = list() self.k = lis...
Record the state/algeb values at time t to self.vars
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L37-L95
cuihantao/andes
andes/variables/varout.py
VarOut.show
def show(self): """ The representation of an Varout object :return: the full result matrix (for use with PyCharm viewer) :rtype: np.array """ out = [] for item in self.vars: out.append(list(item)) return np.array(out)
python
def show(self): """ The representation of an Varout object :return: the full result matrix (for use with PyCharm viewer) :rtype: np.array """ out = [] for item in self.vars: out.append(list(item)) return np.array(out)
The representation of an Varout object :return: the full result matrix (for use with PyCharm viewer) :rtype: np.array
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L97-L109
cuihantao/andes
andes/variables/varout.py
VarOut.concat_t_vars
def concat_t_vars(self): """ Concatenate ``self.t`` with ``self.vars`` and output a single matrix for data dump :return matrix: concatenated matrix with ``self.t`` as the 0-th column """ logger.warning('This function is deprecated and replaced by `concat_t_vars_np`.') ...
python
def concat_t_vars(self): """ Concatenate ``self.t`` with ``self.vars`` and output a single matrix for data dump :return matrix: concatenated matrix with ``self.t`` as the 0-th column """ logger.warning('This function is deprecated and replaced by `concat_t_vars_np`.') ...
Concatenate ``self.t`` with ``self.vars`` and output a single matrix for data dump :return matrix: concatenated matrix with ``self.t`` as the 0-th column
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L111-L131
cuihantao/andes
andes/variables/varout.py
VarOut.concat_t_vars_np
def concat_t_vars_np(self, vars_idx=None): """ Concatenate `self.np_t` with `self.np_vars` and return a single matrix. The first column corresponds to time, and the rest of the matrix is the variables. Returns ------- np.array : concatenated matrix """ s...
python
def concat_t_vars_np(self, vars_idx=None): """ Concatenate `self.np_t` with `self.np_vars` and return a single matrix. The first column corresponds to time, and the rest of the matrix is the variables. Returns ------- np.array : concatenated matrix """ s...
Concatenate `self.np_t` with `self.np_vars` and return a single matrix. The first column corresponds to time, and the rest of the matrix is the variables. Returns ------- np.array : concatenated matrix
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L133-L148
cuihantao/andes
andes/variables/varout.py
VarOut.get_xy
def get_xy(self, yidx, xidx=0): """ Return stored data for the given indices for plot :param yidx: the indices of the y-axis variables(1-indexing) :param xidx: the index of the x-axis variables :return: None """ assert isinstance(xidx, int) if isinstance(...
python
def get_xy(self, yidx, xidx=0): """ Return stored data for the given indices for plot :param yidx: the indices of the y-axis variables(1-indexing) :param xidx: the index of the x-axis variables :return: None """ assert isinstance(xidx, int) if isinstance(...
Return stored data for the given indices for plot :param yidx: the indices of the y-axis variables(1-indexing) :param xidx: the index of the x-axis variables :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L150-L167
cuihantao/andes
andes/variables/varout.py
VarOut.dump_np_vars
def dump_np_vars(self, store_format='csv', delimiter=','): """ Dump the TDS simulation data to files by calling subroutines `write_lst` and `write_np_dat`. Parameters ----------- store_format : str dump format in `('csv', 'txt', 'hdf5')` delimiter :...
python
def dump_np_vars(self, store_format='csv', delimiter=','): """ Dump the TDS simulation data to files by calling subroutines `write_lst` and `write_np_dat`. Parameters ----------- store_format : str dump format in `('csv', 'txt', 'hdf5')` delimiter :...
Dump the TDS simulation data to files by calling subroutines `write_lst` and `write_np_dat`. Parameters ----------- store_format : str dump format in `('csv', 'txt', 'hdf5')` delimiter : str delimiter for the `csv` and `txt` format Returns ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L169-L197
cuihantao/andes
andes/variables/varout.py
VarOut.dump
def dump(self): """ Dump the TDS results to the output `dat` file :return: succeed flag """ logger.warn('This function is deprecated and replaced by `dump_np_vars`.') ret = False if self.system.files.no_output: # return ``True`` because it did not f...
python
def dump(self): """ Dump the TDS results to the output `dat` file :return: succeed flag """ logger.warn('This function is deprecated and replaced by `dump_np_vars`.') ret = False if self.system.files.no_output: # return ``True`` because it did not f...
Dump the TDS results to the output `dat` file :return: succeed flag
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L199-L216
cuihantao/andes
andes/variables/varout.py
VarOut.write_np_dat
def write_np_dat(self, store_format='csv', delimiter=',', fmt='%.12g'): """ Write TDS data stored in `self.np_vars` to the output file Parameters ---------- store_format : str dump format in ('csv', 'txt', 'hdf5') delimiter : str delimiter for th...
python
def write_np_dat(self, store_format='csv', delimiter=',', fmt='%.12g'): """ Write TDS data stored in `self.np_vars` to the output file Parameters ---------- store_format : str dump format in ('csv', 'txt', 'hdf5') delimiter : str delimiter for th...
Write TDS data stored in `self.np_vars` to the output file Parameters ---------- store_format : str dump format in ('csv', 'txt', 'hdf5') delimiter : str delimiter for the `csv` and `txt` format fmt : str output formatting template ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L218-L271
cuihantao/andes
andes/variables/varout.py
VarOut.write_dat
def write_dat(self): """ Write ``system.Varout.vars`` to a ``.dat`` file :return: """ logger.warn('This function is deprecated and replaced by `write_np_dat`.') ret = False system = self.system # compute the total number of columns, excluding time ...
python
def write_dat(self): """ Write ``system.Varout.vars`` to a ``.dat`` file :return: """ logger.warn('This function is deprecated and replaced by `write_np_dat`.') ret = False system = self.system # compute the total number of columns, excluding time ...
Write ``system.Varout.vars`` to a ``.dat`` file :return:
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L273-L315
cuihantao/andes
andes/variables/varout.py
VarOut.write_lst
def write_lst(self): """ Dump the variable name lst file :return: succeed flag """ ret = False out = '' system = self.system dae = self.system.dae varname = self.system.varname template = '{:>6g}, {:>25s}, {:>35s}\n' # header lin...
python
def write_lst(self): """ Dump the variable name lst file :return: succeed flag """ ret = False out = '' system = self.system dae = self.system.dae varname = self.system.varname template = '{:>6g}, {:>25s}, {:>35s}\n' # header lin...
Dump the variable name lst file :return: succeed flag
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L317-L363
cuihantao/andes
andes/variables/varout.py
VarOut.vars_to_array
def vars_to_array(self): """ Convert `self.vars` to a numpy array Returns ------- numpy.array """ logger.warn('This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays ' 'without conversion.') if not self.v...
python
def vars_to_array(self): """ Convert `self.vars` to a numpy array Returns ------- numpy.array """ logger.warn('This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays ' 'without conversion.') if not self.v...
Convert `self.vars` to a numpy array Returns ------- numpy.array
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L365-L384
cuihantao/andes
andes/main.py
config_logger
def config_logger(name='andes', log_file='andes.log', log_path='', stream=True, stream_level=logging.INFO ): """ Configure a logger for the andes package with options for a `FileHandler` and a `StreamHandler`. This fun...
python
def config_logger(name='andes', log_file='andes.log', log_path='', stream=True, stream_level=logging.INFO ): """ Configure a logger for the andes package with options for a `FileHandler` and a `StreamHandler`. This fun...
Configure a logger for the andes package with options for a `FileHandler` and a `StreamHandler`. This function is called at the beginning of ``andes.main.main()``. Parameters ---------- name : str, optional Base logger name, ``'andes'`` by default. Changing this parameter will affec...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L47-L103
cuihantao/andes
andes/main.py
preamble
def preamble(): """ Log the Andes command-line preamble at the `logging.INFO` level Returns ------- None """ from . import __version__ as version logger.info('ANDES {ver} (Build {b}, Python {p} on {os})' .format(ver=version[:5], b=version[-8:], p=...
python
def preamble(): """ Log the Andes command-line preamble at the `logging.INFO` level Returns ------- None """ from . import __version__ as version logger.info('ANDES {ver} (Build {b}, Python {p} on {os})' .format(ver=version[:5], b=version[-8:], p=...
Log the Andes command-line preamble at the `logging.INFO` level Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L106-L126
cuihantao/andes
andes/main.py
cli_new
def cli_new(): """ Construct a CLI argument parser and return the parsed arguments. Returns ------- Namespace A namespace object containing the parsed command-line arguments """ parser = ArgumentParser() parser.add_argument('filename', help='Case file name', nargs='*') # ge...
python
def cli_new(): """ Construct a CLI argument parser and return the parsed arguments. Returns ------- Namespace A namespace object containing the parsed command-line arguments """ parser = ArgumentParser() parser.add_argument('filename', help='Case file name', nargs='*') # ge...
Construct a CLI argument parser and return the parsed arguments. Returns ------- Namespace A namespace object containing the parsed command-line arguments
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L129-L233
cuihantao/andes
andes/main.py
andeshelp
def andeshelp(group=None, category=None, model_list=None, model_format=None, model_var=None, quick_help=None, help_option=None, help_config=None, export='plain', **kwargs): """ Print the...
python
def andeshelp(group=None, category=None, model_list=None, model_format=None, model_var=None, quick_help=None, help_option=None, help_config=None, export='plain', **kwargs): """ Print the...
Print the requested help and documentation to stdout. Parameters ---------- group : None or str Name of a group whose model names will be printed category : None or str Name of a category whose models will be printed model_list : bool If ``True``, print the full model list...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L236-L422
cuihantao/andes
andes/main.py
edit_conf
def edit_conf(edit_config=False, load_config=None, **kwargs): """ Edit the Andes config file which occurs first in the search path. Parameters ---------- edit_config : bool If ``True``, try to open up an editor and edit the config file. Otherwise returns. load_config : None or ...
python
def edit_conf(edit_config=False, load_config=None, **kwargs): """ Edit the Andes config file which occurs first in the search path. Parameters ---------- edit_config : bool If ``True``, try to open up an editor and edit the config file. Otherwise returns. load_config : None or ...
Edit the Andes config file which occurs first in the search path. Parameters ---------- edit_config : bool If ``True``, try to open up an editor and edit the config file. Otherwise returns. load_config : None or str, optional Path to the config file, which will be placed to the...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L425-L480
cuihantao/andes
andes/main.py
remove_output
def remove_output(clean=False, **kwargs): """ Remove the outputs generated by Andes, including power flow reports ``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``, eigenvalue analysis report ``_eig.txt``. Parameters ---------- clean : bool If ``True``, execute the f...
python
def remove_output(clean=False, **kwargs): """ Remove the outputs generated by Andes, including power flow reports ``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``, eigenvalue analysis report ``_eig.txt``. Parameters ---------- clean : bool If ``True``, execute the f...
Remove the outputs generated by Andes, including power flow reports ``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``, eigenvalue analysis report ``_eig.txt``. Parameters ---------- clean : bool If ``True``, execute the function body. Returns otherwise. kwargs : dict ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L483-L524
cuihantao/andes
andes/main.py
search
def search(search, **kwargs): """ Search for models whose names matches the given pattern. Print the results to stdout. .. deprecated :: 1.0.0 `search` will be moved to ``andeshelp`` in future versions. Parameters ---------- search : str Partial or full name of the model to...
python
def search(search, **kwargs): """ Search for models whose names matches the given pattern. Print the results to stdout. .. deprecated :: 1.0.0 `search` will be moved to ``andeshelp`` in future versions. Parameters ---------- search : str Partial or full name of the model to...
Search for models whose names matches the given pattern. Print the results to stdout. .. deprecated :: 1.0.0 `search` will be moved to ``andeshelp`` in future versions. Parameters ---------- search : str Partial or full name of the model to search for kwargs : dict Oth...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L527-L573
cuihantao/andes
andes/main.py
save_config
def save_config(save_config='', **kwargs): """ Save the Andes config to a file at the path specified by ``save_config``. The save action will not run if `save_config = ''`. Parameters ---------- save_config : None or str, optional, ('' by default) Path to the file to save the config fil...
python
def save_config(save_config='', **kwargs): """ Save the Andes config to a file at the path specified by ``save_config``. The save action will not run if `save_config = ''`. Parameters ---------- save_config : None or str, optional, ('' by default) Path to the file to save the config fil...
Save the Andes config to a file at the path specified by ``save_config``. The save action will not run if `save_config = ''`. Parameters ---------- save_config : None or str, optional, ('' by default) Path to the file to save the config file. If the path is an emtpy string, the save act...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L576-L617
cuihantao/andes
andes/main.py
main
def main(): """ The main function of the Andes command-line tool. This function executes the following workflow: * Parse the command line inputs * Show the tool preamble * Output the requested helps, edit/save configs or remove outputs. Exit the main program if any of the above is ex...
python
def main(): """ The main function of the Andes command-line tool. This function executes the following workflow: * Parse the command line inputs * Show the tool preamble * Output the requested helps, edit/save configs or remove outputs. Exit the main program if any of the above is ex...
The main function of the Andes command-line tool. This function executes the following workflow: * Parse the command line inputs * Show the tool preamble * Output the requested helps, edit/save configs or remove outputs. Exit the main program if any of the above is executed * Process th...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L620-L727
cuihantao/andes
andes/main.py
run
def run(case, routine=None, profile=False, dump_raw=False, pid=-1, show_data=None, exit=False, **kwargs): """ Entry function to run a single case study. This function executes the following workflow: * Turn on cProfile if requested * Populate a ``PowerSystem`` object * Parse the inpu...
python
def run(case, routine=None, profile=False, dump_raw=False, pid=-1, show_data=None, exit=False, **kwargs): """ Entry function to run a single case study. This function executes the following workflow: * Turn on cProfile if requested * Populate a ``PowerSystem`` object * Parse the inpu...
Entry function to run a single case study. This function executes the following workflow: * Turn on cProfile if requested * Populate a ``PowerSystem`` object * Parse the input files using filters * Dump the case file is requested * Set up the system * Run the specified routine(s) ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L730-L841
cuihantao/andes
andes/variables/call.py
Call.setup
def setup(self): """ setup the call list after case file is parsed and jit models are loaded """ self.devices = self.system.devman.devices self.ndevice = len(self.devices) self.gcalls = [''] * self.ndevice self.fcalls = [''] * self.ndevice self.gycalls = ...
python
def setup(self): """ setup the call list after case file is parsed and jit models are loaded """ self.devices = self.system.devman.devices self.ndevice = len(self.devices) self.gcalls = [''] * self.ndevice self.fcalls = [''] * self.ndevice self.gycalls = ...
setup the call list after case file is parsed and jit models are loaded
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L36-L59
cuihantao/andes
andes/variables/call.py
Call.build_vec
def build_vec(self): """build call validity vector for each device""" for item in all_calls: self.__dict__[item] = [] for dev in self.devices: for item in all_calls: if self.system.__dict__[dev].n == 0: val = False else...
python
def build_vec(self): """build call validity vector for each device""" for item in all_calls: self.__dict__[item] = [] for dev in self.devices: for item in all_calls: if self.system.__dict__[dev].n == 0: val = False else...
build call validity vector for each device
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L61-L72
cuihantao/andes
andes/variables/call.py
Call.build_strings
def build_strings(self): """build call string for each device""" for idx, dev in enumerate(self.devices): header = 'system.' + dev self.gcalls[idx] = header + '.gcall(system.dae)\n' self.fcalls[idx] = header + '.fcall(system.dae)\n' self.gycalls[idx] = hea...
python
def build_strings(self): """build call string for each device""" for idx, dev in enumerate(self.devices): header = 'system.' + dev self.gcalls[idx] = header + '.gcall(system.dae)\n' self.fcalls[idx] = header + '.fcall(system.dae)\n' self.gycalls[idx] = hea...
build call string for each device
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L74-L82
cuihantao/andes
andes/variables/call.py
Call._compile_newton
def _compile_newton(self): """Newton power flow execution 1. evaluate g and f; 1.1. handle islanded buses by Bus.gisland() 2. factorize when needed; 3. evaluate Gy and Fx. 3.1. take care of islanded buses by Bus.gyisland() "...
python
def _compile_newton(self): """Newton power flow execution 1. evaluate g and f; 1.1. handle islanded buses by Bus.gisland() 2. factorize when needed; 3. evaluate Gy and Fx. 3.1. take care of islanded buses by Bus.gyisland() "...
Newton power flow execution 1. evaluate g and f; 1.1. handle islanded buses by Bus.gisland() 2. factorize when needed; 3. evaluate Gy and Fx. 3.1. take care of islanded buses by Bus.gyisland()
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L84-L134
cuihantao/andes
andes/variables/call.py
Call._compile_fdpf
def _compile_fdpf(self): """Fast Decoupled Power Flow execution: Implement g(y) """ string = '"""\n' string += 'system.dae.init_g()\n' for pflow, gcall, call in zip(self.pflow, self.gcall, self.gcalls): if pflow and gcall: string += call string...
python
def _compile_fdpf(self): """Fast Decoupled Power Flow execution: Implement g(y) """ string = '"""\n' string += 'system.dae.init_g()\n' for pflow, gcall, call in zip(self.pflow, self.gcall, self.gcalls): if pflow and gcall: string += call string...
Fast Decoupled Power Flow execution: Implement g(y)
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L136-L147
cuihantao/andes
andes/variables/call.py
Call._compile_pfload
def _compile_pfload(self): """Post power flow computation for load S_gen + S_line + [S_shunt - S_load] = 0 """ string = '"""\n' string += 'system.dae.init_g()\n' for gcall, pflow, shunt, stagen, call in zip( self.gcall, self.pflow, self.shunt, ...
python
def _compile_pfload(self): """Post power flow computation for load S_gen + S_line + [S_shunt - S_load] = 0 """ string = '"""\n' string += 'system.dae.init_g()\n' for gcall, pflow, shunt, stagen, call in zip( self.gcall, self.pflow, self.shunt, ...
Post power flow computation for load S_gen + S_line + [S_shunt - S_load] = 0
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L149-L162
cuihantao/andes
andes/variables/call.py
Call._compile_pfgen
def _compile_pfgen(self): """Post power flow computation for PV and SW""" string = '"""\n' string += 'system.dae.init_g()\n' for gcall, pflow, shunt, series, stagen, call in zip( self.gcall, self.pflow, self.shunt, self.series, self.stagen, self.gcalls): ...
python
def _compile_pfgen(self): """Post power flow computation for PV and SW""" string = '"""\n' string += 'system.dae.init_g()\n' for gcall, pflow, shunt, series, stagen, call in zip( self.gcall, self.pflow, self.shunt, self.series, self.stagen, self.gcalls): ...
Post power flow computation for PV and SW
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L164-L176
cuihantao/andes
andes/variables/call.py
Call._compile_bus_injection
def _compile_bus_injection(self): """Impose injections on buses""" string = '"""\n' for device, series in zip(self.devices, self.series): if series: string += 'system.' + device + '.gcall(system.dae)\n' string += '\n' string += 'system.dae.reset_small_...
python
def _compile_bus_injection(self): """Impose injections on buses""" string = '"""\n' for device, series in zip(self.devices, self.series): if series: string += 'system.' + device + '.gcall(system.dae)\n' string += '\n' string += 'system.dae.reset_small_...
Impose injections on buses
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L178-L188
cuihantao/andes
andes/variables/call.py
Call._compile_seriesflow
def _compile_seriesflow(self): """Post power flow computation of series device flow""" string = '"""\n' for device, pflow, series in zip(self.devices, self.pflow, self.series): if pflow and series: string += 'system.' + device ...
python
def _compile_seriesflow(self): """Post power flow computation of series device flow""" string = '"""\n' for device, pflow, series in zip(self.devices, self.pflow, self.series): if pflow and series: string += 'system.' + device ...
Post power flow computation of series device flow
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L190-L199
cuihantao/andes
andes/variables/call.py
Call._compile_int
def _compile_int(self): """Time Domain Simulation routine execution""" string = '"""\n' # evaluate the algebraic equations g string += 'system.dae.init_fg(resetz=False)\n' for gcall, call in zip(self.gcall, self.gcalls): if gcall: string += call ...
python
def _compile_int(self): """Time Domain Simulation routine execution""" string = '"""\n' # evaluate the algebraic equations g string += 'system.dae.init_fg(resetz=False)\n' for gcall, call in zip(self.gcall, self.gcalls): if gcall: string += call ...
Time Domain Simulation routine execution
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L201-L250
cuihantao/andes
andes/variables/call.py
Call._compile_int_f
def _compile_int_f(self): """Time Domain Simulation - update differential equations""" string = '"""\n' string += 'system.dae.init_f()\n' # evaluate differential equations f for fcall, call in zip(self.fcall, self.fcalls): if fcall: string += call ...
python
def _compile_int_f(self): """Time Domain Simulation - update differential equations""" string = '"""\n' string += 'system.dae.init_f()\n' # evaluate differential equations f for fcall, call in zip(self.fcall, self.fcalls): if fcall: string += call ...
Time Domain Simulation - update differential equations
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L252-L263
cuihantao/andes
andes/variables/call.py
Call._compile_int_g
def _compile_int_g(self): """Time Domain Simulation - update algebraic equations and Jacobian""" string = '"""\n' # evaluate the algebraic equations g string += 'system.dae.init_g()\n' for gcall, call in zip(self.gcall, self.gcalls): if gcall: string ...
python
def _compile_int_g(self): """Time Domain Simulation - update algebraic equations and Jacobian""" string = '"""\n' # evaluate the algebraic equations g string += 'system.dae.init_g()\n' for gcall, call in zip(self.gcall, self.gcalls): if gcall: string ...
Time Domain Simulation - update algebraic equations and Jacobian
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L265-L298
cuihantao/andes
andes/models/base.py
ModelBase._init
def _init(self): """ Convert model metadata to class attributes. This function is called automatically after ``define()`` in new versions. :return: None """ assert self._name assert self._group # self.n = 0 self.u = [] self.name ...
python
def _init(self): """ Convert model metadata to class attributes. This function is called automatically after ``define()`` in new versions. :return: None """ assert self._name assert self._group # self.n = 0 self.u = [] self.name ...
Convert model metadata to class attributes. This function is called automatically after ``define()`` in new versions. :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L194-L237
cuihantao/andes
andes/models/base.py
ModelBase.param_define
def param_define(self, param, default, unit='', descr='', tomatrix=True, nonzero=False, mandatory=False, power=False, voltage=False...
python
def param_define(self, param, default, unit='', descr='', tomatrix=True, nonzero=False, mandatory=False, power=False, voltage=False...
Define a parameter in the model :param tomatrix: convert this parameter list to matrix :param param: parameter name :param default: parameter default value :param unit: parameter unit :param descr: description :param nonzero: is non-zero :param mandatory: is mand...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L239-L337
cuihantao/andes
andes/models/base.py
ModelBase.var_define
def var_define(self, variable, ty, fname, descr='', uname=''): """ Define a variable in the model :param fname: LaTex formatted variable name string :param uname: unformatted variable name string, `variable` as default :param variable: variable name :param ty: type code ...
python
def var_define(self, variable, ty, fname, descr='', uname=''): """ Define a variable in the model :param fname: LaTex formatted variable name string :param uname: unformatted variable name string, `variable` as default :param variable: variable name :param ty: type code ...
Define a variable in the model :param fname: LaTex formatted variable name string :param uname: unformatted variable name string, `variable` as default :param variable: variable name :param ty: type code in ``('x', 'y')`` :param descr: variable description :type variabl...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L339-L369
cuihantao/andes
andes/models/base.py
ModelBase.service_define
def service_define(self, service, ty): """ Add a service variable of type ``ty`` to this model :param str service: variable name :param type ty: variable type :return: None """ assert service not in self._data assert service not in self._algebs + self._s...
python
def service_define(self, service, ty): """ Add a service variable of type ``ty`` to this model :param str service: variable name :param type ty: variable type :return: None """ assert service not in self._data assert service not in self._algebs + self._s...
Add a service variable of type ``ty`` to this model :param str service: variable name :param type ty: variable type :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L371-L384
cuihantao/andes
andes/models/base.py
ModelBase.get_uid
def get_uid(self, idx): """ Return the `uid` of the elements with the given `idx` :param list, matrix idx: external indices :type idx: list, matrix :return: a matrix of uid """ assert idx is not None if isinstance(idx, (int, float, str)): ret...
python
def get_uid(self, idx): """ Return the `uid` of the elements with the given `idx` :param list, matrix idx: external indices :type idx: list, matrix :return: a matrix of uid """ assert idx is not None if isinstance(idx, (int, float, str)): ret...
Return the `uid` of the elements with the given `idx` :param list, matrix idx: external indices :type idx: list, matrix :return: a matrix of uid
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L386-L406
cuihantao/andes
andes/models/base.py
ModelBase.get_field
def get_field(self, field, idx=None, astype=None): """ Return `self.field` for the elements labeled by `idx` :param astype: type cast of the return value :param field: field name of this model :param idx: element indices, will be the whole list if not specified :return: ...
python
def get_field(self, field, idx=None, astype=None): """ Return `self.field` for the elements labeled by `idx` :param astype: type cast of the return value :param field: field name of this model :param idx: element indices, will be the whole list if not specified :return: ...
Return `self.field` for the elements labeled by `idx` :param astype: type cast of the return value :param field: field name of this model :param idx: element indices, will be the whole list if not specified :return: field values
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L417-L455
cuihantao/andes
andes/models/base.py
ModelBase._alloc
def _alloc(self): """ Allocate empty memory for dae variable indices. Called in device setup phase. :return: None """ nzeros = [0] * self.n for var in self._states: self.__dict__[var] = nzeros[:] for var in self._algebs: self.__dic...
python
def _alloc(self): """ Allocate empty memory for dae variable indices. Called in device setup phase. :return: None """ nzeros = [0] * self.n for var in self._states: self.__dict__[var] = nzeros[:] for var in self._algebs: self.__dic...
Allocate empty memory for dae variable indices. Called in device setup phase. :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L457-L468
cuihantao/andes
andes/models/base.py
ModelBase.data_to_dict
def data_to_dict(self, sysbase=False): """ Return the loaded model parameters as one dictionary. Each key of the dictionary is a parameter name, and the value is a list of all the parameter values. :param sysbase: use system base quantities :type sysbase: bool "...
python
def data_to_dict(self, sysbase=False): """ Return the loaded model parameters as one dictionary. Each key of the dictionary is a parameter name, and the value is a list of all the parameter values. :param sysbase: use system base quantities :type sysbase: bool "...
Return the loaded model parameters as one dictionary. Each key of the dictionary is a parameter name, and the value is a list of all the parameter values. :param sysbase: use system base quantities :type sysbase: bool
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L470-L492
cuihantao/andes
andes/models/base.py
ModelBase.data_to_list
def data_to_list(self, sysbase=False): """ Return the loaded model data as a list of dictionaries. Each dictionary contains the full parameters of an element. :param sysbase: use system base quantities :type sysbase: bool """ ret = list() # for each elem...
python
def data_to_list(self, sysbase=False): """ Return the loaded model data as a list of dictionaries. Each dictionary contains the full parameters of an element. :param sysbase: use system base quantities :type sysbase: bool """ ret = list() # for each elem...
Return the loaded model data as a list of dictionaries. Each dictionary contains the full parameters of an element. :param sysbase: use system base quantities :type sysbase: bool
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L520-L543
cuihantao/andes
andes/models/base.py
ModelBase.data_from_dict
def data_from_dict(self, data): """ Populate model parameters from a dictionary of parameters Parameters ---------- data : dict List of parameter dictionaries Returns ------- None """ nvars = [] for key, val in data.i...
python
def data_from_dict(self, data): """ Populate model parameters from a dictionary of parameters Parameters ---------- data : dict List of parameter dictionaries Returns ------- None """ nvars = [] for key, val in data.i...
Populate model parameters from a dictionary of parameters Parameters ---------- data : dict List of parameter dictionaries Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L561-L588
cuihantao/andes
andes/models/base.py
ModelBase.data_to_df
def data_to_df(self, sysbase=False): """ Return a pandas.DataFrame of device parameters. :param sysbase: save per unit values in system base """ p_dict_comp = self.data_to_dict(sysbase=sysbase) self._check_pd() self.param_df = pd.DataFrame(data=p_dict_comp).set_...
python
def data_to_df(self, sysbase=False): """ Return a pandas.DataFrame of device parameters. :param sysbase: save per unit values in system base """ p_dict_comp = self.data_to_dict(sysbase=sysbase) self._check_pd() self.param_df = pd.DataFrame(data=p_dict_comp).set_...
Return a pandas.DataFrame of device parameters. :param sysbase: save per unit values in system base
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L590-L601
cuihantao/andes
andes/models/base.py
ModelBase.var_to_df
def var_to_df(self): """ Return the current var_to_df of variables :return: pandas.DataFrame """ ret = {} self._check_pd() if self._flags['address'] is False: return pd.DataFrame.from_dict(ret) ret.update({'name': self.name}) ret.upd...
python
def var_to_df(self): """ Return the current var_to_df of variables :return: pandas.DataFrame """ ret = {} self._check_pd() if self._flags['address'] is False: return pd.DataFrame.from_dict(ret) ret.update({'name': self.name}) ret.upd...
Return the current var_to_df of variables :return: pandas.DataFrame
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L603-L627
cuihantao/andes
andes/models/base.py
ModelBase.param_remove
def param_remove(self, param: 'str') -> None: """ Remove a param from this model :param param: name of the parameter to be removed :type param: str """ for attr in self._param_attr_dicts: if param in self.__dict__[attr]: self.__dict__[attr].po...
python
def param_remove(self, param: 'str') -> None: """ Remove a param from this model :param param: name of the parameter to be removed :type param: str """ for attr in self._param_attr_dicts: if param in self.__dict__[attr]: self.__dict__[attr].po...
Remove a param from this model :param param: name of the parameter to be removed :type param: str
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L639-L652
cuihantao/andes
andes/models/base.py
ModelBase.param_alter
def param_alter(self, param, default=None, unit=None, descr=None, tomatrix=None, nonzero=None, mandatory=None, power=None, voltage=None, ...
python
def param_alter(self, param, default=None, unit=None, descr=None, tomatrix=None, nonzero=None, mandatory=None, power=None, voltage=None, ...
Set attribute of an existing parameter. To be used to alter an attribute inherited from parent models. See .. self.param_define for argument descriptions.
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L654-L713
cuihantao/andes
andes/models/base.py
ModelBase.eq_add
def eq_add(self, expr, var, intf=False): """ Add an equation to this model. An equation is associated with the addresses of a variable. The number of equations must equal that of variables. Stored to ``self._equations`` is a tuple of ``(expr, var, intf, ty)`` where ``t...
python
def eq_add(self, expr, var, intf=False): """ Add an equation to this model. An equation is associated with the addresses of a variable. The number of equations must equal that of variables. Stored to ``self._equations`` is a tuple of ``(expr, var, intf, ty)`` where ``t...
Add an equation to this model. An equation is associated with the addresses of a variable. The number of equations must equal that of variables. Stored to ``self._equations`` is a tuple of ``(expr, var, intf, ty)`` where ``ty`` is in ('f', 'g') :param str expr: equation expre...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L715-L764
cuihantao/andes
andes/models/base.py
ModelBase.read_data_ext
def read_data_ext(self, model: str, field: str, idx=None, astype=None): """ Return a field of a model or group at the given indices :param str model: name of the group or model to retrieve :param str field: name of the field :param list, int, float str idx: idx of elements to ac...
python
def read_data_ext(self, model: str, field: str, idx=None, astype=None): """ Return a field of a model or group at the given indices :param str model: name of the group or model to retrieve :param str field: name of the field :param list, int, float str idx: idx of elements to ac...
Return a field of a model or group at the given indices :param str model: name of the group or model to retrieve :param str field: name of the field :param list, int, float str idx: idx of elements to access :param type astype: type cast :return:
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L766-L805
cuihantao/andes
andes/models/base.py
ModelBase.copy_data_ext
def copy_data_ext(self, model, field, dest=None, idx=None, astype=None): """ Retrieve the field of another model and store it as a field. :param model: name of the source model being a model name or a group name :param field: name of the field to retrieve :param dest: name of th...
python
def copy_data_ext(self, model, field, dest=None, idx=None, astype=None): """ Retrieve the field of another model and store it as a field. :param model: name of the source model being a model name or a group name :param field: name of the field to retrieve :param dest: name of th...
Retrieve the field of another model and store it as a field. :param model: name of the source model being a model name or a group name :param field: name of the field to retrieve :param dest: name of the destination field in ``self`` :param idx: idx of elements to access :param ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L807-L837
cuihantao/andes
andes/models/base.py
ModelBase.elem_add
def elem_add(self, idx=None, name=None, **kwargs): """ Add an element of this model :param idx: element idx :param name: element name :param kwargs: keyword arguments of the parameters :return: allocated idx """ idx = self.system.devman.register_element(...
python
def elem_add(self, idx=None, name=None, **kwargs): """ Add an element of this model :param idx: element idx :param name: element name :param kwargs: keyword arguments of the parameters :return: allocated idx """ idx = self.system.devman.register_element(...
Add an element of this model :param idx: element idx :param name: element name :param kwargs: keyword arguments of the parameters :return: allocated idx
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L839-L899
cuihantao/andes
andes/models/base.py
ModelBase.elem_remove
def elem_remove(self, idx=None): """ Remove elements labeled by idx from this model instance. :param list,matrix idx: indices of elements to be removed :return: None """ if idx is not None: if idx in self.uid: key = idx item = ...
python
def elem_remove(self, idx=None): """ Remove elements labeled by idx from this model instance. :param list,matrix idx: indices of elements to be removed :return: None """ if idx is not None: if idx in self.uid: key = idx item = ...
Remove elements labeled by idx from this model instance. :param list,matrix idx: indices of elements to be removed :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L901-L966
cuihantao/andes
andes/models/base.py
ModelBase.data_to_sys_base
def data_to_sys_base(self): """ Converts parameters to system base. Stores a copy in ``self._store``. Sets the flag ``self.flag['sysbase']`` to True. :return: None """ if (not self.n) or self._flags['sysbase']: return Sb = self.system.mva Vb =...
python
def data_to_sys_base(self): """ Converts parameters to system base. Stores a copy in ``self._store``. Sets the flag ``self.flag['sysbase']`` to True. :return: None """ if (not self.n) or self._flags['sysbase']: return Sb = self.system.mva Vb =...
Converts parameters to system base. Stores a copy in ``self._store``. Sets the flag ``self.flag['sysbase']`` to True. :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L968-L1039
cuihantao/andes
andes/models/base.py
ModelBase.data_to_elem_base
def data_to_elem_base(self): """ Convert parameter data to element base Returns ------- None """ if self._flags['sysbase'] is False: return for key, val in self._store.items(): self.__dict__[key] = val self._flags['sysbas...
python
def data_to_elem_base(self): """ Convert parameter data to element base Returns ------- None """ if self._flags['sysbase'] is False: return for key, val in self._store.items(): self.__dict__[key] = val self._flags['sysbas...
Convert parameter data to element base Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1041-L1055
cuihantao/andes
andes/models/base.py
ModelBase._intf_network
def _intf_network(self): """ Retrieve the ac and dc network interface variable indices. :Example: ``self._ac = {'bus1': (a1, v1)}`` gives - indices: self.bus1 - system.Bus.a -> self.a1 - system.Bus.v -> self.v1 ``self._dc = {'node...
python
def _intf_network(self): """ Retrieve the ac and dc network interface variable indices. :Example: ``self._ac = {'bus1': (a1, v1)}`` gives - indices: self.bus1 - system.Bus.a -> self.a1 - system.Bus.v -> self.v1 ``self._dc = {'node...
Retrieve the ac and dc network interface variable indices. :Example: ``self._ac = {'bus1': (a1, v1)}`` gives - indices: self.bus1 - system.Bus.a -> self.a1 - system.Bus.v -> self.v1 ``self._dc = {'node1': v1}`` gives - indices: self...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1070-L1099
cuihantao/andes
andes/models/base.py
ModelBase._intf_ctrl
def _intf_ctrl(self): """ Retrieve variable indices of controlled models. Control interfaces are specified in ``self._ctrl``. Each ``key:value`` pair has ``key`` being the variable names for the reference idx and ``value`` being a tuple of ``(model name, field to read, d...
python
def _intf_ctrl(self): """ Retrieve variable indices of controlled models. Control interfaces are specified in ``self._ctrl``. Each ``key:value`` pair has ``key`` being the variable names for the reference idx and ``value`` being a tuple of ``(model name, field to read, d...
Retrieve variable indices of controlled models. Control interfaces are specified in ``self._ctrl``. Each ``key:value`` pair has ``key`` being the variable names for the reference idx and ``value`` being a tuple of ``(model name, field to read, destination field, return type)``. ...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1101-L1122
cuihantao/andes
andes/models/base.py
ModelBase._addr
def _addr(self): """ Assign dae addresses for algebraic and state variables. Addresses are stored in ``self.__dict__[var]``. ``dae.m`` and ``dae.n`` are updated accordingly. Returns ------- None """ group_by = self._config['address_group_by'] ...
python
def _addr(self): """ Assign dae addresses for algebraic and state variables. Addresses are stored in ``self.__dict__[var]``. ``dae.m`` and ``dae.n`` are updated accordingly. Returns ------- None """ group_by = self._config['address_group_by'] ...
Assign dae addresses for algebraic and state variables. Addresses are stored in ``self.__dict__[var]``. ``dae.m`` and ``dae.n`` are updated accordingly. Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1124-L1164
cuihantao/andes
andes/models/base.py
ModelBase._varname
def _varname(self): """ Set up variable names in ``self.system.varname``. Variable names follows the convention ``VariableName,Model Name``. A maximum of 24 characters are allowed for each variable. :return: None """ if not self._flags['address']: se...
python
def _varname(self): """ Set up variable names in ``self.system.varname``. Variable names follows the convention ``VariableName,Model Name``. A maximum of 24 characters are allowed for each variable. :return: None """ if not self._flags['address']: se...
Set up variable names in ``self.system.varname``. Variable names follows the convention ``VariableName,Model Name``. A maximum of 24 characters are allowed for each variable. :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1166-L1200
cuihantao/andes
andes/models/base.py
ModelBase._param_to_matrix
def _param_to_matrix(self): """ Convert parameters defined in `self._params` to `cvxopt.matrix` :return None """ for item in self._params: self.__dict__[item] = matrix(self.__dict__[item], tc='d')
python
def _param_to_matrix(self): """ Convert parameters defined in `self._params` to `cvxopt.matrix` :return None """ for item in self._params: self.__dict__[item] = matrix(self.__dict__[item], tc='d')
Convert parameters defined in `self._params` to `cvxopt.matrix` :return None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1202-L1209
cuihantao/andes
andes/models/base.py
ModelBase._param_to_list
def _param_to_list(self): """ Convert parameters defined in `self._param` to list :return None """ for item in self._params: self.__dict__[item] = list(self.__dict__[item])
python
def _param_to_list(self): """ Convert parameters defined in `self._param` to list :return None """ for item in self._params: self.__dict__[item] = list(self.__dict__[item])
Convert parameters defined in `self._param` to list :return None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1211-L1218
cuihantao/andes
andes/models/base.py
ModelBase.log
def log(self, msg, level=INFO): """Record a line of log in logger :param str msg: content of the messag :param level: logging level :return: None """ logger.log(level, '<{}> - '.format(self._name) + msg)
python
def log(self, msg, level=INFO): """Record a line of log in logger :param str msg: content of the messag :param level: logging level :return: None """ logger.log(level, '<{}> - '.format(self._name) + msg)
Record a line of log in logger :param str msg: content of the messag :param level: logging level :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1220-L1229
cuihantao/andes
andes/models/base.py
ModelBase.init_limit
def init_limit(self, key, lower=None, upper=None, limit=False): """ check if data is within limits. reset if violates""" above = agtb(self.__dict__[key], upper) for idx, item in enumerate(above): if item == 0.: continue maxval = upper[idx] self...
python
def init_limit(self, key, lower=None, upper=None, limit=False): """ check if data is within limits. reset if violates""" above = agtb(self.__dict__[key], upper) for idx, item in enumerate(above): if item == 0.: continue maxval = upper[idx] self...
check if data is within limits. reset if violates
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1231-L1253
cuihantao/andes
andes/models/base.py
ModelBase.doc
def doc(self, export='plain'): """ Build help document into a Texttable table :param ('plain', 'latex') export: export format :param save: save to file ``help_model.extension`` or not :param writemode: file write mode :return: None """ title = '<{}.{}>'....
python
def doc(self, export='plain'): """ Build help document into a Texttable table :param ('plain', 'latex') export: export format :param save: save to file ``help_model.extension`` or not :param writemode: file write mode :return: None """ title = '<{}.{}>'....
Build help document into a Texttable table :param ('plain', 'latex') export: export format :param save: save to file ``help_model.extension`` or not :param writemode: file write mode :return: None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1276-L1322
cuihantao/andes
andes/models/base.py
ModelBase.check_limit
def check_limit(self, varname, vmin=None, vmax=None): """ Check if the variable values are within the limits. Return False if fails. """ retval = True assert varname in self.__dict__ if varname in self._algebs: val = self.system.dae.y[self.__dict__[...
python
def check_limit(self, varname, vmin=None, vmax=None): """ Check if the variable values are within the limits. Return False if fails. """ retval = True assert varname in self.__dict__ if varname in self._algebs: val = self.system.dae.y[self.__dict__[...
Check if the variable values are within the limits. Return False if fails.
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1324-L1364
cuihantao/andes
andes/models/base.py
ModelBase.on_bus
def on_bus(self, bus_idx): """ Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx """ assert hasattr(self, 'bus') ...
python
def on_bus(self, bus_idx): """ Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx """ assert hasattr(self, 'bus') ...
Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1366-L1396
cuihantao/andes
andes/models/base.py
ModelBase.link_bus
def link_bus(self, bus_idx): """ Return the indices of elements linking the given buses :param bus_idx: :return: """ ret = [] if not self._config['is_series']: self.log( 'link_bus function is not valid for non-series model <{}>'. ...
python
def link_bus(self, bus_idx): """ Return the indices of elements linking the given buses :param bus_idx: :return: """ ret = [] if not self._config['is_series']: self.log( 'link_bus function is not valid for non-series model <{}>'. ...
Return the indices of elements linking the given buses :param bus_idx: :return:
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1398-L1441
cuihantao/andes
andes/models/base.py
ModelBase.elem_find
def elem_find(self, field, value): """ Return the indices of elements whose field first satisfies the given values ``value`` should be unique in self.field. This function does not check the uniqueness. :param field: name of the supplied field :param value: value of fiel...
python
def elem_find(self, field, value): """ Return the indices of elements whose field first satisfies the given values ``value`` should be unique in self.field. This function does not check the uniqueness. :param field: name of the supplied field :param value: value of fiel...
Return the indices of elements whose field first satisfies the given values ``value`` should be unique in self.field. This function does not check the uniqueness. :param field: name of the supplied field :param value: value of field of the elemtn to find :return: idx of the ele...
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1443-L1460
cuihantao/andes
andes/models/base.py
ModelBase._check_Vn
def _check_Vn(self): """Check data consistency of Vn and Vdcn if connected to Bus or Node :return None """ if hasattr(self, 'bus') and hasattr(self, 'Vn'): bus_Vn = self.read_data_ext('Bus', field='Vn', idx=self.bus) for name, bus, Vn, Vn0 in zip(self.name, self....
python
def _check_Vn(self): """Check data consistency of Vn and Vdcn if connected to Bus or Node :return None """ if hasattr(self, 'bus') and hasattr(self, 'Vn'): bus_Vn = self.read_data_ext('Bus', field='Vn', idx=self.bus) for name, bus, Vn, Vn0 in zip(self.name, self....
Check data consistency of Vn and Vdcn if connected to Bus or Node :return None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1462-L1483
cuihantao/andes
andes/models/base.py
ModelBase.link_to
def link_to(self, model, idx, self_idx): """ Register (self.name, self.idx) in `model._from` Returns ------- """ if model in self.system.loaded_groups: # access group instance grp = self.system.__dict__[model] # doing it one by one ...
python
def link_to(self, model, idx, self_idx): """ Register (self.name, self.idx) in `model._from` Returns ------- """ if model in self.system.loaded_groups: # access group instance grp = self.system.__dict__[model] # doing it one by one ...
Register (self.name, self.idx) in `model._from` Returns -------
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1494-L1530
cuihantao/andes
andes/routines/pflow.py
PFLOW.reset
def reset(self): """ Reset all internal storage to initial status Returns ------- None """ self.solved = False self.niter = 0 self.iter_mis = [] self.F = None self.system.dae.factorize = True
python
def reset(self): """ Reset all internal storage to initial status Returns ------- None """ self.solved = False self.niter = 0 self.iter_mis = [] self.F = None self.system.dae.factorize = True
Reset all internal storage to initial status Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L27-L39
cuihantao/andes
andes/routines/pflow.py
PFLOW.pre
def pre(self): """ Initialize system for power flow study Returns ------- None """ logger.info('-> Power flow study: {} method, {} start'.format( self.config.method.upper(), 'flat' if self.config.flatstart else 'non-flat') ) t, s = el...
python
def pre(self): """ Initialize system for power flow study Returns ------- None """ logger.info('-> Power flow study: {} method, {} start'.format( self.config.method.upper(), 'flat' if self.config.flatstart else 'non-flat') ) t, s = el...
Initialize system for power flow study Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L41-L69
cuihantao/andes
andes/routines/pflow.py
PFLOW.run
def run(self, **kwargs): """ call the power flow solution routine Returns ------- bool True for success, False for fail """ ret = None # initialization Y matrix and inital guess self.pre() t, _ = elapsed() # call solu...
python
def run(self, **kwargs): """ call the power flow solution routine Returns ------- bool True for success, False for fail """ ret = None # initialization Y matrix and inital guess self.pre() t, _ = elapsed() # call solu...
call the power flow solution routine Returns ------- bool True for success, False for fail
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L71-L102
cuihantao/andes
andes/routines/pflow.py
PFLOW.newton
def newton(self): """ Newton power flow routine Returns ------- (bool, int) success flag, number of iterations """ dae = self.system.dae while True: inc = self.calc_inc() dae.x += inc[:dae.n] dae.y += inc[d...
python
def newton(self): """ Newton power flow routine Returns ------- (bool, int) success flag, number of iterations """ dae = self.system.dae while True: inc = self.calc_inc() dae.x += inc[:dae.n] dae.y += inc[d...
Newton power flow routine Returns ------- (bool, int) success flag, number of iterations
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L104-L137
cuihantao/andes
andes/routines/pflow.py
PFLOW.dcpf
def dcpf(self): """ Calculate linearized power flow Returns ------- (bool, int) success flag, number of iterations """ dae = self.system.dae self.system.Bus.init0(dae) self.system.dae.init_g() Va0 = self.system.Bus.angle ...
python
def dcpf(self): """ Calculate linearized power flow Returns ------- (bool, int) success flag, number of iterations """ dae = self.system.dae self.system.Bus.init0(dae) self.system.dae.init_g() Va0 = self.system.Bus.angle ...
Calculate linearized power flow Returns ------- (bool, int) success flag, number of iterations
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L139-L179
cuihantao/andes
andes/routines/pflow.py
PFLOW._iter_info
def _iter_info(self, niter, level=logging.INFO): """ Log iteration number and mismatch Parameters ---------- level logging level Returns ------- None """ max_mis = self.iter_mis[niter - 1] msg = ' Iter {:<d}. max misma...
python
def _iter_info(self, niter, level=logging.INFO): """ Log iteration number and mismatch Parameters ---------- level logging level Returns ------- None """ max_mis = self.iter_mis[niter - 1] msg = ' Iter {:<d}. max misma...
Log iteration number and mismatch Parameters ---------- level logging level Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L181-L195
cuihantao/andes
andes/routines/pflow.py
PFLOW.calc_inc
def calc_inc(self): """ Calculate the Newton incrementals for each step Returns ------- matrix The solution to ``x = -A\\b`` """ system = self.system self.newton_call() A = sparse([[system.dae.Fx, system.dae.Gx], [...
python
def calc_inc(self): """ Calculate the Newton incrementals for each step Returns ------- matrix The solution to ``x = -A\\b`` """ system = self.system self.newton_call() A = sparse([[system.dae.Fx, system.dae.Gx], [...
Calculate the Newton incrementals for each step Returns ------- matrix The solution to ``x = -A\\b``
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L197-L228
cuihantao/andes
andes/routines/pflow.py
PFLOW.newton_call
def newton_call(self): """ Function calls for Newton power flow Returns ------- None """ # system = self.system # exec(system.call.newton) system = self.system dae = self.system.dae system.dae.init_fg() system.dae.reset_...
python
def newton_call(self): """ Function calls for Newton power flow Returns ------- None """ # system = self.system # exec(system.call.newton) system = self.system dae = self.system.dae system.dae.init_fg() system.dae.reset_...
Function calls for Newton power flow Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L230-L288
cuihantao/andes
andes/routines/pflow.py
PFLOW.post
def post(self): """ Post processing for solved systems. Store load, generation data on buses. Store reactive power generation on PVs and slack generators. Calculate series flows and area flows. Returns ------- None """ if not self.solved:...
python
def post(self): """ Post processing for solved systems. Store load, generation data on buses. Store reactive power generation on PVs and slack generators. Calculate series flows and area flows. Returns ------- None """ if not self.solved:...
Post processing for solved systems. Store load, generation data on buses. Store reactive power generation on PVs and slack generators. Calculate series flows and area flows. Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L290-L323
cuihantao/andes
andes/routines/pflow.py
PFLOW.fdpf
def fdpf(self): """ Fast Decoupled Power Flow Returns ------- bool, int Success flag, number of iterations """ system = self.system # general settings self.niter = 1 iter_max = self.config.maxit self.solved = True ...
python
def fdpf(self): """ Fast Decoupled Power Flow Returns ------- bool, int Success flag, number of iterations """ system = self.system # general settings self.niter = 1 iter_max = self.config.maxit self.solved = True ...
Fast Decoupled Power Flow Returns ------- bool, int Success flag, number of iterations
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L325-L407
cuihantao/andes
andes/models/pv.py
PV.init0
def init0(self, dae): """ Set initial voltage and reactive power for PQ. Overwrites Bus.voltage values """ dae.y[self.v] = self.v0 dae.y[self.q] = mul(self.u, self.qg)
python
def init0(self, dae): """ Set initial voltage and reactive power for PQ. Overwrites Bus.voltage values """ dae.y[self.v] = self.v0 dae.y[self.q] = mul(self.u, self.qg)
Set initial voltage and reactive power for PQ. Overwrites Bus.voltage values
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pv.py#L99-L105
cuihantao/andes
andes/models/pv.py
PV.disable_gen
def disable_gen(self, idx): """ Disable a PV element for TDS Parameters ---------- idx Returns ------- """ self.u[self.uid[idx]] = 0 self.system.dae.factorize = True
python
def disable_gen(self, idx): """ Disable a PV element for TDS Parameters ---------- idx Returns ------- """ self.u[self.uid[idx]] = 0 self.system.dae.factorize = True
Disable a PV element for TDS Parameters ---------- idx Returns -------
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pv.py#L172-L185
cuihantao/andes
andes/models/pq.py
PQ.init0
def init0(self, dae): """Set initial p and q for power flow""" self.p0 = matrix(self.p, (self.n, 1), 'd') self.q0 = matrix(self.q, (self.n, 1), 'd')
python
def init0(self, dae): """Set initial p and q for power flow""" self.p0 = matrix(self.p, (self.n, 1), 'd') self.q0 = matrix(self.q, (self.n, 1), 'd')
Set initial p and q for power flow
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pq.py#L62-L65
cuihantao/andes
andes/models/pq.py
PQ.init1
def init1(self, dae): """Set initial voltage for time domain simulation""" self.v0 = matrix(dae.y[self.v])
python
def init1(self, dae): """Set initial voltage for time domain simulation""" self.v0 = matrix(dae.y[self.v])
Set initial voltage for time domain simulation
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pq.py#L67-L69
DiamondLightSource/python-workflows
workflows/contrib/status_monitor.py
Monitor.update_status
def update_status(self, header, message): """Process incoming status message. Acquire lock for status dictionary before updating.""" with self._lock: if self.message_box: self.message_box.erase() self.message_box.move(0, 0) for n, field in enum...
python
def update_status(self, header, message): """Process incoming status message. Acquire lock for status dictionary before updating.""" with self._lock: if self.message_box: self.message_box.erase() self.message_box.move(0, 0) for n, field in enum...
Process incoming status message. Acquire lock for status dictionary before updating.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L46-L73
DiamondLightSource/python-workflows
workflows/contrib/status_monitor.py
Monitor._redraw_screen
def _redraw_screen(self, stdscr): """Redraw screen. This could be to initialize, or to redraw after resizing.""" with self._lock: stdscr.clear() stdscr.addstr( 0, 0, "workflows service monitor -- quit with Ctrl+C", curses.A_BOLD ) stdscr.re...
python
def _redraw_screen(self, stdscr): """Redraw screen. This could be to initialize, or to redraw after resizing.""" with self._lock: stdscr.clear() stdscr.addstr( 0, 0, "workflows service monitor -- quit with Ctrl+C", curses.A_BOLD ) stdscr.re...
Redraw screen. This could be to initialize, or to redraw after resizing.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L96-L108
DiamondLightSource/python-workflows
workflows/contrib/status_monitor.py
Monitor._erase_card
def _erase_card(self, number): """Destroy cards with this or higher number.""" with self._lock: if number < (len(self.cards) - 1): self._erase_card(number + 1) if number > (len(self.cards) - 1): return max_cards_horiz = int(curses.COLS ...
python
def _erase_card(self, number): """Destroy cards with this or higher number.""" with self._lock: if number < (len(self.cards) - 1): self._erase_card(number + 1) if number > (len(self.cards) - 1): return max_cards_horiz = int(curses.COLS ...
Destroy cards with this or higher number.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L128-L144
DiamondLightSource/python-workflows
workflows/contrib/status_monitor.py
Monitor._run
def _run(self, stdscr): """Start the actual service monitor""" with self._lock: curses.use_default_colors() curses.curs_set(False) curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_BLACK, -1) curses.init_pair(3, curses....
python
def _run(self, stdscr): """Start the actual service monitor""" with self._lock: curses.use_default_colors() curses.curs_set(False) curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_BLACK, -1) curses.init_pair(3, curses....
Start the actual service monitor
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L146-L217
cuihantao/andes
andes/models/vsc.py
VSC.switch
def switch(self, idx, control): """Switch a single control of <idx>""" old = None new = None if control == 'Q': if self.PQ[idx] == 1: old = 'PQ' new = 'PV' elif self.vQ[idx] == 1: old = 'vQ' new = 'vV...
python
def switch(self, idx, control): """Switch a single control of <idx>""" old = None new = None if control == 'Q': if self.PQ[idx] == 1: old = 'PQ' new = 'PV' elif self.vQ[idx] == 1: old = 'vQ' new = 'vV...
Switch a single control of <idx>
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/vsc.py#L279-L313
cuihantao/andes
andes/models/vsc.py
VSC.disable
def disable(self, idx): """Disable an element and reset the outputs""" if idx not in self.uid.keys(): self.log('Element index {0} does not exist.'.format(idx)) return self.u[self.uid[idx]] = 0
python
def disable(self, idx): """Disable an element and reset the outputs""" if idx not in self.uid.keys(): self.log('Element index {0} does not exist.'.format(idx)) return self.u[self.uid[idx]] = 0
Disable an element and reset the outputs
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/vsc.py#L437-L442
cuihantao/andes
andes/config/base.py
ConfigBase.get_alt
def get_alt(self, option): """ Return the alternative values of an option Parameters ---------- option: str option name Returns ------- str a string of alternative options """ assert hasattr(self, option) ...
python
def get_alt(self, option): """ Return the alternative values of an option Parameters ---------- option: str option name Returns ------- str a string of alternative options """ assert hasattr(self, option) ...
Return the alternative values of an option Parameters ---------- option: str option name Returns ------- str a string of alternative options
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L36-L56
cuihantao/andes
andes/config/base.py
ConfigBase.doc
def doc(self, export='plain'): """ Dump help document for setting classes """ rows = [] title = '<{:s}> config options'.format(self.__class__.__name__) table = Tab(export=export, title=title) for opt in sorted(self.config_descr): if hasattr(self, opt)...
python
def doc(self, export='plain'): """ Dump help document for setting classes """ rows = [] title = '<{:s}> config options'.format(self.__class__.__name__) table = Tab(export=export, title=title) for opt in sorted(self.config_descr): if hasattr(self, opt)...
Dump help document for setting classes
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L58-L80
cuihantao/andes
andes/config/base.py
ConfigBase.dump_conf
def dump_conf(self, conf=None): """ Dump settings to an rc config file Parameters ---------- conf configparser.ConfigParser() object Returns ------- None """ if conf is None: conf = configparser.ConfigParser() ...
python
def dump_conf(self, conf=None): """ Dump settings to an rc config file Parameters ---------- conf configparser.ConfigParser() object Returns ------- None """ if conf is None: conf = configparser.ConfigParser() ...
Dump settings to an rc config file Parameters ---------- conf configparser.ConfigParser() object Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L82-L107
cuihantao/andes
andes/config/base.py
ConfigBase.load_config
def load_config(self, conf): """ Load configurations from an rc file Parameters ---------- rc: str path to the rc file Returns ------- None """ section = self.__class__.__name__ if section not in conf.sections(): ...
python
def load_config(self, conf): """ Load configurations from an rc file Parameters ---------- rc: str path to the rc file Returns ------- None """ section = self.__class__.__name__ if section not in conf.sections(): ...
Load configurations from an rc file Parameters ---------- rc: str path to the rc file Returns ------- None
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L109-L146
DiamondLightSource/python-workflows
workflows/frontend/utilization.py
UtilizationStatistics.update_status
def update_status(self, new_status): """Record a status change with a current timestamp.""" timestamp = time.time() self.status_history[-1]["end"] = timestamp self.status_history.append( {"start": timestamp, "end": None, "status": new_status} )
python
def update_status(self, new_status): """Record a status change with a current timestamp.""" timestamp = time.time() self.status_history[-1]["end"] = timestamp self.status_history.append( {"start": timestamp, "end": None, "status": new_status} )
Record a status change with a current timestamp.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/utilization.py#L20-L26
DiamondLightSource/python-workflows
workflows/frontend/utilization.py
UtilizationStatistics.report
def report(self): """Return a dictionary of different status codes and the percentage of time spent in each throughout the last summation_period seconds. Truncate the aggregated history appropriately.""" timestamp = time.time() cutoff = timestamp - self.period truncate = ...
python
def report(self): """Return a dictionary of different status codes and the percentage of time spent in each throughout the last summation_period seconds. Truncate the aggregated history appropriately.""" timestamp = time.time() cutoff = timestamp - self.period truncate = ...
Return a dictionary of different status codes and the percentage of time spent in each throughout the last summation_period seconds. Truncate the aggregated history appropriately.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/utilization.py#L28-L54
DiamondLightSource/python-workflows
workflows/util/__init__.py
generate_unique_host_id
def generate_unique_host_id(): """Generate a unique ID, that is somewhat guaranteed to be unique among all instances running at the same time.""" host = ".".join(reversed(socket.gethostname().split("."))) pid = os.getpid() return "%s.%d" % (host, pid)
python
def generate_unique_host_id(): """Generate a unique ID, that is somewhat guaranteed to be unique among all instances running at the same time.""" host = ".".join(reversed(socket.gethostname().split("."))) pid = os.getpid() return "%s.%d" % (host, pid)
Generate a unique ID, that is somewhat guaranteed to be unique among all instances running at the same time.
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/util/__init__.py#L7-L12
cuihantao/andes
andes/models/governor.py
GovernorBase.data_to_sys_base
def data_to_sys_base(self): """Custom system base conversion function""" if not self.n or self._flags['sysbase'] is True: return self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen) super(GovernorBase, self).data_to_sys_base() self._store['R']...
python
def data_to_sys_base(self): """Custom system base conversion function""" if not self.n or self._flags['sysbase'] is True: return self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen) super(GovernorBase, self).data_to_sys_base() self._store['R']...
Custom system base conversion function
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/governor.py#L52-L61
cuihantao/andes
andes/models/governor.py
GovernorBase.data_to_elem_base
def data_to_elem_base(self): """Custom system base unconversion function""" if not self.n or self._flags['sysbase'] is False: return self.R = mul(self.R, self.Sn) / self.system.mva super(GovernorBase, self).data_to_elem_base()
python
def data_to_elem_base(self): """Custom system base unconversion function""" if not self.n or self._flags['sysbase'] is False: return self.R = mul(self.R, self.Sn) / self.system.mva super(GovernorBase, self).data_to_elem_base()
Custom system base unconversion function
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/governor.py#L63-L68
cuihantao/andes
andes/variables/fileman.py
add_suffix
def add_suffix(fullname, suffix): """ Add suffix to a full file name""" name, ext = os.path.splitext(fullname) return name + '_' + suffix + ext
python
def add_suffix(fullname, suffix): """ Add suffix to a full file name""" name, ext = os.path.splitext(fullname) return name + '_' + suffix + ext
Add suffix to a full file name
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/fileman.py#L121-L124