Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fujilupe release candidate #69

Merged
merged 114 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
9286237
desimodel data files not needed
moustakas Mar 24, 2022
8c649f4
data model change: faprgrm-->program, hpxpixel-->healpix
moustakas Mar 24, 2022
8081e2b
more data model updates
moustakas Mar 24, 2022
232a18b
and more data model
moustakas Mar 24, 2022
233907d
remove coadd_fiberstatus and zwarn cuts
moustakas Mar 24, 2022
271f168
allow specprod to be an array
moustakas Mar 24, 2022
214f486
documentation
moustakas Mar 25, 2022
118191b
more docs
moustakas Mar 25, 2022
452dcd1
data model change: use narrow,broad,uv average sigma and redshift
moustakas Mar 26, 2022
a72e99f
add [SIII] 6312
moustakas Mar 26, 2022
a4613cc
cleanup
moustakas Mar 27, 2022
a6a3a98
make solve_vdisp an attribute of the ContinuumFit class
moustakas Mar 27, 2022
99772c9
major rewrite of initial line-sigma estimate and smooth continuum alg…
moustakas Mar 27, 2022
87e0d91
remove everest algorithms
moustakas Mar 27, 2022
ddfe0ae
tons of smooth continuum code dev
moustakas Mar 29, 2022
bb1181e
debugging
moustakas Apr 20, 2022
9c09fa1
doc fix
moustakas Apr 20, 2022
3c6c363
Merge branch 'fujidev-continued' of github.com:desihub/fastspecfit in…
moustakas Apr 20, 2022
4c05b7a
more smooth continuum code dev
moustakas Jun 10, 2022
94e2367
Merge branch 'main' into fujidev-continued
moustakas Jun 11, 2022
e87f73e
drop lines with negative amp; reset vshift,sigma to 0.0 for dropped l…
moustakas Jun 11, 2022
495c698
smarter linesigma diagnostic
moustakas Jun 12, 2022
f80294b
bug fix: set initial line-amplitude from the continuum-subtracted, no…
moustakas Jun 12, 2022
3e3ef57
use coadded spectrum for initial line-amplitude, not per-camera spectra
moustakas Jun 13, 2022
5bd6827
use initial line-sigma guess in line-fitting
moustakas Jun 13, 2022
8cf274f
update to use latest gather_targetphot
moustakas Jun 24, 2022
eb5116c
redrock files can come from a different healpixel
moustakas Jun 24, 2022
767ee24
better initialization of broad lines
moustakas Jun 24, 2022
baa8df2
allow broad Balmer lines to be present without their narrow-line coun…
moustakas Jun 24, 2022
fd36a49
iterative fit with and without broad lines
moustakas Jun 26, 2022
4432529
add optional final fit with no constraints (default is false)
moustakas Jun 27, 2022
e9cfc49
ignored tied parameters when computing reduced chi2
moustakas Jun 27, 2022
f1af0fa
more sensible default values in output fastspec table
moustakas Jun 28, 2022
e26a23f
use ivar weights in sliding smooth_continuum
moustakas Jun 28, 2022
55bcf9e
rename CONTINUUM_CHI2 --> CONTINUUM_RCHI2
moustakas Jun 28, 2022
f564a6a
add rchi2 and other new columns; improved initial linesigma guess
moustakas Jun 28, 2022
e48b446
bug when initializing broad UV lines
moustakas Jun 29, 2022
ec9f711
try fitting MgII as two independent lines
moustakas Jun 29, 2022
38b0ab3
more decimal points to MgII wavelengths
moustakas Jun 29, 2022
7cd3108
fit mgii as a single line
moustakas Jun 29, 2022
918f632
interpolate over masked pixels--not happy about this
moustakas Jun 29, 2022
e2c4be9
oops
moustakas Jun 29, 2022
b2f8417
restore MgII as a doublet
moustakas Jun 29, 2022
ae16ef7
mask broader Balmer even if line is not detected
moustakas Jun 29, 2022
fd13a27
corner case: fix linemasking masks full spectrum
moustakas Jun 30, 2022
93e4dee
initial line-amplitudes should not be zero
moustakas Jun 30, 2022
134b342
no lower bound on UV lines; bugs
moustakas Jun 30, 2022
822870f
major cleanup of how fixed and tied lines are handled; speed-ups and …
moustakas Jul 2, 2022
6215849
bug when computing broadlinepix
moustakas Jul 2, 2022
164bee7
show broad and narrow lines separately in QA
moustakas Jul 2, 2022
a4a32e2
drop HeI 3889: too blended with H6 which causes fitting problems
moustakas Jul 2, 2022
f287318
QA update: plot individual lines and change colors
moustakas Jul 3, 2022
79ce636
more qa tweaks
moustakas Jul 3, 2022
a32c0f1
vdisp bug: need to convolve before redshifting and resampling (see #67)
moustakas Jul 3, 2022
9e9c49a
new version 1.1 of SSPs with 10 km/s pixels
moustakas Jul 3, 2022
486fb46
major rewrite of vdisp code; bugs fixed
moustakas Jul 3, 2022
1e082ac
make the refined vdisp fitting optional; vdisp uncertainties remain l…
moustakas Jul 4, 2022
93ec08a
major plotting bug fix which was overbroadening the continuum model--yay
moustakas Jul 4, 2022
5b5f54d
bug when building tileid_list
moustakas Jul 4, 2022
5d18aa9
only refit masking linesigma if S/N>0
moustakas Jul 5, 2022
122e718
bug fix when restoring broad lines
moustakas Jul 6, 2022
dd2860d
bug fix when computing AV and vdisp uncertainties
moustakas Jul 6, 2022
f28d244
update AV prior
moustakas Jul 6, 2022
2c13588
use 12 not 13 Gyr as last template age
moustakas Jul 6, 2022
e87d082
start fixing unit tests
moustakas Jul 6, 2022
f219910
add w3 and w4 photometry
moustakas Jul 7, 2022
e4d76d6
rewrite of 4000-A break code; ivar calculation fixed
moustakas Jul 8, 2022
8728a8c
port redrock dependencies into util
moustakas Jul 8, 2022
bf7f1f3
update install doc
moustakas Jul 8, 2022
cba509c
add simple stellar mass
moustakas Jul 8, 2022
b86d4a7
update fastphot qa
moustakas Jul 9, 2022
464e4a7
wrong factor of 4pi in mstar
moustakas Jul 9, 2022
898f4ca
add W3, W4 to QA but do not fit
moustakas Jul 9, 2022
a87d66c
address #22; update fastphot qa; fix upper limits bug
moustakas Jul 10, 2022
ae2e153
cleanup and minor speed-ups; new cache_vdisp keyword
moustakas Jul 10, 2022
64c2047
more cleanup
moustakas Jul 10, 2022
8ff3b8e
fix #56
moustakas Jul 10, 2022
596736f
significant update to how k-corrections are computed in order to acco…
moustakas Jul 11, 2022
c1c1327
use SDSS filters with atmospheric extinction included https://github.…
moustakas Jul 12, 2022
fc6af5f
fix several kcorrection bugs
moustakas Jul 12, 2022
0e937c0
add survey program tileid etc. to fastspec and fastphot extensions, t…
moustakas Jul 13, 2022
7bdfb22
debugging dust attenuation curve
moustakas Jul 13, 2022
29ba044
switch to Fitzpatrick extinction curve
moustakas Jul 13, 2022
cc20597
remove gather_targetphot dependency; only use gather_tractorphot
moustakas Jul 13, 2022
75d1eb1
test writing out model spectra with fastspec files
moustakas Jul 14, 2022
581807c
add dependencies to header and gzip compress the output
moustakas Jul 14, 2022
4fcef4a
add UV luminosities, rest-frame line-continuum fluxes, and begin addi…
moustakas Jul 14, 2022
d1b367f
more units
moustakas Jul 14, 2022
9cf6c9d
look for gz files when merging
moustakas Jul 14, 2022
2cc0376
add L5100 luminosity; other debugging
moustakas Jul 14, 2022
5b2d835
a few more data model update requests
moustakas Jul 14, 2022
80b65a3
deprecate units and QTable - too slow and doesn't stack
moustakas Jul 15, 2022
d06f32d
fastphot plotting bugs
moustakas Jul 15, 2022
24f705c
assign table units right before writing
moustakas Jul 15, 2022
1732691
fix #72
moustakas Jul 15, 2022
bf078aa
header and io bugs
moustakas Jul 15, 2022
3f21577
cap the velocity dispersion ivar at 1e-5
moustakas Jul 17, 2022
9c116e6
require at least three good photometric bands to attempt a fit
moustakas Jul 17, 2022
fc16ba9
fix #8
moustakas Jul 17, 2022
b2e3c8c
try to fix doc test; remove redrock and numba dependency
moustakas Jul 17, 2022
e7e6cf0
more test fixes; update templates
moustakas Jul 17, 2022
7e0395d
install speclite branch with sdss2010atm filters
moustakas Jul 17, 2022
6be9c76
more test fix attempts
moustakas Jul 17, 2022
cb6ce2e
unit tests finally pass but coverage fails; try one more time
moustakas Jul 17, 2022
c070417
fit at the quasarnet redshift when available
moustakas Jul 18, 2022
c8e1feb
better masking of Lya; tied SiIII and CIII together
moustakas Jul 18, 2022
35123aa
try fixing coveralls failure
moustakas Jul 18, 2022
130f389
updates to MPI interface
moustakas Jul 18, 2022
0880703
more MPI fixes
moustakas Jul 18, 2022
4cc96ef
one more try to fix coverage failing tests
moustakas Jul 18, 2022
cb34c74
fix stellar mass bug
moustakas Jul 20, 2022
4963366
update change log [ci skip]
moustakas Jul 20, 2022
058634c
update dependencies of tags
moustakas Jul 20, 2022
3412295
update speclite filter group
moustakas Jul 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls
run: coveralls --service=github

docs:
name: Doc test
Expand Down
14 changes: 9 additions & 5 deletions bin/CKC2fits
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ DESI at ~1 micron) but to save space every just fourth pixel longward of 1
micron (so an effective pixel spacing of ~100 km/s) is written out. Each SSP
has ~83,000 pixels.

version 1.0: 25 km/s pixels
version 1.1: 10 km/s pixels

"""
import os, pdb
import numpy as np

from scipy import constants
C_LIGHT = constants.c / 1000.0 # [km/s]

ssppath = '/global/cfs/cdirs/desi/science/gqp/templates/SSP-CKC14z-loglam'
ssppath = '/global/cfs/cdirs/desi/science/gqp/templates/SSP-CKC14z'
version = 'v1.1'

def _CKC2fits(metallicity='Z0.0190'):
from astropy.io import fits
Expand All @@ -30,11 +34,11 @@ def _CKC2fits(metallicity='Z0.0190'):

sspfile = os.path.join(ssppath, 'spec', 'SSP_{}_{}_{}_{}.out.spec'.format(
isochrone, library, imf, metallicity))
outfile = os.path.join(ssppath, 'SSP_{}_{}_{}_{}.fits'.format(
outfile = os.path.join(ssppath, version, 'SSP_{}_{}_{}_{}.fits'.format(
isochrone, library, imf, metallicity))

skiprow = 8 # skip the informational header
nage, _npix = np.loadtxt(sspfile, skiprows=skiprow, max_rows=1, dtype=np.int, unpack=True)
nage, _npix = np.loadtxt(sspfile, skiprows=skiprow, max_rows=1, dtype=int, unpack=True)
skiprow += 1

wave = np.loadtxt(sspfile, skiprows=skiprow, max_rows=1) # vacuum wavelengths
Expand All @@ -43,7 +47,7 @@ def _CKC2fits(metallicity='Z0.0190'):

# Resample to constant log-lambda / velocity. In the IR (starting at ~1
# micron), take every fourth sampling, to save space.
pixkms = 25.0 # pixel size [km/s]
pixkms = 10.0 # pixel size [km/s]
irfactor = 4
wavesplit = 1e4
dlogwave = pixkms / C_LIGHT / np.log(10) # pixel size [log-lambda]
Expand Down Expand Up @@ -89,6 +93,7 @@ def _CKC2fits(metallicity='Z0.0190'):

hduflux = fits.PrimaryHDU(flux.value)
hduflux.header['EXTNAME'] = 'FLUX'
hduflux.header['VERSION'] = version
hduflux.header['BUNIT'] = 'erg/(s cm2 Angstrom)'

hduwave = fits.ImageHDU(newwave.value)
Expand All @@ -113,4 +118,3 @@ if __name__ == '__main__':
#for metallicity in [allZ[6]]:
for metallicity in allZ:
_CKC2fits(metallicity)

4 changes: 2 additions & 2 deletions bin/fastspecfit-deredshift
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def main(args=None, comm=None):
petal, tile, thrunights[indx[0]]))
zbestfiles.append(zbestfile)

Spec.find_specfiles(zbestfiles=zbestfiles, specprod=specprod,
coadd_type='cumulative', targetids=targetids)
Spec.select(zbestfiles=zbestfiles, specprod=specprod,
coadd_type='cumulative', targetids=targetids)
#dataphot = Spec.read_and_unpack(CFit, fastphot=True, synthphot=False)
dataspec = Spec.read_and_unpack(CFit, fastphot=False, synthphot=False,
remember_coadd=True)
Expand Down
14 changes: 7 additions & 7 deletions bin/fastspecfit-html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fastspecfit-html --fastspecfile ./fastspect.fits

fastspecfit-html --fastphotfile /global/cfs/cdirs/desi/spectro/fastspecfit/everest/catalogs/fastphot-everest-sv3-dark.fits \
--fastspecfile /global/cfs/cdirs/desi/spectro/fastspecfit/everest/catalogs/fastspec-everest-sv3-dark.fits \
-o /global/cfs/cdirs/desi/users/ioannis/fastspecfit/everest --hpxpixel 10016
-o /global/cfs/cdirs/desi/users/ioannis/fastspecfit/everest --healpix 10016

fastspecfit-html --fastphotfile /global/cfs/cdirs/desi/spectro/fastspecfit/everest/tiles/merged/fastphot-everest-cumulative.fits \
--fastspecfile /global/cfs/cdirs/desi/spectro/fastspecfit/everest/tiles/merged/fastspec-everest-cumulative.fits \
Expand All @@ -30,7 +30,7 @@ def parse(options=None):

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('--hpxpixel', default=None, type=str, nargs='*', help="""Generate QA for all objects
parser.add_argument('--healpix', default=None, type=str, nargs='*', help="""Generate QA for all objects
with this healpixels (only defined for coadd-type 'healpix').""")
parser.add_argument('--tile', default=None, type=str, nargs='*', help='Tile(s) to process.')
parser.add_argument('--night', default=None, type=str, nargs='*', help='Night(s) to process (ignored if coadd-type is cumulative).')
Expand Down Expand Up @@ -101,9 +101,9 @@ def main(args=None, comm=None):
fastphot['NIGHT'] = metaphot['NIGHT']

if coadd_type == 'healpix':
joinkeys += ['HPXPIXEL']
fastspec['HPXPIXEL'] = metaspec['HPXPIXEL']
fastphot['HPXPIXEL'] = metaphot['HPXPIXEL']
joinkeys += ['HEALPIX']
fastspec['HEALPIX'] = metaspec['HEALPIX']
fastphot['HEALPIX'] = metaphot['HEALPIX']

fastfit = join(fastspec, fastphot, keys=joinkeys, join_type='outer',
table_names=['SPEC', 'PHOT'])
Expand Down Expand Up @@ -138,7 +138,7 @@ def main(args=None, comm=None):
metadata = metadata[keep]

fastfit, metadata = select(fastfit, metadata, coadd_type,
hpxpixels=args.hpxpixel,
healpixs=args.healpix,
tiles=args.tile, nights=args.night)

# read the tile info file for this production
Expand All @@ -151,7 +151,7 @@ def main(args=None, comm=None):
# add tileid --> healpix mapping
if coadd_type == 'healpix':
hpxinfo = Table.read(os.path.join(specproddir, 'healpix', 'tilepix.fits'))
metadata['TILEID'] = hpxinfo[np.isin(hpxinfo['HEALPIX'], metadata['HPXPIXEL'])]['TILEID']
metadata['TILEID'] = hpxinfo[np.isin(hpxinfo['HEALPIX'], metadata['HEALPIX'])]['TILEID']
#info['HEALPIX'] = hpxinfo[np.isin(info['TILEID'], hpxinfo['TILEID'])]

itile = np.isin(info['TILEID'], metadata['TILEID'])
Expand Down
137 changes: 66 additions & 71 deletions bin/fastspecfit-qa
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,21 @@ def parse(options=None):

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('--hpxpixel', default=None, type=str, nargs='*', help="""Generate QA for all objects
parser.add_argument('--healpix', default=None, type=str, nargs='*', help="""Generate QA for all objects
with this healpixels (only defined for coadd-type 'healpix').""")
parser.add_argument('--tile', default=None, type=str, nargs='*', help='Generate QA for all objects on this tile.')
parser.add_argument('--night', default=None, type=str, nargs='*', help="""Generate QA for all objects observed on this
night (only defined for coadd-type 'pernight' and 'perexp').""")
parser.add_argument('--redux_dir', default=None, type=str, help='Top-level path to the reduced spectra.')
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.')
parser.add_argument('--firsttarget', type=int, default=0, help='Index of first object to to process in each file (0-indexed).')
parser.add_argument('--mp', type=int, default=1, help='Number of multiprocessing processes per MPI rank or node.')

parser.add_argument('--nolegend', action='store_true', help='Exclude legends from QA.')

parser.add_argument('--outprefix', default=None, type=str, help='Optional prefix for output filename.')
parser.add_argument('-o', '--outdir', default='.', type=str, help='Full path to desired output directory.')

parser.add_argument('--fastphotfile', default=None, type=str, help='Full path to fastphot fitting results.')
parser.add_argument('--fastspecfile', default=None, type=str, help='Full path to fastphot fitting results.')
#parser.add_argument('redrockdata', nargs='*', help='Full path to redrock file(s) or a directory containing redrock file(s).')
parser.add_argument('fastfitfile', nargs=1, help='Full path to fastspec or fastphot fitting results.')

if options is None:
args = parser.parse_args()
Expand All @@ -65,21 +62,18 @@ def main(args=None, comm=None):
if isinstance(args, (list, tuple, type(None))):
args = parse(args)

if args.redux_dir is None:
args.redux_dir = os.path.join(os.environ.get('DESI_ROOT', DESI_ROOT_NERSC), 'spectro', 'redux')
if not os.path.isdir(args.redux_dir):
errmsg = 'Data reduction directory {} not found.'.format(args.redux_dir)
log.critical(errmsg)
raise IOError(errmsg)

# Read the fitting results.
if ((args.fastphotfile is None and args.fastspecfile is None) or
(args.fastphotfile is not None and args.fastspecfile is not None)):
log.warning('Must provide one (but not both) of --fastphotfile or --fastspecfile.')
if not os.path.isfile(args.fastfitfile[0]):
log.warning('File {} not found.'.format(args.fastfitfile[0]))
return
elif args.fastphotfile is None and args.fastspecfile is not None:
fastphot = False
fastfitfile = args.fastspecfile
elif args.fastphotfile is not None and args.fastspecfile is None:
fastphot = True
fastfitfile = args.fastphotfile
else:
pass # should never get here

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

# parse the targetids optional input
if args.targetids:
Expand All @@ -97,32 +91,23 @@ def main(args=None, comm=None):
fastfit = fastfit[keep]
metadata = metadata[keep]

fastfit, metadata = select(fastfit, metadata, coadd_type, hpxpixels=args.hpxpixel,
fastfit, metadata = select(fastfit, metadata, coadd_type, healpixels=args.healpix,
tiles=args.tile, nights=args.night)

# Initialize the continuum- and emission-line fitting classes.
t0 = time.time()
CFit = ContinuumFit(nolegend=args.nolegend)
EMFit = EMLineFit(nolegend=args.nolegend)
Spec = DESISpectra()
Spec = DESISpectra(redux_dir=args.redux_dir)
log.info('Initializing the classes took: {:.2f} sec'.format(time.time()-t0))

if args.outdir:
if not os.path.isdir(args.outdir):
os.makedirs(args.outdir, exist_ok=True)

print('Hacking specprod!!!')
specprod = 'fuji'
specproddir = os.path.join(os.environ.get('DESI_ROOT', DESI_ROOT_NERSC), 'spectro', 'redux', specprod)

#if fastphot:
# synthphot = False
#else:
# synthphot = True

def _wrap_qa(redrockfile, indx):
targetids = fastfit['TARGETID'][indx]
Spec.find_specfiles(redrockfiles=redrockfile, targetids=targetids)
Spec.select(redrockfiles=redrockfile, targetids=targetids)
data = Spec.read_and_unpack(CFit, fastphot=fastphot, synthphot=True, remember_coadd=True)
qaargs = [(CFit, EMFit, data[igal], fastfit[indx[igal]], metadata[indx[igal]],
coadd_type, fastphot, args.outdir, args.outprefix) for igal in np.arange(len(indx))]
Expand All @@ -136,58 +121,68 @@ def main(args=None, comm=None):

t0 = time.time()
if coadd_type == 'healpix':
allspecprods = metadata['SPECPROD'].data
allsurveys = metadata['SURVEY'].data
allprograms = metadata['FAPRGRM'].data
allpixels = metadata['HPXPIXEL'].data
for survey in set(allsurveys):
for program in set(allprograms):
for pixel in set(allpixels):
indx = np.where((survey == allsurveys) * (program == allprograms) * (pixel == allpixels))[0]
if len(indx) == 0:
log.warning('No object found with survey={}, program={}, and healpixel={}!'.format(
survey, program, pixel))
continue
redrockfile = os.path.join(specproddir, 'healpix', str(survey), str(program), str(pixel // 100), str(pixel),
'redrock-{}-{}-{}.fits'.format(survey, program, pixel))
_wrap_qa(redrockfile, indx)
allprograms = metadata['PROGRAM'].data
allpixels = metadata['HEALPIX'].data
for specprod in set(allspecprods):
for survey in set(allsurveys):
for program in set(allprograms):
for pixel in set(allpixels):
indx = np.where((specprod == allspecprods) * (survey == allsurveys) *
(program == allprograms) * (pixel == allpixels))[0]
if len(indx) == 0:
#log.warning('No object found with specprod={}, survey={}, program={}, and healpixel={}!'.format(
# specprod, survey, program, pixel))
continue
redrockfile = os.path.join(args.redux_dir, specprod, 'healpix', str(survey), str(program), str(pixel // 100),
str(pixel), 'redrock-{}-{}-{}.fits'.format(survey, program, pixel))
_wrap_qa(redrockfile, indx)
else:
allspecprods = metadata['SPECPROD'].data
alltiles = metadata['TILEID'].astype(str).data
allnights = metadata['NIGHT'].astype(str).data
allpetals = metadata['FIBER'].data // 500
if coadd_type == 'cumulative':
thrunights = metadata['THRUNIGHT'].astype(str).data
for tile in set(alltiles):
for petal in set(allpetals):
indx = np.where((tile == alltiles) * (petal == allpetals))[0]
if len(indx) == 0:
log.warning('No object found with tileid={} and petal={}!'.format(
tile, petal))
continue
redrockfile = os.path.join(specproddir, 'tiles', 'cumulative', str(tile), thrunights[indx[0]],
'redrock-{}-{}-thru{}.fits'.format(petal, tile, thrunights[indx[0]]))
_wrap_qa(redrockfile, indx)
elif coadd_type == 'pernight':
allnights = metadata['NIGHT'].astype(str).data
for night in set(allnights):
for specprod in set(allspecprods):
for tile in set(alltiles):
for petal in set(allpetals):
indx = np.where((night == allnights) * (tile == alltiles) * (petal == allpetals))[0]
redrockfile = os.path.join(specproddir, 'tiles', 'pernight', str(tile), str(night),
'redrock-{}-{}-{}.fits'.format(petal, tile, night))
indx = np.where((specprod == allspecprods) * (tile == alltiles) * (petal == allpetals))[0]
if len(indx) == 0:
#log.warning('No object found with tileid={} and petal={}!'.format(
# tile, petal))
continue
redrockfile = os.path.join(args.redux_dir, specprod, 'tiles', 'cumulative', str(tile), allnights[indx[0]],
'redrock-{}-{}-thru{}.fits'.format(petal, tile, allnights[indx[0]]))
_wrap_qa(redrockfile, indx)
elif coadd_type == 'perexp':
allnights = metadata['NIGHT'].astype(str).data
allexpids = metadata['EXPID'].data
for night in set(allnights):
for expid in set(allexpids):
elif coadd_type == 'pernight':
for specprod in set(allspecprods):
for night in set(allnights):
for tile in set(alltiles):
for petal in set(allpetals):
indx = np.where((night == allnights) * (expid == allexpids) *
indx = np.where((specprod == allspecprods) * (night == allnights) *
(tile == alltiles) * (petal == allpetals))[0]
redrockfile = os.path.join(specproddir, 'tiles', 'perexp', str(tile), '{:08d}'.format(expid),
'redrock-{}-{}-exp{:08d}.fits'.format(petal, tile, expid))
if len(indx) == 0:
continue
redrockfile = os.path.join(args.redux_dir, specprod, 'tiles', 'pernight', str(tile), str(night),
'redrock-{}-{}-{}.fits'.format(petal, tile, night))
_wrap_qa(redrockfile, indx)
else:
pass
elif coadd_type == 'perexp':
allexpids = metadata['EXPID'].data
for specprod in set(allspecprods):
for night in set(allnights):
for expid in set(allexpids):
for tile in set(alltiles):
for petal in set(allpetals):
indx = np.where((specprod == allspecprods) * (night == allnights) *
(expid == allexpids) * (tile == alltiles) *
(petal == allpetals))[0]
if len(indx) == 0:
continue
redrockfile = os.path.join(args.redux_dir, specprod, 'tiles', 'perexp', str(tile), '{:08d}'.format(expid),
'redrock-{}-{}-exp{:08d}.fits'.format(petal, tile, expid))
_wrap_qa(redrockfile, indx)

log.info('QA for everything took: {:.2f} sec'.format(time.time()-t0))

if __name__ == '__main__':
Expand Down