The pyedb.generic.general_methods library#
Summary#
Scan environment variables and return a dict |
|
Get the filename without its extension. |
|
Get the path of the version environment variable for an AEDT version. |
|
Get the name of the version environment variable for an AEDT version. |
|
Generate a new name given a root name and optional suffix. |
|
Normalize path separators. |
|
Check if two numeric values are equivalent to within a relative tolerance. |
|
Check if a file is remote and either download it or return the path. |
|
Check whether a path exists or not local or remote machine (for remote sessions only). |
|
Check if a folder is remote and either download it or return the path. |
|
Open a file and return the object. |
|
Get the path of the version environment variable for an AEDT student version. |
|
Get the name of the version environment variable for an AEDT student version. |
|
Generate a new AEDT folder name given a rootname. |
|
Generate a new AEDT project name given a rootname. |
|
Check if an AEDT project lock file exists. |
|
Check if an AEDT project exists and try to remove the lock file. |
|
Read information from a CSV file and return a list. |
|
Read information from a CSV file and return a list. |
|
Read information from a TAB file and return a list. |
|
Read information from an XLSX file and return a list. |
|
Filter a tuple of two elements with two search keywords. |
|
Filter a string |
|
Get a list of files matching a pattern, searching recursively from a start path. |
|
Get a key for sorting strings that treats embedded digit sequences as integers. |
|
Compute FFT of input transient data. |
|
Parse a csv file and convert data in list that can be applied to Hfss and Hfss3dLayout sources. |
|
Convert a TECH file to an XML file for use in a GDS or DXF import. |
|
Install a new package using pip. |
Module detail#
- general_methods.installed_ansys_em_versions() Dict[str, str]#
Scan environment variables and return a dict {version: installation_path} for every ANSYS EM release found. Versions are ordered from oldest → latest (latest appears last).
- general_methods.get_filename_without_extension(path)#
Get the filename without its extension.
- general_methods.env_path(input_version)#
Get the path of the version environment variable for an AEDT version.
Examples
>>> env_path_student("2021.2") "C:/Program Files/ANSYSEM/ANSYSEM2021.2/Win64"
- general_methods.get_version_and_release(input_version)#
- general_methods.env_value(input_version)#
Get the name of the version environment variable for an AEDT version.
Examples
>>> env_value("2021.2") "ANSYSEM_ROOT211"
- general_methods.generate_unique_name(rootname, suffix='', n=6)#
Generate a new name given a root name and optional suffix.
- general_methods.normalize_path(path_in, sep=None)#
Normalize path separators.
- general_methods.check_numeric_equivalence(a, b, relative_tolerance=1e-07)#
Check if two numeric values are equivalent to within a relative tolerance.
- Returns:
- bool
Trueif the two passed values are equivalent.
- general_methods.check_and_download_file(local_path, remote_path, overwrite=True)#
Check if a file is remote and either download it or return the path.
- general_methods.check_if_path_exists(path)#
Check whether a path exists or not local or remote machine (for remote sessions only).
- general_methods.check_and_download_folder(local_path, remote_path, overwrite=True)#
Check if a folder is remote and either download it or return the path.
- general_methods.open_file(file_path, file_options='r')#
Open a file and return the object.
- general_methods.get_string_version(input_version)#
- general_methods.env_path_student(input_version)#
Get the path of the version environment variable for an AEDT student version.
- Parameters:
- input_version
str AEDT student version.
- input_version
- Returns:
strPath for the student version environment variable.
Examples
>>> env_path_student("2021.2") "C:/Program Files/ANSYSEM/ANSYSEM2021.2/Win64"
- general_methods.env_value_student(input_version)#
Get the name of the version environment variable for an AEDT student version.
- Parameters:
- input_version
str AEDT student version.
- input_version
- Returns:
strName for the student version environment variable.
Examples
>>> env_value_student("2021.2") "ANSYSEMSV_ROOT211"
- general_methods.generate_unique_folder_name(rootname=None, folder_name=None)#
Generate a new AEDT folder name given a rootname.
- general_methods.generate_unique_project_name(rootname=None, folder_name=None, project_name=None, project_format='aedt')#
Generate a new AEDT project name given a rootname.
- Parameters:
- rootname
str,optional Root name where the new project is to be created.
- folder_name
str,optional Name of the folder to create. The default is
None, in which case a random folder is created. Use""if you do not want to create a subfolder.- project_name
str,optional Name for the project. The default is
None, in which case a random project is created. If a project with this name already exists, a new suffix is added.- project_format
str,optional Project format. The default is
"aedt". Options are"aedt"and"aedb".
- rootname
- Returns:
- general_methods.time_fn(fn, *args, **kwargs)#
- general_methods.isclose(a, b, rel_tol=1e-09, abs_tol=0.0)#
- general_methods.is_number(a)#
- general_methods.is_array(a)#
- general_methods.is_project_locked(project_path)#
Check if an AEDT project lock file exists.
- general_methods.remove_project_lock(project_path)#
Check if an AEDT project exists and try to remove the lock file.
Note
This operation is risky because the file could be opened in another AEDT instance.
- general_methods.read_csv(filename, encoding='utf-8')#
Read information from a CSV file and return a list.
- general_methods.read_csv_pandas(filename, encoding='utf-8')#
Read information from a CSV file and return a list.
- Parameters:
- Returns:
- general_methods.read_tab(filename)#
Read information from a TAB file and return a list.
- general_methods.read_xlsx(filename)#
Read information from an XLSX file and return a list.
- general_methods.write_csv(output, list_data, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)#
- general_methods.filter_tuple(value, search_key1, search_key2)#
Filter a tuple of two elements with two search keywords.
- general_methods.filter_string(value, search_key1)#
Filter a string
- general_methods.recursive_glob(startpath, filepattern)#
Get a list of files matching a pattern, searching recursively from a start path.
Keyword Arguments: startpath – starting path (directory) filepattern – fnmatch-style filename pattern
- general_methods.number_aware_string_key(s)#
Get a key for sorting strings that treats embedded digit sequences as integers.
- general_methods.compute_fft(time_vals, value)#
Compute FFT of input transient data.
- Parameters:
- time_valspandas.Series
- valuepandas.Series
- Returns:
tupleFrequency and Values.
- general_methods.parse_excitation_file(file_name, is_time_domain=True, x_scale=1, y_scale=1, impedance=50, data_format='Power', encoding='utf-8', out_mag='Voltage')#
Parse a csv file and convert data in list that can be applied to Hfss and Hfss3dLayout sources.
- Parameters:
- file_name
str Full name of the input file.
- is_time_domainbool,
optional Either if the input data is Time based or Frequency Based. Frequency based data are Mag/Phase (deg).
- x_scale
float,optional Scaling factor for x axis.
- y_scale
float,optional Scaling factor for y axis.
- data_format
str,optional Either “Power”, “Current” or “Voltage”.
- impedance
float,optional Excitation impedance. Default is 50.
- encoding
str,optional Csv file encoding.
- out_mag
str,optional Output magnitude format. It can be “Voltage” or “Power” depending on Hfss solution.
- file_name
- Returns:
tupleFrequency, magnitude and phase.
- general_methods.tech_to_control_file(tech_path, unit='nm', control_path=None)#
Convert a TECH file to an XML file for use in a GDS or DXF import.
- general_methods.install_with_pip(package_name, package_path=None, upgrade=False, uninstall=False)#
Install a new package using pip. This method is useful for installing a package from the AEDT Console without launching the Python environment.
Warning
Do not execute this function with untrusted function argument, environment variables or pyedb global settings. See the security guide for details.
- Parameters:
- package_name
str Name of the package to install.
- package_path
str,optional Path for the GitHub package to download and install. For example,
git+https://......- upgradebool,
optional Whether to upgrade the package. The default is
False.- uninstallbool,
optional Whether to install the package or uninstall the package.
- package_name
- general_methods.is_linux#
- general_methods.is_windows#
- general_methods.clamp#
- general_methods.rgb_color_codes#
- general_methods.online_help#