Skip to content

Commit

Permalink
Merge pull request #133 from desihub/dr10
Browse files Browse the repository at this point in the history
add support for DR10 photometry
  • Loading branch information
moustakas committed Aug 2, 2023
2 parents 3b3572c + 517ef94 commit cec13e9
Show file tree
Hide file tree
Showing 11 changed files with 784 additions and 457 deletions.
56 changes: 39 additions & 17 deletions bin/fastspecfit-qa
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ def parse(options=None):
parser.add_argument('--specfile-prefix', type=str, default='coadd-', help='Prefix of the spectral file(s).')
parser.add_argument('--qnfile-prefix', type=str, default='qso_qn-', help='Prefix of the QuasarNet afterburner file(s).')
parser.add_argument('--mapdir', type=str, default=None, help='Optional directory name for the dust maps.')
parser.add_argument('--dr9dir', type=str, default=None, help='Optional directory name for the DR9 photometry.')
parser.add_argument('--fphotodir', type=str, default=None, help='Top-level location of the source photometry.')
parser.add_argument('--fphotoinfo', type=str, default=None, help='Photometric information file.')

parser.add_argument('--emline_snrmin', type=float, default=0.0, help='Minimum emission-line S/N to be displayed.')
parser.add_argument('--nsmoothspec', type=int, default=0, help='Smoothing pixel value.')

parser.add_argument('--minspecwave', type=float, default=3500., help='Minimum spectral wavelength (Angstrom).')
parser.add_argument('--maxspecwave', type=float, default=9900., help='Maximum spectral wavelength (Angstrom).')
parser.add_argument('--minphotwave', type=float, default=0.1, help='Minimum photometric wavelength (micron).')
parser.add_argument('--maxphotwave', type=float, default=35., help='Maximum photometric wavelength (micron).')

parser.add_argument('--targetids', type=str, default=None, help='Comma-separated list of target IDs to process.')
parser.add_argument('-n', '--ntargets', type=int, help='Number of targets to process in each file.')
Expand Down Expand Up @@ -84,13 +93,6 @@ def main(args=None, comm=None):

fastfit, metadata, coadd_type, fastphot = read_fastspecfit(args.fastfitfile[0])

# check for the input redshifts header card
hdr = fitsio.read_header(args.fastfitfile[0])
if 'INPUTZ' in hdr and hdr['INPUTZ']:
input_redshifts = True
else:
input_redshifts = False

# parse the targetids optional input
if args.targetids:
targetids = [int(x) for x in args.targetids.split(',')]
Expand All @@ -115,6 +117,18 @@ def main(args=None, comm=None):
log.critical(errmsg)
raise IOError(errmsg)

# check for the input redshifts header card
hdr = fitsio.read_header(args.fastfitfile[0])
if 'INPUTZ' in hdr and hdr['INPUTZ']:
inputz = True
else:
inputz = False

if 'NOSCORR' in hdr and hdr['NOSCORR']:
no_smooth_continuum = True
else:
no_smooth_continuum = False

if args.outdir:
if not os.path.isdir(args.outdir):
os.makedirs(args.outdir, exist_ok=True)
Expand All @@ -138,7 +152,9 @@ def main(args=None, comm=None):
log.info('Building QA for {} objects.'.format(len(metadata)))

# Initialize the I/O class.
Spec = DESISpectra(redux_dir=args.redux_dir, dr9dir=args.dr9dir, mapdir=args.mapdir)

Spec = DESISpectra(redux_dir=args.redux_dir, fphotodir=args.fphotodir,
fphotoinfo=args.fphotoinfo, mapdir=args.mapdir)

templates = get_templates_filename(templateversion=args.templateversion, imf=args.imf)

Expand All @@ -155,20 +171,26 @@ def main(args=None, comm=None):
maxspecwave = np.max(data[0]['coadd_wave']) + 20
else:
targetids = fastfit['TARGETID'][indx]
Spec.select(redrockfiles=redrockfile, targetids=targetids,
if inputz:
input_redshifts = fastfit['Z'][indx]
else:
input_redshifts = None
Spec.select(redrockfiles=redrockfile, targetids=targetids,
input_redshifts=input_redshifts,
redrockfile_prefix=args.redrockfile_prefix,
specfile_prefix=args.specfile_prefix,
qnfile_prefix=args.qnfile_prefix)
data = Spec.read_and_unpack(fastphot=fastphot, synthphot=True, mp=args.mp)

minspecwave = 3500.
maxspecwave = 9900.
minspecwave = args.minspecwave
maxspecwave = args.maxspecwave

qaargs = [(data[igal], fastfit[indx[igal]], metadata[indx[igal]],
templates, coadd_type, minspecwave, maxspecwave,
fastphot, args.nophoto, stackfit, input_redshifts,
args.outdir, args.outprefix, log)
for igal in np.arange(len(indx))]
templates, coadd_type, Spec.fphoto, minspecwave, maxspecwave,
args.minphotwave, args.maxphotwave, args.emline_snrmin,
args.nsmoothspec, fastphot, args.nophoto, stackfit, inputz,
no_smooth_continuum, args.outdir, args.outprefix, log)
for igal in np.arange(len(indx))]
if args.mp > 1:
import multiprocessing
with multiprocessing.Pool(args.mp) as P:
Expand Down
9 changes: 8 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
Change Log
==========

2.2.0 (not released yet)
2.3.0 (not released yet)
------------------------

* Support non-DR9 photometry via a new photometric configuration file [`PR #133`_].

.. _`PR #133`: https://github.com/desihub/fastspecfit/pull/133

2.2.0 (2023-08-02)
------------------

* Allow the Redrock redshift to be overridden [`PR #115`_].
* Code to support fitting stacked spectra [`PR #116`_].
* Bug fix of reversed tied flux ratio of [OII]7320,7330 doublet [`PR #120`_].
Expand Down
Loading

0 comments on commit cec13e9

Please sign in to comment.