Skip to content

Commit

Permalink
Use numpy.float64 instead of numpy.float_ (platform default) for nump…
Browse files Browse the repository at this point in the history
…y 2 compatibility.
  • Loading branch information
cmeyer committed Aug 14, 2024
1 parent aec8bc5 commit 4e4b131
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nionswift_plugin/usim/EELSCameraSimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_frame_data(self, readout_area: Geometry.IntRect, binning_shape: Geometry
self._last_frame_settings = frame_settings

if self._needs_recalculation or self.__cached_frame is None:
data: numpy.typing.NDArray[numpy.float_] = numpy.zeros(tuple(self._sensor_dimensions), float)
data: numpy.typing.NDArray[numpy.float64] = numpy.zeros(tuple(self._sensor_dimensions), float)
slit_attenuation = 10 if self.instrument.is_slit_in else 1
intensity_calibration = Calibration.Calibration(units="counts")
dimensional_calibrations = self.get_dimensional_calibrations(readout_area, binning_shape)
Expand All @@ -135,14 +135,14 @@ def get_frame_data(self, readout_area: Geometry.IntRect, binning_shape: Geometry
if scan_context.is_valid and frame_settings.current_probe_position is not None:

# make a buffer for the spectrum
spectrum: numpy.typing.NDArray[numpy.float_] = numpy.zeros((data.shape[1], ), float)
spectrum: numpy.typing.NDArray[numpy.float64] = numpy.zeros((data.shape[1], ), float)

# configure a calibration for the reference spectrum. then plot the ZLP on the reference data. sum it to
# get the zlp_pixel_count and the zlp_scale. this is the value to multiple zlp data by to scale it so
# that it will produce the target pixel count. since we will be storing the spectra in a 2d array,
# divide by the height of that array so that when it is summed, the value comes out correctly.
zlp0_calibration = Calibration.Calibration(scale=used_calibration.scale, offset=-20)
spectrum_ref: numpy.typing.NDArray[numpy.float_] = numpy.zeros((int(zlp0_calibration.convert_from_calibrated_value(-20 + 1000) - zlp0_calibration.convert_from_calibrated_value(-20)), ), float)
spectrum_ref: numpy.typing.NDArray[numpy.float64] = numpy.zeros((int(zlp0_calibration.convert_from_calibrated_value(-20 + 1000) - zlp0_calibration.convert_from_calibrated_value(-20)), ), float)
plot_norm(spectrum_ref, 1.0, Calibration.Calibration(scale=used_calibration.scale, offset=-20), 0, 0.5 / slit_attenuation)
zlp_ref_pixel_count = float(numpy.sum(spectrum_ref))

Expand Down

0 comments on commit 4e4b131

Please sign in to comment.