Skip to content

Commit

Permalink
source commit: 73d69a3
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 12, 2023
0 parents commit 471098c
Show file tree
Hide file tree
Showing 179 changed files with 51,448 additions and 0 deletions.
953 changes: 953 additions & 0 deletions 01-query.md

Large diffs are not rendered by default.

825 changes: 825 additions & 0 deletions 02-coords.md

Large diffs are not rendered by default.

774 changes: 774 additions & 0 deletions 03-transform.md

Large diffs are not rendered by default.

669 changes: 669 additions & 0 deletions 04-motion.md

Large diffs are not rendered by default.

588 changes: 588 additions & 0 deletions 05-select.md

Large diffs are not rendered by default.

1,098 changes: 1,098 additions & 0 deletions 06-join.md

Large diffs are not rendered by default.

707 changes: 707 additions & 0 deletions 07-photo.md

Large diffs are not rendered by default.

832 changes: 832 additions & 0 deletions 08-plot.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "Contributor Code of Conduct"
---

As contributors and maintainers of this project,
we pledge to follow the [The Carpentries Code of Conduct][coc].

Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by following our [reporting guidelines][coc-reporting].


[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
79 changes: 79 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: "Licenses"
---

## Instructional Material

All Carpentries (Software Carpentry, Data Carpentry, and Library Carpentry)
instructional material is made available under the [Creative Commons
Attribution license][cc-by-human]. The following is a human-readable summary of
(and not a substitute for) the [full legal text of the CC BY 4.0
license][cc-by-legal].

You are free:

- to **Share**---copy and redistribute the material in any medium or format
- to **Adapt**---remix, transform, and build upon the material

for any purpose, even commercially.

The licensor cannot revoke these freedoms as long as you follow the license
terms.

Under the following terms:

- **Attribution**---You must give appropriate credit (mentioning that your work
is derived from work that is Copyright (c) The Carpentries and, where
practical, linking to <https://carpentries.org/>), provide a [link to the
license][cc-by-human], and indicate if changes were made. You may do so in
any reasonable manner, but not in any way that suggests the licensor endorses
you or your use.

- **No additional restrictions**---You may not apply legal terms or
technological measures that legally restrict others from doing anything the
license permits. With the understanding that:

Notices:

* You do not have to comply with the license for elements of the material in
the public domain or where your use is permitted by an applicable exception
or limitation.
* No warranties are given. The license may not give you all of the permissions
necessary for your intended use. For example, other rights such as publicity,
privacy, or moral rights may limit how you use the material.

## Software

Except where otherwise noted, the example programs and other software provided
by The Carpentries are made available under the [OSI][osi]-approved [MIT
license][mit-license].

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Trademark

"The Carpentries", "Software Carpentry", "Data Carpentry", and "Library
Carpentry" and their respective logos are registered trademarks of [Community
Initiatives][ci].

[cc-by-human]: https://creativecommons.org/licenses/by/4.0/
[cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode
[mit-license]: https://opensource.org/licenses/mit-license.html
[ci]: https://communityin.org/
[osi]: https://opensource.org
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# copy notebooks from jb

cp ~/AstronomicalData/01_query.ipynb 01-query.ipynb
cp ~/AstronomicalData/02_coords.ipynb 02-coords.ipynb

# convert tags to comments
python convert.py

# convert ipynb to md
jupyter nbconvert --to markdown 01-query.ipynb
jupyter nbconvert --to markdown 02-coords.ipynb


# push it to GutHub
#git add 01-query.md
#git add 02-coords.md
#git commit -m "Automated push from AstronomicalData"
#git push
217 changes: 217 additions & 0 deletions calculating_MIST_isochrone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
---
title: Making the Isochrone DataFrame
---

::::::::::::::::::::::::::::::::::::::::: callout

## Calculating Isochrone

In fact, we can use [MESA Isochrones \& Stellar Tracks](https://waps.cfa.harvard.edu/MIST/) (MIST)
to compute it for us.
Using the [MIST Version 1.2 web interface](https://waps.cfa.harvard.edu/MIST/interp_isos.html),
we computed an isochrone with the following parameters:

- Rotation initial v/v\_crit = 0.4
- Single age, linear scale = 12e9
- Composition [Fe/H] = -1.35
- Synthetic Photometry, PanStarrs
- Extinction av = 0


::::::::::::::::::::::::::::::::::::::::::::::::::

The following cell downloads the results:

```python
download('https://github.com/AllenDowney/AstronomicalData/raw/main/' +
'data/MIST_iso_5fd2532653c27.iso.cmd')
```

To read this file we will download a Python module [from this
repository](https://github.com/jieunchoi/MIST_codes).

```python
download('https://github.com/jieunchoi/MIST_codes/raw/master/scripts/' +
'read_mist_models.py')
```

Now we can read the file:

```python
import read_mist_models

filename = 'MIST_iso_5fd2532653c27.iso.cmd'
iso = read_mist_models.ISOCMD(filename)
```

```output
Reading in: MIST_iso_5fd2532653c27.iso.cmd
```

The result is an `ISOCMD` object.

```python
type(iso)
```

```output
read_mist_models.ISOCMD
```

It contains a list of arrays, one for each isochrone.

```python
type(iso.isocmds)
```

```output
list
```

We only got one isochrone.

```python
len(iso.isocmds)
```

```output
1
```

So we can select it like this:

```python
iso_array = iso.isocmds[0]
```

It is a NumPy array:

```python
type(iso_array)
```

```output
numpy.ndarray
```

But it is an unusual NumPy array, because it contains names for the columns.

```python
iso_array.dtype
```

```output
dtype([('EEP', '<i4'), ('isochrone_age_yr', '<f8'), ('initial_mass', '<f8'), ('star_mass', '<f8'), ('log_Teff', '<f8'), ('log_g', '<f8'), ('log_L', '<f8'), ('[Fe/H]_init', '<f8'), ('[Fe/H]', '<f8'), ('PS_g', '<f8'), ('PS_r', '<f8'), ('PS_i', '<f8'), ('PS_z', '<f8'), ('PS_y', '<f8'), ('PS_w', '<f8'), ('PS_open', '<f8'), ('phase', '<f8')])
```

Which means we can select columns using the bracket operator:

```python
iso_array['phase']
```

```output
array([0., 0., 0., ..., 6., 6., 6.])
```

We can use `phase` to select the part of the isochrone for stars in
the main sequence and red giant phases.

```python
phase_mask = (iso_array['phase'] >= 0) & (iso_array['phase'] < 3)
phase_mask.sum()
```

```output
354
```

```python
main_sequence = iso_array[phase_mask]
len(main_sequence)
```

```output
354
```

The other two columns we will use are `PS_g` and `PS_i`, which contain
simulated photometry data for stars with the given age and
metallicity, based on a model of the Pan-STARRS sensors.

We will use these columns to superimpose the isochrone on the
color-magnitude diagram, but first we have to use a [distance
modulus](https://en.wikipedia.org/wiki/Distance_modulus) to scale the
isochrone based on the estimated distance of GD-1.

We can use the `Distance` object from Astropy to compute the distance modulus.

```python
import astropy.coordinates as coord
import astropy.units as u

distance = 7.8 * u.kpc
distmod = coord.Distance(distance).distmod.value
distmod
```

```output
14.4604730134524
```

Now we can compute the scaled magnitude and color of the isochrone.

```python
mag_g = main_sequence['PS_g'] + distmod
color_g_i = main_sequence['PS_g'] - main_sequence['PS_i']
```

Now we can plot it on the color-magnitude diagram like this.

```python
plot_cmd(candidate_df)
plt.plot(color_g_i, mag_g);
```

```output
<Figure size 432x288 with 1 Axes>
```

![](fig/07-photo_files/07-photo_42_0.png){alt='Color magnitude diagram of our selected stars with theoretical isochrone overlaid as blue curve.'}

The theoretical isochrone passes through the overdense region where we
expect to find stars in GD-1.

We will save this result so we can reload it later without repeating the
steps in this section.

So we can save the data in an HDF5 file, we will put it in a Pandas
`DataFrame` first:

```python
import pandas as pd

iso_df = pd.DataFrame()
iso_df['mag_g'] = mag_g
iso_df['color_g_i'] = color_g_i

iso_df.head()
```

```output
mag_g color_g_i
0 28.294743 2.195021
1 28.189718 2.166076
2 28.051761 2.129312
3 27.916194 2.093721
4 27.780024 2.058585
```

And then save it.

```python
filename = 'gd1_isochrone.hdf5'
iso_df.to_hdf(filename, 'iso_df')
```


Loading

0 comments on commit 471098c

Please sign in to comment.