Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
DUVERNE Pierre-Alexandre
MUPHOTEN
Commits
bfd971b6
Commit
bfd971b6
authored
May 10, 2021
by
DUVERNE Pierre-Alexandre
Browse files
Delete plot_divers_papier.py
parent
97dcd43a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
1355 deletions
+0
-1355
muphoten/plot_divers_papier.py
muphoten/plot_divers_papier.py
+0
-1355
No files found.
muphoten/plot_divers_papier.py
deleted
100755 → 0
View file @
97dcd43a
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 25 22:44:01 2021
@author: duverne
"""
import
numpy
as
np
from
astropy.table
import
Table
import
matplotlib.pyplot
as
plt
from
astropy.io
import
ascii
import
plot_image
as
plotim
import
numpy.polynomial.polynomial
as
poly
from
astropy.visualization
import
ZScaleInterval
,
imshow_norm
,
SqrtStretch
from
astropy.io
import
fits
from
astropy.wcs.wcs
import
WCS
import
mag_lim
as
ml
import
catalog
as
cata
from
muphoten.background
import
background_estimation
,
bkg_to_array
import
photometry
as
photo
import
background
as
back
# reu = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/iris_g_paper.dat', 2)
# reu = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper.dat', 2)
# reu = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper----.dat', 2)
# reu = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper_v2.dat', 3)
# path_iris = '/home/duverne/Documents/agatha_pipeline/results/g_band_iris_paper_v3_isophotal_radius_5_time.dat'
# iris_table = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_iris_paper_v3_isophotal_radius_5_time.dat', 2.5)
# iris = Table.read('/home/duverne/Documents/agatha_pipeline/results/iris_g_paper_v2.dat',
# format='ascii.commented_header')
# mask = (iris['flag_dist'] == 0)
# iris = iris[mask]
# lt_table = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper_v3_isophotal_radius_5.dat', 3.0)
# lt = Table.read('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper_v3_isophotal_radius_3.dat',
# format='ascii.commented_header')
# mask = (lt['flag_dist'] == 0)
# lt = lt[mask]
# path_kait = '/home/duverne/Documents/agatha_pipeline/results/results_kait_B_paper_isophotal_radius_5_time.dat'
# kait_table = plotim.prepare_light_curve( '/home/duverne/Documents/agatha_pipeline/results/results_kait_B_paper_isophotal_radius_5_time.dat', 3.)
# kait = Table.read('/home/duverne/Documents/agatha_pipeline/results/results_kait_B_paper_isophotal_radius_5.dat',
# format='ascii.commented_header')
# mask = (kait['flag_dist'] == 0)
# kait = kait[mask]
# # lt = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/g_band_LT_paper_v3_isophotal_radius_5.dat', 3.0)
# lt_table_b = plotim.prepare_light_curve('/home/duverne/Documents/agatha_pipeline/results/B_band_LT_paper_v3_isophotal_radius_5.dat', 3.)
# mask = (lt_table_b['flag_dist'] == 0)
# lt_table_b = lt_table_b[mask]
do_psf
=
False
if
do_psf
:
kait
[
'psf_err'
]
=
0.01
kait_table
[
'psf_err'
]
=
0.01
iris_table
[
'psf_err'
]
=
0.01
iris
[
'psf_err'
]
=
0.01
fig
,
main_axes
=
plt
.
subplots
(
2
,
1
)
plt
.
gcf
().
subplots_adjust
(
left
=
0.1
,
bottom
=
0.1
,
right
=
0.99
,
top
=
0.95
,
wspace
=
2.5
,
hspace
=
0.5
)
main_axes
[
0
].
errorbar
(
kait
[
'time'
],
kait
[
'psf'
],
yerr
=
kait
[
'psf_err'
],
label
=
r
'$Before$ $Clipping$'
,
marker
=
'x'
,
linestyle
=
'none'
,
color
=
'red'
,
ms
=
5
)
main_axes
[
0
].
errorbar
(
kait_table
[
'time'
],
kait_table
[
'psf'
],
yerr
=
kait_table
[
'psf_err'
],
label
=
r
'$After$ $Clipping$'
,
marker
=
'd'
,
linestyle
=
'none'
,
color
=
'blue'
,
ms
=
6
)
median_psf_kait
=
[
np
.
median
(
kait_table
[
'psf'
]),
np
.
median
(
kait_table
[
'psf'
])]
time_psf_kait
=
[
kait_table
[
'time'
][
0
]
-
1
,
kait_table
[
'time'
][
-
1
]
+
1
]
main_axes
[
0
].
plot
(
time_psf_kait
,
median_psf_kait
,
linestyle
=
'--'
,
color
=
'black'
)
main_axes
[
0
].
set_xlabel
(
r
'$Time$ $-$ $MJD$ $58285.441$ $(days)$'
,
fontsize
=
14
)
main_axes
[
0
].
set_ylabel
(
r
'$FWHM$ $PSF$ $(pixels)$'
,
fontsize
=
12
)
main_axes
[
0
].
set_title
(
r
'$PSF$ $Evolution$ $KAIT$'
,
fontsize
=
14
)
main_axes
[
0
].
legend
()
main_axes
[
0
].
xaxis
.
set_tick_params
(
labelsize
=
12
)
main_axes
[
0
].
yaxis
.
set_tick_params
(
labelsize
=
12
)
main_axes
[
1
].
errorbar
(
iris
[
'time'
],
iris
[
'psf'
],
yerr
=
iris
[
'psf_err'
],
label
=
r
'$Before$ $Clipping$'
,
marker
=
'x'
,
linestyle
=
'none'
,
color
=
'red'
,
ms
=
5
)
main_axes
[
1
].
errorbar
(
iris_table
[
'time'
],
iris_table
[
'psf'
],
yerr
=
iris_table
[
'psf_err'
],
label
=
r
'$After$ $Clipping$'
,
marker
=
'd'
,
linestyle
=
'none'
,
color
=
'blue'
,
ms
=
6
)
median_psf_iris
=
[
np
.
median
(
iris_table
[
'psf'
]),
np
.
median
(
iris_table
[
'psf'
])]
time_psf_iris
=
[
iris_table
[
'time'
][
0
]
-
1
,
iris_table
[
'time'
][
-
1
]
+
1
]
main_axes
[
1
].
plot
(
time_psf_iris
,
median_psf_iris
,
linestyle
=
'--'
,
color
=
'black'
)
main_axes
[
1
].
set_xlabel
(
r
'$Time$ $-$ $MJD$ $58285.441$ $(days)$'
,
fontsize
=
14
)
main_axes
[
1
].
set_ylabel
(
r
'$FWHM$ $PSF$ $(pixels)$'
,
fontsize
=
12
)
main_axes
[
1
].
set_title
(
r
'$PSF$ $Evolution$ $IRiS$'
,
fontsize
=
14
)
main_axes
[
1
].
legend
()
main_axes
[
1
].
xaxis
.
set_tick_params
(
labelsize
=
12
)
main_axes
[
1
].
yaxis
.
set_tick_params
(
labelsize
=
12
)
do_calib
=
False
if
do_calib
:
iris_calib
=
Table
.
read
(
'/home/duverne/Documents/agatha_pipeline/results/iris_table_for_calibration.dat'
,
format
=
'ascii.commented_header'
)
iris_calib
[
'mag_err'
]
=
2.5
/
(
np
.
log
(
10
)
*
np
.
sqrt
(
iris_calib
[
'aperture_sum'
]))
fit_coef
=
np
.
ma
.
polyfit
(
iris_calib
[
'Magnitude'
],
iris_calib
[
'gmag'
],
1
)
fig
,
ax
=
plt
.
subplots
(
1
,
2
,
figsize
=
(
20
,
12.5
))
plt
.
gcf
().
subplots_adjust
(
left
=
0.05
,
bottom
=
0.1
,
right
=
0.99
,
top
=
0.95
,
wspace
=
0.1
,
hspace
=
0.5
)
fit_lin
=
poly
.
polyval
(
iris_calib
[
'Magnitude'
],
np
.
flip
(
fit_coef
))
ax
[
0
].
plot
(
iris_calib
[
'Magnitude'
],
fit_lin
,
label
=
r
'Fit : a={0:.4f} and b={1:.2f}'
.
format
(
fit_coef
[
0
],
fit_coef
[
1
]),
color
=
'red'
)
khi
=
np
.
sum
(((
poly
.
polyval
(
iris_calib
[
'Magnitude'
],
np
.
flip
(
fit_coef
))
-
(
iris_calib
[
'gmag'
]))
**
2
)
/
iris_calib
[
'e_gmag'
])
khi_dof
=
khi
/
(
len
(
iris_calib
[
'Magnitude'
])
-
2
)
print
(
khi_dof
)
label
=
r
'$\frac{\chi^2}{dof}$'
label
+=
r
' = {0:.4f}'
.
format
(
khi_dof
)
ax
[
0
].
errorbar
(
iris_calib
[
'Magnitude'
],
iris_calib
[
'gmag'
],
xerr
=
iris_calib
[
'mag_err'
],
yerr
=
iris_calib
[
'e_gmag'
],
marker
=
"x"
,
ms
=
'9'
,
color
=
'black'
,
linestyle
=
'none'
,
label
=
label
)
ax
[
0
].
set_xlabel
(
r
'$Instrumental$ $Magnitude$'
,
fontsize
=
18
)
ax
[
0
].
set_ylabel
(
r
'$g$ $Magnitude$'
,
fontsize
=
18
)
ax
[
0
].
set_title
(
r
'$IRiS$ $Calibration$ $Curve$'
,
fontsize
=
18
)
ax
[
0
].
legend
(
fontsize
=
22
)
ax
[
0
].
xaxis
.
set_tick_params
(
labelsize
=
18
)
ax
[
0
].
yaxis
.
set_tick_params
(
labelsize
=
18
)
kait_calib
=
Table
.
read
(
'/home/duverne/Documents/agatha_pipeline/results/kait_table_for_calibration.dat'
,
format
=
'ascii.commented_header'
)
# '/media/duverne/DISQUE ESSB/AT2018cow_data/2018cow_kaitdata/B_c_band/2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
kait_calib
[
'mag_err'
]
=
2.5
/
(
np
.
log
(
10
)
*
np
.
sqrt
(
kait_calib
[
'aperture_sum'
]))
fit_coef
=
np
.
ma
.
polyfit
(
kait_calib
[
'Magnitude'
],
kait_calib
[
'BMag'
],
1
)
fit_lin
=
poly
.
polyval
(
kait_calib
[
'Magnitude'
],
np
.
flip
(
fit_coef
))
khi
=
np
.
sum
(((
poly
.
polyval
(
kait_calib
[
'Magnitude'
],
np
.
flip
(
fit_coef
))
-
kait_calib
[
'BMag'
])
**
2
)
/
kait_calib
[
'error_from_transformation'
])
khi_dof
=
khi
/
(
len
(
kait_calib
[
'Magnitude'
])
-
2
)
print
(
khi_dof
)
label
=
r
'$\frac{\chi^2}{dof}$'
label
+=
r
' = {0:.4f}'
.
format
(
khi_dof
)
ax
[
1
].
errorbar
(
kait_calib
[
'Magnitude'
],
kait_calib
[
'BMag'
],
xerr
=
kait_calib
[
'mag_err'
],
yerr
=
kait_calib
[
'error_from_transformation'
],
marker
=
"x"
,
ms
=
'9'
,
color
=
'black'
,
linestyle
=
'none'
,
label
=
label
)
ax
[
1
].
plot
(
kait_calib
[
'Magnitude'
],
fit_lin
,
label
=
'Fit : a={0:.4f} and b={1:.2f}'
.
format
(
fit_coef
[
0
],
fit_coef
[
1
]),
color
=
'red'
)
ax
[
1
].
set_xlabel
(
r
'$Instrumental$ $Magnitude$'
,
fontsize
=
18
)
ax
[
1
].
set_ylabel
(
r
'$B_c$ $Magnitude$'
,
fontsize
=
18
)
ax
[
1
].
set_title
(
r
'$KAIT$ $Calibration$ $Curve$'
,
fontsize
=
18
)
ax
[
1
].
legend
(
fontsize
=
22
)
ax
[
1
].
xaxis
.
set_tick_params
(
labelsize
=
18
)
ax
[
1
].
yaxis
.
set_tick_params
(
labelsize
=
18
)
do_star
=
False
if
do_star
:
fig
,
main_axes
=
plt
.
subplots
(
2
,
1
)
plt
.
gcf
().
subplots_adjust
(
left
=
0.1
,
bottom
=
0.1
,
right
=
0.9
,
top
=
0.9
,
wspace
=
2.5
,
hspace
=
0.5
)
do_back
=
False
if
do_back
:
coordinate
=
[
244.000927647
,
+
22.2680094118
]
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/soustraction_iris_avec_ps/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g.fits'
hdu
=
fits
.
open
(
image
)[
0
]
data_iris
,
header_iris
=
hdu
.
data
,
hdu
.
header
wcs_data_iris
=
WCS
(
header_iris
,
relax
=
False
)
coord_iris
=
wcs_data_iris
.
all_world2pix
([
coordinate
],
1
)
background_object_iris
=
back
.
background_estimation
(
data_iris
,
n_sigma
=
3.0
,
box_size
=
(
50
,
50
),
bkg_estimator
=
'sex'
,
filter_size
=
(
3
,
3
))
#, mask=mask)
background_array_iris
,
background_rms_iris
=
back
.
bkg_to_array
(
background_object_iris
)
data_cleaned_iris
=
data_iris
-
background_array_iris
kait_calib
=
Table
.
read
(
'/home/duverne/Documents/agatha_pipeline/results/kait_table_for_calibration.dat'
,
format
=
'ascii.commented_header'
)
iris_calib
=
Table
.
read
(
'/home/duverne/Documents/agatha_pipeline/results/iris_table_for_calibration.dat'
,
format
=
'ascii.commented_header'
)
# image = '/media/duverne/DISQUE ESSB/AT2018cow_data/kait/B_c_band/SUB_2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/2018cow_kaitdata/B_c_band/2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
hdu
=
fits
.
open
(
image
)[
0
]
data_kait
,
header_kait
=
hdu
.
data
,
hdu
.
header
wcs_data_kait
=
WCS
(
header_kait
,
relax
=
False
)
coord_kait
=
wcs_data_kait
.
all_world2pix
([
coordinate
],
1
)
# mask=(data_kait == 1e-30)
mask
=
(
data_kait
==
1e-30
)
|
(
data_kait
==
0
)
background_object_kait
=
back
.
background_estimation
(
data_kait
,
n_sigma
=
3.0
,
box_size
=
(
60
,
60
),
bkg_estimator
=
'sex'
,
filter_size
=
(
3
,
3
),
mask
=
mask
)
background_array_kait
,
background_rms_kait
=
back
.
bkg_to_array
(
background_object_kait
)
data_cleaned_kait
=
data_kait
-
background_array_kait
fig
,
ax
=
plt
.
subplots
(
2
,
3
,
figsize
=
(
20
,
12.5
),
sharey
=
'row'
,
sharex
=
'row'
)
plt
.
gcf
().
subplots_adjust
(
left
=
0.06
,
bottom
=
0.08
,
right
=
0.99
,
top
=
0.95
,
wspace
=
0.05
,
hspace
=
0.07
)
font_size
=
15
im
,
norm
=
imshow_norm
(
data_kait
,
ax
[
0
,
0
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
0
][
0
])
im
,
norm
=
imshow_norm
(
background_array_kait
,
ax
[
0
,
1
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
0
][
1
])
im
,
norm
=
imshow_norm
(
data_cleaned_kait
,
ax
[
0
,
2
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
0
][
2
])
ax
[
0
][
2
].
scatter
(
coord_kait
[
0
][
0
]
+
20
,
coord_kait
[
0
][
1
]
-
5
,
marker
=
"_"
,
s
=
200
,
color
=
'black'
,
linewidths
=
4
)
ax
[
0
][
2
].
scatter
(
coord_kait
[
0
][
0
],
coord_kait
[
0
][
1
]
+
20
,
marker
=
"|"
,
s
=
200
,
color
=
'black'
,
linewidths
=
4
)
ax
[
0
][
2
].
scatter
(
kait_calib
[
'xcentroid'
],
kait_calib
[
'ycentroid'
],
color
=
'blue'
,
marker
=
'o'
,
s
=
18
)
ax
[
0
][
2
].
set_title
(
r
'Cleaned Image'
,
fontsize
=
22
)
#ax[0][2].set_xlabel(r'X', fontsize=22)
#ax[0][2].set_ylabel(r'Y', fontsize=22)
ax
[
0
][
2
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
0
][
2
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
0
][
1
].
set_title
(
r
'Background'
,
fontsize
=
22
)
#ax[0][1].set_xlabel(r'X', fontsize=22)
#ax[0][1].set_ylabel(r'Y', fontsize=22)
ax
[
0
][
1
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
0
][
1
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
0
][
0
].
set_title
(
r
'Image'
,
fontsize
=
22
)
#ax[0][0].set_xlabel(r'X', fontsize=22)
ax
[
0
][
0
].
set_ylabel
(
r
'Y'
,
fontsize
=
22
)
ax
[
0
][
0
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
0
][
0
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
im
,
norm
=
imshow_norm
(
data_iris
,
ax
[
1
,
0
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
1
][
0
])
im
,
norm
=
imshow_norm
(
background_array_iris
,
ax
[
1
,
1
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
1
][
1
])
im
,
norm
=
imshow_norm
(
data_cleaned_iris
,
ax
[
1
,
2
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
(),
aspect
=
"auto"
)
fig
.
colorbar
(
im
,
ax
=
ax
[
1
][
2
])
ax
[
1
][
2
].
scatter
(
iris_calib
[
'xcentroid'
],
iris_calib
[
'ycentroid'
],
color
=
'blue'
,
marker
=
'o'
,
s
=
18
)
ax
[
1
][
2
].
scatter
(
coord_iris
[
0
][
0
]
+
80
,
coord_iris
[
0
][
1
],
marker
=
"_"
,
s
=
400
,
color
=
'black'
,
linewidths
=
5
)
ax
[
1
][
2
].
scatter
(
coord_iris
[
0
][
0
],
coord_iris
[
0
][
1
]
+
90
,
marker
=
"|"
,
s
=
400
,
color
=
'black'
,
linewidths
=
5
)
#ax[1][2].set_title(r'IRiS Cleaned Image', fontsize=22)
#ax[1][2].set_xlabel(r'X', fontsize=22)
#ax[1][2].set_ylabel(r'Y', fontsize=22)
ax
[
1
][
2
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
1
][
2
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
#ax[1][1].set_title(r'IRiS Background Image', fontsize=22)
ax
[
1
][
1
].
set_xlabel
(
r
'X'
,
fontsize
=
22
)
#ax[1][1].set_ylabel(r'Y', fontsize=22)
ax
[
1
][
1
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
1
][
1
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
# ax[1][0].set_title(r'IRiS Image', fontsize=22)
#ax[1][0].set_xlabel(r'X', fontsize=22)
ax
[
1
][
0
].
set_ylabel
(
r
'Y'
,
fontsize
=
22
)
ax
[
1
][
0
].
xaxis
.
set_tick_params
(
labelsize
=
font_size
)
ax
[
1
][
0
].
yaxis
.
set_tick_params
(
labelsize
=
font_size
)
do_diff
=
False
if
do_diff
:
coordinate
=
[
244.000927647
,
+
22.2680094118
]
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/soustraction_iris_avec_ps/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g.fits'
hdu
=
fits
.
open
(
image
)[
0
]
data_iris
,
header_iris
=
hdu
.
data
,
hdu
.
header
wcs_data_iris
=
WCS
(
header_iris
,
relax
=
False
)
coord_iris
=
wcs_data_iris
.
all_world2pix
([
coordinate
],
1
)
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/soustraction_iris_avec_ps/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g/substraction/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g_reg_0_sub.fits'
hdu_sub
=
fits
.
open
(
image
)[
0
]
data_sub_iris
,
header_sub_iris
=
hdu_sub
.
data
,
hdu_sub
.
header
wcs_data_sub_iris
=
WCS
(
header_sub_iris
,
relax
=
False
)
coord_sub_iris
=
wcs_data_sub_iris
.
all_world2pix
([
coordinate
],
1
)
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/2018cow_kaitdata/B_c_band/2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
hdu
=
fits
.
open
(
image
)[
0
]
data_kait
,
header_kait
=
hdu
.
data
,
hdu
.
header
wcs_data_kait
=
WCS
(
header_kait
,
relax
=
False
)
coord_kait
=
wcs_data_kait
.
all_world2pix
([
coordinate
],
1
)
image
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/kait/B_c_band/SUB_2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
hdu
=
fits
.
open
(
image
)[
0
]
data_sub_kait
,
header_sub_kait
=
hdu
.
data
,
hdu
.
header
wcs_data_sub_kait
=
WCS
(
header_sub_kait
,
relax
=
False
)
coord_sub_subkait
=
wcs_data_sub_kait
.
all_world2pix
([
coordinate
],
1
)
fig
,
ax
=
plt
.
subplots
(
2
,
2
,
figsize
=
(
10
,
12.5
),
sharey
=
'row'
,
sharex
=
'row'
)
im
,
norm
=
imshow_norm
(
data_iris
,
ax
[
0
,
0
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
())
fig
.
colorbar
(
im
,
ax
=
ax
[
0
][
0
])
ax
[
0
][
0
].
scatter
(
coord_iris
[
0
][
0
]
+
25
,
coord_iris
[
0
][
1
]
-
1
,
marker
=
"_"
,
s
=
200
,
color
=
'black'
)
ax
[
0
][
0
].
scatter
(
coord_iris
[
0
][
0
]
-
1
,
coord_iris
[
0
][
1
]
+
25
,
marker
=
"|"
,
s
=
200
,
color
=
'black'
)
im
,
norm
=
imshow_norm
(
data_sub_iris
,
ax
[
0
,
1
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
())
# im.set_clim(np.min(data_sub_iris),np.max(data_sub_iris))
fig
.
colorbar
(
im
,
ax
=
ax
[
0
][
1
])
ax
[
0
][
1
].
scatter
(
coord_sub_iris
[
0
][
0
]
+
10
,
coord_sub_iris
[
0
][
1
]
-
1
,
marker
=
"_"
,
s
=
200
,
color
=
'black'
)
ax
[
0
][
1
].
scatter
(
coord_sub_iris
[
0
][
0
]
-
1
,
coord_sub_iris
[
0
][
1
]
+
10
,
marker
=
"|"
,
s
=
200
,
color
=
'black'
)
im
,
norm
=
imshow_norm
(
data_kait
,
ax
[
1
,
0
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
())
fig
.
colorbar
(
im
,
ax
=
ax
[
1
][
0
])
ax
[
1
][
0
].
scatter
(
coord_kait
[
0
][
0
]
+
15
,
coord_kait
[
0
][
1
]
-
1
,
marker
=
"_"
,
s
=
200
,
color
=
'black'
)
ax
[
1
][
0
].
scatter
(
coord_kait
[
0
][
0
]
-
1
,
coord_kait
[
0
][
1
]
+
15
,
marker
=
"|"
,
s
=
200
,
color
=
'black'
)
im
,
norm
=
imshow_norm
(
data_sub_kait
,
ax
[
1
,
1
],
origin
=
'lower'
,
cmap
=
'Greys_r'
,
interval
=
ZScaleInterval
(),
stretch
=
SqrtStretch
())
fig
.
colorbar
(
im
,
ax
=
ax
[
1
][
1
])
ax
[
1
][
1
].
scatter
(
coord_sub_subkait
[
0
][
0
]
+
10
,
coord_sub_subkait
[
0
][
1
]
-
1
,
marker
=
"_"
,
s
=
200
,
color
=
'black'
)
ax
[
1
][
1
].
scatter
(
coord_sub_subkait
[
0
][
0
]
-
1
,
coord_sub_subkait
[
0
][
1
]
+
10
,
marker
=
"|"
,
s
=
200
,
color
=
'black'
)
ax
[
0
][
1
].
xaxis
.
set_tick_params
(
labelsize
=
15
)
ax
[
0
][
1
].
yaxis
.
set_tick_params
(
labelsize
=
15
)
do_lim
=
False
def
do_plot_ratio
(
mag_lim
,
lim
,
region
,
index
,
threshold
=
0.5
,
save
=
False
,
name
=
'ratio'
,
title
=
r
'$Limit$ $Magnitude$ $Ratio$'
):
mask
=
(
mag_lim
[:
index
+
1
]
==
0.
)
y
=
np
.
ma
.
array
(
mag_lim
[:
index
+
1
],
mask
=
mask
).
compressed
()
x
=
np
.
ma
.
array
(
region
[
1
][:
index
+
1
],
mask
=
mask
).
compressed
()
fig
,
ax
=
plt
.
subplots
(
1
,
1
,
figsize
=
(
10
,
10
))
label
=
r
'$Limit$ $Magnitude$ = '
+
'%.2f'
%
lim
ax
.
axvline
(
lim
,
label
=
label
,
color
=
'grey'
,
linestyle
=
'dashed'
,
linewidth
=
3
)
ax
.
plot
(
x
,
y
,
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
)
ax
.
plot
(
region
[
1
][
index
+
1
:
-
1
],
mag_lim
[
index
+
1
:],
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
)
ax
.
axhline
(
threshold
,
label
=
r
'threshold'
,
color
=
'black'
,
linestyle
=
'-'
,
linewidth
=
3
)
ax
.
set_title
(
title
,
fontsize
=
18
)
ax
.
set_xlabel
(
r
'$Magnitude$ '
,
fontsize
=
18
)
ax
.
set_ylabel
(
r
'$ratio$ $of$ $detected$ $objects$'
,
fontsize
=
18
)
ax
.
legend
(
fontsize
=
12
)
ax
.
xaxis
.
set_tick_params
(
labelsize
=
12
)
ax
.
yaxis
.
set_tick_params
(
labelsize
=
12
)
if
save
:
fig
.
savefig
(
name
+
'.png'
)
plt
.
close
(
fig
)
if
do_lim
:
image_kait
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/2018cow_kaitdata/B_c_band/2018cow_20180622_060312_Jun8mgky_kait_B_c.fit'
hdu
=
fits
.
open
(
image_kait
)[
0
]
data_kait
,
header_kait
=
hdu
.
data
,
hdu
.
header
band_kait
=
'BMag'
# data=data[0:250]
wcs_data_kait
=
WCS
(
header_kait
)
center_kait
=
ml
.
get_sky_coord_center
(
data_kait
,
wcs_data_kait
)
width_kait
,
height_kait
=
ml
.
get_fov
(
data_kait
,
wcs_data_kait
)
region_kait
=
ml
.
get_region
(
data_kait
,
wcs_data_kait
)
region_kait
=
cata
.
from_PS2Johnson
(
band_kait
,
region_kait
)
# all_stars_2 = cata.from_PS2Johnson(band, all_stars_2)
all_star_detected_kait
=
ml
.
detect_objects
(
data_kait
,
header_kait
,
band_kait
)
# all_star_detected_kait = cata.from_PS2Johnson(band_kait, all_star_detected_kait)
histo_detected_objects_kait
,
histo_region_kait
,
mag_lim_kait
=
ml
.
build_ratio
(
region_kait
,
all_star_detected_kait
,
band_kait
,
precision
=
0.2
,
interval
=
[
13.
,
22.
])
lim_kait
,
index_kait
=
ml
.
get_mag_lim
(
mag_lim_kait
,
histo_region_kait
,
precision
=
0.2
,
threshold
=
0.5
)
do_plot_ratio
(
mag_lim_kait
,
lim_kait
,
histo_region_kait
,
index_kait
,
title
=
r
'$Limit$ $Magnitude$ $Ratio$ $KAIT$'
)
image_iris
=
'/media/duverne/DISQUE ESSB/AT2018cow_data/soustraction_iris_avec_ps/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g/20180628_ATLAS18qqn-S001-R001-C008-SDSS_g.fits'
hdu
=
fits
.
open
(
image_iris
)[
0
]
data_iris
,
header_iris
=
hdu
.
data
,
hdu
.
header
band_iris
=
'gmag'
# data=data[0:250]
wcs_data_iris
=
WCS
(
header_iris
)
center_iris
=
ml
.
get_sky_coord_center
(
data_iris
,
wcs_data_iris
)
width_iris
,
height_iris
=
ml
.
get_fov
(
data_iris
,
wcs_data_iris
)
region_iris
=
ml
.
get_region
(
data_iris
,
wcs_data_iris
)
# all_stars_2 = cata.from_PS2Johnson(band, all_stars_2)
all_star_detected_iris
=
ml
.
detect_objects
(
data_iris
,
header_iris
,
band_iris
)
detected_objects_iris
,
region_iris
,
mag_lim_iris
=
ml
.
build_ratio
(
region_iris
,
all_star_detected_iris
,
band_iris
,
precision
=
0.2
,
interval
=
[
11.
,
22.
])
lim_iris
,
index_iris
=
ml
.
get_mag_lim
(
mag_lim_iris
,
region_iris
,
precision
=
0.2
,
threshold
=
0.5
)
do_plot_ratio
(
mag_lim_iris
,
lim_iris
,
region_iris
,
index_iris
,
title
=
r
'$Limit$ $Magnitude$ $IRiS$'
)
threshold
=
0.5
fig
,
ax
=
plt
.
subplots
(
1
,
2
,
figsize
=
(
20
,
12.5
))
plt
.
gcf
().
subplots_adjust
(
left
=
0.06
,
bottom
=
0.1
,
right
=
0.99
,
top
=
0.95
,
wspace
=
0.1
,
hspace
=
0.5
)
mask
=
(
mag_lim_kait
[:
index_kait
+
1
]
==
0.
)
y
=
np
.
ma
.
array
(
mag_lim_kait
[:
index_kait
+
1
],
mask
=
mask
).
compressed
()
x
=
np
.
ma
.
array
(
histo_region_kait
[
1
][:
index_kait
+
1
],
mask
=
mask
).
compressed
()
# label = r'$Limit$ $Magnitude$ = ' + '%.2f' %lim_kait
label
=
r
'$Limit$ $Magnitude$ = {:.2f} $\pm$ {}'
.
format
(
lim_kait
,
0.2
)
ax
[
0
].
axvline
(
lim_kait
,
label
=
label
,
color
=
'grey'
,
linestyle
=
'dashed'
,
linewidth
=
3
)
ax
[
0
].
plot
(
x
,
y
,
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
,
markersize
=
12
)
ax
[
0
].
plot
(
histo_region_kait
[
1
][
index_kait
+
1
:
-
1
],
mag_lim_kait
[
index_kait
+
1
:],
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
,
markersize
=
12
)
ax
[
0
].
axhline
(
threshold
,
label
=
r
'threshold'
,
color
=
'black'
,
linestyle
=
'-'
,
linewidth
=
3
)
ax
[
0
].
set_title
(
r
'$Limit$ $Magnitude$ $KAIT$'
,
fontsize
=
22
)
ax
[
0
].
set_xlabel
(
r
'$Magnitude$'
,
fontsize
=
22
)
ax
[
0
].
set_ylabel
(
r
'$ratio$ $of$ $detected$ $objects$'
,
fontsize
=
22
)
ax
[
0
].
legend
(
fontsize
=
20
)
ax
[
0
].
xaxis
.
set_tick_params
(
labelsize
=
22
)
ax
[
0
].
yaxis
.
set_tick_params
(
labelsize
=
22
)
mask
=
(
mag_lim_iris
[:
index_iris
+
1
]
==
0.
)
y
=
np
.
ma
.
array
(
mag_lim_iris
[:
index_iris
+
1
],
mask
=
mask
).
compressed
()
x
=
np
.
ma
.
array
(
region_iris
[
1
][:
index_iris
+
1
],
mask
=
mask
).
compressed
()
# label = r'$Limit$ $Magnitude$ = ' + '%.2f' %lim_iris
label
=
r
'$Limit$ $Magnitude$ = {:.2f} $\pm$ {}'
.
format
(
lim_iris
,
0.2
)
ax
[
1
].
axvline
(
lim_iris
,
label
=
label
,
color
=
'grey'
,
linestyle
=
'dashed'
,
linewidth
=
3
)
ax
[
1
].
plot
(
x
,
y
,
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
,
markersize
=
12
)
ax
[
1
].
plot
(
region_iris
[
1
][
index_iris
+
1
:
-
1
],
mag_lim_iris
[
index_iris
+
1
:],
linestyle
=
'none'
,
marker
=
'o'
,
color
=
'blue'
,
markersize
=
12
)
ax
[
1
].
axhline
(
threshold
,
label
=
r
'threshold'
,
color
=
'black'
,
linestyle
=
'-'
,
linewidth
=
3
)
ax
[
1
].
set_title
(
r
'$Limit$ $Magnitude$ $Ratio$ $IRiS$'
,
fontsize
=
22
)
ax
[
1
].
set_xlabel
(
r
'$Magnitude$'
,
fontsize
=
22
)
ax
[
1
].
legend
(
fontsize
=
18
)
ax
[
1
].
xaxis
.
set_tick_params
(
labelsize
=
22
)
ax
[
1
].
yaxis
.
set_tick_params
(
labelsize
=
22
)
do_star_ref
=
False
if
do_star_ref
:
fig
,
main_axes
=
plt
.
subplots
(
2
,
1
)
plt
.
gcf
().
subplots_adjust
(
left
=
0.1
,
bottom
=
0.1
,
right
=
0.9
,
top
=
0.9
,
wspace
=
2.5
,
hspace
=
0.5
)
main_axes
[
0
].
errorbar
(
kait_table
[
'time'
],
kait_table
[
'star_ref_magnitude'
],
yerr
=
kait_table
[
'star_ref_error_tot'
],
label
=
r
'$B$ $band$ $KAIT$'
,
marker
=
'x'
,
linestyle
=
'none'
,
color
=
'red'
,
ms
=
5
)
main_axes
[
0
].
errorbar
(
kait_table
[
'time'
],
kait_table
[
'star_ref_magnitude_cata'
],
yerr
=
kait_table
[
'star_ref_error_cata'
],
label
=
r
'$Catalog$ $Magnitude = $'
+
'%.2f'
%
kait_table
[
'star_ref_magnitude_cata'
][
0
],
linestyle
=
'-'
,
color
=
'black'
,
ms
=
5
)
mask
=
(
kait_table
[
'star_ref_error_tot'
]
<
0.3
)
kait_table_clean
=
kait_table
[
mask
]
main_axes
[
0
].
errorbar
(
kait_table_clean
[
'time'
],
kait_table_clean
[
'star_ref_magnitude'
],
yerr
=
kait_table_clean
[
'star_ref_error_tot'
],
label
=
r
'$B$ $band$ $KAIT$ $Cleaned$'
,
marker
=
'd'
,
linestyle
=
'none'
,
color
=
'blue'
,
ms
=
7
)
main_axes
[
0
].
set_xlabel
(
r
'$Time$ $-$ $MJD$ $58285.441$ $(days)$'
)
main_axes
[
0
].
set_ylabel
(
r
'$Magnitude$'
)
main_axes
[
0
].
set_title
(
r
'$Lightcurve$ $Star$ $KAIT$'
)
main_axes
[
0
].
legend
()
main_axes
[
0
].
invert_yaxis
()