diff --git a/ruff.toml b/ruff.toml index 5606bba..db7bffb 100644 --- a/ruff.toml +++ b/ruff.toml @@ -14,12 +14,13 @@ target-version = "py39" select = ["E4", "E7", "E9", "F", "B", "D417"] # extend-select = ["D417"] deactivated by default in case of pep257 codestyle. # see also: https://docs.astral.sh/ruff/rules/undocumented-param/ -ignore = ["B008", "D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "E722", "E731", "F403", "F405", "F841", "B904"] +ignore = ["B008", "D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "E722", "E731", "F403", "F405", "F841", "B904", "F401"] fixable = ["ALL"] unfixable = [] # ignore list in docstring according to numpy codestyles for Dxxx. # http://www.pydocstyle.org/en/5.0.1/error_codes.html#default-conventions # B904: Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +# F401: xxx imported but unused [lint.pydocstyle] convention = "pep257" diff --git a/template_example/template_example.py b/template_example/template_example.py index d6b9004..6b80bc2 100644 --- a/template_example/template_example.py +++ b/template_example/template_example.py @@ -1,11 +1,4 @@ # imports -import numpy as np -import datetime -import sys -import os -from pymongo import MongoClient -from matplotlib import pyplot as plt -import json import transistordatabase as tdb diff --git a/tests/test_tdb_classes.py b/tests/test_tdb_classes.py index 9f48e0b..988b755 100644 --- a/tests/test_tdb_classes.py +++ b/tests/test_tdb_classes.py @@ -355,12 +355,12 @@ def data_setup_for_gecko_exporter(request): def test_export_geckocircuits(data_setup_for_gecko_exporter): """ - Test case for the transistor method to check if the gecko exporter handles the 4 possible cases while exporting a transistor to .scl files + Test case for the transistor method to check if the gecko exporter handles the 4 possible cases while exporting a transistor to .scl files - :param data_setup_for_gecko_exporter: a fixture to arrange the required transistor object and recording the results that obtained during act operation. - The recorded results are used for assertion + :param data_setup_for_gecko_exporter: a fixture to arrange the required transistor object and recording the results that obtained during act operation. + The recorded results are used for assertion - :return: assertion based result + :return: assertion based result """ actual_data = data_setup_for_gecko_exporter expected = {} diff --git a/transistordatabase/checker_functions.py b/transistordatabase/checker_functions.py index ed7a51e..4f8639b 100644 --- a/transistordatabase/checker_functions.py +++ b/transistordatabase/checker_functions.py @@ -168,7 +168,7 @@ def check_keys(keys_to_check: Dict, req_type: str, switch_type: str): def check_duplicates(current_items: List[Dict], item_to_append: Dict) -> bool: """ - A helper method to check if the item being added already exists in the list + Helper method to check if the item being added already exists in the list. :param current_items: list of particular class object converted to dictionaries using which the checks are conducted :type current_items: list(dict) diff --git a/transistordatabase/constants.py b/transistordatabase/constants.py index 6aa4f92..3ff2148 100644 --- a/transistordatabase/constants.py +++ b/transistordatabase/constants.py @@ -1,5 +1,5 @@ # On and Off gate voltages -"""IGBT Module Constants""" +"""IGBT Module Constants.""" IGBT_VG_ON = 15 IGBT_VG_OFF = -15 DIODE_VGS = 0 diff --git a/transistordatabase/data_classes.py b/transistordatabase/data_classes.py index 177abfc..36ba9c9 100644 --- a/transistordatabase/data_classes.py +++ b/transistordatabase/data_classes.py @@ -11,7 +11,7 @@ from transistordatabase.helper_functions import isvalid_dict, get_img_raw_data class GateChargeCurve: - """ A class to hold gate charge characteristics of switch which is added as a optional attribute inside switch class""" + """A class to hold gate charge characteristics of switch which is added as a optional attribute inside switch class""" v_supply: float #: same as drain-to-source (v_ds)/ collector-emitter (v_ce) voltages t_j: float #: junction temperature @@ -21,7 +21,7 @@ class GateChargeCurve: def __init__(self, args): """ - Initialization method for GateChargeCurve object + Initialize a GateChargeCurve object. :param args: arguments to be passed for initialization """ @@ -35,7 +35,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts GateChargeCurve object into dict datatype + Convert a GateChargeCurve object into dict datatype. :return: GateChargeCurve object of dict type :rtype: dict @@ -48,7 +48,7 @@ def convert_to_dict(self) -> dict: def get_plots(self, ax=None): """ - Plots gate charge vs gate source/ gate emitter voltage of switch type mosfet and igbt respectively + Plot the gate charge vs. gate source/ gate emitter voltage of switch type mosfet and igbt respectively. :param ax: figure axes to append the curves @@ -68,7 +68,7 @@ def get_plots(self, ax=None): plt.show() class SOA: - """ A class to hold safe operating area characteristics of transistor type which is added as a optional attribute inside transistor class""" + """A class to hold safe operating area characteristics of transistor type which is added as a optional attribute inside transistor class""" t_c: float | None #: case temperature time_pulse: float | None #: applied pulse duration @@ -101,7 +101,7 @@ def convert_to_dict(self) -> dict: def get_plots(self, ax=None): """ - Plots drain current/reverse diode current vs drain-to-source voltage/diode applied reverse voltage of switch type mosfet/igbt + Plot drain current/reverse diode current vs drain-to-source voltage/diode applied reverse voltage of switch type mosfet/igbt. :param ax: figure axes to append the curves @@ -122,8 +122,9 @@ def get_plots(self, ax=None): class TemperatureDependResistance: """ - class to store temperature dependant resistance curve + Store temperature dependant resistance curve. """ + i_channel: float #: channel current at which the graph is recorded v_g: float #: gate voltage dataset_type: str #: curve datatype, can be either 't_r' or 't_factor'. 't_factor' is used to denote normalized gate curves @@ -146,7 +147,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts TemperatureDependResistance object into dict datatype + Convert a TemperatureDependResistance object into dict datatype. :return: TemperatureDependResistance object of dict type :rtype: dict @@ -159,7 +160,7 @@ def convert_to_dict(self) -> dict: def get_plots(self, ax=None): """ - Plots On resistance vs Junction temperature + Plot the on-resistance vs. Junction temperature. :param ax: figure axes to append the curves @@ -181,8 +182,9 @@ def get_plots(self, ax=None): class EffectiveOutputCapacitance: """ - The class EffectiveOutputCapacitance is used to record energy related or time related output capacitance of the switch. + Record energy related or time related output capacitance of the switch. """ + c_o: float #: Value of the fixed output capacitance. Units in F v_gs: float #: Gate to source voltage of the switch. Units in V v_ds: float #: Drain to source voltage of the switch ex: V_DS = (0-400V) i.e v_ds=400 (max value, min assumed a 0). Units in V @@ -201,7 +203,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts EffectiveOutputCapacitance object into dict datatype + Convert a EffectiveOutputCapacitance object into dict datatype. :return: EffectiveOutputCapacitance object of dict type :rtype: dict @@ -309,11 +311,11 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts SwitchEnergyData object into dict datatype + Convert a SwitchEnergyData object into dict datatype. - :return: SwitchEnergyData object of dict type - :rtype: dict - """ + :return: SwitchEnergyData object of dict type + :rtype: dict + """ d = dict(vars(self)) for att_key in d: if isinstance(d[att_key], np.ndarray): @@ -322,7 +324,7 @@ def convert_to_dict(self) -> dict: def plot_graph(self) -> None: """ - Plots switch / diode energy curve characteristics (either from graph_i_e or graph_r_e dataset) + Plot switch / diode energy curve characteristics (either from graph_i_e or graph_r_e dataset). :return: Respective plots are displayed :rtype: None @@ -370,7 +372,8 @@ class ChannelData: """Contains channel V-I data for either switch or diode. Data is given for only one junction temperature t_j. For different temperatures: Create additional ChannelData-objects and store them as a list in the respective Diode- or Switch-object. - This data can be used to linearize the transistor at a specific operating point """ + This data can be used to linearize the transistor at a specific operating point + """ # # Test condition: Must be given as scalar. Create additional objects for different temperatures. t_j: float #: Junction temperature of switch\diode. (Mandatory key) @@ -381,7 +384,7 @@ class ChannelData: def __init__(self, args): """ - Initialization method for ChannelData object + Initialize a ChannelData object. :param args: arguments to be passed for initialization """ @@ -393,7 +396,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts ChannelData object into dict datatype + Convert a ChannelData object into dict datatype. :return: ChannelData object of dict type :rtype: dict @@ -422,7 +425,9 @@ def plot_graph(self) -> None: class LinearizedModel: """Contains data for a linearized Switch/Diode depending on given operating point. Operating point specified by - t_j, i_channel and (not for all diode types) v_g.""" + t_j, i_channel and (not for all diode types) v_g. + """ + t_j: float #: Junction temperature of diode\switch. Units in K (Mandatory key) v_g: float | None #: Gate voltage of switch or diode. Units in V (Mandatory for Switch, Optional for some Diode types) i_channel: float #: Channel current of diode\switch. Units in A (Mandatory key) @@ -431,7 +436,7 @@ class LinearizedModel: def __init__(self, args): """ - Initialization method for linearizedmodel object + Initialize a linearizedmodel object. :param args: arguments to passed for initialization """ @@ -455,6 +460,7 @@ class VoltageDependentCapacitance: """Contains graph_v_c data for transistor class. Data is given for only one junction temperature t_j. For different temperatures: Create additional VoltageDependentCapacitance-objects and store them as a list in the transistor-object. """ + # # Test condition: Must be given as scalar. Create additional objects for different temperatures. t_j: float #: Junction temperature (Mandatory key) # Dataset: Represented as a 2xm Matrix where row 1 is the voltage and row 2 the capacitance. @@ -474,7 +480,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts VoltageDependentCapacitance object into dict datatype + Convert a VoltageDependentCapacitance object into dict datatype. :return: VoltageDependentCapacitance object of dict type :rtype: dict @@ -487,7 +493,8 @@ def convert_to_dict(self) -> dict: def get_plots(self, ax=None, label=None): """ - Plots the voltage dependant capacitance graph_v_c of the VoltageDependentCapacitance object. + Plot the voltage dependant capacitance graph_v_c of the VoltageDependentCapacitance object. + Also attaches the plot to figure axes for the purpose virtual datasheet if ax argument is specified :param ax: figure axes for making the graph_v_c plot in virtual datasheet @@ -540,7 +547,7 @@ class FosterThermalModel: def __init__(self, args): """ - Initialization method of FosterThermalModel object + Initialize a FosterThermalModel object. :param args: argument to be passed for initialization :type args: dict @@ -566,7 +573,7 @@ def __init__(self, args): def convert_to_dict(self) -> dict: """ - The method converts FosterThermalModel object into dict datatype + Convert a FosterThermalModel object into dict datatype. :return: FosterThermalModel of dict type :rtype: dict @@ -655,11 +662,10 @@ class RawMeasurementData: def __init__(self, args): """ - Initialization method for RawMeasurementData object + Initialize a RawMeasurementData object. :param args: arguments to be passed for initialization """ - self.dataset_type = args.get('dataset_type') self.comment = args.get('dataset_type') if self.dataset_type == 'dpt_u_i' or self.dataset_type == 'dpt_u_i_r': @@ -700,21 +706,20 @@ def convert_to_dict(self) -> dict: def dpt_calculate_energies(self, integration_interval: str, dataset_type: str, energies: str, mode: str): """ - Imports double pulse measurements and calculates switching losses to each given working point. - - [1] options for the integration interval are based on following paper: - Link: https://ieeexplore.ieee.org/document/8515553 + Import double pulse measurements and calculates switching losses to each given working point. - :param integration_interval: calculation standards for switching losses - :type integration_interval: str - :param dataset_type: defines what measurement set should should be calculated - :type dataset_type: str - :param energies: defines which switching energies should be calculated - :type energies: str + [1] options for the integration interval are based on following paper: + Link: https://ieeexplore.ieee.org/document/8515553 + :param integration_interval: calculation standards for switching losses + :type integration_interval: str + :param dataset_type: defines what measurement set should should be calculated + :type dataset_type: str + :param energies: defines which switching energies should be calculated + :type energies: str - """ + """ if integration_interval == 'IEC 60747-9': off_vds_limit = 0.1 off_is_limit = 0.02 diff --git a/transistordatabase/database_manager.py b/transistordatabase/database_manager.py index 44cfffe..8ca420e 100644 --- a/transistordatabase/database_manager.py +++ b/transistordatabase/database_manager.py @@ -17,13 +17,18 @@ from transistordatabase.checker_functions import check_float class OperationMode(Enum): + """Operation mode definitions.""" JSON = "json" MONGODB = "mongodb" class DatabaseManager: - """The DatabaseManager is the base class of the transistordatabase. After creation a operation mode must be set (either JSON or MongoDB) and - then from the DatabaseManager the Transistor data can be acessed. """ + Base class of the transistordatabase. + + After creation, a operation mode must be set (either JSON or MongoDB) and + then from the DatabaseManager the Transistor data can be accessed. + """ + operation_mode: OperationMode tdb_directory: str @@ -106,8 +111,9 @@ def set_operation_mode_mongodb(self, collection: str = "local") -> None: def save_transistor(self, transistor: Transistor, overwrite: bool = None) -> None: """ - The method save the transistor object to the desired database depending on the set operation mode. - Currently receives the execution instructions from update_from_fileexchange(..) + Save the transistor object to the desired database depending on the set operation mode. + + Receives the execution instructions from update_from_fileexchange(..). :param transistor: The transistor object which shall be stored in the database. :type collection: Transistor @@ -205,7 +211,7 @@ def load_transistor(self, transistor_name: str) -> Transistor: def get_transistor_names_list(self) -> List[str]: """ - Returns a list containing every transistor name. + Return a list containing every transistor name. :return: List containing the names. :rtype: List[str] @@ -233,7 +239,7 @@ def get_transistor_names_list(self) -> List[str]: def print_tdb(self, filters: List[str] = None) -> List[str]: """ - Print all transistorelements stored in the local database + Print all transistor elements stored in the local database. :param filters: filters for searching the database, e.g. 'name' or 'type' :type filters: List[str] @@ -338,7 +344,9 @@ def update_from_fileexchange(self, overwrite: bool = True, print("Updated housing types.") def compare_with_fileexchange(self, index_url: str, output_file: str): - """Compares the current database with the given database from the fileexchange. + """ + Compare the current database with the given database from the fileexchange. + Writes the difference in the given output_file. :param index_url: URL to the index file containing links to the Transistors of the Database. @@ -387,7 +395,8 @@ def compare_with_fileexchange(self, index_url: str, output_file: str): json.dump(diff_dict, fd, indent=2) def export_all_datasheets(self, filter_list: list = None): - """A method to export all the available transistor data present in the local mongoDB database + """ + Export all the available transistor data present in the local mongoDB database. :param filter_list: a list of transistor names that needs to be exported in specific :type filter_list: list @@ -419,9 +428,9 @@ def export_all_datasheets(self, filter_list: list = None): def convert_dict_to_transistor_object(self, transistor_dict: dict) -> Transistor: """ - Converts a dictionary to a transistor object. - This is a helper function of the following functions: + Convert a dictionary to a transistor object. + This is a helper function of the following functions: - parallel_transistors() - load() - import_json() @@ -673,12 +682,13 @@ def import_xml_data(files: Dict) -> Transistor: @staticmethod def export_single_transistor_to_json(transistor: Transistor, file_path: str): + """Export a single transistor object to a json file.""" with open(file_path, "w") as fd: json.dump(transistor.convert_to_dict(), fd, indent=2) @staticmethod def dpt_save_data(measurement_dict: Dict) -> Dict: - """Imports double pulse measurements and calculates switching losses to each given working point. + """Import double pulse measurements and calculates switching losses to each given working point. Note: This function brings the measurement data to a dictionary. It does not store the data to the transistor! @@ -710,7 +720,6 @@ def dpt_save_data(measurement_dict: Dict) -> Dict: >>> dpt_energies_dict = tdb.dpt_save_data(dpt_save_dict) """ - if measurement_dict.get('integration_interval') == 'IEC 60747-9': # FETs off_vds_limit = 0.1 diff --git a/transistordatabase/diode.py b/transistordatabase/diode.py index 98b5540..220d6b5 100644 --- a/transistordatabase/diode.py +++ b/transistordatabase/diode.py @@ -1,3 +1,4 @@ +"""Diode class.""" # Python standard libraries from __future__ import annotations from matplotlib import pyplot as plt @@ -12,10 +13,8 @@ from transistordatabase.exceptions import MissingDataError class Diode: - """ - Contains data associated with the (reverse) diode-characteristics of a MOSFET/SiC-MOSFET or IGBT. Can contain - multiple channel- and e_rr- datasets. - """ + """Data associated with the (reverse) diode-characteristics of a MOSFET/SiC-MOSFET or IGBT. Can contain multiple channel- and e_rr- datasets.""" + # Metadata comment: str | None #: Comment if any specified by the user. (Optional key) manufacturer: str | None #: Name of the manufacturer. (Optional key) @@ -28,16 +27,15 @@ class Diode: t_j_max: float #: Diode maximum junction temperature. Units in °C (Mandatory key) soa: List[SOA] | None #: Safe operating area of Diode - def __init__(self, diode_args): + def __init__(self, diode_args: dict): """ - Initialization method of Diode object + Initialize a Diode object. :param diode_args: argument to be passed for initialization + :type diode_args: dict :raises KeyError: Expected during the channel/e_rr instance initialization :raises ValueError: Expected during the channel/e_rr instance initialization - - """ # Current behavior on empty 'foster' dictionary: thermal_foster object is still created but with empty # attributes. @@ -143,12 +141,11 @@ def __init__(self, diode_args): def convert_to_dict(self) -> dict: """ - The method converts Diode object into dict datatype + Convert a Diode object into dict datatype. :return: Diode object of dict type :rtype: dict """ - d = dict(vars(self)) d['thermal_foster'] = self.thermal_foster.convert_to_dict() d['channel'] = [c.convert_to_dict() for c in self.channel] @@ -160,7 +157,8 @@ def convert_to_dict(self) -> dict: def find_next_gate_voltage(self, req_gate_vltgs: dict, export_type: str, check_specific_curves: list = None, diode_loss_dataset_type: str = "graph_i_e"): """ - Finds the diode gate voltage nearest to the specified values from the available gate voltages in curve datasets. + Find the diode gate voltage nearest to the specified values from the available gate voltages in curve datasets. + The diode has only turn-off gate voltage which is the switch turn-on gate voltage :param req_gate_vltgs: the provided gate voltages to find the nearest neighbour to the corresponding key-value pairs @@ -213,7 +211,7 @@ def find_approx_wp(self, t_j: float, v_g: float, normalize_t_to_v: float = 10, switch_energy_dataset_type: str = "graph_i_e") \ -> tuple[ChannelData, SwitchEnergyData]: """ - This function looks for the smallest distance to stored object value and returns this working point + Search for the smallest distance to stored object value and returns this working point. :param t_j: junction temperature :type t_j: float @@ -365,7 +363,7 @@ def plot_energy_data(self, buffer_req: bool = False): def plot_energy_data_r(self, buffer_req: bool = False): """ - Plots all diode energy r-e characteristic curves + Plot all diode energy r-e characteristic curves. :param buffer_req: internally required for generating virtual datasheets :type buffer_req: bool @@ -408,12 +406,12 @@ def plot_energy_data_r(self, buffer_req: bool = False): def plot_soa(self, buffer_req: bool = False): """ - A helper function to plot and convert safe operating region characteristic plots in raw data format. + Helper function to plot and convert safe operating region characteristic plots in raw data format. - :param buffer_req: internally required for generating virtual datasheets + :param buffer_req: internally required for generating virtual datasheets - :return: Respective plots are displayed - """ + :return: Respective plots are displayed + """ if not self.soa: return None fig = plt.figure() @@ -436,7 +434,7 @@ def plot_soa(self, buffer_req: bool = False): def collect_data(self) -> dict: """ - Collects diode data in form of dictionary for generating virtual datasheet + Collect diode data in form of dictionary for generating virtual datasheet. :return: Diode data in form of dictionary :rtype: dict diff --git a/transistordatabase/examples/first_example.py b/transistordatabase/examples/first_example.py index eba6255..304599f 100644 --- a/transistordatabase/examples/first_example.py +++ b/transistordatabase/examples/first_example.py @@ -8,6 +8,7 @@ from transistordatabase.database_manager import DatabaseManager def extract_from_mongodb_to_json(): + """Extract transistors from the mongo-database to single json-files.""" tdb = DatabaseManager() tdb.set_operation_mode_mongodb() transistor_names = tdb.get_transistor_names_list() @@ -24,6 +25,7 @@ def extract_from_mongodb_to_json(): tdb_json.save_transistor(transistor, overwrite=False) def insert_mongodb_from_json(): + """Add transistors from json files to the mongo-db database.""" path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tdb_example") tdb_json = DatabaseManager() tdb_json.set_operation_mode_json(path) @@ -39,17 +41,20 @@ def insert_mongodb_from_json(): tdb_mongodb.save_transistor(transistor) def example_json_database(): + """Example for the json database operation mode (recommended).""" path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tdb_example") tdb_json = DatabaseManager() tdb_json.set_operation_mode_json(path) tdb_json.print_tdb() def example_mongodb_database(): + """Example for the mongo-db operation mode (optional, not recommended).""" tdb_mongodb = DatabaseManager() tdb_mongodb.set_operation_mode_mongodb() tdb_mongodb.print_tdb() def example_update_from_online_database(): + """Update the local database from the online database.""" path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tdb_example_downloaded") db = DatabaseManager() db.set_operation_mode_json(path) diff --git a/transistordatabase/exceptions.py b/transistordatabase/exceptions.py index ba86fbd..68da341 100644 --- a/transistordatabase/exceptions.py +++ b/transistordatabase/exceptions.py @@ -1,5 +1,6 @@ +"""Handling of exceptions.""" class MissingDataError(Exception): - """Custom exception class for plecs_exporter""" + """Custom exception class for plecs_exporter.""" # define the error codes & messages here em = {1101: "Switch conduction channel information is missing, cannot export to", diff --git a/transistordatabase/exporter.py b/transistordatabase/exporter.py index c9808bb..6e0dcff 100644 --- a/transistordatabase/exporter.py +++ b/transistordatabase/exporter.py @@ -1,10 +1,11 @@ +"""Exporter functions.""" # Python standard libraries from typing import Dict import numpy as np def dict2matlab(input_dict: Dict) -> Dict: """ - Cleans a python dict and makes it compatible with matlab + Clean a python dict and make it compatible with matlab. Dict must be cleaned from 'None's to np.nan (= NaN in Matlab) see https://stackoverflow.com/questions/35985923/replace-none-in-a-python-dictionary diff --git a/transistordatabase/gui/buck_boost_converter_functions.py b/transistordatabase/gui/buck_boost_converter_functions.py index bfc0055..2ae08cc 100644 --- a/transistordatabase/gui/buck_boost_converter_functions.py +++ b/transistordatabase/gui/buck_boost_converter_functions.py @@ -400,7 +400,6 @@ def f_m_p_on1(zeta, v_in, v_out, p_out, v_g_on1, r_g_on1, frequency, transistor1 :param transistor2: transistor object for transistor1 :return: m_p_on1: turn-on switching losses transistor1 """ - channel = f_m_calc_channel(f_m_i_peak(zeta, v_in, v_out, p_out, v_g_on1, transistor1, transistor2), v_g_on1, transistor1, transistor2) v_channel1 = channel[0] v_channel2 = channel[1] @@ -452,7 +451,6 @@ def f_m_p_off1(zeta, v_in, v_out, p_out, v_g_on1, r_g_off1, frequency, transisto :param transistor2: transistor object for transistor1 :return: m_p_off1: turn-off switching losses transistor1 """ - # turn-off current for transistor1 is i_peak for CCM and DCM m_i_off1 = f_m_i_peak(zeta, v_in, v_out, p_out, v_g_on1, transistor1, transistor2) diff --git a/transistordatabase/gui/comparison_tools_functions.py b/transistordatabase/gui/comparison_tools_functions.py index 0dd779f..6067666 100644 --- a/transistordatabase/gui/comparison_tools_functions.py +++ b/transistordatabase/gui/comparison_tools_functions.py @@ -56,7 +56,6 @@ def plot_all_energy_data(transistor, matplotlibwidget, switch_diode): :return: None """ - annotations_list = [] def clicked(event): @@ -162,7 +161,6 @@ def plot_all_energy_data_r_g(transistor, matplotlibwidget, switch_diode): :param switch_diode: "switch" or "diode" :return: None """ - annotations_list = [] def clicked(event): @@ -269,7 +267,6 @@ def plot_all_channel_data(transistor, matplotlibwidget, switch_diode): :param switch_diode: "switch" or "diode" :return: None """ - annotations_list = [] def clicked(event): @@ -416,7 +413,6 @@ def plot_e_on(transistor1, transistor2, transistor3, matplotlibwidget, t_j1, t_j :return: None """ - annotations_list = [] def clicked(event): @@ -556,7 +552,6 @@ def plot_e_off(transistor1, transistor2, transistor3, matplotlibwidget, t_j1, t_ :return: None """ - annotations_list = [] def clicked(event): @@ -699,7 +694,6 @@ def plot_e_rr(transistor1, transistor2, transistor3, matplotlibwidget, t_j1, t_j :return: None """ - annotations_list = [] def clicked(event): @@ -833,7 +827,6 @@ def plot_channel(transistor1, transistor2, transistor3, matplotlibwidget, t_j1, :return: None """ - annotations_list = [] def clicked(event): @@ -1000,7 +993,6 @@ def plot_v_eoss(transistor1, transistor2, transistor3, matplotlibwidget): :param matplotlibwidget: matplotlibwidget object :return: """ - annotations_list = [] def clicked(event): @@ -1046,7 +1038,6 @@ def plot_v_qoss(transistor1, transistor2, transistor3, matplotlibwidget): :return: """ - annotations_list = [] def clicked(event): diff --git a/transistordatabase/gui/gui.py b/transistordatabase/gui/gui.py index 028e269..1657221 100644 --- a/transistordatabase/gui/gui.py +++ b/transistordatabase/gui/gui.py @@ -741,7 +741,6 @@ def email_add_transistor_to_transistordatabase_file_exchange(self): Email workflow to start a request for adding a new transistor to the transistordatabase file exchange. This routine will open the mailprogram with predefined adresses. The .json file needs to be added manually. """ - transistor = self.get_marked_transistor() transistor.export_json() @@ -2522,7 +2521,6 @@ def create_transistor(self): :return: transistor object """ - # TRANSISTOR PARAMETERS # try: @@ -3961,14 +3959,12 @@ def compare_create_plot(self, widget_plot: QWidget, matplotlibwidget, comboBox_p """ Adds a Matplotlib figure to a QWidget and creates a plot based on all the possible inputs and selections - :param widget_compare_plot: widget for the matplotlib figure :type widget_compare_plot: QWidget :param matplotlibwidget_compare: matplotlib figure :param comboBox_compare_plot: comboBox to choose plot :return: None """ - matplotlibwidget.axis.clear() self.layout = QVBoxLayout(widget_plot) self.layout.addWidget(matplotlibwidget) @@ -4485,7 +4481,6 @@ def comboBox_topology_topology_changed(self): :return: None """ - if self.comboBox_topology_topology.currentText() == "Buck-Converter": self.label_picture_topology.setMaximumSize(QtCore.QSize(450, 115)) self.label_picture_topology.setPixmap(QtGui.QPixmap(resource_path("buck_converter_schematic.png"))) @@ -4551,7 +4546,6 @@ def comboBox_topology_plot_x_axis_changed(self, comboBox_topology_plot_x_axis, c :param comboBox_topology_plot_line_contour: ComboBox to choose between line-plot and contour-plot :return: None """ - items_comboBox_y_z_axis = ["RMS Current Transistor1 [A]", "RMS Current Diode Transistor2 [A]", "Mean Current Transistor1 [A]", @@ -4770,7 +4764,7 @@ def topology_create_plot(self, widget_topology_plot, matplotlibwidget, comboBox_ comboBox_topology_plot_y_axis, comboBox_topology_plot_z_axis, comboBox_topology_line_contour, converter): """ - Adds a Matplotlib figure to a QWidget and creates a plot based on all the possible inputs and selections using + Add a Matplotlib figure to a QWidget and creates a plot based on all the possible inputs and selections using the calculation-functions from buck_converter_functions.py, boost_converter_functions.py and buck_boost_converter_functions.py. :param widget_topology_plot: widget for the Matplotlib figure @@ -4782,7 +4776,6 @@ def topology_create_plot(self, widget_topology_plot, matplotlibwidget, comboBox_ :param converter: "buck_converter", "boost_converter" or "buck_boost_converter" :return: None """ - annotations_list = [] def clicked(event): @@ -5360,7 +5353,7 @@ def topology_update_plots(self): def get_converter(self): """ - Returns a converter_functions python file depending on which converter is currently selected + Return a converter_functions python file depending on which converter is currently selected. :return: converter_functions python file """ @@ -5375,7 +5368,7 @@ def get_converter(self): def topology_pop_out_plot1(self): """ - Opens new window with plot1 from Topology Calculator + Open a new window with plot1 from Topology Calculator. :return: """ @@ -5706,7 +5699,6 @@ def button_cancel_pressed(self): :return: None """ - MainWindow.button_create_transistor_create.setDisabled(True) self.close() @@ -5854,6 +5846,7 @@ class EmittingStream(QtCore.QObject): :return: None """ + text_written = QtCore.pyqtSignal(str) def write(self, text): diff --git a/transistordatabase/helper_functions.py b/transistordatabase/helper_functions.py index fdf69a5..137f7f5 100644 --- a/transistordatabase/helper_functions.py +++ b/transistordatabase/helper_functions.py @@ -23,7 +23,7 @@ # ==== Validation functions ==== def isvalid_transistor_name(transistor_name): - """Checks if the given transistor name is valid.""" + """Check if the given transistor name is valid.""" return False if re.match(transistor_name_regex, transistor_name) is None else True def isvalid_dict(dataset_dict: Dict, dict_type: str) -> bool: @@ -45,7 +45,6 @@ def isvalid_dict(dataset_dict: Dict, dict_type: str) -> bool: .. todo:: Error if given key is not used? """ - supported_types = ['MOSFET', 'IGBT', 'SiC-MOSFET', 'GaN-Transistor'] instructions = { 'Transistor': { @@ -237,7 +236,7 @@ def isvalid_dict(dataset_dict: Dict, dict_type: str) -> bool: def matlab_compatibility_test(transistor, attribute): """ - checks attribute for occurrences of None an replace it with np.nan + Check attribute for occurrences of None an replace it with np.nan. .. todo: This function might can be replaced by dict_clean() @@ -264,7 +263,7 @@ def matlab_compatibility_test(transistor, attribute): # ==== Input/Output ==== def get_xml_data(file: str) -> Dict: """ - A helper function to import_xml_data method to extract the xml file data i.e turn on/off energies, channel data, foster thermal data. + Helper function to import_xml_data method to extract the xml file data i.e turn on/off energies, channel data, foster thermal data. :param file: name of the xml file to be read :type file: str @@ -600,7 +599,7 @@ def get_loss_curves(loss_data: List, plecs_holder: Dict, loss_type: str, v_g: in def get_channel_data(channel_data: List, plecs_holder: Dict, v_on: int, is_diode: bool, has_body_diode: bool) -> Dict: """ - A helper method to extract channel data of switch/diode for plecs exporter. Called internally by get_curve_data() for using plecs exporter feature. + Helper method to extract channel data of switch/diode for plecs exporter. Called internally by get_curve_data() for using plecs exporter feature. :param channel_data: channel data taken from transistor class switch/diode object :type channel_data: list @@ -661,7 +660,8 @@ def gen_exp_func(order: int): def merge_curve(curve: np.array, curve_detail: np.array) -> np.array: """ - Merges two equal curves, one of which contains an enlarged section of the first curve. + Merge two equal curves, one of which contains an enlarged section of the first curve. + Use case is the merging of capacity curves, here often two curves (normal and zoom) are given in the data sheets. :param curve: full curve @@ -680,7 +680,6 @@ def merge_curve(curve: np.array, curve_detail: np.array) -> np.array: >>> c_oss_merged = tdb.merge_curve(c_oss_normal, c_oss_detail) """ - # find out max(x) from detailed curve curve_detail_max_x = max(curve_detail[0]) @@ -696,8 +695,7 @@ def merge_curve(curve: np.array, curve_detail: np.array) -> np.array: def r_g_max_rapid_channel_turn_off(v_gsth: float, c_ds: float, c_gd: float, i_off: float | List[float], v_driver_off: float) -> float: """ - Calculates the maximum gate resistor to achieve no turn-off losses when working with MOSFETs - 'rapid channel turn-off' (rcto) + Calculate the maximum gate resistor to achieve no turn-off losses when working with MOSFETs 'rapid channel turn-off' (rcto). :param v_gsth: gate threshold voltage :type v_gsth: float @@ -724,16 +722,16 @@ def r_g_max_rapid_channel_turn_off(v_gsth: float, c_ds: float, c_gd: float, i_of return (v_gsth - v_driver_off) / i_off * (1 + c_ds / c_gd) def compare_list(parameter: List): - """ - check through the list of value for odd one out. - """ + """Check through the list of value for odd one out.""" for i, j in enumerate(parameter[:-1]): if j != parameter[i + 1]: return False return True def get_copy_transistor_name(current_name: str) -> str: - """Returns the current name but with an index at the end similar to windows copies. + """ + Return the current name but with an index at the end similar to windows copies. + '{current_name} (i)' """ result = re.match(transistor_name_regex, current_name) diff --git a/transistordatabase/mongodb_handling.py b/transistordatabase/mongodb_handling.py index 82102f6..cd239df 100644 --- a/transistordatabase/mongodb_handling.py +++ b/transistordatabase/mongodb_handling.py @@ -1,10 +1,11 @@ +"""Hanle with the mongodb database.""" # Third party libraries import pymongo from pymongo.errors import ServerSelectionTimeoutError def connect_tdb(host: str): """ - A method for establishing connection with transistordatabase_exchange. + Establish a connection with transistordatabase_exchange. :param host: "local" is specified by default, other cases need to be investigated :type host: str @@ -19,7 +20,8 @@ def connect_tdb(host: str): def connect_local_tdb(): """ - A method for establishing connection with transistordatabase_exchange. + Establish a connection with transistordatabase_exchange. + Internally used by - update_from_fileexchange() method to sync the local with transistordatabase_File_Exchange @@ -44,7 +46,7 @@ def connect_local_tdb(): def drop_local_tdb(): """ - Drop the local database + Drop the local database. :raises pymongo.errors.ServerSelectionTimeoutError: if there is no mongoDB instance running """ diff --git a/transistordatabase/switch.py b/transistordatabase/switch.py index 2eca694..4b5429e 100644 --- a/transistordatabase/switch.py +++ b/transistordatabase/switch.py @@ -1,3 +1,4 @@ +"""Switch class.""" # Python standard libraries from __future__ import annotations from matplotlib import pyplot as plt @@ -14,7 +15,9 @@ class Switch: """Contains data associated with the switching-characteristics of a MOSFET/SiC-MOSFET or IGBT. Can contain multiple - channel-, e_on- and e_off-datasets. """ + channel-, e_on- and e_off-datasets. + """ + # Metadata comment: str | None #: Comment if any to be specified (Optional key) manufacturer: str | None #: Name of the manufacturer (Optional key) @@ -34,7 +37,7 @@ class Switch: def __init__(self, switch_args): """ - Initialization method of Switch object + Initializes the Switch object. :param switch_args: argument to be passed for initialization @@ -245,7 +248,7 @@ def __init__(self, switch_args): def convert_to_dict(self) -> Dict: """ - The method converts Switch object into dict datatype + Convert Switch object into dict datatype. :return: Switch object of dict type :rtype: dict @@ -267,6 +270,7 @@ def find_next_gate_voltage(self, req_gate_vltgs: Dict, export_type: str, check_s switch_loss_dataset_type: str = "graph_i_e") -> Dict: """ Finds the switch gate voltage nearest to the specified values from the available gate voltages in curve datasets. + Applicable to either plecs exporter or gecko exporter :param req_gate_vltgs: the provided gate voltages for find the nearest neighbour to the corresponding key-value pairs @@ -343,7 +347,7 @@ def find_approx_wp(self, t_j: float, v_g: float, normalize_t_to_v: float = 10, switch_energy_dataset_type: str = "graph_i_e") \ -> Tuple[ChannelData, SwitchEnergyData, SwitchEnergyData]: """ - This function looks for the smallest distance to stored object value and returns this working point + Search for the smallest distance to stored object value and returns this working point. :param t_j: junction temperature :type t_j: float @@ -392,7 +396,7 @@ def find_approx_wp(self, t_j: float, v_g: float, normalize_t_to_v: float = 10, def plot_channel_data_vge(self, gatevoltage: float) -> None: """ - Plot channel data with a chosen gate-voltage + Plot channel data with a chosen gate-voltage. :param gatevoltage: gatevoltage at which the channel curves are selected and plotted :type gatevoltage: float @@ -415,7 +419,7 @@ def plot_channel_data_vge(self, gatevoltage: float) -> None: def plot_channel_data_temp(self, temperature: float) -> None: """ - Plot channel data with chosen temperature + Plot channel data with chosen temperature. :param temperature: junction temperature at which the channel curves are selected and plotted :param temperature: float @@ -423,7 +427,6 @@ def plot_channel_data_temp(self, temperature: float) -> None: :return: Respective plots are displayed :rtype: None """ - plt.figure() for i_channel in np.array(range(0, len(self.channel))): if self.channel[i_channel].t_j == temperature: @@ -439,14 +442,13 @@ def plot_channel_data_temp(self, temperature: float) -> None: def plot_all_channel_data(self, buffer_req: bool = False): """ - Plot all switch channel characteristic curves + Plot all switch channel characteristic curves. :param buffer_req: internally required for generating virtual datasheets :param buffer_req: bool :return: Respective plots are displayed """ - # ToDo: only 12(?) colors available. Change linestyle for more curves. categorize_with_temp_plots = {} categorize_with_vgs_plots = {} @@ -510,7 +512,7 @@ def plot_all_channel_data(self, buffer_req: bool = False): def plot_energy_data(self, buffer_req: bool = False): """ - Plots all switch energy i-e characteristic curves which are extracted from the manufacturer datasheet + Plot all switch energy i-e characteristic curves which are extracted from the manufacturer datasheet. :param buffer_req: internally required for generating virtual datasheets :param buffer_req: bool @@ -556,7 +558,7 @@ def plot_energy_data(self, buffer_req: bool = False): def plot_energy_data_r(self, buffer_req: bool = False): """ - Plots all switch energy r-e characteristic curves + Plot all switch energy r-e characteristic curves. :param buffer_req: internally required for generating virtual datasheets :param buffer_req: bool @@ -669,12 +671,12 @@ def plot_all_charge_curves(self, buffer_req: bool = False): def plot_soa(self, buffer_req: bool = False): """ - A helper function to plot and convert safe operating region characteristic plots in raw data format. + A helper function to plot and convert safe operating region characteristic plots in raw data format. - :param buffer_req: internally required for generating virtual datasheets + :param buffer_req: internally required for generating virtual datasheets - :return: Respective plots are displayed - """ + :return: Respective plots are displayed + """ if not self.soa: return None fig = plt.figure() diff --git a/transistordatabase/transistor.py b/transistordatabase/transistor.py index 5b51db0..5cbc781 100644 --- a/transistordatabase/transistor.py +++ b/transistordatabase/transistor.py @@ -42,6 +42,7 @@ class Transistor: - Groups data of all other classes for a single transistor. Methods are specified in such a way that only user-interaction with this class is necessary - Documentation on how to add or extract a transistor-object to/from the database can be found in """ + # ToDo: Add database id as attribute _id: int #: ID of the object being created. (Automatic key) Only Used in MongoDB name: str #: Name of the transistor. Choose as specific as possible. (Mandatory key) @@ -214,7 +215,8 @@ def __init__(self, transistor_args: dict, switch_args: dict, diode_args: dict, p raise def convert_raw_measurement_data(self, input: List | Dict, name: str = None) -> List[RawMeasurementData]: - """Converts input (list or dict) to list of raw_measurement_data + """ + Convert input (list or dict) to list of raw_measurement_data. :param input: Input data :type input: List | Dict @@ -249,7 +251,8 @@ def convert_raw_measurement_data(self, input: List | Dict, name: str = None) -> return output_list def convert_voltage_dependent_capacitance(self, input: List | Dict, name: str = None) -> List[VoltageDependentCapacitance]: - """Converts input (list or dict) to list of raw_measurement_data + """ + Convert input (list or dict) to list of raw_measurement_data. :param input: Input data :type input: List | Dict @@ -339,8 +342,9 @@ def convert_to_dict(self) -> Dict: def update_wp(self, t_j: float, v_g: float, i_channel: float, switch_or_diode: str = "both", normalize_t_to_v=10) -> None: """ - Fills the .wp-class, a temporary storage for self-written user-programs - Searches for the input values and fills the .wp-class with data next to this points + Fill the .wp-class, a temporary storage for self-written user-programs. + + Searches for the input values and fills the .wp-class with data next to this points. :param t_j: junction temperature :type t_j: float @@ -431,9 +435,9 @@ def init_switch_channel_matrix(self): def quickstart_wp(self) -> None: """ - Function to fill out the .wp-class by just one command 'quickstart_wp()'. - Uses typical working points + Fill out the .wp-class by just one command 'quickstart_wp()'. + Uses typical working points - channel linearization next to v_g = 15V, i_cont and t_j = t_j_abs_max - 25 degree - switching loss curves next to t_j = t_j_abs_max - 25 degree @@ -456,7 +460,7 @@ def calc_v_eoss(self) -> np.array: def calc_v_qoss(self) -> np.array: """ - Calculates q_oss stored in c_oss depend on the voltage. Uses transistor.c_oss[0].graph_v_coss + Calculate q_oss stored in c_oss depend on the voltage. Uses transistor.c_oss[0].graph_v_coss. :return: q_oss numpy array :rtype: np.array @@ -488,7 +492,7 @@ def plot_v_eoss(self, buffer_req: bool = False): def plot_v_qoss(self, buffer_req: bool = False): """ - Plots v_qoss with method calc_v_qoss + Plot v_qoss with method calc_v_qoss. :param buffer_req: Internally required for generating virtual datasheets :type buffer_req: bool @@ -509,7 +513,7 @@ def plot_v_qoss(self, buffer_req: bool = False): def get_object_v_i(self, switch_or_diode: str, t_j: float, v_g: float) -> List: """ - Used for getting a channel curve including boundary conditions + Get a channel curve including boundary conditions. :param switch_or_diode: 'switch' or 'diode' :type switch_or_diode: float @@ -572,7 +576,7 @@ def get_object_v_i(self, switch_or_diode: str, t_j: float, v_g: float) -> List: def get_object_i_e(self, e_on_off_rr: str, t_j: float, v_g: float, v_supply: float, r_g: float) -> List: """ - Function to get the loss graphs out of the transistor class + Get the loss graphs out of the transistor class. :param e_on_off_rr: can be the following: 'e_on', 'e_off' or 'e_rr' :type e_on_off_rr: str @@ -637,7 +641,7 @@ def get_object_i_e(self, e_on_off_rr: str, t_j: float, v_g: float, v_supply: flo def get_object_i_e_simplified(self, e_on_off_rr: str, t_j: float): """ - Function to get the loss graphs out of the transistor class, simplified version + Get the loss graphs out of the transistor class, simplified version. :param e_on_off_rr: can be the following: 'e_on', 'e_off' or 'e_rr' :type e_on_off_rr: str @@ -693,7 +697,8 @@ def get_object_i_e_simplified(self, e_on_off_rr: str, t_j: float): def get_object_r_e_simplified(self, e_on_off_rr: str, t_j: float, v_g: float, v_supply: float, normalize_t_to_v: float) -> List: """ - Function to get the loss graphs out of the transistor class, simplified version + Get the loss graphs out of the transistor class, simplified version. + :param e_on_off_rr: can be the following: 'e_on', 'e_off' or 'e_rr' :type e_on_off_rr: str :param t_j: junction temperature @@ -745,6 +750,7 @@ def calc_object_i_e(self, e_on_off_rr: str, r_g: float, t_j: float, v_supply: fl -> SwitchEnergyData: """ Calculate loss curves for other gate resistor than the standard one. + This function uses i_e loss curve in combination with r_e loss curve, to calculate a new i_e loss curve for a chosen gate resistor. Also voltage correction is implemented (e.g. half voltage compared to datasheet means half losses) @@ -801,7 +807,7 @@ def calc_object_i_e(self, e_on_off_rr: str, r_g: float, t_j: float, v_supply: fl def calc_i_e_curve_using_r_e_curve(self, i_e_object: SwitchEnergyData, r_e_object: SwitchEnergyData, r_g: float, v_supply_chosen: float) -> np.array: """ - Calculates the loss energy curve at the provided gate resistance value based on the r_e_graph data + Calculate the loss energy curve at the provided gate resistance value based on the r_e_graph data. :param i_e_object: selected loss energy curve object of datatype = 'graph_i_e' :type i_e_object: Transistor.SwitchEnergyData @@ -856,7 +862,6 @@ def calc_lin_channel(self, t_j: float, v_g: float, i_channel: float, switch_or_d - Error handling - Unittest for this method """ - # in case of failure, return None v_channel = None r_channel = None @@ -1029,7 +1034,8 @@ def upper_limit(x): def compare_channel_linearized(self, i_channel: float, t_j: float = 150, v_g: float = 15) -> None: """ - Shows channel plots for switch and diode comparing the linearized graph and the original graph. + Show channel plots for switch and diode comparing the linearized graph and the original graph. + This function searches for the closest available curves for given arguments t_j and v_g :param i_channel: current to linearize the channel @@ -1042,7 +1048,6 @@ def compare_channel_linearized(self, i_channel: float, t_j: float = 150, v_g: fl :return: Plot, showing original channel data and linearized channel data :rtype: None """ - # search for closest objects switch_channel, eon, eoff = self.switch.find_approx_wp(t_j, v_g, normalize_t_to_v=10, switch_energy_dataset_type="graph_i_e") diode_channel, err = self.diode.find_approx_wp(t_j, v_g, normalize_t_to_v=10, @@ -1093,7 +1098,7 @@ def compare_channel_linearized(self, i_channel: float, t_j: float = 150, v_g: fl def raw_measurement_data_plots(self) -> list: """ - Takes the raw measurement data attribute and traverses through + Take the raw measurement data attribute and traverses through the list for each present method and loads the ids and vds data for in 3 separate lists. The three lists are used as input for plot_curves function which returns the combined and scaled plots for the data. The combined plots are returned in img bytes format @@ -1135,9 +1140,9 @@ def raw_measurement_data_plots(self) -> list: return plots_with_conditions def plot_curves(self, time_array, vds_values, ids_values, buffer_req: bool = False): - - ''' - Takes three lists of time, vds and id values and generates a combined plot. + """ + Take three lists of time, vds and id values and generates a combined plot. + Calls the get_img_raw_data function for returning img form of the plot and returns the images. :param time_array : time values in the raw measurement data @@ -1145,7 +1150,7 @@ def plot_curves(self, time_array, vds_values, ids_values, buffer_req: bool = Fal :param id_values : id values in the raw measurement data return image form of the plot rtype decoded raw image data to utf-8 - ''' + """ color = 'tab:blue' plt.xlabel('time (s)') plt.ylabel('Voltage (V)', color=color) @@ -1162,7 +1167,7 @@ def plot_curves(self, time_array, vds_values, ids_values, buffer_req: bool = Fal def export_datasheet(self, build_collection=False) -> str | None: """ - Generates and exports the virtual datasheet in form of pdf + Generate and export the virtual datasheet in form of a pdf-file. :return: pdf file is created in the current working directory :rtype: None @@ -1224,8 +1229,9 @@ def export_datasheet(self, build_collection=False) -> str | None: def export_simulink_loss_model(self, r_g_on: float = None, r_g_off: float = None, v_supply: float = None, normalize_t_to_v: float = 10) -> None: """ - Exports a simulation model for simulink inverter loss models, - see https://de.mathworks.com/help/physmod/sps/ug/loss-calculation-in-a-three-phase-3-level-inverter.html + Export a simulation model for simulink inverter loss models. + + See also: https://de.mathworks.com/help/physmod/sps/ug/loss-calculation-in-a-three-phase-3-level-inverter.html :param r_g_on: gate turn on resistance, optional :type r_g_on: float @@ -1414,7 +1420,7 @@ def export_simulink_loss_model(self, r_g_on: float = None, r_g_off: float = None def export_matlab(self) -> None: """ - Exports a transistor dictionary to a matlab dictionary + Export a transistor dictionary to a matlab dictionary. :return: File stored in current working path :rtype: None @@ -1439,7 +1445,7 @@ def export_matlab(self) -> None: def collect_i_e_and_r_e_combination(self, switch_type: str, loss_type: str) -> Tuple[List, List]: """ - A function to gather the i_e and r_e graph combinations from the available energy curves which are further used in gecko circuit exporter function + Gather the i_e and r_e graph combinations from the available energy curves which are further used in gecko circuit exporter function. :param switch_type: argument to specify if either 'switch' or 'diode' energy curve to be considered :type switch_type: str @@ -1474,7 +1480,7 @@ def collect_i_e_and_r_e_combination(self, switch_type: str, loss_type: str) -> T def export_geckocircuits(self, recheck: bool = True, v_supply: float = None, v_g_on: float = None, v_g_off: float = None, r_g_on: float = None, r_g_off: float = None) -> None: """ - Export transistor data to GeckoCIRCUITS + Export transistor data to GeckoCIRCUITS. :param recheck: Default to set to true, to enable the neighbouring select feature of the exporter :type recheck: bool @@ -1500,7 +1506,6 @@ def export_geckocircuits(self, recheck: bool = True, v_supply: float = None, v_g .. note:: These .scl files are then imported as semiconductor characteristics inside geckoCIRCUITS """ - # programming notes # exporting the diode: # diode off losses: @@ -1788,7 +1793,7 @@ def export_geckocircuits(self, recheck: bool = True, v_supply: float = None, v_g def export_plecs(self, recheck: bool = True, gate_voltages=None) -> None: """ - Generates and exports the switch and diode .xmls files to be imported into plecs simulator + Generate and export the switch and diode .xmls files to be imported into plecs simulator. :param recheck: enables the selection of gate voltages near to the provided values if not found :type recheck: bool @@ -1837,9 +1842,10 @@ def export_plecs(self, recheck: bool = True, gate_voltages=None) -> None: class WP: """ - The WP class is intended for user calculations in Python. It is used to access transistor data in user-written programs. - It allows the user to linearize the channel and store the result in transistor.wp. Switching loss curves can be stored - for specific boundary conditions, so that the same variable is always accessed in the self-written program, regardless of the transistor. + WP class is intended for user calculations in Python. It is used to access transistor data in user-written programs. + + It allows the user to linearize the channel and store the result in transistor.wp. Switching loss curves can be stored + for specific boundary conditions, so that the same variable is always accessed in the self-written program, regardless of the transistor. The class WP... @@ -1847,6 +1853,7 @@ class WP: - Is always exported as None to .json or to the database. - Is a temporary workspace. """ + # type hints switch_v_channel: float | None switch_r_channel: float | None @@ -1879,7 +1886,9 @@ def __init__(self): def validate_transistor(self) -> Dict: """ - A helper function for plecs exporter. Checks if curve characteristics and thermal network parameters of both switch and diode to be None or empty + Check the transistor object if it is valid for plecs exporter. + + Checks if curve characteristics and thermal network parameters of both switch and diode to be None or empty Appends corresponding codes for further verification in get_curve_data(..) method .. todo: May rename to 'plecs_validate_transistor' @@ -2072,7 +2081,7 @@ def get_curve_data(self, channel_recheck: bool, gate_voltages: List) -> Dict: def add_dpt_measurement(self, measurement_data): """ - This method adds new measurement data to the transistor object. + Add new measurement data to the transistor object. :param measurement_data: Dict of data you want to add to given attribute. :type measurement_data: dict @@ -2139,7 +2148,7 @@ def add_dpt_measurement(self, measurement_data): def add_soa_data(self, soa_data: Union[Dict, List], switch_type: str, clear: bool = False): """ - A transistor method to add the SOA class object to the loaded transistor.switch.soa or transistor.diode.soa attribute. + Add the SOA class object to the loaded transistor.switch.soa or transistor.diode.soa attribute. :param soa_data: argument represents the soa dictionaries objects that needs to be added to transistor switch or diode object :type soa_data: dict or list @@ -2204,7 +2213,8 @@ def add_soa_data(self, soa_data: Union[Dict, List], switch_type: str, clear: boo def add_gate_charge_data(self, charge_data: Union[Dict, List], clear: bool = False): """ - A transistor method to add the GateChargeCurve class objects to the loaded transistor.switch.charge_curve attribute. + Add the GateChargeCurve class objects to the loaded transistor.switch.charge_curve attribute. + .. note:: Transistor object must be loaded first before calling this method :param charge_data: argument represents the gatechargecurve dictionaries objects that needs to be added to transistor object @@ -2256,7 +2266,8 @@ def add_gate_charge_data(self, charge_data: Union[Dict, List], clear: bool = Fal def add_temp_depend_resistor_data(self, r_channel_data: Union[Dict, List], clear: bool = False): """ - A transistor method to add the TemperatureDependResistance class objects to the loaded transistor.switch.r_channel_th attribute. + Add the TemperatureDependResistance class objects to the loaded transistor.switch.r_channel_th attribute. + .. note:: Transistor object must be loaded first before calling this method :param r_channel_data: argument represents the TemperatureDependResistance dictionaries objects that needs @@ -2366,7 +2377,7 @@ def compare_measurement_datasheet(self): def attach_units(trans: Dict, devices: Dict): """ - The function will attach units for the virtual datasheet parameters when a call is made in export_datasheet() method. + Attach units for the virtual datasheet parameters when a call is made in export_datasheet() method. :param trans: pdf data which contains the transistor related generic information :type trans: dict