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
44625d3d
Commit
44625d3d
authored
Mar 30, 2018
by
Médéric Boquien
Browse files
Use more a more compact variable name and get rid of aliases.
parent
768ffa71
Changes
1
Hide whitespace changes
Inline
Side-by-side
pcigale/analysis_modules/pdf_analysis/utils.py
View file @
44625d3d
...
@@ -120,7 +120,7 @@ def dchi2_over_ds2(s, obs_values, obs_errors, mod_values):
...
@@ -120,7 +120,7 @@ def dchi2_over_ds2(s, obs_values, obs_errors, mod_values):
return
func
return
func
def
_compute_scaling
(
model_fluxes
,
model_propsmass
,
obs
ervation
):
def
_compute_scaling
(
model_fluxes
,
model_propsmass
,
obs
):
"""Compute the scaling factor to be applied to the model fluxes to best fit
"""Compute the scaling factor to be applied to the model fluxes to best fit
the observations. Note that we look over the bands to avoid the creation of
the observations. Note that we look over the bands to avoid the creation of
an array of the same size as the model_fluxes array. Because we loop on the
an array of the same size as the model_fluxes array. Because we loop on the
...
@@ -132,34 +132,29 @@ def _compute_scaling(model_fluxes, model_propsmass, observation):
...
@@ -132,34 +132,29 @@ def _compute_scaling(model_fluxes, model_propsmass, observation):
Fluxes of the models
Fluxes of the models
model_propsmass: array
model_propsmass: array
Extensive properties of the models to be fitted
Extensive properties of the models to be fitted
observation
: C
lass
obs
: Obs
ervation
c
lass
instance
C
lass instance c
ontain
ing
the fluxes, intensive properties, extensive
Contain
s
the fluxes, intensive properties, extensive
properties and
properties and
their errors, for a sigle observation.
their errors, for a sigle observation.
Returns
Returns
-------
-------
scaling: array
scaling: array
Scaling factors minimising the χ²
Scaling factors minimising the χ²
"""
"""
obs_fluxes
=
observation
.
fluxes
obs_fluxes_err
=
observation
.
fluxes_err
obs_propsmass
=
observation
.
extprops
obs_propsmass_err
=
observation
.
extprops_err
num
=
np
.
zeros
(
model_fluxes
.
shape
[
1
])
num
=
np
.
zeros
(
model_fluxes
.
shape
[
1
])
denom
=
np
.
zeros
(
model_fluxes
.
shape
[
1
])
denom
=
np
.
zeros
(
model_fluxes
.
shape
[
1
])
for
i
in
range
(
obs
_
fluxes
.
size
):
for
i
in
range
(
obs
.
fluxes
.
size
):
if
np
.
isfinite
(
obs
_
fluxes
[
i
])
and
obs
_
fluxes_err
[
i
]
>
0.
:
if
np
.
isfinite
(
obs
.
fluxes
[
i
])
and
obs
.
fluxes_err
[
i
]
>
0.
:
num
+=
model_fluxes
[
i
,
:]
*
(
obs
_
fluxes
[
i
]
/
(
obs
_
fluxes_err
[
i
]
*
num
+=
model_fluxes
[
i
,
:]
*
(
obs
.
fluxes
[
i
]
/
(
obs
.
fluxes_err
[
i
]
*
obs
_
fluxes_err
[
i
]))
obs
.
fluxes_err
[
i
]))
denom
+=
np
.
square
(
model_fluxes
[
i
,
:]
*
(
1.
/
obs
_
fluxes_err
[
i
]))
denom
+=
np
.
square
(
model_fluxes
[
i
,
:]
*
(
1.
/
obs
.
fluxes_err
[
i
]))
for
i
in
range
(
obs
_propsmas
s
.
size
):
for
i
in
range
(
obs
.
extprop
s
.
size
):
if
np
.
isfinite
(
obs
_propsmas
s
[
i
])
and
obs
_propsmas
s_err
[
i
]
>
0.
:
if
np
.
isfinite
(
obs
.
extprop
s
[
i
])
and
obs
.
extprop
s_err
[
i
]
>
0.
:
num
+=
model_propsmass
[
i
,
:]
*
(
obs
_propsmas
s
[
i
]
/
num
+=
model_propsmass
[
i
,
:]
*
(
obs
.
extprop
s
[
i
]
/
(
obs
_propsmas
s_err
[
i
]
*
(
obs
.
extprop
s_err
[
i
]
*
obs
_propsmas
s_err
[
i
]))
obs
.
extprop
s_err
[
i
]))
denom
+=
np
.
square
(
model_propsmass
[
i
,
:]
*
denom
+=
np
.
square
(
model_propsmass
[
i
,
:]
*
(
1.
/
obs
_propsmas
s_err
[
i
]))
(
1.
/
obs
.
extprop
s_err
[
i
]))
return
num
/
denom
return
num
/
denom
...
...
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