Skip to content

Commit bdc3aa6

Browse files
authored
Moved dark current example to a separate report. (#31)
1 parent bc36658 commit bdc3aa6

File tree

3 files changed

+191
-41
lines changed

3 files changed

+191
-41
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ justify the decisions made in this package.
3131
:maxdepth: 1
3232

3333
reports/bias
34+
reports/dark-current
3435

3536
|
3637

docs/reports/dark-current.ipynb

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "raw",
5+
"id": "47a11a1d",
6+
"metadata": {
7+
"raw_mimetype": "text/restructuredtext"
8+
},
9+
"source": [
10+
"Dark Current Model\n",
11+
"------------------\n",
12+
"Dark current is the charge accumulated by an unilluminated sensor.\n",
13+
"Teledyne/e2v provides a dark current model in the \n",
14+
"`datasheet <https://www.teledyne-e2v.com/en-us/Solutions_/Documents/datasheets/230-42+1337.pdf>`_ as\n",
15+
"\n",
16+
".. math::\n",
17+
"\n",
18+
" \\frac{Q_d}{Q_{do}} = 122 T^3 e^{-6400 / T}\n",
19+
" \n",
20+
"where :math:`Q_d` is the dark current,\n",
21+
":math:`Q_{do}` is the dark current at 293 K,\n",
22+
"and :math:`T` is the temperature.\n",
23+
" \n",
24+
"In this notebook we will plot this theoretical dark current over a range of temperatures."
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"id": "b5a6ceb5",
31+
"metadata": {
32+
"ExecuteTime": {
33+
"end_time": "2025-08-14T04:53:22.158437Z",
34+
"start_time": "2025-08-14T04:53:18.967940Z"
35+
}
36+
},
37+
"outputs": [],
38+
"source": [
39+
"import matplotlib.pyplot as plt\n",
40+
"import astropy.units as u\n",
41+
"import astropy.visualization\n",
42+
"import named_arrays as na\n",
43+
"import msfc_ccd"
44+
]
45+
},
46+
{
47+
"cell_type": "raw",
48+
"id": "1d9c610d",
49+
"metadata": {
50+
"raw_mimetype": "text/restructuredtext"
51+
},
52+
"source": [
53+
"Define a grid of temperatures with which to sample the dark current"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"id": "70708419",
60+
"metadata": {
61+
"ExecuteTime": {
62+
"end_time": "2025-08-14T04:53:22.158437Z",
63+
"start_time": "2025-08-14T04:53:18.967940Z"
64+
}
65+
},
66+
"outputs": [],
67+
"source": [
68+
"temperature = na.linspace(200, 300, axis=\"temperature\", num=101) * u.K"
69+
]
70+
},
71+
{
72+
"cell_type": "raw",
73+
"id": "0c1da283",
74+
"metadata": {
75+
"raw_mimetype": "text/restructuredtext"
76+
},
77+
"source": [
78+
"Initialize the sensor model"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"id": "4f8f2c79",
85+
"metadata": {
86+
"ExecuteTime": {
87+
"end_time": "2025-08-14T04:53:22.158437Z",
88+
"start_time": "2025-08-14T04:53:18.967940Z"
89+
}
90+
},
91+
"outputs": [],
92+
"source": [
93+
"sensor = msfc_ccd.TeledyneCCD230()"
94+
]
95+
},
96+
{
97+
"cell_type": "raw",
98+
"id": "bde0cbb9",
99+
"metadata": {
100+
"raw_mimetype": "text/restructuredtext"
101+
},
102+
"source": [
103+
"Compute the theoretical dark current using the :meth:`msfc_ccd.TeledyneCCD230.dark_current` method."
104+
]
105+
},
106+
{
107+
"cell_type": "code",
108+
"execution_count": null,
109+
"id": "00ee0ef1",
110+
"metadata": {
111+
"ExecuteTime": {
112+
"end_time": "2025-08-14T04:53:22.158437Z",
113+
"start_time": "2025-08-14T04:53:18.967940Z"
114+
}
115+
},
116+
"outputs": [],
117+
"source": [
118+
"dark_current = sensor.dark_current(temperature)"
119+
]
120+
},
121+
{
122+
"cell_type": "raw",
123+
"id": "1786fae2",
124+
"metadata": {
125+
"raw_mimetype": "text/restructuredtext"
126+
},
127+
"source": [
128+
"Plot the dark current vs. temperature"
129+
]
130+
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": null,
134+
"id": "initial_id",
135+
"metadata": {
136+
"ExecuteTime": {
137+
"end_time": "2025-08-14T04:53:22.158437Z",
138+
"start_time": "2025-08-14T04:53:18.967940Z"
139+
}
140+
},
141+
"outputs": [],
142+
"source": [
143+
"with astropy.visualization.quantity_support():\n",
144+
" fig, ax = plt.subplots()\n",
145+
" ax2 = ax.twiny()\n",
146+
" na.plt.plot(\n",
147+
" temperature,\n",
148+
" dark_current,\n",
149+
" ax=ax,\n",
150+
" )\n",
151+
" na.plt.plot(\n",
152+
" temperature.to(u.deg_C, equivalencies=u.temperature()),\n",
153+
" dark_current,\n",
154+
" ax=ax2,\n",
155+
" )\n",
156+
" ax.set_yscale(\"log\")\n",
157+
" ax.set_xlabel(f\"temperature ({ax.get_xlabel()})\")\n",
158+
" ax2.set_xlabel(f\"temperature ({ax2.get_xlabel()})\")\n",
159+
" ax.set_ylabel(f\"dark current ({ax.get_ylabel()})\")"
160+
]
161+
}
162+
],
163+
"metadata": {
164+
"celltoolbar": "Raw Cell Format",
165+
"kernelspec": {
166+
"display_name": "Python 3 (ipykernel)",
167+
"language": "python",
168+
"name": "python3"
169+
},
170+
"language_info": {
171+
"codemirror_mode": {
172+
"name": "ipython",
173+
"version": 3
174+
},
175+
"file_extension": ".py",
176+
"mimetype": "text/x-python",
177+
"name": "python",
178+
"nbconvert_exporter": "python",
179+
"pygments_lexer": "ipython3",
180+
"version": "3.11.1"
181+
}
182+
},
183+
"nbformat": 4,
184+
"nbformat_minor": 5
185+
}

msfc_ccd/_sensors.py

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -193,48 +193,12 @@ def dark_current(
193193
The temperature of the sensor.
194194
If :obj:`None`, the value of :attr:`temperature` is used.
195195
196-
Examples
197-
--------
198-
Plot the theoretical dark current of this sensor according to the
199-
datasheet.
200-
201-
.. jupyter-execute::
202-
203-
import matplotlib.pyplot as plt
204-
import astropy.units as u
205-
import astropy.visualization
206-
import named_arrays as na
207-
import msfc_ccd
208-
209-
# Define a grid of temperatures to sample
210-
temperature = na.linspace(200, 300, axis="temperature", num=101) * u.K
211-
212-
# Initialize the sensor model
213-
sensor = msfc_ccd.TeledyneCCD230()
214-
215-
# Compute the dark current of the sensor
216-
# given the grid of temperatures
217-
dark_current = sensor.dark_current(temperature)
218-
219-
# Plot the results
220-
with astropy.visualization.quantity_support():
221-
fig, ax = plt.subplots()
222-
ax2 = ax.twiny()
223-
na.plt.plot(
224-
temperature,
225-
dark_current,
226-
ax=ax,
227-
)
228-
na.plt.plot(
229-
temperature.to(u.deg_C, equivalencies=u.temperature()),
230-
dark_current,
231-
ax=ax2,
232-
)
233-
ax.set_yscale("log")
234-
ax.set_xlabel(f"temperature ({ax.get_xlabel()})")
235-
ax2.set_xlabel(f"temperature ({ax2.get_xlabel()})")
236-
ax.set_ylabel(f"dark current ({ax.get_ylabel()})")
237196
197+
.. nblinkgallery::
198+
:caption: Examples
199+
:name: rst-link-gallery
200+
201+
../reports/dark-current
238202
"""
239203
if temperature is None:
240204
temperature = self.temperature

0 commit comments

Comments
 (0)