-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial_5_summary.py
More file actions
176 lines (131 loc) · 6.89 KB
/
Copy pathtutorial_5_summary.py
File metadata and controls
176 lines (131 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
"""
Tutorial 9: Summary
===================
In this chapter, we have learnt that:
1) **PyAutoGalaxy** uses Cartesian `Grid2D`'s of $(y,x)$ coordinates to evaluate galaxy luminous emission.
2) These grids are combined with light profiles to compute images and other quantities.
3) Profiles are grouped together to make galaxies.
4) Collections of galaxies (at the same redshift) can be made..
5) The Universe's cosmology can be input into this `Galaxies` to convert its units to kiloparsecs.
6) The galaxies's image can be used to simulate galaxy `Imaging` like it was observed with a real telescope.
7) This data can be fitted, so to as quantify how well a model galaxy system represents the observed image.
In this summary, we'll go over all the different Python objects introduced throughout this chapter and consider how
they come together as one.
__Contents__
- **Initial Setup:** Create profiles, galaxies and a Galaxies object for illustration.
- **Object Composition:** How Galaxies, Galaxy and Profile objects compose together.
- **Visualization:** Customize and visualize any aspect of galaxies using the plotting API.
- **Code Design:** Discussion of PyAutoGalaxy's object-oriented design philosophy.
- **Source Code:** Links to the source code repositories for PyAutoFit, PyAutoArray and PyAutoGalaxy.
- **Wrap Up:** Summary of chapter 1 and preview of the modeling chapter.
"""
# from autogalaxy import setup_notebook; setup_notebook()
from pathlib import Path
import autogalaxy as ag
import autogalaxy.plot as aplt
"""
__Initial Setup__
Below, we do all the steps we have learned this chapter, making profiles, galaxies, etc.
Note that we use two galaxies, the first of which has a bulge and disk.
"""
grid = ag.Grid2D.uniform(shape_native=(100, 100), pixel_scales=0.05)
galaxy_0 = ag.Galaxy(
redshift=0.5,
bulge=ag.lp.Sersic(
centre=(0.0, 0.0),
ell_comps=(0.0, 0.111111),
intensity=1.0,
effective_radius=1.0,
sersic_index=2.5,
),
disk=ag.lp.Exponential(
centre=(0.0, 0.0),
ell_comps=(0.0, 0.111111),
intensity=1.0,
effective_radius=1.0,
),
)
galaxy_1 = ag.Galaxy(
redshift=0.5,
bulge=ag.lp.Sersic(
centre=(1.0, 1.0),
ell_comps=(0.0, 0.111111),
intensity=1.0,
effective_radius=1.0,
sersic_index=2.5,
),
)
galaxies = ag.Galaxies(galaxies=[galaxy_0, galaxy_1])
"""
__Object Composition__
Lets now consider how all of the objects we've covered throughout this chapter (`LightProfile`'s, `MassProfile`'s,
`Galaxy`'s, `Galaxies`'s) come together.
The `Galaxies` contain the `Galaxy`'s which contains the `Profile`'s:
"""
print(galaxies[0])
print()
print(galaxies[0].bulge)
print()
print(galaxies[0].disk)
print()
print(galaxies[1].bulge)
print()
"""
Once we have defined the galaxies, we can plot any quantity introduced throughout this chapter for a specific component,
a single galaxy, or multiple galaxies as needed.
For example, if we want to plot the image of the first galaxy's bulge and disk, we can do this in a variety of
different ways.
"""
aplt.plot_array(array=galaxies.image_2d_from(grid=grid), title="Image")
aplt.plot_array(array=galaxies[0].image_2d_from(grid=grid), title="Image")
"""
Understanding how these objects decompose into the different components of a galaxy is important for general
**PyAutoGalaxy** use.
As the galaxy systems that we analyse become more complex, it is useful to know how to decompose their light
profiles, galaxies and galaxies to extract different pieces of information about the galaxy.
For example, we made our galaxy above with two light profiles, a `bulge` and `disk`. We can plot the image of
each component individually, now that we know how to break-up the different components of the galaxies.
"""
aplt.plot_array(array=galaxies[0].bulge.image_2d_from(grid=grid), title="Bulge Image")
aplt.plot_array(array=galaxies[0].disk.image_2d_from(grid=grid), title="Disk Image")
"""
__Visualization__
Furthermore, using the `MatPLot2D` and `Visuals2D` objects we can visualize any aspect we're interested
in and fully customize the figure.
Before beginning chapter 2 of **HowToGalaxy**, you should checkout the package `autogalaxy_workspace/plot`.
This provides a full API reference of every plotting option in **PyAutoGalaxy**, allowing you to create your own
fully customized figures of galaxies with minimal effort!
"""
aplt.plot_array(array=galaxies[0].bulge.image_2d_from(grid=grid), title="Bulge Image")
"""
And, we're done, not just with the tutorial, but the chapter!
__Code Design__
To end, I want to quickly talk about the **PyAutoGalaxy** code-design and structure, which was really the main topic of
this tutoriag.
Throughout this chapter, we never talk about anything like it was code. We didn`t refer to 'variables', 'parameters`'
'functions' or 'dictionaries', did we? Instead, we talked about 'galaxies'. We discussed
the objects that we, as scientists, think about when we consider a galaxy system.
Software that abstracts the underlying code in this way follows an `object-oriented design`, and it is our hope
with **PyAutoGalaxy** that we've made its interface (often called the API for short) very intuitive, whether you were
previous familiar with galaxy morphology or a complete newcomer!
__Source Code__
If you do enjoy code, variables, functions, and parameters, you may want to dig deeper into the **PyAutoGalaxy** source
code at some point in the future. Firstly, you should note that all of the code we discuss throughout the **HowToGalaxy**
lectures is not contained in just one project (e.g. the **PyAutoGalaxy** GitHub repository) but in fact three repositories:
**PyAutoFit** - Everything required for modeling (the topic of chapter 2): https://github.com/PyAutoLabs/PyAutoFit
**PyAutoArray** - Handles all data structures and Astronomy dataset objects: https://github.com/PyAutoLabs/PyAutoArray
**PyAutoGalaxy** - Contains the light profiles and galaxies: https://github.com/PyAutoLabs/PyAutoGalaxy
Instructions on how to build these projects from source are provided here:
https://pyautogalaxy.readthedocs.io/en/latest/installation/source.html
We take a lot of pride in our source code, so I can promise you its well written, well documented and thoroughly
tested (check out the `test` directory if you're curious how to test code well!).
__Wrap Up__
You`ve learn a lot in this chapter, but what you have not learnt is how to 'model' a real galaxy.
In the real world, we have no idea what the 'correct' combination of light profiles are that will give a good fit to
a galaxy. Modeling is the process of finding the model which provides a good fit and it is the topic of chapter 2
of **HowToGalaxy**.
Finally, if you enjoyed doing the **HowToGalaxy** tutorials please git us a star on the **PyAutoGalaxy** GitHub
repository:
https://github.com/PyAutoLabs/PyAutoGalaxy
Even the smallest bit of exposure via a GitHub star can help our project grow!
"""