Updated to new measurement data structure.

This commit is contained in:
jupfi 2024-12-28 16:08:05 +01:00
parent 235a3259cd
commit 14d1101591
5 changed files with 31 additions and 34 deletions

View file

@ -32,17 +32,17 @@ if __name__ == "__main__":
plt.title("Time domain Simulation of BiPh3 COMPFID")
plt.xlabel("Time (µs)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.tdx[-1], result.tdy[-1].imag, label="imaginary")
plt.plot(result.tdx[-1], result.tdy[-1].real, label="real")
plt.plot(result.tdx[-1], abs(result.tdy[-1]), label="abs")
plt.plot(result.tdx, result.tdy[:, -1].imag, label="imaginary")
plt.plot(result.tdx, result.tdy[:, -1].real, label="real")
plt.plot(result.tdx, abs(result.tdy[:, -1]), label="abs")
plt.subplot(1, 2, 2)
plt.title("Frequency domain Simulation of BiPh3 COMPFID")
plt.xlabel("Frequency (kHz)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.fdx[-1], result.fdy[-1].imag, label="imaginary")
plt.plot(result.fdx[-1], result.fdy[-1].real, label="real")
plt.plot(result.fdx[-1], abs(result.fdy[-1]), label="abs")
plt.plot(result.fdx, result.fdy[:, -1].imag, label="imaginary")
plt.plot(result.fdx, result.fdy[:, -1].real, label="real")
plt.plot(result.fdx, abs(result.fdy[:, -1]), label="abs")
plt.legend()
plt.show()

View file

@ -29,17 +29,17 @@ if __name__ == "__main__":
plt.title("Time domain Simulation of BiPh3 FID")
plt.xlabel("Time (µs)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.tdx[0], result.tdy[0].imag, label="imaginary")
plt.plot(result.tdx[0], result.tdy[0].real, label="real")
plt.plot(result.tdx[0], abs(result.tdy[0]), label="abs")
plt.plot(result.tdx, result.tdy[:, 0].imag, label="imaginary")
plt.plot(result.tdx, result.tdy[:, 0].real, label="real")
plt.plot(result.tdx, abs(result.tdy[:, 0]), label="abs")
plt.subplot(1, 2, 2)
plt.title("Frequency domain Simulation of BiPh3 FID")
plt.xlabel("Frequency (kHz)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.fdx[0], result.fdy[0].imag, label="imaginary")
plt.plot(result.fdx[0], result.fdy[0].real, label="real")
plt.plot(result.fdx[0], abs(result.fdy[0]), label="abs")
plt.plot(result.fdx, result.fdy[:, 0].imag, label="imaginary")
plt.plot(result.fdx, result.fdy[:, 0].real, label="real")
plt.plot(result.fdx, abs(result.fdy[:, 0]), label="abs")
plt.legend()
plt.show()

View file

@ -27,17 +27,17 @@ if __name__ == "__main__":
plt.title("Time domain Simulation of BiPh3 SE")
plt.xlabel("Time (µs)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.tdx[0], result.tdy[0].imag, label="imaginary")
plt.plot(result.tdx[0], result.tdy[0].real, label="real")
plt.plot(result.tdx[0], abs(result.tdy[0]), label="abs")
plt.plot(result.tdx, result.tdy[:, 0].imag, label="imaginary")
plt.plot(result.tdx, result.tdy[:, 0].real, label="real")
plt.plot(result.tdx, abs(result.tdy[:, 0]), label="abs")
plt.subplot(1, 2, 2)
plt.title("Frequency domain Simulation of BiPh3 SE")
plt.xlabel("Frequency (kHz)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.fdx[0], result.fdy[0].imag, label="imaginary")
plt.plot(result.fdx[0], result.fdy[0].real, label="real")
plt.plot(result.fdx[0], abs(result.fdy[0]), label="abs")
plt.plot(result.fdx, result.fdy[:, 0].imag, label="imaginary")
plt.plot(result.fdx, result.fdy[:, 0].real, label="real")
plt.plot(result.fdx, abs(result.fdy[:, 0]), label="abs")
plt.legend()
plt.show()

View file

@ -27,17 +27,17 @@ if __name__ == "__main__":
plt.title("Time domain Simulation of BiPh3 SEPC")
plt.xlabel("Time (µs)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.tdx[-1], result.tdy[-1].imag, label="imaginary")
plt.plot(result.tdx[-1], result.tdy[-1].real, label="real")
plt.plot(result.tdx[-1], abs(result.tdy[-1]), label="abs")
plt.plot(result.tdx, result.tdy[:, -1].imag, label="imaginary")
plt.plot(result.tdx, result.tdy[:, -1].real, label="real")
plt.plot(result.tdx, abs(result.tdy[:, -1]), label="abs")
plt.subplot(1, 2, 2)
plt.title("Frequency domain Simulation of BiPh3 SEPC")
plt.xlabel("Frequency (kHz)")
plt.ylabel("Signal (a.u.)")
plt.plot(result.fdx[-1], result.fdy[-1].imag, label="imaginary")
plt.plot(result.fdx[-1], result.fdy[-1].real, label="real")
plt.plot(result.fdx[-1], abs(result.fdy[-1]), label="abs")
plt.plot(result.fdx, result.fdy[:, -1].imag, label="imaginary")
plt.plot(result.fdx, result.fdy[:, -1].real, label="real")
plt.plot(result.fdx, abs(result.fdy[:, -1]), label="abs")
plt.legend()
plt.show()

View file

@ -39,8 +39,6 @@ class SimulatorController(SpectrometerController):
# Empty measurement object
measurement_data = None
readout_scheme = None
for cycle in range(number_phasecycles):
sample = self.get_sample_from_settings()
@ -72,6 +70,8 @@ class SimulatorController(SpectrometerController):
evidx = np.where((tdx > rx_begin) & (tdx < rx_stop))[0]
tdx = tdx[evidx]
result = result[evidx]
# Add empty second dimension to result so it has shape (n_points, 1)
result = np.expand_dims(result, axis=1)
# Measurement name date + module + target frequency + averages + sequence name
name = f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Simulator - {self.simulator.model.target_frequency / 1e6} MHz - {self.simulator.model.averages} averages - {sequence.name}"
@ -85,7 +85,7 @@ class SimulatorController(SpectrometerController):
sample.resonant_frequency,
)
else:
measurement_data.add_dataset(tdx, result / simulation.averages)
measurement_data.add_dataset(result / simulation.averages)
if (rx_begin and rx_stop) and phase:
logger.debug(f"Phase: {phase}")
@ -94,15 +94,12 @@ class SimulatorController(SpectrometerController):
if phase and number_phasecycles > 1:
# Apply the readout scheme
tdy = np.zeros(len(measurement_data.tdx[0]), dtype=np.complex128)
for cycle in range(number_phasecycles):
tdy += (measurement_data.tdy[cycle])
tdy_sum = np.sum(measurement_data.tdy, axis=1, keepdims=True)
measurement_data.add_dataset(measurement_data.tdx[0], tdy)
logger.info(f"Length of tdy: {len(tdy)}")
measurement_data.add_dataset(tdy_sum)
logger.debug(f"Measurement data shape: {measurement_data.tdy.shape}")
return measurement_data
def get_sample_from_settings(self) -> Sample: