Commit 42f5ffb5 authored by Mohammad Akhlaghi's avatar Mohammad Akhlaghi

Top level dirs in build made by one rule

The directories directly under the build directory are now built by
one rule in the top level `Makefile' to avoid the confusion and Make
errors that can be caused by doing it every time. This can also
encourage building more of these directories for easy checking.

The size of the kernel was also increased because in the MUSE PSF, 21
pixels was too small. The problem with the deconvolution is certainly
more fundamental than that and must be solved separately. So for the
time being we are ignoring the steps in generating the HST PSF.
parent 487d752d
......@@ -48,6 +48,22 @@ all: $(BSYM) file.txt
# Top build directories
# ---------------------
#
# The outputs of the separate steps will be in the build directory. We
# don't want to repeatedly call a command to build those directories,
# so we are defining a pattern rule to do the job for all. Just note
# that it is important that you do not put a `/' after the directory
# name when defining its variable, since in a pattern rule, `/' will
# not match.
$(BDIR)/%: | $(BDIR);
mkdir $@
# Rules
# -----
#
......@@ -76,4 +92,4 @@ include $(foreach m, preparations download degrade-hst input-cutouts \
#
# To clean the outputs if necessary.
clean:
rm -rf $(BDIR)/*
rm -rf $(BDIR)/* $(BSYM)
......@@ -13,6 +13,7 @@
hdu 0
kernel kernel.fits
khdu 0
minsharpspec 0.01
# Output:
......
# The size of the PSFs from MUSE and HST to match.
psf-match-width = 21
psf-match-width = 71
......@@ -24,21 +24,14 @@
# Top level directory for all cutouts.
dhstdir = $(BDIR)/degrade-hst
$(dhstdir): $(BDIR); mkdir $@
# Get the PSF information from the headers
mpsfdir = $(BDIR)/muse-psfs
all-muse-udf-psfs = $(foreach f, $(filters), $(MUSEINPUTS)/muse-udf-$(f).fits) \
$(foreach f, $(filters), $(MUSEINPUTS)/muse-udf10-$(f).fits)
$(dhstdir)/muse-psfs.txt: $(all-muse-udf-psfs) \
$(mpsfdir)/muse-psfs.txt: $(all-muse-udf-psfs) \
reproduce/config/internal/truncation-muse-psf.mk \
reproduce/config/internal/hst-pixel-scale.mk \
| $(dhstdir)
| $(mpsfdir)
# Delete the output file because we will be appending to it,
# so if it already exists, there is going to be trouble.
......@@ -46,7 +39,7 @@ $(dhstdir)/muse-psfs.txt: $(all-muse-udf-psfs) \
# Write the information for each PSF in the file. The
# MakeProfiles columns are defined in its configuration file.
for file in $^; do \
for file in $(filter %.fits, $^); do \
astheader $$file | grep FSF | \
awk 'BEGIN{print "#", "'$$file'"; bc=0; fc=0;} \
/FSF0.BET/ {beta[bc++]=$$NF} \
......@@ -70,8 +63,8 @@ $(dhstdir)/muse-psfs.txt: $(all-muse-udf-psfs) \
# the same results. For the seed, I just typed in some numbers to make
# a long integer. The important thing is that it be fixed, its
# absolute value is irrelevant.
muse-rawpsfs = $(dhstdir)/udf10-f850lp-rawpsf.fits
$(muse-rawpsfs): $(dhstdir)/muse-psfs.txt $(mkprof) | $(dhstdir)
muse-rawpsfs = $(mpsfdir)/udf10-f850lp-rawpsf.fits
$(muse-rawpsfs): $(mpsfdir)/muse-psfs.txt $(mkprof)
# Generate all the PSFs using MakeProfiles. Note that
export GSL_RNG_TYPE="mt19937"; \
......@@ -127,6 +120,8 @@ $(muse-rawpsfs): $(dhstdir)/muse-psfs.txt $(mkprof) | $(dhstdir)
# Cutout the MUSE PSFs to the proper size
#
# The size of the images created by MakeProfiles was based on the PSF
......@@ -134,8 +129,8 @@ $(muse-rawpsfs): $(dhstdir)/muse-psfs.txt $(mkprof) | $(dhstdir)
# in the reproduction pipeline configurations). So here, we will crop
# the desired region from the raw psfs.
muse-psfs = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(dhstdir)/udf$(uid)-$(f)-psf.fits) )
$(muse-psfs): %-psf.fits: $(muse-rawpsfs) \
$(foreach f, $(filters), $(mpsfdir)/udf$(uid)-$(f).fits) )
$(muse-psfs): %.fits: $(muse-rawpsfs) \
reproduce/config/internal/psf-match-width.mk
# First do a sanity check, since the size is fixed. Note that
......@@ -152,15 +147,27 @@ $(muse-psfs): %-psf.fits: $(muse-rawpsfs) \
######################################################################
#################### Ignored rules for now ####################
################ | ################
################ \ / ################
################ . ################
######################################################################
# HST PSF
#
# Crop out one star from the HST image, center it and then use it for
# the HST PSF.
hpsfdir=$(BDIR)/hst-psfs
xdf-prefix = $(XDF)/hlsp_xdf_hst_acswfc-$(hstpixelscale)0mas_hudf_
hst-star-cats = $(foreach f, $(filters), $(dhstdir)/star-$(f).txt)
$(hst-star-cats): $(dhstdir)/star-%.txt: $(xdf-prefix)%_v1_sci.fits \
hst-star-cats = $(foreach f, $(filters), $(hpsfdir)/star-$(f).txt)
$(hst-star-cats): $(hpsfdir)/star-%.txt: $(xdf-prefix)%_v1_sci.fits \
reproduce/config/internal/hst-star-position.mk \
reproduce/config/internal/star-cat-threshold.mk | $(dhstdir)
reproduce/config/internal/star-cat-threshold.mk | $(hpsfdir)
# Crop the region in the vicinity of the star in a large
# enough box that the Sky can be accurate calculated. A width
......@@ -194,8 +201,8 @@ $(hst-star-cats): $(dhstdir)/star-%.txt: $(xdf-prefix)%_v1_sci.fits \
# Using the central position of the star calculated from the catalog,
# warp the image into a grid with the star center exactly in the
# center of a pixel
hst-centered-star = $(foreach f, $(filters), $(dhstdir)/star-$(f).fits)
$(hst-centered-star): $(dhstdir)/star-%.fits: $(dhstdir)/star-%.txt \
hst-centered-star = $(foreach f, $(filters), $(hpsfdir)/star-$(f).fits)
$(hst-centered-star): $(hpsfdir)/star-%.fits: $(hpsfdir)/star-%.txt \
reproduce/config/internal/psf-match-width.mk
# Generate the proper options for ImageWarp, then run it. As
......@@ -220,8 +227,7 @@ $(hst-centered-star): $(dhstdir)/star-%.fits: $(dhstdir)/star-%.txt \
} \
END{printf "--xc=%d --yc=%d", 250+xc-3, 250+yc-3}' \
$(@D)/$*-c.txt); \
astimgcrop $$xyc $(@D)/$*-w.fits --iwidth=$(psf-match-width) \
-o$(@D)/$*-cc.txt
astimgcrop $$xyc $(@D)/$*-w.fits --iwidth=$(psf-match-width) -o$@
# Clean up
rm $(@D)/$*-c.txt $(@D)/$*-w.fits
......@@ -235,11 +241,27 @@ $(hst-centered-star): $(dhstdir)/star-%.fits: $(dhstdir)/star-%.txt \
# Using the PSF images for MUSE and HST, now we want to find the
# kernel that the HST images should be convolved with to have similar
# PSF to MUSE.
kerneldir = $(BDIR)/kernels
kernels = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(dhstdir)/udf$(uid)-$(f)-ker.fits) )
$(kernels): $(dhstdir)/udf%-ker.fits: $(dhstdir)/udf%-psf.fits
$(foreach f, $(filters), $(kerneldir)/udf$(uid)-$(f).fits) )
$(kernels): $(kerneldir)/udf%.fits: $(mpsfdir)/udf%.fits \
$(hst-centered-star) | $(kerneldir)
# Get the HST image name and find the kernel
filter=$(word 2, $(subst -, , $*)); \
astconvolve --kernel=$< $(dhstdir)/star-$$filter".fits" --makekernel=8 \
--viewfreqsteps
filter=$(word 2, $(subst -, , $*)); \
astconvolve --kernel=$(hpsfdir)/star-$$filter".fits" $< \
--makekernel=8 --viewfreqsteps -o$@
######################################################################
################ . ################
################ / \ ################
################ | ################
#################### Ignored rules for now ####################
######################################################################
file.txt: $(muse-psfs)
echo; echo "-- REACHED THE END ---"; echo
......@@ -26,7 +26,6 @@
# Top level directory for all cutouts.
indir = $(BDIR)/input-cutouts
$(indir): $(BDIR); mkdir $@
......@@ -40,7 +39,6 @@ $(indir): $(BDIR); mkdir $@
# them to ease the processing.
audfdir=$(BDIR)/aligned-udf
udfaligned = $(foreach f, $(filters), $(audfdir)/muse-udf-$(f).fits)
$(audfdir): $(BDIR); mkdir $@
$(udfaligned): $(audfdir)/muse-udf-%.fits: \
$(MUSEINPUTS)/muse-udf-%.fits $(imgwarp) | $(audfdir)
astimgwarp $< --align -h1 -o$@
......@@ -117,10 +115,3 @@ udf-muse-cutouts = $(udf1-muse-cutouts) $(udf2-muse-cutouts) \
$(udf5-muse-cutouts) $(udf6-muse-cutouts) \
$(udf7-muse-cutouts) $(udf8-muse-cutouts) \
$(udf9-muse-cutouts) $(udf10-muse-cutouts)
file.txt: $(udf-muse-cutouts)
echo; echo "-- REACHED THE END ---"; echo
......@@ -30,7 +30,6 @@ $(BDIR):; mkdir $@;
ifneq ($(BSYM),)
$(BSYM): | $(BDIR); ln -s $(BDIR) $(BSYM)
endif
$(locks): | $(BDIR); mkdir $@
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment