python - Extracting parameters from astropy.modeling Gaussian2D -
i have managed use astropy.modeling
model 2d gaussian on image , parameters has produced fit image seem reasonable. however, need run 2d gaussian on thousands of images because interested in examining mean x , y of model , x , y standard deviations on our images. model output looks this:
m2 <gaussian2d(amplitude=0.0009846091239480168, x_mean=30.826676737477573, y_mean=31.004045976953222, x_stddev=2.5046722491074536, y_stddev=3.163048479350727, theta=-0.0070295894129793896)>
i can tell this:
type(m2) <class 'astropy.modeling.functional_models.gaussian2d'> name: gaussian2d inputs: (u'x', u'y') outputs: (u'z',) fittable parameters: ('amplitude', 'x_mean', 'y_mean', 'x_stddev', 'y_stddev', 'theta')
what need method extract parameters of model, namely:
x_mean y_mean x_stddev y_stddev
i not familiar form output stuck on how extract parameters.
the models have attributes can access:
from astropy.modeling import models g2d = models.gaussian2d(1,2,3,4,5) g2d.amplitude.value # 1.0 g2d.x_mean.value # 2.0 g2d.y_mean.value # 3.0 g2d.x_stddev.value # 4.0 g2d.y_stddev.value # 5.0
you need extract these values after fitted model can access them in same way: .<name>.value
.
you can extract them in 1 go need keep track parameter in position:
g2d.parameters # array([ 1., 2., 3., 4., 5., 0.]) # amplitude g2d.parameters[0] # 1.0 # x-mean g2d.parameters[1] # 2.0 # ...
Comments
Post a Comment