Create elliptical model image

This script takes the output from the CIAO
dmellipse tool
and uses it to create a model image.
dmellipseWe start by running dmellipse to create an ellipse profile of
the image. dmellipse takes the input image img2.fits and a
stack of
integrated fractions.
In this example I’ve filtered the input image with a region so that
the edge of the image is stored in the file’s data-subspace.
dmimghull img.fits hull.fits clob+dmcopy "img.fits[sky=region(hull.fits)][opt full]" img2.fits clob+dmellipse img2.fits ellipses.fits fraction="lgrid(0.05:1.0:0.025)" step=20 mode=h clob+
This example generates the ellipse profile which enclose from 5% to 100%
of the total flux in the image, in steps of 2.5%. The step parameter is
increased to match the scale of the image which allows the tool to run
faster.
ds9 img2.fits -region ellipses.fits -scale log \-scale limits 0 175 \-cmap load ~/ds9_hacks/LUT/Neota/neota_sunset-in-atlantis.lut \-view colorbar no -saveimage png ellipses.png -quit

emodelNow we will reconstruct a model of the image based on the
ellipse profile
emodel ellipses.fits img2.fits model.fits weight=flat clob+ norm=486119
emodel takes the information about the ellipses and the fraction
of the total flux in each ellipse to reconstruct a 2D model. The weight
parameter controls how the flux is distributed within the ellipse. The
default flat equally distributes the flux into each pixel in the ellipse.
ds9 model.fits -scale log -scale limits 0 175 \-cmap load ~/ds9_hacks/LUT/Neota/neota_sunset-in-atlantis.lut \-view colorbar no -saveimage png model.png -quit

Experimental
The weight option is still experimental. The flat and linear
are well behaved but the other options may produces some artifacts,
especially at the boundary between ellipses.
emodel ellipses.fits img2.fits model_flat.fits weight=flat clob+ norm=486119emodel ellipses.fits img2.fits model_linear.fits weight=linear clob+ norm=486119emodel ellipses.fits img2.fits model_gaussian.fits weight=gaussian clob+ norm=486119emodel ellipses.fits img2.fits model_square.fits weight=square clob+ norm=486119emodel ellipses.fits img2.fits model_sqrt.fits weight=sqrt clob+ norm=486119emodel ellipses.fits img2.fits model_hemi.fits weight=hemi clob+ norm=486119
The effect of the weighting is most obvious in the center of the
image
ds9 model_flat.fits -scale log -scale limits 0 175 -zoom 4 -tile -view colorbar no\-cmap load ~/ds9_hacks/LUT/Neota/neota_sunset-in-atlantis.lut \model_linear.fits model_gaussian.fits model_square.fits model_sqrt.fits model_hemi.fits \-pan to 4270 3960 physical -match frames physical \-saveimage png weights.png -quit

This script requires ciao-4.10
or later. It will not work with earlier versions of CIAO.
Users must have sourced the CIAO setup script before installing this
script.
$ source /soft/ciao/bin/ciao.bashCIAO configuration is complete...CIAO 4.10 Thursday, April 12, 2018bindir : /soft/ciao-4.10/binCALDB : 4.7.8
replace /soft/ciao with your location where you installed CIAO, then
$ git clone https://github.com/kglotfelty/ellipse_modelCloning into 'ellipse_model'...remote: Counting objects: 110, done.remote: Compressing objects: 100% (76/76), done.remote: Total 110 (delta 53), reused 86 (delta 29), pack-reused 0Receiving objects: 100% (110/110), 960.65 KiB | 0 bytes/s, done.Resolving deltas: 100% (53/53), done.Checking connectivity... done.$ cd ellipse_model/$ python setup.py install