-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nb added and logic corrected in absfinder
- Loading branch information
Showing
10 changed files
with
743 additions
and
59 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
# imports | ||
import numpy as np | ||
from astropy.io import fits | ||
from astropy.table import Table | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# exploring ..data/qso_test.fits file | ||
|
||
hdul = fits.open(f'../data/qso_test.fits') | ||
# If you want to see headers of other HDUs, you can do so as follows | ||
for i, hdu in enumerate(hdul): | ||
print(f"Header of HDU {i}:") | ||
print(hdu.header) | ||
print("\n") | ||
|
||
hdul.close() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# ! export absorber='MgII' | ||
# !qsoabsfind --input-fits-file ../data/qso_test.fits \ | ||
# --output ../data/${absorber}_cat.fits\ | ||
# --absorber ${absorber} \ | ||
# --n-tasks 4 --ncpus 4 \ | ||
# --headers AUTHOR=ABHIJEET SURVEY=SDSS | ||
|
||
|
||
|
||
|
||
|
||
hdul_abs = fits.open(f'../data/MgII_cat.fits') | ||
# If you want to see headers of other HDUs, you can do so as follows | ||
for i, hdul_abs in enumerate(hdul_abs): | ||
print(f"Header of HDU {i}:") | ||
print(hdul_abs.header) | ||
print("\n") | ||
|
||
|
||
|
||
abs_tab = Table.read(f'../data/MgII_cat.fits', hdu=1) | ||
zabs = abs_tab["Z_ABS"].data | ||
plt.hist(zabs, bins=20) | ||
plt.xlabel('MgII redshift') | ||
|
||
|
||
ew1 = abs_tab["MGII_2796_EW"].data | ||
ew2 = abs_tab["MGII_2803_EW"].data | ||
bins = np.arange(0.1, 3.5, 0.1) | ||
plt.hist(ew1, bins=bins, label='ew1') | ||
plt.hist(ew2, bins=bins, label = 'ew2') | ||
plt.legend() | ||
plt.xlabel(r'$EW_{\rm MgII}\, [\AA]$') | ||
|
||
|
||
|
||
|
||
|
||
from qsoabsfind.utils import plot_absorber | ||
from qsoabsfind.spec import QSOSpecRead | ||
|
||
# select a random spectra from MgII_cat.fits | ||
|
||
index = np.random.choice(abs_tab["INDEX_SPEC"].data) | ||
spectra = QSOSpecRead(f'../data/qso_test.fits', index) | ||
|
||
# select corresponding zabs table | ||
zabs = abs_tab[abs_tab["INDEX_SPEC"].data==index] | ||
plot_absorber(spectra, 'MgII', zabs, show_error=True, xlabel='obs wave (ang)', \ | ||
ylabel='residual', title=f'QSO, index = {index}, z = {spectra.metadata["Z_QSO"]:.4f}', plot_filename=None) | ||
|
||
|
||
|
||
|
||
|
||
# if want to run qsoabsfind on one spectrum | ||
from qsoabsfind.absfinder import read_single_spectrum_and_find_absorber | ||
from qsoabsfind.constants import search_parameters | ||
help(read_single_spectrum_and_find_absorber) | ||
|
||
|
||
read_single_spectrum_and_find_absorber(f'../data/qso_test.fits', 212, 'MgII', **search_parameters["MgII"]) | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
# imports | ||
import numpy as np | ||
from astropy.io import fits | ||
from astropy.table import Table | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# exploring ..data/qso_test.fits file | ||
|
||
hdul = fits.open(f'../data/qso_test.fits') | ||
# If you want to see headers of other HDUs, you can do so as follows | ||
for i, hdu in enumerate(hdul): | ||
print(f"Header of HDU {i}:") | ||
print(hdu.header) | ||
print("\n") | ||
|
||
hdul.close() | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# ! export absorber='MgII' | ||
# !qsoabsfind --input-fits-file ../data/qso_test.fits \ | ||
# --output ../data/${absorber}_cat.fits\ | ||
# --absorber ${absorber} \ | ||
# --n-tasks 4 --ncpus 4 \ | ||
# --headers AUTHOR=ABHIJEET SURVEY=SDSS | ||
|
||
|
||
|
||
|
||
|
||
hdul_abs = fits.open(f'../data/MgII_cat.fits') | ||
# If you want to see headers of other HDUs, you can do so as follows | ||
for i, hdul_abs in enumerate(hdul_abs): | ||
print(f"Header of HDU {i}:") | ||
print(hdul_abs.header) | ||
print("\n") | ||
|
||
|
||
|
||
abs_tab = Table.read(f'../data/MgII_cat.fits', hdu=1) | ||
zabs = abs_tab["Z_ABS"].data | ||
plt.hist(zabs, bins=20) | ||
plt.xlabel('MgII redshift') | ||
|
||
|
||
ew1 = abs_tab["MGII_2796_EW"].data | ||
ew2 = abs_tab["MGII_2803_EW"].data | ||
bins = np.arange(0.1, 3.5, 0.1) | ||
plt.hist(ew1, bins=bins, label='ew1') | ||
plt.hist(ew2, bins=bins, label = 'ew2') | ||
plt.legend() | ||
plt.xlabel(r'$EW_{\rm MgII}\, [\AA]$') | ||
|
||
|
||
|
||
|
||
|
||
from qsoabsfind.utils import plot_absorber | ||
from qsoabsfind.spec import QSOSpecRead | ||
|
||
# select a random spectra from MgII_cat.fits | ||
|
||
index = np.random.choice(abs_tab["INDEX_SPEC"].data) | ||
spectra = QSOSpecRead(f'../data/qso_test.fits', index) | ||
|
||
# select corresponding zabs table | ||
zabs = abs_tab[abs_tab["INDEX_SPEC"].data==index] | ||
plot_absorber(spectra, 'MgII', zabs, show_error=True, xlabel='obs wave (ang)', \ | ||
ylabel='residual', title=f'QSO, index = {index}, z = {spectra.metadata["Z_QSO"]:.4f}', plot_filename=None) | ||
|
||
|
||
|
||
|
||
|
||
# if want to run qsoabsfind on one spectrum | ||
from qsoabsfind.absfinder import read_single_spectrum_and_find_absorber | ||
from qsoabsfind.constants import search_parameters | ||
help(read_single_spectrum_and_find_absorber) | ||
|
||
|
||
read_single_spectrum_and_find_absorber(f'../data/qso_test.fits', 497, 'MgII', **search_parameters["MgII"]) | ||
|
||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.