You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## \brief Read in CSV data, name it, and add to class-defined dictionaries
26
+
#
27
+
# Only one reference dataset can be defined at a time.
28
+
# Multiple comparison datasets can be defined at a time.
29
+
# When using comparison capabilities in this class,
30
+
# each of the comparison datasets will be compared to the reference dataset.
31
+
# It is recommended that a new object be created for each reference dataset
32
+
# a user wants to work with.
33
+
#
34
+
# \param[in] filePath string, local path to file read in by pandas
35
+
# \param[in] type string, choose between reference or comparison dataset
36
+
# \param[in] name string, optional parameter to name file data (otherwise name will be full file path)
37
+
# \returns Sets as attributes the dictionaries of reference and comparison datasets
38
+
defreadCSV(self, filePath, type, name=None):
39
+
iftypenotin ('reference', 'comparison'): raiseException ("\'type\' must be either \'reference\' or \'comparison\'.")
40
+
ifname==None: name=filePath
41
+
assertisinstance(name, str)
42
+
iftype=="reference":
43
+
iflen(self.reference) >0:
44
+
warnings.warn("Only one reference dataset allowed at a time; new reference dataset has overwritten old reference dataset. Comparison datasets may contain values computed with different reference datasets. To ensure the clarity and purity of the computed values, create a new object for every reference dataset you want to use.")
iflen(self.reference) ==0: warnings.warn("There is no reference dataset. A reference dataset is necessary to compute differences with the comparison datasets. Results of this function call may not return expected values.")
61
+
iflen(self.comparison) ==0: warnings.warn("There is no comparison dataset. At least one comparison dataset is required to compute differences. Results of this function call may not return expected values.")
62
+
ifSignedOrUnsignedDiffsnotin {'signed' , 'unsigned'}: raiseException ("\'SignedOrUnsignedDiffs\' must be either \'relative\' or \'absolute\'.")
63
+
ifAbsoluteOrRelativeDiffsnotin {'relative', 'absolute'}: raiseException ("\'AbsoluteOrRelativeDiffs\' must be either \'relative\' or \'absolute\'.")
else : warnings.warn(f"The Reference Dataset does not have any uncertainty values associated with the {quantity} values. The propogation of error uncertainty has been skipped for this operation.")
else: warnings.warn(f"{key} does not have any uncertainty values associated with the {quantity} values. The propogation of error uncertainty has been skipped for this operation.")
89
+
90
+
## \brief Compute metrics (i.e. mean absolute, root mean squared, and max absolute) of the difference values in the comparison DataFrames
91
+
#
92
+
# Comparison datasets with no difference values will be skipped with warning given.
93
+
#
94
+
# \param[in] rowIdentifier str, default 'Diff', used to search datasets for difference values
95
+
# \returns Adds difference metrics values as new row(s) to the comparison dataset(s)
iflen(self.comparison) ==0: raiseException("There is no comparison dataset. At least one comparison dataset is required to compute differences. Results of this function call may not return expected values.")
98
+
assertisinstance(rowIdentifier, str)
99
+
forkeyinself.comparison:
100
+
# Create temp DataFrame with rows containing the rowIdentifier string in the row index
expandedTitle=" ".join([self.shorthand_mapping.get(word, word) forwordintitle.split()]) # Expands the short-hand version of the title
144
+
plt.title(expandedTitle, fontsize=25)
145
+
plt.ylabel('Leakage Values', fontsize=20)
146
+
147
+
# Check if any data points have been plotted
148
+
check=plt.gca()
149
+
iflen(check.lines) ==0: raiseException ('None of the datasets have difference values according to the specified identifiers. No plot will be displayed.')
150
+
# Continue plotting
151
+
plt.xlabel('Case', fontsize=20)
152
+
ifyLim: plt.ylim(yLim)
153
+
plt.legend(fontsize=10)
154
+
plt.xticks(fontsize=15)
155
+
plt.yticks(fontsize=15)
156
+
ifflSavePlot: plt.savefig(fileName+'.png')
157
+
ifflShowPlot: plt.show()
158
+
plt.clf()
159
+
plt.close()
160
+
161
+
## \brief Plots the difference values specified by the user
162
+
#
163
+
# \param[in] quantity str, default None (e.g. Refl, Trans), used to identify and collect data from the DataFrames
164
+
# \param[in] dataIdentifiers tuple of strings, default None (e.g. ('Sign', 'Rel')), strings to search for in the row indexes of the datasets
165
+
# \param[in] fileName str, default 'differences', used to specify file name of plots generated
166
+
# \param[in] flShowPlot bool, default True, used to display plot to user after calculations
167
+
# \param[in] flSavePlot bool, default True, used to automatically save generated plots to a .png file at the location of the driver script
168
+
# \param[in] yLim tuple of floats, default None (e.g. (-1, 1.5)), sets the y-axis limits of the plot
169
+
# \param[in] plotTitle str, default None, allows user to specify a title for the plot (otherwise one will be generated automatically)
170
+
# \returns Displays and saves a difference plot dependent on user specifications
expandedTitle=" ".join([self.shorthand_mapping.get(word, word) forwordintitle.split()]) # Expands the short-hand version of the title
205
+
plt.title(expandedTitle, fontsize=25)
206
+
plt.ylabel('Difference Values', fontsize=20)
207
+
208
+
# Check if any data points have been plotted
209
+
check=plt.gca()
210
+
iflen(check.lines) ==0: raiseException ('None of the datasets have difference values according to the specified identifiers. No plot will be displayed.')
0 commit comments