Debug for calculating atom number.

Add selecting the effective area function in AbsorptionImaging.py.

Optimaze plotting function.
This commit is contained in:
gao 2022-07-25 12:23:14 +02:00
parent 5b80d7d87f
commit ac51408793
9 changed files with 81 additions and 44 deletions

37
.idea/workspace.xml generated
View File

@ -1,7 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="" />
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="First working version. Need introductions">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/dylab/AbsorptionImaging.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test_absorption_imaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_absorption_imaging.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -14,6 +18,9 @@
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="2CCrwoItH5rBCZFtzaw6hxgrIjy" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
@ -65,12 +72,36 @@
<updated>1658317648754</updated>
<workItem from="1658317653047" duration="53940000" />
<workItem from="1658490102584" duration="2917000" />
<workItem from="1658494814456" duration="16216000" />
</task>
<task id="LOCAL-00001" summary="First working version. Need introductions">
<created>1658494877565</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1658494877565</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="First working version. Need introductions" />
<option name="LAST_COMMIT_MESSAGE" value="First working version. Need introductions" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
@ -89,6 +120,10 @@
<line>7</line>
<option name="timeStamp" value="55" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/test_absorption_imaging.py</url>
<option name="timeStamp" value="56" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
<breakpoint type="python-exception">

Binary file not shown.

Binary file not shown.

View File

@ -1,17 +0,0 @@
Metadata-Version: 2.1
Name: dylab
Version: 0.0.1
Summary: An internal toolbox package used for analyzation data of an ultracold atom experiment.
Home-page: UNKNOWN
Author: QF-group (AG Chomaz), Heidelberg university
Author-email: gao@physi.uni-heidelberg.de
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
UNKNOWN

View File

@ -1,14 +0,0 @@
LICENSE
README.md
setup.py
dylab/AbsorptionImaging.py
dylab/Camera.py
dylab/DyTransition.py
dylab/Fitting.py
dylab/FittingFunction.py
dylab/TransitionClass.py
dylab/__init__.py
dylab.egg-info/PKG-INFO
dylab.egg-info/SOURCES.txt
dylab.egg-info/dependency_links.txt
dylab.egg-info/top_level.txt

View File

@ -1 +0,0 @@

View File

@ -1 +0,0 @@
dylab

View File

@ -52,6 +52,13 @@ class absorption_imaging:
self.image_dark = None
self.image_absorption = None
#
self.image_absorption_cut = None
self.x_start = None
self.y_start = None
self.x_end = None
self.y_end = None
# import the data of transition
# The transition should be an object of TransitionClass.py in module TransitionConstant
# self.transition = transition
@ -93,10 +100,6 @@ class absorption_imaging:
self.image_background = self.image_background.astype(float)
self.image_dark = self.image_dark.astype(float)
if not (self.intensity is None):
intensity = np.ones(self.image_atoms.shape)
self.intensity = intensity * self.intensity
def close(self):
self.save()
@ -107,6 +110,19 @@ class absorption_imaging:
if self.atom_number is not None:
self.data_handle.save_result('atom_number', self.atom_number, 'results/absorption_imaging/')
# select the effective data in an rectangle area defined by coordinates of two conner
# The select region will be presented as a red box in the plotting
def select_effective_data(self, left_up_conner, right_down_conner):
self.x_start = left_up_conner[0]
self.x_end = right_down_conner[0]
self.y_start = left_up_conner[1]
self.y_end = right_down_conner[1]
self.image_absorption_cut = self.image_absorption[self.y_start:self.y_end, self.x_start:self.x_end]
return self.image_absorption_cut
# The function do the analyzation for absorption imaging
# It will return a two-dimensional array, which stores the absorption imaging
def get_image_absorption(self):
@ -155,14 +171,22 @@ class absorption_imaging:
if self.atom_number is not None and not force_to_run:
return self.atom_number
if self.image_absorption is None and not force_to_run:
if self.image_absorption is None or not force_to_run:
self.image_absorption = self.get_image_absorption()
OD_act = self.image_absorption
if self.image_absorption_cut is None:
self.image_absorption_cut = self.image_absorption
self.x_start = 0
self.x_end = self.image_absorption.shape[1]
self.y_start = 0
self.y_end = self.image_absorption.shape[0]
OD_act = self.image_absorption_cut
cross_section = self.transition.get_cross_section(self.detuning, self.intensity)
self.atom_number = np.sum(cross_section * OD_act) * self.camera['pixel_size_V'] * self.camera['pixel_size_H']
self.atom_number = np.sum(1 / cross_section * OD_act) * self.camera['pixel_size_V'] * self.camera[
'pixel_size_H']
return self.atom_number
@ -171,7 +195,7 @@ class absorption_imaging:
cmap = plt.cm.get_cmap("jet")
grid = plt.GridSpec(3, 3, wspace=0.2, hspace=0.2)
grid = plt.GridSpec(3, 3, wspace=0.3, hspace=0.3)
ax1 = plt.subplot(grid[0, 0])
pos = ax1.imshow(self.image_atoms, cmap=cmap)
@ -188,9 +212,19 @@ class absorption_imaging:
ax3.set_title('Dark')
plt.colorbar(pos, ax=ax3)
ax4 = plt.subplot(grid[0:3, 1:3])
ax4 = plt.subplot(grid[0:2, 1:3])
pos = ax4.imshow(self.image_absorption, cmap=cmap, vmin=vmin, vmax=vmax)
ax4.set_title('Absorption Imaging')
plt.colorbar(pos, ax=ax4)
ax4.plot([self.x_start, self.x_start], [self.y_start, self.y_end], color='black')
ax4.plot([self.x_end, self.x_end], [self.y_start, self.y_end], color='black')
ax4.plot([self.x_start, self.x_end], [self.y_start, self.y_start], color='black')
ax4.plot([self.x_start, self.x_end], [self.y_end, self.y_end], color='black')
ax5 = plt.subplot(grid[2:3, 1:3])
atom_number_str = '{:g}'.format(self.atom_number)
ax5.text(0, 0.55, 'Atom Number : '+atom_number_str, horizontalalignment='left', verticalalignment='center',
transform=ax5.transAxes, fontsize=40)
plt.axis('off')
plt.show()

View File

@ -8,6 +8,7 @@ mot_3D_camera = Camera.c11440_36u(absorption_imaging_transition['wavelength'])
with AbsorptionImaging.absorption_imaging(path, 'MOT_3D_Camera', 'in_situ_absorption',
absorption_imaging_transition, mot_3D_camera, 0, 0) as absorption_image:
absorption_image.plot_result(-0.05, 0.03)
absorption_image.select_effective_data((800, 500), (1000, 700))
absorption_image.plot_result(-0.05, 0.05)
print(absorption_image.atom_number)