Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Massana Zapata, Pol Dr (PG/R - Physics)
astro_lab
Commits
eae07bb7
Commit
eae07bb7
authored
Jan 18, 2019
by
Delorme, Maxime Dr (Physics)
Browse files
Decoupled data and subtracted data
parent
533ca7b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
astro_lab.py
View file @
eae07bb7
...
...
@@ -19,6 +19,7 @@ import os, sys, warnings
# Objects
data
=
None
data_sub
=
None
h0
=
None
h1
=
None
zs
=
ZScaleInterval
()
...
...
@@ -66,16 +67,21 @@ def get_parameter(param_name):
return
None
def
plot_data
(
zscale
=
True
):
if
bg_sub
:
pdata
=
data_sub
else
:
pdata
=
data
if
zscale
:
lims
=
zs
.
get_limits
(
data
)
lims
=
zs
.
get_limits
(
p
data
)
else
:
lims
=
[
data
.
min
(),
data
.
max
()]
lims
=
[
p
data
.
min
(),
p
data
.
max
()]
plt
.
imshow
(
data
,
cmap
=
'Greys_r'
,
vmin
=
lims
[
0
],
vmax
=
lims
[
1
],
origin
=
'lower'
)
plt
.
imshow
(
p
data
,
cmap
=
'Greys_r'
,
vmin
=
lims
[
0
],
vmax
=
lims
[
1
],
origin
=
'lower'
)
plt
.
show
()
def
subtract_background
(
bg_wsize
=
50
,
sclip
=
3.0
,
plot
=
False
):
global
data
,
error
,
bg_sub
global
data
,
error
,
data_sub
,
bg_sub
sigma_clip
=
SigmaClip
(
sigma
=
sclip
)
bkg_estimator
=
MedianBackground
()
bkg
=
Background2D
(
data
,
(
bg_wsize
,
bg_wsize
),
sigma_clip
=
sigma_clip
,
bkg_estimator
=
bkg_estimator
)
...
...
@@ -83,7 +89,7 @@ def subtract_background(bg_wsize=50, sclip=3.0, plot=False):
plt
.
imshow
(
bkg
.
background
,
origin
=
'lower'
,
cmap
=
'Greys_r'
)
plt
.
show
()
error
=
calc_total_error
(
data
,
bkg
.
background_rms
,
eff_gain
)
data
=
data
-
bkg
.
background
data
_sub
=
data
-
bkg
.
background
bg_sub
=
True
print
(
'Background successfully subtracted'
)
...
...
@@ -95,10 +101,10 @@ def find_center(x, y, mod_fit_size=10, plot=True, contour=True):
y_min
=
y
-
mod_fit_size
y_max
=
y
+
mod_fit_size
window
=
data
[
y_min
:
y_max
+
1
,
x_min
:
x_max
+
1
]
window
=
data
_sub
[
y_min
:
y_max
+
1
,
x_min
:
x_max
+
1
]
# Initial guess
z0
=
data
[
y
,
x
]
z0
=
data
_sub
[
y
,
x
]
m_init
=
models
.
Moffat2D
(
z0
,
x
,
y
)
manual_pick
=
False
...
...
@@ -161,7 +167,7 @@ def compute_photometry(x, y, aperture_r=3.0, sky_in=6.0, sky_out=8.0):
print
(
' Performing photometry measures without error model'
)
phot_table
=
aperture_photometry
(
data
,
apers
)
else
:
phot_table
=
aperture_photometry
(
data
,
apers
,
error
)
phot_table
=
aperture_photometry
(
data
_sub
,
apers
,
error
)
# Mean sky subtraction
bkg_mean
=
phot_table
[
'aperture_sum_1'
]
/
annulus_apertures
.
area
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment