# Galaxy surface brightness analysis¶

1. Identify a source in a SourceList which we want to analyse. Actually you will probably be thinking of an image rather than a SourceList. So lets start with that. Retrieve the image with the following filename:

Sci-EHELMICH-WFI-------#842---Coadd---Sci-54552.5317447-4d2189f46deed79e536
cdbfb0af72ae24187ffd8.fits


Presumably you don’t want to type in the full name, so use a wildcard:

awe> c = CoaddedRegriddedFrame.filename.like('*ffd8.fits')[0]


Lets have a look at this image, and select a galaxy from it.

awe> c.retrieve()
awe> c.display()


A SourceList exists for this image:

awe> sl = (SourceList.SLID == 423431)[0]


Make a skycat catalog for the image and find the SID of an interesting source.

awe> sl.make_skycat_on_sources()


Now overplot the catalog in skycat. Open the file and select Data-Servers -:math:> Local Catalogs -:math:> Load from file…. As filter fill in .scat. You may need to increase the number of sources to get all of them to display. If you click on a symbol the corresponding entry in the catalog is highlighted. Here you can determine the SID of the source.

Take the source with SID 16246 in the SourceList with SLID 423431.

## GalPhot: Isophotal analysis: GalPhot¶

It is instructive to first read HOW-TO Use Galphot in Astro-WISE in particular to get an idea of the names of classes and methods defined for Galphot.

Isophotes can be fit to sources using the Galphot package. The main classes used to store the information of the fit are GalPhotModel and GalPhotEllipse. Lets follow an example here.

awe> task = GalPhotTask(slid=423431, sids=[16246], commit=1)

# or
awe> dpu.run('GalPhot', slid=423431, sids=[16246], C=1)

2. Inspect the model. We must start by finding the model we made in the previous step in the database. This can be done by selecting the most recent GalPhotModel created by yourself.

awe> m = (GalPhotModel.SLID == 423431).user_only().max('GPID')


The methods get_model(), get_residual(), get_science() can be used on a GalPhotModel to visually inspect its quality.

awe> s = m.get_science()
awe> s.display()
awe> r = m.get_residual()
awe> r.display()


The fitted ellipses are stored in the model, and they can also be obtained:

awe> m.ellipses[0].r


For a description of the ellipse parameters see the help page of one of the ellipses:

awe> help(m.ellipses[0])


You can obtain/visualize the ellipse parameters:

awe> ellipses = m.get_model_parameters()
awe> rad = [e['r'] for e in ellipses]
awe> pos = [e['pos'] for e in ellipses]


## GalFit: 2D Parametric fits to a galaxy surface brightness distribution¶

The main classes used to store Galfit models are GalFitModel and a number of classes named e.g. GalFitSeric, each of which is a function that can be fit to the data. See the first section of HOW-TO Use Galfit in Astro-WISE. for an overview of the important classes defined for using Galfit in Astro-WISE.

1. Here too, we first need to identify a source on which we want to run Galfit. We can take the same source as in the previous example, the source from the SourceList with SLID 423431 and SID 16246.

2. Create a Sersic model for the galaxy where the index of the Sersic model is fixed at 3. The model components are specified as a list of dictionaries. Each dictionary describes one component. (Physical) component parameters come in 3 variants e.g.: ix, x, dx, respectively the initial, final and error values. Additionally the parameter is set to be fixed or free with the free_x parameter.

awe> task = GalFitTask(slid=423431, sids=[16246],
models=[{'name': 'sersic', 'iN': 3, 'free_N': 0}],
commit=1)

# or
awe> dpu.run('GalFit', slid=423431, sids=[16246],
m=[{'name': 'sersic', 'iN': 3, 'free_N': 0}], C=1)

3. Again we need to find the result in the database:

awe> m = (GalFitModel.SLID == 423431).user_only().max('GFID')

4. Now we can inspect the model: retrieve the residual image of the science and the model.

awe> sci = m.get_science()
awe> res = m.get_residual()
awe> mod = m.get_model()
awe> sci.display()
etc.

5. Have a look at the parameters of the model:

awe> m.show_model_parameters()

# or
awe> m.info()

awe> m.components[0].info()