MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / Cadence2traces

Function Cadence2traces

SLiCAP/SLiCAPplots.py:1702–1825  ·  view source on GitHub ↗

Generates a dictionary with traces (key = label, value = trace object) from data from a csv file generated in Cadence. :param csvFile: name of the csv file (in the ini.csv_path directory) :type csvFile: str :param absx: if 'True', it applies the absolute (abs) function to the in

(csvFile, absx = False, logx = False, absy = False, logy = False, selection=['all'], assignID=True)

Source from the content-addressed store, hash-verified

1700 return traceDict
1701
1702def Cadence2traces(csvFile, absx = False, logx = False, absy = False, logy = False, selection=['all'], assignID=True):
1703 """
1704 Generates a dictionary with traces (key = label, value = trace object) from
1705 data from a csv file generated in Cadence.
1706 :param csvFile: name of the csv file (in the ini.csv_path directory)
1707 :type csvFile: str
1708 :param absx: if 'True', it applies the absolute (abs) function to the indpendent variable data (xData)
1709 :type absx: bool
1710 :param logx: if 'True', it applies the logarithm in base 10 (log10) function to the independent variable data (xData)
1711 :type logx: bool
1712 :param absy: if 'True', it applies the absolute (abs) function to the dependent variable data (yData)
1713 :type absy: bool
1714 :param logy: if 'True', it applies the logarithm in base 10 (log10) function to the dependent variable data (yData)
1715 :type logy: bool
1716 :param selection: if:
1717
1718 - selection=['all']: Selects all traces in the dictionary and does not replace any label
1719 - selection=['all',("Var1","Variable"),("Var2","Variable2")]: selects all traces and replaces all character strings mentioned in the first element of the tuples (e.g. "Var1" and "Var2") with the strings in the second element of the tuples ("Variable" and "Variable2").
1720 - selection=[('Var1 (SweepVar=1e-06) Y',"New Label"),('Var2 (SweepVar=1e-06) Y',"")]: selects only the traces that are explicitly mentioned in the first element of the tuple (e.g. 'Var1 (SweepVar=1e-06) Y' and 'Var2 (SweepVar=1e-06) Y') and replaces its label with the second element of the tuple unless it is "".
1721
1722 :type selection: list of tuples
1723 :param assignID: if 'True', it generates an ID for each processed trace to avoid overwriting when merging dictionaries.
1724 :type assignID: bool
1725 :return: dictionary with key-value pairs:
1726 - key: *str*: label of the trace
1727 - value: *SLiCAPplots.trace* trace object
1728
1729 :rtype: dict
1730 """
1731 try:
1732 f = open(ini.csv_path + csvFile)
1733 lines = f.readlines()
1734 f.close()
1735 except:
1736 print('Error: could not find CSV trace data:', ini.csv_path + csvFile)
1737 return {}
1738 traceDict = {}
1739 labels = []
1740 if assignID:
1741 ID_dict=" (ID:"+str(randint(0,100)) + ")"
1742 else:
1743 ID_dict=""
1744 last_raw_x=lines[-1].split(',')[1::2]
1745 for element in last_raw_x:
1746 try:
1747 limiter=eval(element)
1748 break
1749 except:
1750 pass
1751 for i in range(len(lines)):
1752 if i==0 and lines[0][0]=='"':
1753 data = lines[i][1:-1].split('","')
1754 else:
1755 data = lines[i].split(',')
1756 if len(data) % 2 != 0:
1757 print("Error: expected an even number of columns in csv file:", ini.csv_path + csvFile)
1758 return traceDict
1759 elif i == 0:

Callers

nothing calls this directly

Calls 1

traceClass · 0.85

Tested by

no test coverage detected