Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cigale
CIGALE
Commits
6a53d6c5
Commit
6a53d6c5
authored
Mar 01, 2018
by
Médéric Boquien
Browse files
Scale the extensive properties to the right distance when computing the χ².
parent
f10d9f86
Changes
2
Hide whitespace changes
Inline
Side-by-side
pcigale/analysis_modules/pdf_analysis/utils.py
View file @
6a53d6c5
...
...
@@ -165,7 +165,7 @@ def _compute_scaling(model_fluxes, model_propsmass, observation):
def
compute_chi2
(
model_fluxes
,
model_props
,
model_propsmass
,
observation
,
lim_flag
):
corr_dz
,
lim_flag
):
"""Compute the χ² of observed fluxes with respect to the grid of models. We
take into account upper limits if need be. Note that we look over the bands
to avoid the creation of an array of the same size as the model_fluxes
...
...
@@ -183,6 +183,8 @@ def compute_chi2(model_fluxes, model_props, model_propsmass, observation,
observation: Class
Class instance containing the fluxes, intensive properties, extensive
properties and their errors, for a sigle observation.
corr_dz: correction factor to scale the extensive properties to the right
distance
lim_flag: boolean
Boolean indicating whether upper limits should be treated (True) or
discarded (False)
...
...
@@ -222,10 +224,12 @@ def compute_chi2(model_fluxes, model_props, model_propsmass, observation,
if
np
.
isfinite
(
obs_fluxes
[
i
])
and
obs_fluxes_err
[
i
]
>
0.
:
chi2
+=
np
.
square
((
obs_fluxes
[
i
]
-
model_fluxes
[
i
,
:]
*
scaling
)
*
(
1.
/
obs_fluxes_err
[
i
]))
for
i
in
range
(
obs_propsmass
.
size
):
if
np
.
isfinite
(
obs_propsmass
[
i
]):
chi2
+=
np
.
square
((
obs_propsmass
[
i
]
-
model_propsmass
[
i
,
:]
*
scaling
)
*
(
1.
/
obs_propsmass_err
[
i
]))
chi2
+=
np
.
square
((
obs_propsmass
[
i
]
-
corr_dz
*
(
scaling
*
model_propsmass
[
i
,
:]))
*
(
1.
/
obs_propsmass_err
[
i
]))
for
i
in
range
(
obs_props
.
size
):
if
np
.
isfinite
(
obs_props
[
i
]):
...
...
pcigale/analysis_modules/pdf_analysis/workers.py
View file @
6a53d6c5
...
...
@@ -178,10 +178,9 @@ def analysis(idx, obs):
wz
=
slice
(
0
,
None
,
1
)
corr_dz
=
1.
observation
=
gbl_obs
.
observations
[
idx
]
chi2
,
scaling
=
compute_chi2
(
gbl_models
.
fluxes
[:,
wz
],
gbl_models
.
intprops
[:,
wz
],
gbl_models
.
extprops
[:,
wz
],
obs
ervation
,
gbl_models
.
extprops
[:,
wz
],
obs
,
corr_dz
,
gbl_models
.
conf
[
'analysis_params'
][
'lim_flag'
])
if
np
.
any
(
np
.
isfinite
(
chi2
)):
...
...
@@ -260,10 +259,11 @@ def bestfit(oidx, obs):
intprops
=
np
.
array
([
sed
.
info
[
prop
]
for
prop
in
gbl_obs
.
intprops
])
extprops
=
np
.
array
([
sed
.
info
[
prop
]
for
prop
in
gbl_obs
.
extprops
])
corr_dz
=
compute_corr_dz
(
obs
.
redshift
,
obs
.
distance
)
_
,
scaling
=
compute_chi2
(
fluxes
[:,
None
],
intprops
[:,
None
],
extprops
[:,
None
],
obs
,
extprops
[:,
None
],
obs
,
corr_dz
,
gbl_conf
[
'analysis_params'
][
'lim_flag'
])
corr_dz
=
compute_corr_dz
(
obs
.
redshift
,
obs
.
distance
)
gbl_results
.
best
.
properties
[
oidx
,
:]
=
[
sed
.
info
[
k
]
for
k
in
gbl_results
.
best
.
propertiesnames
]
...
...
Write
Preview
Supports
Markdown
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