Skip to content

Commit

Permalink
Merge pull request #76 from MingjieJian/develop
Browse files Browse the repository at this point in the history
docs(driver_guide): renew ordinary driver_guide
  • Loading branch information
MingjieJian authored Jul 14, 2024
2 parents eb9abfd + ca7d5e7 commit 229332b
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 56 deletions.
92 changes: 47 additions & 45 deletions docs/driver_guide/abfind.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,67 @@
Suppose we have a list of lines (stored as as a DataFrame called `linelist`) with their measured EW as follow (appended to the line list as the last column):

```
wavelength id EP loggf C6 D0 EW
0 11032.103 12.0 5.9460 -1.801 0.000 NaN 23.05
1 11033.662 12.0 5.9460 -2.073 0.000 NaN 13.33
2 11034.481 12.0 5.9460 -2.426 0.000 NaN 6.24
3 11005.127 14.0 6.2228 -2.098 -7.200 NaN 5.54
4 11013.703 14.0 6.2061 -0.983 -7.320 NaN 48.24
5 11017.966 14.0 6.2061 0.760 -7.320 NaN 281.02
6 11040.405 14.0 6.2061 -1.449 -7.320 NaN 22.53
7 11019.848 19.0 2.6700 -0.010 3073.329 NaN 11.13
8 11022.653 19.0 2.6703 -0.161 3073.329 NaN 7.98
9 11015.530 24.0 3.4493 -0.429 -7.530 NaN 43.10
10 11044.610 24.0 3.0112 -1.930 -7.780 NaN 5.74
11 11013.235 26.0 4.7955 -1.383 -7.550 NaN 35.22
12 11026.788 26.0 3.9434 -2.805 -7.810 NaN 11.92
13 11045.599 26.0 5.5870 -0.624 -7.500 NaN 35.73
14 11057.772 26.0 4.8349 -1.967 -7.550 NaN 11.55
15 11069.374 26.0 6.2223 -1.055 -7.140 NaN 5.06
16 11081.595 26.0 5.6425 -1.419 -7.470 NaN 7.37
17 11088.584 28.0 4.1647 -1.512 -7.560 NaN 16.36
18 11054.253 30.0 5.7958 -0.300 0.000 NaN 18.43
wavelength id EP loggf C6 D0 EW
85992 8002.576 26.0 4.580 -1.618 -7.79 NaN 22.80
86381 8026.940 14.0 6.261 -1.004 -6.98 NaN 34.24
86400 8027.941 26.0 3.252 -2.785 -7.73 NaN 28.46
86401 8028.313 26.0 4.473 -0.686 -7.54 NaN 76.66
86520 8035.618 14.0 5.984 -1.372 -7.16 NaN 24.95
86696 8046.047 26.0 4.415 -0.100 -7.55 NaN 125.55
86735 8047.617 26.0 0.859 -4.742 -7.85 NaN 50.73
86750 8049.366 14.0 6.269 -1.287 -6.98 NaN 20.15
87069 8071.283 14.0 6.099 -1.192 -7.06 NaN 31.16
87075 8072.164 26.0 2.424 -3.519 -7.82 NaN 32.43
87105 8073.028 14.0 6.274 -1.381 -6.98 NaN 16.29
87158 8075.150 26.0 0.915 -5.088 -7.85 NaN 30.34
87245 8080.545 26.0 3.301 -2.710 -7.73 NaN 29.76
87316 8085.172 26.0 4.446 -0.121 -7.55 NaN 121.43
87399 8089.354 26.0 5.067 -1.141 -7.73 NaN 23.30
87433 8093.232 14.0 5.863 -1.075 -7.19 NaN 47.38
87518 8096.875 26.0 4.076 -1.767 -7.80 NaN 37.74
```

```{note}
The DataFrame has to be sorted in id and wavelength.
```

This line list can be loaded using:

```py
ges_linelist = pymoog.line_data.read_linelist('ges')
ges_linelist = ges_linelist[(ges_linelist['wavelength'] > 8000) & (ges_linelist['wavelength'] < 8100) & (ges_linelist['EW'] > 15)]
ges_linelist = ges_linelist[(ges_linelist['id'] == 26) | (ges_linelist['id'] == 14)]
ges_linelist
```

Then abfind can run as:
```py
a = pymoog.abfind.abfind(5000, 4.0, 0.0, line_list=linelist)
a = pymoog.abfind.abfind(5777, 4.0, 0, line_list=ges_linelist)
a.prepare_file()
a.run_moog()
a.read_output()
```
The output of abfind, `a.abfind_res` will be stored as a dict with it keys as elements and values as DataFrame:
```
{12.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11032.103 12.0 5.946 -1.801 23.05 -5.680 7.376 -0.002
1 11033.662 12.0 5.946 -2.073 13.33 -5.918 7.378 0.000
2 11034.481 12.0 5.946 -2.426 6.24 -6.248 7.379 0.001,
14.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11005.127 14.0 6.223 -2.098 5.54 -6.298 7.606 -0.030
1 11013.703 14.0 6.206 -0.983 48.24 -5.359 7.639 0.003
2 11017.966 14.0 6.206 0.760 281.02 -4.593 7.667 0.031
3 11040.405 14.0 6.206 -1.449 22.53 -5.690 7.632 -0.004,
19.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11019.848 19.0 2.67 -0.010 11.13 -5.996 4.866 -0.002
1 11022.653 19.0 2.67 -0.161 7.98 -6.140 4.871 0.002,
24.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11015.53 24.0 3.449 -0.429 43.10 -5.408 5.044 0.002
1 11044.61 24.0 3.011 -1.930 5.74 -6.284 5.040 -0.002,
26.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11013.235 26.0 4.795 -1.383 35.22 -5.495 7.129 -0.076
1 11026.788 26.0 3.943 -2.805 11.92 -5.966 7.046 -0.159
2 11045.599 26.0 5.587 -0.624 35.73 -5.490 7.242 0.037
3 11057.772 26.0 4.835 -1.967 11.55 -5.981 7.171 -0.033
4 11069.374 26.0 6.222 -1.055 5.06 -6.340 7.359 0.154
5 11081.595 26.0 5.643 -1.419 7.37 -6.177 7.282 0.077,
28.0: wavelength ID EP logGF EWin logRWin abund delavg
0 11088.584 28.0 4.165 -1.512 16.36 -5.831 6.009 0.0}
{14.0: wavelength ID EP logGF EWin logRWin abund delavg
0 8071.283 14.0 6.099 -1.192 31.16 -5.413 7.497 0.016
1 8026.940 14.0 6.261 -1.004 34.24 -5.370 7.509 0.027
2 8035.618 14.0 5.984 -1.372 24.95 -5.508 7.448 -0.033
3 8049.366 14.0 6.269 -1.287 20.15 -5.601 7.504 0.023
4 8093.232 14.0 5.863 -1.075 47.38 -5.233 7.432 -0.049
5 8073.028 14.0 6.274 -1.381 16.29 -5.695 7.497 0.016,
26.0: wavelength ID EP logGF EWin logRWin abund delavg
0 8089.354 26.0 5.067 -1.141 23.30 -5.541 7.387 0.053
1 8085.172 26.0 4.446 -0.121 121.43 -4.823 7.266 -0.068
2 8080.545 26.0 3.301 -2.710 29.76 -5.434 7.376 0.042
3 8075.150 26.0 0.915 -5.088 30.34 -5.425 7.373 0.039
4 8002.576 26.0 4.580 -1.618 22.80 -5.545 7.387 0.053
5 8047.617 26.0 0.859 -4.742 50.73 -5.200 7.293 -0.041
6 8046.047 26.0 4.415 -0.100 125.55 -4.807 7.271 -0.063
7 8028.313 26.0 4.473 -0.686 76.66 -5.020 7.238 -0.096
8 8027.941 26.0 3.252 -2.785 28.46 -5.450 7.380 0.046
9 8072.164 26.0 2.424 -3.519 32.43 -5.396 7.361 0.027
10 8096.875 26.0 4.076 -1.767 37.74 -5.332 7.340 0.006}
```

![](../img/driver_guide/abfind.png)
10 changes: 10 additions & 0 deletions docs/driver_guide/binary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# binary

```py
b = pymoog.binary.binary([[5777, 4, 0], [5777, 2, 0]], 10540, 10600, 50000, line_list='vald_3000_24000')
b.prepare_file(deltaradvel=10.5, lumratio=1)
b.run_moog()
b.read_spectra()
```

Using `plt.plot(b.wav, b.flux)`:
11 changes: 6 additions & 5 deletions docs/driver_guide/blends.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# blends: force-fitting abundances to match blended-line equivalent widths

Blends driver fit the EW of a feature as a whole, only varing the abunance specified.
The following example shows a fitting of Fe abundance of the feature from 10817.7 to 10818.9A, with an observed EW of 80mA.
The following example shows a fitting of Fe abundance of the feature from 8002.076 to 8003.076A, with an observed EW of 38.76mA.

```py
b = pymoog.blends.blends(5000, 4.0, 0, 10817.7, 10818.9, 80, 26, line_list='vald_3000_24000')
b = pymoog.blends.blends(5777, 4.0, 0, 8002.576-0.5, 8002.576+0.5, 38.76, 26)
b.prepare_file()
b.run_moog()
b.read_output()
b.blends_s_df
```

The result is sotred in `b.blends_s_df`:

```py
wavelength ID EP logGF EWin logRWin abund delavg
0 10818.275 26.0 3.96 -1.948 80.0 -5.131 7.325 0.0
wavelength ID EP logGF EWin logRWin abund delavg
0 8002.576 26.0 4.58 -1.618 38.76 -5.315 7.706 0.0
```
15 changes: 12 additions & 3 deletions docs/driver_guide/cog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ The `cog` driver generate the curve-of-growth for individual line.
Let’s look at a Si line with following parameters (and stored in file `use.list`):

```
wavelength id EP loggf C6 D0 EW
0 11040.405 14.0 6.2061 -1.449 -7.32 NaN 22.53
wavelength id EP loggf C6 D0 EW
1001 9122.791 20.0 6.001 -4.956 -6.55 NaN NaN
```

This line can be loaded by:

```py
c = pymoog.cog.cog(5000, 4.0, 0, line_list=MOOG_run_path+'use.list')
vald = pymoog.line_data.read_linelist('vald_winered')
use_list = vald.loc[1001:1001]
```

```py
c = pymoog.cog.cog(5000, 4, 0, line_list=use_list)
c.prepare_file()
c.run_moog()
c.read_output()
```

The result is sotred in `c.loggf` and `c.logrw`.

![](../img/driver_guide/cog.png)
28 changes: 25 additions & 3 deletions docs/driver_guide/weedout.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,35 @@
It is sometimes useful to remove the weak lines which do not affect the spectra so much, keeping the line list short and clean.
The `weedout` driver is for this task.

After `w.read_linelist`, the strong lines are stored in `w.keep_list`, while the weak lines are sotred in `w.toss_list`.

```py
w = pymoog.weedout.weedout(5000, 4.0, 0, 10830-15, 10830+15, kappa_ratio=0.2, line_list='vald_3000_11000',)
w = pymoog.weedout.weedout(5000, 2, 0, 10800, 10830, kappa_ratio=0.2)
w.prepare_file()
w.run_moog()
w.read_linelist(remove=False) # remove=False is used for w.compare(); see below.
```

The difference between the line lists can be seen by:

```py
w.compare(50000)
plt.plot(w.wav_all, w.flux_all, label='before weedout')
plt.plot(w.wav_keep, w.flux_keep, label='after weedout')

plt.figure(figsize=(12, 4), dpi=200)
ln1 = plt.plot(w.wav_all, w.flux_all, label='Before weedout')
ln2 = plt.plot(w.wav_keep, w.flux_keep, label='After weedout')

plt.xlabel('Wavelength ($\mathrm{\AA}$)')
plt.ylabel('Normalized flux (solid)')

plt.twinx()
ln3 = plt.plot(w.wav_keep, w.flux_keep - w.flux_all, ls='--', c='C3', label='Flux difference')
plt.ylim(top=0.1)
plt.ylabel('Flux difference (dashed)')

lns = ln1 + ln2 + ln3
labs = [l.get_label() for l in lns]
plt.legend(lns, labs, loc=4)
```

![](../img/driver_guide/weedout.png)
Expand Down
Binary file added docs/img/driver_guide/binary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/driver_guide/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/driver_guide/weedout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 229332b

Please sign in to comment.