Skip to content

Commit 018d8dc

Browse files
committed
ruff and nbstrip on all notebooks
1 parent 6ee3959 commit 018d8dc

File tree

25 files changed

+1824
-1429
lines changed

25 files changed

+1824
-1429
lines changed

tutorials/FITS-cubes/FITS-cubes.ipynb

Lines changed: 162 additions & 99 deletions
Large diffs are not rendered by default.

tutorials/FITS-header/FITS-header.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"metadata": {},
6868
"outputs": [],
6969
"source": [
70-
"hdu_number = 0 # HDU means header data unit\n",
71-
"fits.getheader('input_file.fits', hdu_number)"
70+
"hdu_number = 0 # HDU means header data unit\n",
71+
"fits.getheader(\"input_file.fits\", hdu_number)"
7272
]
7373
},
7474
{
@@ -89,7 +89,7 @@
8989
"source": [
9090
"# But hdu_number = 0 is the PRIMARY HDU.How many HDUs are in this file?\n",
9191
"fits_inf = fits.open(\"input_file.fits\")\n",
92-
"fits_inf.info() \n",
92+
"fits_inf.info()\n",
9393
"fits_inf[0].header"
9494
]
9595
},
@@ -113,7 +113,7 @@
113113
"metadata": {},
114114
"outputs": [],
115115
"source": [
116-
"header['OBJECT'] = \"M31\""
116+
"header[\"OBJECT\"] = \"M31\""
117117
]
118118
},
119119
{
@@ -130,7 +130,7 @@
130130
"metadata": {},
131131
"outputs": [],
132132
"source": [
133-
"fits.writeto('output_file.fits', data, header, overwrite=True)"
133+
"fits.writeto(\"output_file.fits\", data, header, overwrite=True)"
134134
]
135135
},
136136
{
@@ -185,7 +185,7 @@
185185
"metadata": {},
186186
"outputs": [],
187187
"source": [
188-
"fits.writeto('output_file.fits', data, header, overwrite=True)"
188+
"fits.writeto(\"output_file.fits\", data, header, overwrite=True)"
189189
]
190190
},
191191
{
@@ -201,8 +201,8 @@
201201
"metadata": {},
202202
"outputs": [],
203203
"source": [
204-
"with fits.open('input_file.fits', mode='update') as filehandle:\n",
205-
" filehandle[0].header['MYHDRKW'] = \"My Header Keyword\""
204+
"with fits.open(\"input_file.fits\", mode=\"update\") as filehandle:\n",
205+
" filehandle[0].header[\"MYHDRKW\"] = \"My Header Keyword\""
206206
]
207207
},
208208
{

tutorials/FITS-images/FITS-images.ipynb

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"\n",
4949
"# Set up matplotlib\n",
5050
"import matplotlib.pyplot as plt\n",
51+
"\n",
5152
"%matplotlib inline\n",
5253
"\n",
5354
"from astropy.io import fits"
@@ -82,7 +83,10 @@
8283
"outputs": [],
8384
"source": [
8485
"from astropy.utils.data import download_file\n",
85-
"image_file = download_file('http://data.astropy.org/tutorials/FITS-images/HorseHead.fits', cache=True )"
86+
"\n",
87+
"image_file = download_file(\n",
88+
" \"http://data.astropy.org/tutorials/FITS-images/HorseHead.fits\", cache=True\n",
89+
")"
8690
]
8791
},
8892
{
@@ -245,8 +249,8 @@
245249
},
246250
"outputs": [],
247251
"source": [
248-
"print(type(image_data)) # Show the Python type for image_data\n",
249-
"print(image_data.shape) # Show the number of pixels per side in the 2-D image"
252+
"print(type(image_data)) # Show the Python type for image_data\n",
253+
"print(image_data.shape) # Show the number of pixels per side in the 2-D image"
250254
]
251255
},
252256
{
@@ -273,7 +277,7 @@
273277
},
274278
"outputs": [],
275279
"source": [
276-
"plt.imshow(image_data, cmap='gray')\n",
280+
"plt.imshow(image_data, cmap=\"gray\")\n",
277281
"plt.colorbar()\n",
278282
"\n",
279283
"# To see more color maps\n",
@@ -304,10 +308,10 @@
304308
},
305309
"outputs": [],
306310
"source": [
307-
"print('Min:', np.min(image_data))\n",
308-
"print('Max:', np.max(image_data))\n",
309-
"print('Mean:', np.mean(image_data))\n",
310-
"print('Stdev:', np.std(image_data))"
311+
"print(\"Min:\", np.min(image_data))\n",
312+
"print(\"Max:\", np.max(image_data))\n",
313+
"print(\"Mean:\", np.mean(image_data))\n",
314+
"print(\"Stdev:\", np.std(image_data))"
311315
]
312316
},
313317
{
@@ -376,7 +380,7 @@
376380
},
377381
"outputs": [],
378382
"source": [
379-
"histogram = plt.hist(image_data.flatten(), bins='auto')"
383+
"histogram = plt.hist(image_data.flatten(), bins=\"auto\")"
380384
]
381385
},
382386
{
@@ -419,11 +423,11 @@
419423
},
420424
"outputs": [],
421425
"source": [
422-
"plt.imshow(image_data, cmap='gray', norm=LogNorm())\n",
426+
"plt.imshow(image_data, cmap=\"gray\", norm=LogNorm())\n",
423427
"\n",
424428
"# I chose the tick marks based on the histogram above\n",
425-
"cbar = plt.colorbar(ticks=[5.e3,1.e4,2.e4])\n",
426-
"cbar.ax.set_yticklabels(['5,000','10,000','20,000'])"
429+
"cbar = plt.colorbar(ticks=[5.0e3, 1.0e4, 2.0e4])\n",
430+
"cbar.ax.set_yticklabels([\"5,000\", \"10,000\", \"20,000\"])"
427431
]
428432
},
429433
{
@@ -453,10 +457,9 @@
453457
"metadata": {},
454458
"outputs": [],
455459
"source": [
456-
"base_url = 'http://data.astropy.org/tutorials/FITS-images/M13_blue_{0:04d}.fits'\n",
460+
"base_url = \"http://data.astropy.org/tutorials/FITS-images/M13_blue_{0:04d}.fits\"\n",
457461
"\n",
458-
"image_list = [download_file(base_url.format(n), cache=True) \n",
459-
" for n in range(1, 5+1)]\n",
462+
"image_list = [download_file(base_url.format(n), cache=True) for n in range(1, 5 + 1)]\n",
460463
"image_concat = [fits.getdata(image) for image in image_list]"
461464
]
462465
},
@@ -507,7 +510,7 @@
507510
},
508511
"outputs": [],
509512
"source": [
510-
"image_hist = plt.hist(final_image.flatten(), bins='auto')"
513+
"image_hist = plt.hist(final_image.flatten(), bins=\"auto\")"
511514
]
512515
},
513516
{
@@ -534,7 +537,7 @@
534537
},
535538
"outputs": [],
536539
"source": [
537-
"plt.imshow(final_image, cmap='gray', vmin=2E3, vmax=3E3)\n",
540+
"plt.imshow(final_image, cmap=\"gray\", vmin=2e3, vmax=3e3)\n",
538541
"plt.colorbar()"
539542
]
540543
},
@@ -565,7 +568,7 @@
565568
"metadata": {},
566569
"outputs": [],
567570
"source": [
568-
"outfile = 'stacked_M13_blue.fits'\n",
571+
"outfile = \"stacked_M13_blue.fits\"\n",
569572
"\n",
570573
"hdu = fits.PrimaryHDU(final_image)\n",
571574
"hdu.writeto(outfile, overwrite=True)"

tutorials/FITS-tables/FITS-tables.ipynb

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"\n",
3838
"# Set up matplotlib\n",
3939
"import matplotlib.pyplot as plt\n",
40+
"\n",
4041
"%matplotlib inline"
4142
]
4243
},
@@ -71,8 +72,9 @@
7172
"metadata": {},
7273
"outputs": [],
7374
"source": [
74-
"event_filename = download_file('http://data.astropy.org/tutorials/FITS-tables/chandra_events.fits', \n",
75-
" cache=True)"
75+
"event_filename = download_file(\n",
76+
" \"http://data.astropy.org/tutorials/FITS-tables/chandra_events.fits\", cache=True\n",
77+
")"
7678
]
7779
},
7880
{
@@ -175,7 +177,7 @@
175177
"metadata": {},
176178
"outputs": [],
177179
"source": [
178-
"energy_hist = plt.hist(evt_data['energy'], bins='auto')"
180+
"energy_hist = plt.hist(evt_data[\"energy\"], bins=\"auto\")"
179181
]
180182
},
181183
{
@@ -205,7 +207,7 @@
205207
"metadata": {},
206208
"outputs": [],
207209
"source": [
208-
"ii = np.in1d(evt_data['ccd_id'], [0, 1, 2, 3])\n",
210+
"ii = np.in1d(evt_data[\"ccd_id\"], [0, 1, 2, 3])\n",
209211
"np.sum(ii)"
210212
]
211213
},
@@ -229,16 +231,18 @@
229231
"metadata": {},
230232
"outputs": [],
231233
"source": [
232-
"NBINS = (100,100)\n",
234+
"NBINS = (100, 100)\n",
233235
"\n",
234-
"img_zero, yedges, xedges = np.histogram2d(evt_data['x'][ii], evt_data['y'][ii], NBINS)\n",
236+
"img_zero, yedges, xedges = np.histogram2d(evt_data[\"x\"][ii], evt_data[\"y\"][ii], NBINS)\n",
235237
"\n",
236238
"extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]\n",
237239
"\n",
238-
"plt.imshow(img_zero, extent=extent, interpolation='nearest', cmap='gist_yarg', origin='lower')\n",
240+
"plt.imshow(\n",
241+
" img_zero, extent=extent, interpolation=\"nearest\", cmap=\"gist_yarg\", origin=\"lower\"\n",
242+
")\n",
239243
"\n",
240-
"plt.xlabel('x')\n",
241-
"plt.ylabel('y')\n",
244+
"plt.xlabel(\"x\")\n",
245+
"plt.ylabel(\"y\")\n",
242246
"\n",
243247
"# To see more color maps\n",
244248
"# http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps"
@@ -257,15 +261,16 @@
257261
"metadata": {},
258262
"outputs": [],
259263
"source": [
260-
"NBINS = (100,100)\n",
261-
"img_zero_mpl = plt.hist2d(evt_data['x'][ii], evt_data['y'][ii], NBINS, \n",
262-
" cmap='viridis', norm=LogNorm())\n",
264+
"NBINS = (100, 100)\n",
265+
"img_zero_mpl = plt.hist2d(\n",
266+
" evt_data[\"x\"][ii], evt_data[\"y\"][ii], NBINS, cmap=\"viridis\", norm=LogNorm()\n",
267+
")\n",
263268
"\n",
264-
"cbar = plt.colorbar(ticks=[1.0,3.0,6.0])\n",
265-
"cbar.ax.set_yticklabels(['1','3','6'])\n",
269+
"cbar = plt.colorbar(ticks=[1.0, 3.0, 6.0])\n",
270+
"cbar.ax.set_yticklabels([\"1\", \"3\", \"6\"])\n",
266271
"\n",
267-
"plt.xlabel('x')\n",
268-
"plt.ylabel('y')"
272+
"plt.xlabel(\"x\")\n",
273+
"plt.ylabel(\"y\")"
269274
]
270275
},
271276
{

0 commit comments

Comments
 (0)