Commit 2c31a594 authored by Mohammad Akhlaghi's avatar Mohammad Akhlaghi

Correct estimation of MUSE PSFs and deconvolution

The model MUSE PSFs were incorrectly calculated until now! I was
mistakenly assuming that the `FSF01FWA' was the FWHM. However, the
FWHM must be calculated from `b*lambda+a' where `b' is the value to
`FSF01FWB' keyword and `a' is the value of `FSF01FWA'. The effective
`lambda' (or wavelength) to use for each broad-band filter is the
throughput-weighted average wavelength of the filter.

So, the pipeline now uses the HST filter throughputs to find `lambda'
and then uses the values of these keywords to generate the proper FWHM
for the Moffat function. The throughputs will be downloaded if not
already available. The FWHMs decreased from around 14 pixels to around
10 pixels.

After implementing this correction, a test run of the deconvolution
gave a better result. The reason was that the image crop to feed into
the deconvolution algorithm was larger and so lower frequencies could
be sampled. After seeing this trend, I increased the truncation radius
of the model MUSE PSFs and also the deconvolution image size and saw
that the deconvolution output kernel is becoming better and better. I
finally stopped at 6 times the FWHM since it was apparently not making
much more change.

So, now the proper kernel to convolve with the HST images is created
and we can directly compare the results with the MUSE images without
worrying about a larger PSF. After convolution, the HST images are now
also sampled to the same pixel size as MUSE.
parent 42f5ffb5
......@@ -48,15 +48,16 @@ all: $(BSYM) file.txt
# Top build directories
# ---------------------
# Top directories under BDIR
# --------------------------
#
# 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.
# so we are defining a pattern rule to do the job for any similarly
# formatted directory. 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, an ending `/' will not match. Add the `/'
# everytime you want to call the directory variable.
$(BDIR)/%: | $(BDIR);
mkdir $@
......
......@@ -24,13 +24,15 @@
# Survey directories
#
# This is where the survey images (with the same file-name standard as
# the main webpage) are stored. If this directory doesn't exist, or it
# doesn't contain the images (with the correct file-name formats), it
# will be created and the images will be downloaded. See
# `src/downloads.mk', for the URLs containing the expected inputs for
# each survey.
# This is where the survey images and necessary files (with the same
# file-name standard as the main webpage) are stored. If this
# directory doesn't exist, or it doesn't contain the images (with the
# correct file-name formats), it will be created and the images will
# be downloaded. See `src/downloads.mk', for the URLs containing the
# expected inputs for each survey.
XDF = /home/mohammad/work/datasets/xdf
TROUGHPUTS = /home/mohammad/work/datasets/hst-throughputs
MUSEINPUTS = /home/mohammad/work/datasets/muse-udf-photometry
......@@ -56,12 +58,3 @@ BDIR = /home/mohammad/work/builds/muse-udf-photometry
# link. If the value is empty (nothing after the `=' sign) then no
# symbolic link will be created.
BSYM = reproduce/build
# MUSE inputs
#
# Directory keeping all the input MUSE images.
MUSEINPUTS = /home/mohammad/work/datasets/muse-udf-photometry
# Configuration files for programs
mkprof = reproduce/config/gnuastro/astmkprof.conf
arithmetic = reproduce/config/gnuastro/astarithmetic.conf
convolve = reproduce/config/gnuastro/astconvolve.conf
header = reproduce/config/gnuastro/astheader.conf
imgcrop = reproduce/config/gnuastro/astimgcrop.conf
imgwarp = reproduce/config/gnuastro/astimgwarp.conf
mkcatalog = reproduce/config/gnuastro/astmkcatalog.conf
mkprof = reproduce/config/gnuastro/astmkprof.conf
noisechisel = reproduce/config/gnuastro/astnoisechisel.conf
......@@ -2,4 +2,4 @@
#
# The reason it is in units of 0.01 arcseconds is that we want to use
# it in the filenames and this makes it easy.
hstpixelscale = 3
hstpixelscale = 6
# The size of the PSFs from MUSE and HST to match.
psf-match-width = 71
psf-match-width = 51
# Truncation radius for generating the MUSE PSF
#
# This is in units of the FWHM.
truncation-muse-psf = 3
truncation-muse-psf = 6
This diff is collapsed.
......@@ -23,8 +23,13 @@
# Identify the downloader tool
# ----------------------------
# Downloader and lock
# -------------------
#
# See if the downloader tools are ready and set them
# accordingly. Afterwards, define the lock directory for operations
# that must not be done in parallel.
locks = $(BDIR)/locks
downloader := $(shell if type curl > /dev/null; then downloader="curl -o"; \
else downloader="wget -O"; \
fi; echo "$$downloader"; )
......@@ -43,3 +48,16 @@ allxdf = $(foreach f, $(xdfacs), $(XDF)/$(xdfacspre)$(f)_v1_sci.fits) \
$(XDF):; mkdir $@
$(allxdf): $(XDF)/%: | $(XDF) $(locks)
flock $(locks)/download -c "$(downloader) $@ $(xdfweb)/$*"
# Filter throughputs
# ------------------
throughputsweb = http://www.stsci.edu/hst/acs/analysis/throughputs/tables
filtersup := $(shell for f in $(filters); do echo $$f | tr a-z A-Z; done)
throughputs = $(foreach F, $(filtersup), $(TROUGHPUTS)/wfc_$(F).dat)
$(TROUGHPUTS):; mkdir $@
$(throughputs): $(TROUGHPUTS)/%: | $(TROUGHPUTS) $(locks)
flock $(locks)/download -c "$(downloader) $@ $(throughputsweb)/$*"
......@@ -24,12 +24,6 @@
# Top level directory for all cutouts.
indir = $(BDIR)/input-cutouts
# Align the MUSE UDF region
# -------------------------
......@@ -49,69 +43,105 @@ $(udfaligned): $(audfdir)/muse-udf-%.fits: \
# From original MUSE images
# -------------------------
#
# Cutout the 10 udf regions
udf1-muse-cutouts = $(foreach f, $(filters), $(indir)/udf1-$(f)-m.fits)
$(udf1-muse-cutouts): $(indir)/udf1-%-m.fits: $(audfdir)/muse-udf-%.fits \
# Cutout the original MUSE images.
mcutdir = $(BDIR)/muse-cutouts
udf1-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf1-$(f).fits)
$(udf1-muse-cutouts): $(mcutdir)/udf1-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf1.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf1polygon) $< -o$@
udf2-muse-cutouts = $(foreach f, $(filters), $(indir)/udf2-$(f)-m.fits)
$(udf2-muse-cutouts): $(indir)/udf2-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf2-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf2-$(f).fits)
$(udf2-muse-cutouts): $(mcutdir)/udf2-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf2.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf2polygon) $< -o$@
udf3-muse-cutouts = $(foreach f, $(filters), $(indir)/udf3-$(f)-m.fits)
$(udf3-muse-cutouts): $(indir)/udf3-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf3-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf3-$(f).fits)
$(udf3-muse-cutouts): $(mcutdir)/udf3-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf3.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf3polygon) $< -o$@
udf4-muse-cutouts = $(foreach f, $(filters), $(indir)/udf4-$(f)-m.fits)
$(udf4-muse-cutouts): $(indir)/udf4-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf4-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf4-$(f).fits)
$(udf4-muse-cutouts): $(mcutdir)/udf4-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf4.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf4polygon) $< -o$@
udf5-muse-cutouts = $(foreach f, $(filters), $(indir)/udf5-$(f)-m.fits)
$(udf5-muse-cutouts): $(indir)/udf5-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf5-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf5-$(f).fits)
$(udf5-muse-cutouts): $(mcutdir)/udf5-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf5.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf5polygon) $< -o$@
udf6-muse-cutouts = $(foreach f, $(filters), $(indir)/udf6-$(f)-m.fits)
$(udf6-muse-cutouts): $(indir)/udf6-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf6-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf6-$(f).fits)
$(udf6-muse-cutouts): $(mcutdir)/udf6-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf6.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf6polygon) $< -o$@
udf7-muse-cutouts = $(foreach f, $(filters), $(indir)/udf7-$(f)-m.fits)
$(udf7-muse-cutouts): $(indir)/udf7-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf7-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf7-$(f).fits)
$(udf7-muse-cutouts): $(mcutdir)/udf7-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf7.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf7polygon) $< -o$@
udf8-muse-cutouts = $(foreach f, $(filters), $(indir)/udf8-$(f)-m.fits)
$(udf8-muse-cutouts): $(indir)/udf8-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf8-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf8-$(f).fits)
$(udf8-muse-cutouts): $(mcutdir)/udf8-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf8.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf8polygon) $< -o$@
udf9-muse-cutouts = $(foreach f, $(filters), $(indir)/udf9-$(f)-m.fits)
$(udf9-muse-cutouts): $(indir)/udf9-%-m.fits: $(audfdir)/muse-udf-%.fits \
udf9-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf9-$(f).fits)
$(udf9-muse-cutouts): $(mcutdir)/udf9-%.fits: $(audfdir)/muse-udf-%.fits \
$(imgcrop) reproduce/config/internal/vertices-udf9.mk \
| $(indir)
| $(mcutdir)
astimgcrop $(udf9polygon) $< -o$@
udf10-muse-cutouts = $(foreach f, $(filters), $(indir)/udf10-$(f)-m.fits)
$(udf10-muse-cutouts): $(indir)/udf10-%-m.fits: \
udf10-muse-cutouts = $(foreach f, $(filters), $(mcutdir)/udf10-$(f).fits)
$(udf10-muse-cutouts): $(mcutdir)/udf10-%.fits: \
$(MUSEINPUTS)/muse-udf10-%.fits $(imgcrop) \
reproduce/config/internal/vertices-udf10.mk | $(indir)
reproduce/config/internal/vertices-udf10.mk | $(mcutdir)
astimgcrop $(udf10polygon) -h1 $< -o$@
udf-muse-cutouts = $(udf1-muse-cutouts) $(udf2-muse-cutouts) \
$(udf3-muse-cutouts) $(udf4-muse-cutouts) \
$(udf5-muse-cutouts) $(udf6-muse-cutouts) \
$(udf7-muse-cutouts) $(udf8-muse-cutouts) \
$(udf9-muse-cutouts) $(udf10-muse-cutouts)
# MUSE pixel resolution
# ---------------------
#
# For the final degrading of HST images, we also need the MUSE pixel
# resolution, so read the MUSE pixel resolution from one of the
# aligned images, then also read the HST pixel resolution from one of
# the images and find scale factor
$(hcutdir)/pix-res-scale.txt: $(mcutdir)/udf1-f606w.fits \
$(hcutdir)/udf1-f606w-c.fits
mres=$$(astheader $(mcutdir)/udf1-f606w.fits | grep PC2_2 \
| awk '{print $$3*3600}'); \
hres=$$(astheader $(hcutdir)/udf1-f606w-c.fits | grep PC2_2 \
| awk '{print $$3*3600}'); \
echo | awk '{print '$$hres'/'$$mres'}' > $@
# HST images to MUSE resolution
# -----------------------------
#
# The HST images were convolved with the MUSE PSF for the same spatial
# resolution, now, we need to warp them to the MUSE pixel grid to get
# be able to easily use one segmentation map over both images.
h-to-m-pixres = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(hcutdir)/udf$(uid)-$(f).fits) )
$(h-to-m-pixres): %.fits: %-c.fits $(hcutdir)/pix-res-scale.txt
scalefactor=$$(cat $(hcutdir)/pix-res-scale.txt); \
astimgwarp $< --scale=$$scalefactor -o $@ --numthreads=1
file.txt: $(hst-convolved)
@echo; echo "reached end"; echo;
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