Created
January 31, 2019 01:25
-
-
Save Samreay/2af3b94f640cae3e94056762cff33df1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def get_data(filename="OzDES_GRC_2019_01_23.fits", source='DES_AAOmega'): | |
from astropy.io import fits | |
fit = fits.open(filename) | |
data = fit[1].data | |
if source is not None: | |
mask = data['source'] == source | |
data = data[mask] | |
fit.close() | |
return np.array(data) | |
# Get data | |
data = get_data() | |
zs = data['z'] | |
qops = data['flag'].astype(np.int) | |
# Plot redshift distribution for qop 4 and 3 | |
b = np.linspace(0, 2, 500) | |
fig, axes = plt.subplots(nrows=2, figsize=(14,6), sharex=True) | |
for ax, q, c in zip(axes, [4,3], ["#1976D2", "#8BC34A"]): | |
ax.hist(zs[qops == q], histtype="step", bins=b, label="QOP %d" % q, color=c) | |
ax.legend(frameon=False) | |
ax.set_ylabel("N") | |
axes[1].set_xlabel("z") | |
fig.subplots_adjust(hspace=0.07) | |
fig.savefig("output.png", dpi=300, bbox_inches="tight", transparent=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment