In [ ]:
module use /global/common/$NERSC_HOST/contrib/desi/modulefiles
module load desiconda/20170719-1.1.9-imaging
conda create --prefix $CSCRATCH/conda-envs/20170719-1.1.9-imaging --file $DESICONDA/pkg_list.txt
source activate $CSCRATCH/conda-envs/20170719-1.1.9-imaging
In [ ]:
# SF98 dust maps
export MYDIR=$CSCRATCH/repos
mkdir -p $MYDIR/dust/maps
cd $MYDIR/dust/maps
wget -c http://portal.nersc.gov/project/cosmo/temp/dstn/travis-ci/maps/SFD_dust_4096_ngp.fits
wget -c http://portal.nersc.gov/project/cosmo/temp/dstn/travis-ci/maps/SFD_dust_4096_sgp.fits
export DUST_DIR=$MYREPO/dust
# imaging pipeline
cd $MYDIR
git clone https://github.com/legacysurvey/legacypipe.git
cd legacypipe
git checkout f4fc46ea0
In [ ]:
cd py/test
wget https://raw.githubusercontent.com/legacysurvey/obiwan/master/py/obiwan/test/end_to_end/test_decam_rex.p
cd ../
python py/test_decam_rex.py
$MYREPO
/dust $MYREPO
/legacypipe/py/test/testcase6What this command does:
In [ ]:
main(args=['--brick', '1102p240', '--zoom', '500', '600', '650', '750',
'--force-all', '--no-write', '--no-wise',
'--survey-dir', surveydir,
'--outdir', outdir])
The main() above does the following:
REMEMBER: create the calibration files BEFORE running legacypipe
In [ ]:
# https://github.com/legacysurvey/legacypipe/blob/master/py/legacypipe/decam.py
# Edited to be barebones
from __future__ import print_function
import os
import numpy as np
import fitsio
from legacypipe.image import CalibMixin
from legacypipe.cpimage import CPImage
from legacypipe.survey import LegacySurveyData
'''
Code specific to images from the Dark Energy Camera (DECam).
'''
class DecamImage(CPImage, CalibMixin):
'''
A LegacySurveyImage subclass to handle images from the Dark Energy
Camera, DECam, on the Blanco telescope.
'''
# background subtraction fitting spline to every 512 pixels, interpolating between
splinesky_boxsize = 512
def __init__(self, survey, t):
super(DecamImage, self).__init__(survey, t)
# Check that these are set properly
#self.imgfn # image relative path starting from legacy_survey_dir/images/
#self.dqfn # bad pixel image
#self.wtfn # invvar image
# zeropoint units in ADU/sec
self.ccdzpt += 2.5 * np.log10(self.exptime)
def __str__(self):
return 'DECam ' + self.name
@classmethod
def nominal_zeropoints(self):
# Units ADU/sec for a good night 2 years ago
return dict(g = 25.08,
r = 25.29,
z = 24.92,)
@classmethod
def photometric_ccds(self, survey, ccds):
"""Remove exposures from survey-ccds-1.fits.gz if image quality not
good enough
Args:
ccds: the survey-ccds-1.fits.gz table
"""
# Nominal zeropoints (DECam)
z0 = self.nominal_zeropoints()
z0 = np.array([z0[f[0]] for f in ccds.filter])
# You can skipping removing any of them with:
good = np.ones(len(ccds), bool)
return np.flatnonzero(good)
@classmethod
def ccd_cuts(self, survey, ccds):
return np.zeros(len(ccds), np.int32)
def get_good_image_subregion(self):
"""Optional"""
x0,x1,y0,y1 = None,None,None,None
# x0,x1,y0,y1 = 100,1023,100,self.height-100
return x0,x1,y0,y1
def read_dq(self, header=False, **kwargs):
"""read bad pixel image and possibly its header"""
print('Reading data quality from', self.dqfn, 'hdu', self.hdu)
dq,hdr = self._read_fits(self.dqfn, self.hdu, header=True, **kwargs)
if header:
return dq,hdr
else:
return dq
def read_invvar(self, clip=True, clipThresh=0.2, **kwargs):
print('Reading inverse-variance from', self.wtfn, 'hdu', self.hdu)
invvar = self._read_fits(self.wtfn, self.hdu, **kwargs)
return invvar
def run_calibs(self, psfex=True, sky=True, se=False,
funpack=False, fcopy=False, use_mask=True,
force=False, just_check=False, git_version=None,
splinesky=False):
"""Read psfex PSF model and splinesky model"""
self.read_psf_model(0, 0, pixPsf=True, hybridPsf=True)
self.read_sky_model(splinesky=splinesky)
That should be 99% of getting it running
In [ ]: