Skip to content

Commit

Permalink
Merge pull request #29 from jurjen93/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
jurjen93 authored Oct 17, 2024
2 parents 9401361 + 9da7124 commit b7420d6
Show file tree
Hide file tree
Showing 39 changed files with 693 additions and 3,351 deletions.
Empty file added __init__.py
Empty file.
Empty file added catalogue_helpers/__init__.py
Empty file.
515 changes: 0 additions & 515 deletions catalogue_helpers/find_sources.py

This file was deleted.

File renamed without changes.
Empty file added ds9_helpers/__init__.py
Empty file.
132 changes: 0 additions & 132 deletions ds9_helpers/select_facets.py

This file was deleted.

6 changes: 3 additions & 3 deletions ds9_helpers/split_polygon_facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def main():
H.close()

#TODO: dangerous! Convert to degrees
if np.all(np.abs(dirs)<2*np.pi):
dirs %= (2*np.pi)
dirs *= 360/(2*np.pi)
if np.all(np.abs(dirs) < 2 * np.pi):
# Converting radians to degrees
dirs = np.degrees(dirs)

f = open('polygon_info.csv', 'w')
writer = csv.writer(f)
Expand Down
Empty file added fits_helpers/__init__.py
Empty file.
10 changes: 7 additions & 3 deletions fits_helpers/crop_nan_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ def parse_args():
:return: parsed arguments
"""
parser = ArgumentParser(description='Crop fits file with nan boundaries')
parser.add_argument('--fits_input', help='fits input file', required=True, type=str)
parser.add_argument('--fits_output', help='fits output file', required=True, type=str)
parser.add_argument('fits_in', help='fits input file', type=str)
parser.add_argument('--output_name', help='fits output file', type=str)
return parser.parse_args()

def main():
""" Main function"""
args = parse_args()
crop_nan_boundaries(args.fits_input, args.fits_output)
if args.output_name is None:
outname = args.fits_in
else:
outname = args.output_name
crop_nan_boundaries(args.fits_in, outname)

if __name__ == '__main__':
main()
24 changes: 24 additions & 0 deletions fits_helpers/cropy_2048.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""
Crop image to 2048x2048 (for neural network)
"""

from astropy.io import fits
import numpy as np
from argparse import ArgumentParser


def crop_fits_image(input_filename, output_filename, center=None):
Expand Down Expand Up @@ -55,3 +60,22 @@ def crop_fits_image(input_filename, output_filename, center=None):
# Write the cropped image to the output file
hdu = fits.PrimaryHDU(data=np.array([[cropped_data]]), header=header)
hdu.writeto(output_filename, overwrite=True)


def parse_args():
"""
Command line argument parser
:return: parsed arguments
"""
parser = ArgumentParser(description='Crop image to 2048x2048')
parser.add_argument('--fits_input', help='fits input file', required=True, type=str)
parser.add_argument('--fits_output', help='fits output file', required=True, type=str)
return parser.parse_args()

def main():
""" Main function"""
args = parse_args()
crop_fits_image(args.fits_input, args.fits_output)

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def parse_args():
:return: parsed arguments
"""
parser = ArgumentParser(description='Cut fits file with region file')
parser.add_argument('--fits_input', help='fits input file', required=True, type=str)
parser.add_argument('--fits_output', help='fits output file', required=True, type=str)
parser.add_argument('fits_input', help='fits input file', type=str)
parser.add_argument('--output_name', help='fits output file', type=str)
parser.add_argument('--region', help='region file', required=True, type=str)
return parser.parse_args()

Expand All @@ -24,7 +24,9 @@ def main():

fitsfile = args.fits_input
regionfile = args.region
outputfits = args.fits_output
outputfits = args.output_name
if outputfits is None:
outputfits = fitsfile

hdu = fits.open(fitsfile)

Expand Down
61 changes: 0 additions & 61 deletions fits_helpers/get_beam_rms_facet.py

This file was deleted.

File renamed without changes.
File renamed without changes.
109 changes: 0 additions & 109 deletions fits_helpers/plot_baseline_track.py

This file was deleted.

Empty file added h5_helpers/__init__.py
Empty file.
Loading

0 comments on commit b7420d6

Please sign in to comment.