Commit 0654f265 authored by Mohammad Akhlaghi's avatar Mohammad Akhlaghi

Catalogs generated for similar sized cutouts

Magnitude and position catalogs are now generated for both the HST
images and the MUSE images. Using GNU Make's Secondary expansion, we
don't need the `-h' or `-m' suffixes for the segmentation maps any
more. Since the instrument name will be removed from the output
filename during secondary expansion.

The Sky and Sky standard deviation images are now also created. Note
that since the purpose of this study is calibration, they are set to
all 0 and all 1 valued images. Finally, using the filters and
instrument the zeropoint magnitudes are calculated and used for
MakeCatalog.

Currently the catalogs are only used for similarly sized original
cutouts. But the cutouts can be differently sized (due to sub-pixel
differences in the WCS). So when the images have a different size, it
currently stops.
parent e4e7a6c5
......@@ -65,6 +65,17 @@ $(BDIR)/%: | $(BDIR);
# Enable secondary expansion
# --------------------------
#
# We want secondary expansion to to use functions in the prerequisite
# list.
.SECONDEXPANSION:
# Rules
# -----
#
......
......@@ -62,12 +62,9 @@
# links. The actual segmentation map will be the `-h.fits' file, but
# the `-m.fits' file will be a link to it.
segdir = $(BDIR)/seg-maps
segments-m = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(segdir)/udf$(uid)-$(f)-m.fits) )
segments-h = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(segdir)/udf$(uid)-$(f)-h.fits) )
$(segments-m): $(segdir)/%-m.fits: $(segdir)/%-h.fits; ln -s $< $@
$(segments-h): $(segdir)/%-h.fits: $(hdegdir)/%-o.fits \
segments = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), $(segdir)/udf$(uid)-$(f).fits) )
$(segments): $(segdir)/%.fits: $(hdegdir)/%-o.fits \
$(hdegdir)/pix-res-scale.txt $(noisechisel) $(imgwarp) \
$(arithmetic) | $(segdir)
......@@ -89,7 +86,7 @@ $(segments-h): $(segdir)/%-h.fits: $(hdegdir)/%-o.fits \
astarithmetic $(@D)/$*-wd.fits 0 + --type=long -o$(@D)/$*-wl.fits
astarithmetic $(@D)/$*-wl.fits \
$(@D)/$*-wl.fits $(@D)/$*-wd.fits neq \
0 where -o$@
0 where --type=long -o$@
# Clean up.
rm $(@D)/$*-nc.fits $(@D)/$*-wd.fits $(@D)/$*-wl.fits
......@@ -98,13 +95,91 @@ $(segments-h): $(segdir)/%-h.fits: $(hdegdir)/%-o.fits \
# Make a Sky and Sky_std image
# ----------------------------
#
# Since the purpose of this study is calibration, we don't want to
# subtract the Sky value. For the Sky value we will set all pixels to
# zero and for the STD we will set them all to 1.
ssdir = $(BDIR)/sky-and-std
skys-and-stds = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(ssdir)/udf$(uid)-sky.fits)
$(skys-and-stds): $(ssdir)/%-sky.fits: $(segdir)/%-f606w.fits | $(ssdir)
# The segmentation map is only 0 and positive values, so if we
# check the equality with a negative value, all the pixels
# will be zero and if we check greater or equal to zero, then
# all pixels will be 1.
astarithmetic $< 0 ge -o$(ssdir)/$*-std.fits
astarithmetic $< -1 eq -o$@
# Generate the MUSE and HST catalogs
# ----------------------------------
#
# The MUSE zeropoint values are calculated based on the following:
#
# From the BUNIT keyword on MUSE data, the data have units of `10**-20
# Angstrom-1 cm-2 erg s-1'. However, the AB magnitude is defined like
# this (https://en.wikipedia.org/wiki/AB_magnitude):
#
# M_AB = -2.5 * log10(f_n/Jy) + 8.90 (1)
#
# Where `f_n' is in units of `erg s-1 cm-2 Hz-1'. The conversion from
# flux in units of wavelength is (`L' is for lambda):
#
# f_n/Jy = 3.34 * 10^4 * (L/Angstrom)^2 * f_l/(erg s-1 cm-2 A-1)
#
# So assuming `L' and `f_l' have been divided by their units and thus
# unitless (and `f_l' is the MUSE pixel units), we can say:
#
# log10(f_n/Jy) = log10( 3.34 * 10^4 * (L)^2 * 10^(-20) * f_l )
# = log10( f_l ) + 2*log10( L ) - 15.4763
#
# So the AB magnitude of a measurement on the MUSE images is:
#
# M_AB = -2.5 * [ log10( f_l ) + 2*log10( L ) - 15.4763 ] + 8.90
# = -2.5*log10( f_l ) - 5*log10( L ) + 47.5908
#
# Hence, the zeropoint magnitude is: `47.5908 - 5*log10( L )'.
#
# Note on `genssname' and `genskyname': One segmentation map is
# generated for both HST and MUSE in each field and filter, also all
# filters of one field have the same Sky file name. These functions
# are used to generate the proper name from the output's name.
catdir = $(BDIR)/catalogs
catalogs = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), \
$(foreach i, m h, $(catdir)/udf$(uid)-$(f)-$(i).fits) ) )
$(catalogs): $(catdir)/%: $(cutdir)/% $(segdir)/% $(mkcatalog) | $(catdir)
fieldfilter = $(word 1, $(subst -, ,$(1)))-$(word 2, $(subst -, ,$(1)))
catalogs = $(foreach uid, 1 2 3 4 5 6 7 8 9 10, \
$(foreach f, $(filters), \
$(foreach i, h m, $(catdir)/udf$(uid)-$(f)-$(i).txt) ) )
gensegname = $(segdir)/$(call fieldfilter, $(1)).fits
genssname = $(ssdir)/$(word 1, $(subst -, ,$(1)))-$(2).fits
$(catalogs): $(catdir)/%.txt: $(cutdir)/%.fits $$(call gensegname,%) \
$$(call genssname,%,sky) $(lambda-eff) $(mkcatalog) \
| $(catdir)
# Set the zeropoint value from the filter depending on the
# instrument.
filter=$(word 2, $(subst -, ,$*)); \
if [ $(lastword $(subst -, ,$*)) = "h" ]; then \
if [ $$filter = "f606w" ]; then zp=26.51; \
elif [ $$filter = "f775w" ]; then zp=25.69; \
elif [ $$filter = "f814w" ]; then zp=25.94; \
elif [ $$filter = "f850lp" ]; then zp=24.87; \
fi; \
else \
zp=$$(awk '{print 47.5908 - 5*log($$1)/log(10)}' \
$(leffdir)/$$filter".txt"); \
fi; \
astmkcatalog $< --zeropoint=$$zp --magnitude --dec --ra -o$@ \
--objlabs=$(call gensegname, $*) --objhdu=0 \
--skyfilename=$(call genssname, $*,sky) --skyhdu=0 \
--stdfilename=$(call genssname, $*,std) --stdhdu=0
......
......@@ -136,7 +136,24 @@ $(hdegdir)/pix-res-scale.txt: $(cutdir)/udf1-f606w-m.fits \
# 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), $(cutdir)/udf$(uid)-$(f)-h.fits) )
$(h-to-m-pixres): $(cutdir)/%-h.fits: $(hdegdir)/%-c.fits \
$(h-to-m-pixres): $(cutdir)/%-h.fits: $(hdegdir)/%-c.fits $(cutdir)/%-m.fits \
$(hdegdir)/pix-res-scale.txt
# Warp the HST image to the MUSE pixel scale.
scalefactor=$$(cat $(hdegdir)/pix-res-scale.txt); \
astimgwarp $< --scale=$$scalefactor -o$@ --numthreads=1
# The final segmentation map will also be from the HST image
# and warped with the same scale factor. So if the MUSE cutout
# image is not the same size as this warped image, we need to
# make it the same size.
msize=$$(astheader $(cutdir)/$*-m.fits | awk '$$1=="NAXIS1" {x=$$3} \
$$1=="NAXIS2"{y=$$3} END{print x, y}'); \
hsize=$$(astheader $(cutdir)/$*-h.fits | awk '$$1=="NAXIS1" {x=$$3} \
$$1=="NAXIS2"{y=$$3} END{print x, y}'); \
if [ "$$msize" != "$$hsize" ]; then \
echo "$*: Not equal."; \
exit 1; \
else \
echo "$*: Equal."; \
fi
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