Commit 65d0d5d7 authored by Akke Viitanen's avatar Akke Viitanen
Browse files

Fixes plot scripts using the database

parent 83f121dd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
*.png

.ipynb_checkpoints
._*
*.pye
*.pyc
+229 −11
Original line number Diff line number Diff line
test:
	PYTHONPATH=opt:src/python:$(PYTHONPATH) \
		python3 \
			src/python/main.py \
			--config etc/config_test.ini

debug:
	PYTHONPATH=opt:src/python:$(PYTHONPATH) \
		python3 -m pdb \
			src/python/main.py \
			--config etc/config_test.ini
.PHONY: test

dr1:
	python3 python/main.py --config etc/config_dr1.ini

dr1_figures:
	#python3 python/plot_catalog.py --dirname=fig/dr1 --config=etc/config_dr1.ini --regex='.*quasar_luminosity_function.*'
	#python3 python/plot_catalog.py --dirname=fig/dr1 --config=etc/config_dr1.ini --regex='.*logn_B.*'
	python3 python/plot_catalog.py --dirname=fig/dr1 --config=etc/config_dr1.ini

dr1_new_figures:
	#python3 python/plot_catalog.py --dirname=fig/dr1_new --config=etc/config_dr1_new.ini --regex='.*quasar_luminosity_function.*'
	#python3 python/plot_catalog.py --dirname=fig/dr1_new --config=etc/config_dr1_new.ini --regex='.*logn_B.*'
	python3 python/plot_catalog.py --dirname=fig/dr1_new --config=etc/config_dr1_new.ini

dr1_new_new_figures:
	#python3 python/plot_catalog.py --dirname=fig/dr1_new --config=etc/config_dr1_new.ini --regex='.*quasar_luminosity_function.*'
	#python3 python/plot_catalog.py --dirname=fig/dr1_new --config=etc/config_dr1_new.ini --regex='.*logn_B.*'
	python3 python/plot_catalog.py --dirname=fig/dr1_new_new --config=etc/config_dr1_new_new.ini

test_figures:
	#python3 python/plot_catalog.py --dirname=fig/dr1 --config=etc/config_dr1.ini --regex='.*quasar_luminosity_function.*'
	#python3 python/plot_catalog.py --dirname=fig/dr1 --config=etc/config_dr1.ini --regex='.*logn_B.*'
	python3 python/plot_catalog.py --dirname=fig/test --config=etc/config_test.ini --regex='.*black_hole.*_local'

my_plots:
	#python3 python/main.py --config etc/config_zou_1.00deg2_v2.ini
	#python3 python/plot_catalog.py --dirname fig/test --config etc/config_zou_1.00deg2_v2.ini
	#python3 python/plot_catalog.py --dirname fig/test_24 --config etc/config_zou_24.00deg2_v2.ini
	#python3 python/plot_catalog.py --dirname fig/test_1 --config etc/config_zou_1.00deg2_v3.ini
	#python3 python/plot_catalog.py --dirname fig/test_24_v3 --config etc/config_zou_24.00deg2_v3.ini
	#python3 python/plot_catalog.py --dirname fig/test_24_v4 --config etc/config_zou_24.00deg2_v4.ini
	#python3 python/plot_catalog.py --dirname fig/test_0.10_v4 --config etc/config_zou_0.10deg2_v4.ini
	#python3 python/plot_catalog.py --dirname fig/dr1 --config etc/config_dr1.ini
	python3 python/plot_catalog.py --dirname data/dr1/fig/ --config etc/config_dr1.ini

run:
	sbatch scripts/run.sh etc/config_zou_1.00deg2.ini
	#sbatch run.sh etc/config_bon_0.10deg2.ini
	#sbatch run.sh etc/config_bon_1.00deg2.ini
	#sbatch run.sh etc/config_bon_12.00deg2.ini
	#sbatch run.sh etc/config_zou_0.10deg2.ini
	#sbatch run.sh etc/config_zou_12.00deg2.ini

#plots:
#	python3 python/plot_catalog.py \
#		--dirname fig/for_torino \
#		--config etc/config_zou_12.00deg2.ini #etc/config_bon_12.00deg2.ini

plots:
	python3 python/plot_catalog.py \
		--dirname fig/plots_to_shankar/ \
		--config etc/config_zou_24.00deg2.ini

step1:
	scripts/pipetask.sh $(REPO) isr characterizeImage calibrate writeSourceTable transformSourceTable 1> step1.out 2> step1.err

step2:
	scripts/pipetask.sh $(REPO) step2 1> step2.out 2> step2.err


fig/plambda_ctk.pdf:
	python3 test/test_get_plambda_ctk.py

cake:
	#python3 python/plot_catalog.py --dirname fig/cake --config etc/config_dr1_*deg2_r*.ini --regex='(luminosity|logn|stellar)'
	python3 python/plot_catalog.py --dirname fig/cake --config etc/config_cake_*deg2_r*.ini --regex='(luminosity|logn|stellar)'

###############################################################################
# Figures
###############################################################################

figures: \
	fig/example_calexp.png \
	fig/example_coadd.png \
	fig/flux_sigma_eta.pdf \
	fig/flux_sigma_eta_ratio.pdf \
	fig/example_lightcurve_ugrizy.pdf

fig/example_calexp.png:
	# Make example calexp images
	# 1. make $@
	# 2. zoom -> last menu entry -> 150.081 2.216
	# 3. region -> load data/ds9_example_ruler_30arcsec.reg
	# 4. file -> export as png
	## NOTE 20250707: for some reason the above instructions on save images dont
	# work on my current machine. The workaround is to take a screenshot.
	ds9 \
		-wcs align yes \
		-match frame wcs \
		-lock frame wcs -lock scale yes -lock colorbar yes \
		-zoom 0.50 \
		-scale limits 0 300 \
		-colorbar match \
		-colorbar lock yes \
		-cmap Heat \
		-width 1600 \
		-height 1200 \
		-view multi no \
		-view info no \
		-view panner no \
		-view magnifier no \
		-view buttons no \
		-view colorbar yes \
		$(wildcard data/calexp/calexp_LSSTCam_u_u_24_7025050100829_R22_S11_u_viitanen_output_20250520T160244Z.fits) \
		$(wildcard data/calexp/calexp_LSSTCam_g_g_6_7025050100779_R22_S11_u_viitanen_output_20250520T160244Z.fits) \
		$(wildcard data/calexp/calexp_LSSTCam_r_r_57_7025050100809_R22_S11_u_viitanen_output_20250520T160244Z.fits) \
		$(wildcard data/calexp/calexp_LSSTCam_i_i_39_7025050100789_R22_S11_u_viitanen_output_20250520T160244Z.fits) \
		$(wildcard data/calexp/calexp_LSSTCam_z_z_20_7025050100837_R22_S11_u_viitanen_output_20250520T160244Z.fits) \
		$(wildcard data/calexp/calexp_LSSTCam_y_y_10_7025050302384_R22_S11_u_viitanen_output_20250520T160244Z.fits)

fig/example_coadd.png:
	# Make example coadd images
	# 1. make $@
	# 2. zoom -> last menu entry -> 150.081 2.216
	# 3. region -> load data/ds9_example_ruler_30arcsec.reg
	# 4. region -> load data/dr1/ds9_agn.reg
	# 5. file -> export as png
	ds9 \
		-wcs align yes \
		-match frame wcs \
		-lock frame wcs \
		-lock scale yes \
		-lock colorbar yes \
		-zoom 0.50 \
		-scale limits 0 1 \
		-colorbar match \
		-colorbar lock yes \
		-cmap Heat \
		-width 1600 \
		-height 1200 \
		-view multi no \
		-view info no \
		-view panner no \
		-view magnifier no \
		-view buttons no \
		-view colorbar yes \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/u/deepCoadd_calexp*.fits) \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/g/deepCoadd_calexp*.fits) \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/r/deepCoadd_calexp*.fits) \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/i/deepCoadd_calexp*.fits) \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/z/deepCoadd_calexp*.fits) \
		$(wildcard $(PATH_AMUSE)/precario3/viitanen/agile/data/dr1/repo_1det/u/viitanen/output/20241211T013547Z/deepCoadd_calexp/9813/25/y/deepCoadd_calexp*.fits)

fig/flux_sigma_eta.pdf: python/plot_flux_sigma_eta.py
	python3 $< $@ 1

fig/flux_sigma_eta_class.pdf: python/plot_flux_sigma_eta.py
	python3 $< $@ 0

fig/flux_sigma_eta_ratio.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0

fig/flux_sigma_eta_ratio_20250707.pdf: src/python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 #> table/table_flux_sigma_eta_ratio.tex

fig/flux_sigma_eta_ratio_u.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 u > table/flux_sigma_eta_u.table
fig/flux_sigma_eta_ratio_g.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 g > table/flux_sigma_eta_g.table
fig/flux_sigma_eta_ratio_r.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 r > table/flux_sigma_eta_r.table
fig/flux_sigma_eta_ratio_i.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 i > table/flux_sigma_eta_i.table
fig/flux_sigma_eta_ratio_z.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 z > table/flux_sigma_eta_z.table
fig/flux_sigma_eta_ratio_y.pdf: python/plot_flux_sigma_eta_ratio.py
	python3 $< $@ 0 y > table/flux_sigma_eta_y.table

fig/example_lightcurve_ugrizy.pdf: python/plot_example_lightcurve/plot_example_lightcurve.py
	# if necessary, run python/plot_example_lightcurve/create_dataset.py
	python3 $^

fig/example_sed.pdf: python/plot_example_sed.py
	python3 $^

demo:
	# Create the dir structure
	mkdir -vp demo demo/seds demo/lightcurves demo/repo

	# Copy over the catalog
	#stilts tcat in=data/dr1/catalog.fits icmd='select skyDistanceDegrees(RA,DEC,150.11916667,2.20583333)<0.5641895835477563' out=demo/catalog.fits
	stilts tcat in=data/dr1/catalog.fits icmd='select skyDistanceDegrees(RA,DEC,150.11916667,2.20583333)<0.23' out=demo/catalog.fits
	#stilts tcat in=data/dr1/catalog.fits icmd='select skyDistanceDegrees(RA,DEC,150.11916667,2.20583333)<0.10' out=demo/catalog.fits

	# Copy over the SEDs and lightcurves
	./scripts/demo_copy_seds_lightcurves.sh demo/catalog.fits

	# Copy over the repo
	./scripts/demo_copy_repo.sh

	# Copy over the baseline
	cp -v data/baseline_v3.0_10yrs.db demo/

	tar -zcvf demo.tar.gz demo

fig/plambda_qu_sf_ctn_ctk.pdf: python/plot_plambda_qu_sf_ctn_ctk.py
	python3 $< $@


fig/mbh_mstar.pdf: python/plot_mbh_mstar.py
	python3 $< $@

fig/xray_luminosity_function.pdf: python/plot_xray_luminosity_function.py
	python3 $< $@


fig/quasar_luminosity_function.pdf: python/plot_quasar_luminosity_function.py
	python3 $< $@

table/catalog_column_description.tex: python/create_table_catalog_column_description.py
	python3 $< 0 > $@


table/catalog_column_description_public.tex: python/create_table_catalog_column_description.py
	python3 $< 1 > $@


fig/mag_sigma_ivezic.pdf: test/test_ivezic.py python/ivezic.py
	python3 $< 2>&1 | tee var/test_ivezic.log


# Calculates statistics in the baselines
var/baseline_statistics.log: python/calculate_baseline_statistics.py
	python3 $^ | tee $@


numbers_truth_catalog:
	python3 python/get_numbers_truth_catalog.py
+3 −0
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ filename_stars: ${common:dirname_prefix}/stars.fits
# Filename of the binary star catalog
filename_binaries: ${common:dirname_prefix}/binaries.fits

# Filename of the database file
filename_database: ${common:dirname_prefix}/db/20250703/master.db

# Directory to save the SEDs in
seds_file: ${common:seds_file}

+0 −2
Original line number Diff line number Diff line
@@ -128,9 +128,7 @@ class CatalogAGN:
            ("log_L_2_keV",      np.float64, "Monochromatic 2 keV luminosity",                      "erg/s/Hz"),
            ("log_L_2500",       np.float64, "Monochromatic 2500keV luminosity",                    "erg/s/Hz"),
            ("MBH",              np.float64, "Black hole mass",                                     "Msun"),
            ("log_L_AGN_5GHz",   np.float64, "Monochromatic 5 GHz AGN luminosity",                  "erg/s"),
            ("log_L_bol",        np.float64, "Bolometric AGN luminosity",                           "erg/s"),
            ("log_lambda_Edd",   np.float64, "log10 of Eddington accretion rate",                   ""),
        ] + [
            (b.strip() + "_point", np.float64, f"AGN {b} flux", "uJy") for b in bands
        ] + [
+8 −1
Original line number Diff line number Diff line
@@ -20,7 +20,14 @@ logger = logging.getLogger(__name__)

class CatalogCombined:

    def __init__(self, dirname, catalog_agn, catalog_galaxy, catalog_star, catalog_binary):
    def __init__(
            self,
            dirname,
            catalog_agn,
            catalog_galaxy,
            catalog_star,
            catalog_binary
    ):

        self.dirname = dirname
        self.filename = f"{dirname}/catalog.fits"
Loading