Skip to content

Commit 6b16fcc

Browse files
committed
Add start of plotting of cutout
1 parent 361e8a7 commit 6b16fcc

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

lofarnn/data/datasets.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ def get_lotss_objects(fname, verbose=False):
3333
return Table(table)
3434

3535

36-
def get_panstarrs_download_name(p_download_loc, f_ra, f_dec, p_size, filter):
37-
"""
38-
Get the download name of a PanSTARRS fits file in a fixed format
39-
"""
40-
return f'{p_download_loc}ra={f_ra}_dec={f_dec}_s={p_size}_{filter}.fits'
41-
42-
4336
def create_coco_annotations(image_names,
4437
image_dir='images', image_destination_dir=None,
4538
json_dir='', json_name='json_data.pkl', image_size=None,
@@ -414,7 +407,8 @@ def create_fixed_cutouts(mosaic, value_added_catalog, pan_wise_catalog, mosaic_l
414407

415408

416409
def create_fixed_source_dataset(cutout_directory, pan_wise_location,
417-
value_added_catalog_location, dr_two_location, fixed_size=300, use_multiprocessing=False,
410+
value_added_catalog_location, dr_two_location, fixed_size=300,
411+
use_multiprocessing=False,
418412
num_threads=os.cpu_count()):
419413
"""
420414
Creates fixed size dataset using LGZ data

lofarnn/visualization/cutouts.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import matplotlib.patches as patches
2+
import matplotlib.pyplot as plt
3+
import numpy as np
4+
5+
6+
def plot_cutout_and_bbox(image_name, title):
7+
"""
8+
9+
:param image_name:
10+
:param title:
11+
:return:
12+
"""
13+
14+
cutout_and_bboxes = np.load(image_name)
15+
cutout = cutout_and_bboxes[0]
16+
bboxes = cutout_and_bboxes[1]
17+
fig,ax = plt.subplots(1)
18+
if cutout.shape[2] == 3:
19+
ax.imshow(cutout)
20+
21+
for bbox in bboxes:
22+
rect = patches.Rectangle((bbox[0], bbox[1]), 1, 1, linewidth=1, edgecolor='r', facecolor='none')
23+
ax.add_patch(rect)
24+
25+
plt.show()

0 commit comments

Comments
 (0)