-
Notifications
You must be signed in to change notification settings - Fork 52
Updates for v4.0 #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Updates for v4.0 #180
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,8 +54,10 @@ def __init__(self, | |||||||||||
| self.data = {} | ||||||||||||
| self.data['temporal'] = self._get_temporal(data['temporal']) | ||||||||||||
| self.data['spatial'] = self._get_spatial(data['spatial']) | ||||||||||||
| self.data['darkcurrent'] =self._get_temporal(data['darkcurrent'], True) | ||||||||||||
| print() | ||||||||||||
|
|
||||||||||||
| def _get_temporal(self, data): | ||||||||||||
| def _get_temporal(self, data, dark_only=False): | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't mind adding |
||||||||||||
| """Fill the temporal dict, with the stuff that we need. | ||||||||||||
| Compute the averages and variances from the sums (sum and pvar) | ||||||||||||
|
|
||||||||||||
|
|
@@ -84,8 +86,10 @@ def _get_temporal(self, data): | |||||||||||
| time and photon count, | ||||||||||||
| *'u_ydark'*: the array of the mean digital dark value | ||||||||||||
| for each exposure time | ||||||||||||
| and *'s2_ydark'*: the | ||||||||||||
| array of the digital dark value variance for each exposure time. | ||||||||||||
| *'s2_ydark'*: the | ||||||||||||
| array of the digital dark value variance for each exposure time | ||||||||||||
| and *'diff_u_y'*: the difference of the mean values of the images | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can keep
Suggested change
|
||||||||||||
| for each exposure time. | ||||||||||||
|
|
||||||||||||
| Raises | ||||||||||||
| ------ | ||||||||||||
|
|
@@ -106,6 +110,7 @@ def _get_temporal(self, data): | |||||||||||
| s2_y = [] | ||||||||||||
| u_ydark = [] | ||||||||||||
| s2_ydark = [] | ||||||||||||
| diff_u_y = [] | ||||||||||||
|
|
||||||||||||
| for t in exposures: | ||||||||||||
| # photons is a list of photon counts | ||||||||||||
|
|
@@ -115,7 +120,7 @@ def _get_temporal(self, data): | |||||||||||
| if 0.0 not in photons: | ||||||||||||
| raise ValueError('Every exposure point must have a 0.0 photon') | ||||||||||||
|
|
||||||||||||
| if len(photons) < 2: | ||||||||||||
| if len(photons) < 2 and not dark_only: | ||||||||||||
| raise ValueError('There must be at least one bright photon') | ||||||||||||
|
|
||||||||||||
| # get data for dark image | ||||||||||||
|
|
@@ -129,13 +134,15 @@ def _get_temporal(self, data): | |||||||||||
| d = self._get_temporal_data(data[t][p]) | ||||||||||||
| u_y.append(d['mean']) | ||||||||||||
| s2_y.append(d['var'] - d['dmean']) | ||||||||||||
| diff_u_y.append(data[t][p]['dmean']) # we need to use the raw difference here | ||||||||||||
|
|
||||||||||||
| # Append all data to temporal dict | ||||||||||||
| temporal['u_p'] = np.asarray(u_p) | ||||||||||||
| temporal['u_y'] = np.asarray(u_y) | ||||||||||||
| temporal['s2_y'] = np.asarray(s2_y) | ||||||||||||
| temporal['u_ydark'] = np.asarray(u_ydark) | ||||||||||||
| temporal['s2_ydark'] = np.asarray(s2_ydark) | ||||||||||||
| temporal['diff_u_y'] = np.asarray(diff_u_y) | ||||||||||||
|
|
||||||||||||
| # In case we have only one exposure, we need arrays with the | ||||||||||||
| # same length as the up | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,6 +194,93 @@ def plot(self, test): | |
| self.set_legend(ax) | ||
|
|
||
|
|
||
| class PlotUyDarkCurrent(Emva1288Plot): | ||
| name = 'Dark Current From Mean' | ||
| xlabel = 'exposure time [ns]' | ||
| ylabel = r'$\mu_{y.dark}$ [DN]' | ||
|
|
||
| def plot(self, test): | ||
| ax = self.ax | ||
|
|
||
| if len(test.darkcurrent['texp']) > 2: | ||
| data = test.darkcurrent | ||
| else: | ||
| data = test.temporal | ||
|
|
||
| if test.dark_current_fit_mean() is not np.nan: | ||
| X = data['texp'] | ||
|
|
||
| ax.plot(X, | ||
| data['u_ydark'], | ||
| marker='o', | ||
| markersize=5, | ||
|
Comment on lines
+215
to
+216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| label='Data', | ||
| gid='%d:data' % test.id) | ||
| ax.plot(X, | ||
| test.dark_current_fit_mean()['fit_slope'] * | ||
| X + test.dark_current_fit_mean()['fit_offset'], | ||
| linestyle='--', | ||
| label='Fit', | ||
| gid='%d:fit' % test.id) | ||
| ax.ticklabel_format(axis='x', style='sci', scilimits=(1, 4)) | ||
| self.set_legend(ax) | ||
|
|
||
| class PlotVaryDarkCurrent(Emva1288Plot): | ||
| name = 'Dark Current From Variance' | ||
| xlabel = 'exposure time [ns]' | ||
| ylabel = r'$\sigma^2_{y.dark}$ [DN$^2$]' | ||
|
|
||
|
|
||
| def plot(self, test): | ||
| ax = self.ax | ||
|
|
||
| if len(test.darkcurrent['texp']) > 2: | ||
| data = test.darkcurrent | ||
| else: | ||
| data = test.temporal | ||
|
|
||
| if test.dark_current_fit_var() is not np.nan: | ||
| X = data['texp'] | ||
|
|
||
| ax.plot(X, | ||
| data['s2_ydark'], | ||
| marker='o', | ||
| markersize=5, | ||
|
Comment on lines
+247
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| label='Data', | ||
| gid='%d:data' % test.id) | ||
| ax.plot(X, | ||
| test.dark_current_fit_var()['fit_slope'] * | ||
| X + test.dark_current_fit_var()['fit_offset'], | ||
| linestyle='--', | ||
| label='Fit', | ||
| gid='%d:fit' % test.id) | ||
| ax.ticklabel_format(axis='x', style='sci', scilimits=(1, 4)) | ||
| self.set_legend(ax) | ||
|
|
||
|
|
||
| class PlotStabilityCheck(Emva1288Plot): | ||
| ''' Create the stability check plot ''' | ||
| name = 'Stability Check' | ||
| xlabel = r'gray value [DN]' | ||
| ylabel = r'difference/std gray value [DN]' | ||
|
|
||
| def plot(self, test): | ||
| ax = self.ax | ||
|
|
||
| X = test.temporal['u_y'] - test.temporal['u_ydark'] | ||
| Y1 = np.sqrt(test.temporal['s2_y']) | ||
| Y2 = test.temporal['diff_u_y'] | ||
| ax.plot(X, Y1, | ||
| label='Std', | ||
| gid='%d:std' % test.id) | ||
| ax.plot(X, Y2, | ||
| label='Difference', | ||
| marker='.', | ||
| ls=' ', | ||
| gid='%d:difference' % test.id) | ||
| self.set_legend(ax) | ||
|
|
||
|
|
||
| class PlotPTC(Emva1288Plot): | ||
| '''Create Photon Transfer plot''' | ||
|
|
||
|
|
@@ -792,10 +879,13 @@ def rearrange(self): | |
|
|
||
| EVMA1288plots = [PlotPTC, | ||
| PlotSNR, | ||
| PlotStabilityCheck, | ||
| PlotSensitivity, | ||
| PlotUyDark, | ||
| PlotLinearity, | ||
| PlotDeviationLinearity, | ||
| PlotUyDarkCurrent, | ||
| PlotVaryDarkCurrent, | ||
| PlotHorizontalSpectrogramPRNU, | ||
| PlotHorizontalSpectrogramDSNU, | ||
| PlotVerticalSpectrogramPRNU, | ||
|
|
@@ -812,10 +902,13 @@ def rearrange(self): | |
|
|
||
| - :class:`~emva1288.process.plotting.PlotPTC` | ||
| - :class:`~emva1288.process.plotting.PlotSNR` | ||
| - :class:`~emva1288.process.plotting.PlotStabilityCheck` | ||
| - :class:`~emva1288.process.plotting.PlotSensitivity` | ||
| - :class:`~emva1288.process.plotting.PlotUyDark` | ||
| - :class:`~emva1288.process.plotting.PlotLinearity` | ||
| - :class:`~emva1288.process.plotting.PlotDeviationLinearity` | ||
| - :Class:`~emva1288.process.plotting.PlotUyDarkCurrent` | ||
| - :Class:`~emva1288.process.plotting.PlotVaryDarkCurrent` | ||
| - :class:`~emva1288.process.plotting.PlotHorizontalSpectrogramPRNU` | ||
| - :class:`~emva1288.process.plotting.PlotHorizontalSpectrogramDSNU` | ||
| - :class:`~emva1288.process.plotting.PlotVerticalSpectrogramPRNU` | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.