Skip to content

Commit

Permalink
Specify summary image with id=0. #70
Browse files Browse the repository at this point in the history
  • Loading branch information
kmhess committed Sep 16, 2024
1 parent a96a70c commit 27c6910
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/image_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
# Import default Python libraries
from argparse import ArgumentParser, RawTextHelpFormatter
import os
import sys

# Import installed Python libraries
from astropy.io import fits # change to table.read?
from astropy.table import Table
from astropy import units as u
import pkg_resources # part of setuptools
import numpy as np

from src import make_images, make_spectra
from src.modules.functions import get_radecfreq
from src.modules.functions import get_radecfreq, make_source
from src.combine_images import combine_images

version = pkg_resources.require("SoFiA-image-pipeline")[0].version
Expand All @@ -29,7 +27,8 @@ def main():
help='Required: Specify the input XML or ascii catalog name. No default.')

parser.add_argument('-id', '--source-id', default=[], nargs='*', #type=int,
help='Space-separated list, or range of sources to include in the plotting. Default all sources')
help='Space-separated list, or range of sources to include in the plotting. If set to 0, do summary figure. \n'
' Default all sources.')

parser.add_argument('-x', '--suffix', default='png',
help='Optional: specify the output image file type: png, pdf, eps, jpeg, tiff, etc (default: %(default)s).')
Expand Down Expand Up @@ -212,6 +211,15 @@ def main():

n_src += 1

if 0 in args.source_id:
print("\n\tMaking summary images of full field.")
new_source = make_source(catalog=catalog, fits_name=catalog_file.split("_cat.")[0] + '.fits')
catalog.add_row(new_source)
src_basename = src_basename.split('_cubelets')[0]
make_images.main(catalog[-1], src_basename, opt_view=opt_view, suffix=suffix, sofia=sofia, beam=beam,
chan_width=args.chan_width[0], surveys=list(surveys), snr_range=args.snr_range,
user_image=args.user_image, user_range=args.user_range, spec_line=args.spectral_line)

print("\n\tDONE! Made images for {} sources.".format(n_src))
print("*****************************************************************\n")

Expand Down
7 changes: 3 additions & 4 deletions src/modules/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def felo2vel(channels, fits_name):
:param channels:
:type channels: Iterable[int]
:param fits_name:
:param fits_name: name of the FITS file
:type fits_name: str
:return: calculated velocities
:rtype: Iterable[float]
Expand Down Expand Up @@ -151,7 +151,7 @@ def sbr2nhi(sbr, bunit, bmaj, bmin, source, spec_line=None):
return nhi, nhi_label, nhi_labels


def get_info(fits_name, beam=None):
def get_info(fits_name, beam=None, source_id=0):
"""Get the beam info from a FITS file.
:param fits_name: name of the FITS file
Expand Down Expand Up @@ -264,11 +264,10 @@ def get_info(fits_name, beam=None):
pass

# Try to determine the spectral properties
if fits_name[-9:] != 'cube.fits':
if (fits_name[-9:] != 'cube.fits') and (source_id != 0):
print("\tWARNING: Retrieving info from a moment map or other 2D image?")
chan_width = None
spec_axis = None

else:
spec_axis = header['CTYPE3']
chan_width = header['CDELT3']
Expand Down

0 comments on commit 27c6910

Please sign in to comment.