statistics.mk 3.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
# Broad-band photometry checks with MUSE generated broad-band images.
#
# The rules in this file are for measuring the statistics over each
# field to compare.
#
# Original author:
#     Mohammad Akhlaghi <mohammad.akhlaghi@univ-lyon1.fr>
# Contributing author(s):
# Copyright (C) 2016, Mohammad Akhlaghi.
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License is available at
# <http://www.gnu.org/licenses/>.



# Prepare 2D histograms
# ---------------------
#
# For time being, we are plotting 2D histograms.
twodxmin=20
twodxmax=30
twodxnbins=40
twodymin=-1.8125
twodymax=1.8125
twodynbins=42
twoddir = $(BDIR)/tex/2D-histograms
two-d-hists = $(foreach field, udf udf10,                                 \
	        $(foreach filter, $(filters),                             \
	          $(twoddir)/$(field)-$(filter).txt) )
$(two-d-hists): $(twoddir)/%.txt: $(ccatdir)/%.txt                        \
	        reproduce/scripts/two-dim-hist.awk                        \
	        reproduce/scripts/checks.awk | $(twoddir)

        # Pull out the two columns to generate the histogram
	awk '!/^#/{print $$5, $$8}' $(ccatdir)/$*.txt > $(twoddir)/$*_fh.txt

        # Generate the 2D histogram.
	awk -vxmin=$(twodxmin) -vxmax=$(twodxmax) -vymin=$(twodymin)      \
	    -vymax=$(twodymax) -vxnumbins=$(twodxnbins)                   \
	    -vynumbins=$(twodynbins) -vcol=8 -vshowemptylast=1            \
	    -vextraout=0 -i reproduce/scripts/checks.awk                  \
	    -f reproduce/scripts/two-dim-hist.awk $(twoddir)/$*_fh.txt > $@

        # Clean up
	rm $(twoddir)/$*_fh.txt





# Average and dispersion in bins
# ------------------------------
#
# To confirm that there is no problem in the individual fields, we
# also need the average and standard deviation in each bin of each
# field to plot as lines over the 2D histograms.
histxnbins = 15
histstdmultip = 3
statdir = $(BDIR)/statistics
mag-ave-std = $(foreach uid, 1 2 3 4 5 6 7 8 9 10,                    \
	        $(foreach f, $(filters), $(statdir)/udf$(uid)-$(f).txt) )
$(mag-ave-std): $(statdir)/%.txt: $(ccatdir)/%.txt                    \
	        reproduce/scripts/bin-ave-std.awk | $(statdir)

	awk -vxmin=$(twodxmin) -vxmax=$(twodxmax) -vxcol=5 -vycol=8   \
	    -vxnumbins=$(twodxnbins) -vstdmultip=$(histstdmultip)     \
	    -i reproduce/scripts/checks.awk                           \
	    -f reproduce/scripts/bin-ave-std.awk  $<

	exit 1





# TeX macros
# ----------
$(mtexdir)/statistics.tex: $(two-d-hists) | $(mtexdir)
	echo "\\newcommand{\\twodxmin}{$(twodxmin)}"             > $@
	echo "\\newcommand{\\twodxmax}{$(twodxmax)}"            >> $@
	echo "\\newcommand{\\twodxnbins}{$(twodxnbins)}"        >> $@
	echo "\\newcommand{\\twodynbins}{$(twodynbins)}"        >> $@
	echo "\\newcommand{\\histstdmultip}{$(histstdmultip)}"  >> $@