This repository was archived by the owner on Jun 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
executable file
·91 lines (75 loc) · 2 KB
/
Copy pathplot.py
File metadata and controls
executable file
·91 lines (75 loc) · 2 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Plot distributions of the ZTF alert properties.
Loads the NumPy arrays produced by alerts.py and saves histograms of the
magnitude (magpsf), RealBogus quality score (rb), Julian date (jd) and
full-width half-max (fwhm) into figures/.
Created on Tue Mar 10 22:35:43 2020
"""
from pathlib import Path
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import statistics as st
# Resolve paths relative to the repo root so the script runs from anywhere.
ROOT = Path(__file__).resolve().parent.parent
ARRAYS = ROOT / "data" / "arrays"
FIGURES = ROOT / "figures"
FIGURES.mkdir(parents=True, exist_ok=True)
# Loading different arrays
magpsf = np.load(ARRAYS / 'magpsf.npy')
rb = np.load(ARRAYS / 'rb.npy')
jd = np.load(ARRAYS / 'jd.npy')
sigmagap = np.load(ARRAYS / 'sigmagap.npy')
fwhm = np.load(ARRAYS / 'fwhm.npy')
# Substracting min jd
jd = jd - min(jd)
# printing median of fwhm
print(st.median(fwhm))
# plt.clf()
# Plotting diff figures
# Magpsf
plt.figure(1)
plt.hist(magpsf, bins=20)
plt.title('Magnitude from PSF-fit photometry')
plt.ylabel('No of alerts')
plt.xlabel('Mag')
# plt.show()
plt.savefig(FIGURES / "magpsf", dpi=1200)
# RB
plt.figure(2)
plt.hist(rb, bins=20)
plt.title('RealBogus quality score')
plt.ylabel('No of alerts')
plt.xlabel('RB Score')
# plt.show()
plt.savefig(FIGURES / "rb", dpi=1200)
# JD
plt.figure(3)
plt.hist(jd, bins=20)
plt.title('Julian Date')
plt.ylabel('No of alerts')
plt.xlabel('Julian Date - min')
# plt.show()
plt.savefig(FIGURES / "jd", dpi=1200)
'''
#Sigmagap
#plt.figure(4)
plt.hist(sigmagap, bins = 20)
plt.title('1-sigma uncertainty in magpsf')
plt.ylabel('No of alerts')
plt.xlabel('MAG')
#plt.show()
plt.savefig("graphs/sigmapsf",dpi = 1200)
'''
# FWHM
plt.figure(5)
plt.hist(fwhm, bins=20)
plt.title('Full Width Half Max assuming a Gaussian core, from SExtractor')
plt.ylabel('No of alerts')
plt.xlabel('Pixels')
# plt.show()
plt.savefig(FIGURES / "fwhm", dpi=1200)
print(st.median(fwhm))