-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20-00-ngc346-bowshock-cloudy.py
761 lines (642 loc) · 20.7 KB
/
20-00-ngc346-bowshock-cloudy.py
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light,md
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.15.2
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---
# # Cloudy models of NGC 346 bow shock around Walborn 3
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
import cmasher as cmr
import astropy.units as u
from pathlib import Path
import sys
from cloudytab import cloudytab
# +
# cloudytab?
# -
sns.set_context("talk")
sns.set_color_codes()
ROOT = Path.cwd().parent.parent
m1 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n010")
m2 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n010-p")
m3 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n030-p")
m1.data.keys()
# ## Optical lines
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12))
# colnames = m.data["emis"].colnames[1:]
embands = [
'He 2 4685.70A',
'Ar 4 4740.12A',
'Ne 3 3868.76A',
'O 3 5006.84A',
'Blnd 5875.66A',
'Ar 3 7135.79A',
'H 1 4861.33A',
'Ca B 6562.82A',
'O 2 7319.99A',
]
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.neon',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m1, m2, m3], axes):
radius = m.data["rad"]["radius"] * u.cm.to(u.pc)
hb = m.data["emis"]['H 1 4861.33A']
for emband, color in zip(embands, colors):
em = m.data["emis"][emband]
ax.plot(radius, em / hb.max(), label=emband, color=color)
ax.set(
yscale="log",
ylim=[0.001, 10.1],
xlabel="Radius, pc",
ylabel="Emissivity",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant density, n = 10")
axes[1].set_title("Constant pressure, n = 10")
axes[2].set_title("Constant pressure, n = 30")
sns.despine()
fig.tight_layout();
# -
# ## Infrared lines and bands
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12))
# colnames = m.data["emis"].colnames[1:]
embands = [
"Ne 3 15.5509m",
"Ne 2 12.8101m",
"S 4 10.5076m",
"S 3 18.7078m",
"S 3 33.4704m",
"Si 2 34.8046m",
]
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.neon',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m1, m2, m3], axes):
radius = m.data["rad"]["radius"] * u.cm.to(u.pc)
hb = m.data["emis"]['H 1 4861.33A']
for emband, color in zip(embands, colors):
em = m.data["emis"][emband]
ax.plot(radius, em / hb.max(), label=emband, color=color)
ax.set(
yscale="log",
ylim=[0.001, 10.1],
xlabel="Radius, pc",
ylabel="Emissivity",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant density, n = 10")
axes[1].set_title("Constant pressure, n = 10")
axes[2].set_title("Constant pressure, n = 30")
sns.despine()
fig.tight_layout();
# -
# ## Physical variables
# Class to make dataframe of all cloudy files
class C:
"""Dictionary of pandas dataframes"""
def __init__(self, d):
for k, v in d.items():
setattr(self, k, v.to_pandas())
m1.p = C(m1.data)
m2.p = C(m2.data)
m3.p = C(m3.data)
fig, axes = plt.subplots(3, 1, figsize=(15, 12))
for m, ax in zip([m1, m2, m3], axes):
m.radius = m.p.rad.radius * u.cm.to(u.pc)
ax.plot(m.radius, m.p.ovr.eden, label="eden")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HII, label="H II")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HeII, label="He II")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HeIII, label="He III")
ax.plot(m.radius, m.p.ovr.hden * m.p.Ar["Ar+3"], label="Ar IV")
ax.plot(m.radius, m.p.ovr.hden * m.p.Ne["Ne+2"], label="Ne III")
ax.plot(m.radius, m.p.ovr.hden * m.p.O["O+2"], label="O III")
ax.plot(m.radius, m.p.ovr.hden * m.p.S["S+2"], label="S III")
ax.plot(m.radius, m.p.ovr.hden * m.p.S["S+3"], label="S IV")
ax.plot(m.radius, 0.001 * m.p.ovr.Te, label="Te, kK")
axes[0].legend(ncol=3)
axes[0].set_title("Constant density, n = 10")
axes[1].set_title("Constant pressure, n = 10")
axes[2].set_title("Constant pressure, n = 30")
axes[-1].set(
xlabel="Radius, pc",
)
sns.despine()
fig.tight_layout();
m.p.Ar
m.p.cont
import astropy.constants as const
wavnorm = (const.h * const.c / u.rydberg).to(u.micron)
freqnorm = (u.rydberg / const.h).to(u.Hz)
sednorm = (u.erg / u.s) / const.L_sun.cgs
#m.p.cont["Cont nu"] * wavnorm
wavs = wavnorm / m1.data["cont"]["Cont nu"]
freqs = freqnorm * m1.data["cont"]["Cont nu"]
sednorm
# +
fig, ax = plt.subplots(figsize=(15, 10))
ax.plot(wavs, sednorm * m3.data["cont"]["incident"])
ax.plot(wavs, sednorm * m3.data["cont"]["DiffOut"])
ax.plot(wavs, sednorm * m3.data["cont"]["trans"])
ax.axvline(24.0, lw=5, color="k", alpha=0.3)
for ip in 1.0, 1.8, 4.0:
ax.axvspan(0, 0.0912/ip, lw=0, color="r", alpha=0.1)
ax.set(
xscale="log",
yscale="log",
xlim=[1e-2, 1e3],
ylim=[300, 1e6],
xlabel="Wavelength, micron",
ylabel=r"$\nu L_\nu$, L$_\odot$",
)
sns.despine()
fig.tight_layout();
# -
m4 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n010-p-r08")
m5 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n005-p-r08")
m6 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n100-p-r08")
m7 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n050-p-r08")
m8 = cloudytab.CloudyModel(ROOT / "cloudy/models/w3-n010-d01-r08")
m4.data.keys()
# +
fig, ax = plt.subplots(figsize=(15, 10))
ax.plot(wavs, sednorm * m4.data["cont"]["incident"])
ax.plot(wavs, sednorm * m4.data["cont"]["DiffOut"], label="n010-p-r08")
ax.plot(wavs, sednorm * m1.data["cont"]["DiffOut"], label="n010")
ax.plot(wavs, sednorm * m8.data["cont"]["DiffOut"], label="n010-d01-r08")
ax.plot(wavs, sednorm * m7.data["cont"]["DiffOut"], label="n050-p-r08")
ax.axvline(24.0, lw=5, color="k", alpha=0.3)
ax.axvspan(0, 0.0912/4, lw=0, color="r", alpha=0.3)
ax.set(
xscale="log",
yscale="log",
xlim=[1e-2, 1e3],
ylim=[1.0, 1.0e7],
xlabel="Wavelength, micron",
ylabel=r"$\nu L_\nu$, L$_\odot$",
)
ax.legend()
sns.despine()
fig.tight_layout();
# -
for m in m4, m5, m6, m7, m8:
m.p = C(m.data)
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
for m, ax in zip([m4, m7, m8], axes):
m.radius = m.p.rad.radius * u.cm.to(u.pc)
ax.plot(m.radius, m.p.ovr.eden, label="eden")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HII, label="H II")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HeII, label="He II")
ax.plot(m.radius, m.p.ovr.hden * m.p.ovr.HeIII, label="He III")
ax.plot(m.radius, m.p.ovr.hden * m.p.Ar["Ar+3"], label="Ar IV")
ax.plot(m.radius, m.p.ovr.hden * m.p.S["S+3"], label="S IV")
ax.plot(m.radius, m.p.ovr.hden * m.p.Ne["Ne+2"], label="Ne III")
ax.plot(m.radius, m.p.ovr.hden * m.p.O["O+2"], label="O III")
ax.plot(m.radius, 0.001 * m.p.ovr.Te, label="Te, kK")
axes[-1].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
axes[-1].set(
xlabel="Radius, pc",
)
sns.despine()
fig.tight_layout();
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnames = m.data["emis"].colnames[1:]
embands = [
'He 2 4685.70A',
'Ar 4 4740.12A',
'Ne 3 3868.76A',
'O 3 5006.84A',
'Blnd 5875.66A',
'Ar 3 7135.79A',
'H 1 4861.33A',
'H 1 6562.82A',
'O 2 7319.99A',
]
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.data["rad"]["radius"] * u.cm.to(u.pc)
hb = m.data["emis"]['H 1 4861.33A']
for emband, color in zip(embands, colors):
em = m.data["emis"][emband]
ax.plot(radius, em / hb.max(), label=emband, color=color)
ax.set(
yscale="log",
ylim=[0.001, 10.1],
xlabel="Radius, pc",
ylabel="Emissivity",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnames = m.data["emis"].colnames[1:]
embands = [
'He 2 4685.70A',
'Ar 4 4740.12A',
'Ne 3 3868.76A',
'O 3 5006.84A',
'Blnd 5875.66A',
'Ar 3 7135.79A',
# 'H 1 4861.33A',
'H 1 6562.82A',
'O 2 7319.99A',
]
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.data["rad"]["radius"] * u.cm.to(u.pc)
hb = m.data["emis"]['H 1 4861.33A']
for emband, color in zip(embands, colors):
em = m.data["emis"][emband]
ax.plot(radius, em / em.max(), label=emband, color=color)
ax.set(
yscale="linear",
ylim=[0.00, 1.1],
xlabel="Radius, pc",
ylabel="Emissivity",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# -
# ## Brightness versus projected radius in spherical symmetry
#
# First approximation to bow shock shape is that it is a hemisphere
#
# Therefore at each projected radius $b$, the brightness is given by:
# $$
# S(b) = \int_{-\infty}^\infty j(r) \, dz
# $$
# where
# $$
# r^2 = b^2 + z^2
# \quad \Rightarrow \quad
# 2 r\, dr = 2 z\, dz
# \quad \Rightarrow \quad
# dz = \frac{r}{z}\, dr
# $$
# Therefore
# $$
# S(b) = 2 \int_b^\infty j(r) \, \frac{r}{(r^2 - b^2)^{1/2}} \, dr
# $$
# ### Naive implementation of surface brightness intergral
#
# This version makes a regular grid of impact paramezter and a regular grid of dummy radii for the integration
nb = 200
def brightness_regrid(r, dr, e, nb, verbose=False):
b = np.linspace(0.0, r.max(), nb)
drmin = np.min(dr)
drmin = np.percentile(dr, 0.5)
_r = np.arange(0.0, r.max(), step=drmin)
nr = len(_r)
if verbose:
print(f"{nr=}, {drmin=:.2e}")
# _r = np.linspace(0.0, r.max(), 30 * nb + 5)
_e = np.interp(_r, r, e, left=0.0, right=0.0)
_dr = [r.max() / nr] * nr
bgrid = np.stack([b] * nr, axis=0)
rgrid = np.stack([_r] * nb, axis=1)
egrid = np.stack([_e] * nb, axis=1)
drgrid = np.stack([_dr] * nb, axis=1)
rgrid[rgrid <= bgrid + 0.5 * drgrid] = np.nan
sb = 2 * np.nansum(egrid * rgrid * drgrid / (drgrid + np.sqrt(rgrid**2 - bgrid**2)), axis=0)
return b, sb
# ### Alternatively, we can do the integral in z
#
# This is better, since we have no singularity. Since we have discrete points, we can do it without having to do any interpolation, using either trapezium or simpson.
from scipy import integrate
def brightness_discrete(r, dr, e, n_inner=50, verbose=False, integrator=np.trapz):
"""Perform integral of surface brightness along line of sight
Suitable values for `integrator` are numpy.trapz or scipy.integrate.simpson
"""
# Use the Cloudy radial points with additional uniform grid from origin to inner boundary
b_inner = np.linspace(0.0, r.min(), num=n_inner, endpoint=False)
b = np.concatenate((b_inner, r))
sb = np.zeros_like(b)
# For each impact parameter
for i, _b in enumerate(b):
# Select all radii greater than impact parameter
m = r >= _b
# Array of LOS positions for each of these radii
z = np.sqrt(r[m]**2 - _b**2)
_e = e[m]
# Integrate along z to find brightness
sb[i] = 2 * integrator(_e, z)
return b, sb
brightness = brightness_discrete
m = m8
nb = None
r = m.data["rad"]["radius"]
dr = m.data["rad"]["dr"]
e = m.data["emis"]["He 2 4685.70A"]
b, s = brightness(r, dr, e)
len(s)
m7.data["emis"].colnames[]
# ### Pre-calculate the surface brightness profiles for all models
#
# +
from astropy.table import Table
def sb_table(model):
r = model.data["rad"]["radius"]
dr = model.data["rad"]["dr"]
elabels = model.data["emis"].colnames[1:] # skip the depth column
sbdict = {}
for elabel in elabels:
sbdict["b"], sbdict[elabel] = brightness(r, dr, model.data["emis"][elabel])
return Table(sbdict)
# -
# %%timeit -n 1 -r 1
for m in m1, m2, m3, m4, m5, m6, m7, m8:
m.sb = sb_table(m)
# ### Optical line surface brightness
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnsmes = m.data["emis"].colnames[1:]
embands = [
'He 2 4685.70A',
'Ar 4 4740.12A',
'Ne 3 3868.76A',
'O 3 5006.84A',
'Blnd 5875.66A',
'Ar 3 7135.79A',
'H 1 6562.82A',
'O 2 7319.99A',
]
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.sb["b"] * u.cm.to(u.pc)
for emband, color in zip(embands, colors):
sb = m.sb[emband]
ax.plot(radius, sb / sb.max(), "-", label=emband, color=color)
ax.set(
yscale="linear",
ylim=[0.00, 1.1],
xlabel="Radius, pc",
ylabel="Surface brightness",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# -
# ### IR line and continuum surface brightness
# First, the infrared emission lines, which we normalise to the [S III] 18 micron line
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnames = m.data["emis"].colnames[1:]
embands = [
"S 4 10.5076m",
"Ne 3 15.5509m",
"S 3 18.7078m",
"S 3 33.4704m",
"Ne 2 12.8101m",
"Si 2 34.8046m",
]
normband = "S 3 18.7078m"
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
sbnorm = m.sb[normband].mean()
radius = m.sb["b"] * u.cm.to(u.pc)
for emband, color in zip(embands, colors):
sb = m.sb[emband]
ax.plot(radius, sb / sbnorm, label=emband, color=color)
ax.set(
yscale="linear",
ylim=[0.00, None],
xlabel="Radius, pc",
ylabel="Surface brightness",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# -
# Now the infrared continuum we try in two different ways. First, the `nuFnu` samples that I found, but I am not convinced that these are really the full continuum. *Perhaps they are just the bound-free part*
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnames = m.data["emis"].colnames[1:]
embands = [
"nFnu 15.6901m",
"nFnu 19.6199m",
"nFnu 24.7829m",
"nFnu 30.8695m",
"nFnu 41.2152m",
"nFnu 60.8322m",
]
normband = "nFnu 15.6901m"
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.sb["b"] * u.cm.to(u.pc)
sbnorm = m.sb[normband].mean()
for emband, color in zip(embands, colors):
sb = m.sb[emband]
ax.plot(radius, sb / sbnorm, label=emband, color=color)
ax.set(
yscale="linear",
ylim=[0.00, None],
xlabel="Radius, pc",
ylabel="Surface brightness",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# -
# So, those profiles look rather weird.
#
# If we plot the pre-defined bands for different instruments, then we get something more reasonable.
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# colnames = m.data["emis"].colnames[1:]
embands = [
"PAHC 10.9000m",
"IRAC 8.00000m",
"F12 12.0000m",
"MIPS 24.0000m",
"PAC1 70.0000m",
"PAC2 100.000m",
"PAC3 160.000m",
]
normband = "MIPS 24.0000m"
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(embands),
cmap_range=(0.15, 0.85),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.sb["b"] * u.cm.to(u.pc)
sbnorm = m.sb[normband].mean()
for emband, color in zip(embands, colors):
sb = m.sb[emband]
ax.plot(radius, sb / sbnorm, label=emband, color=color)
ax.set(
yscale="linear",
ylim=[0.00, None],
xlabel="Radius, pc",
ylabel="Surface brightness",
)
axes[0].legend(ncol=3)
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# -
# ## Line ratio diagnostics
#
# I can look at the same infrared line ratios as in the Spitzer data. And also at optical ratios
ratio_dict = {
# "c15-11-mir": ("nFnu 15.6901m", "PAHC 10.9000m"),
# "c25-15-mir": ("nFnu 24.7829m", "nFnu 15.6901m"),
"c12-08-mir": ("F12 12.0000m", "IRAC 8.00000m"),
"c24-12-mir": ("MIPS 24.0000m", "F12 12.0000m"),
"c70-24-mir": ("PAC1 70.0000m", "MIPS 24.0000m"),
"s43-mir": ("S 4 10.5076m", "S 3 18.7078m"),
"ne3s3-mir": ("Ne 3 15.5509m", "S 3 18.7078m"),
"ne32-mir": ("Ne 3 15.5509m", "Ne 2 12.8101m"),
"c12-ne3-mir": ("F12 12.0000m", "Ne 3 15.5509m"),
"ar43-opt": ("Ar 4 4740.12A", "Ar 3 7135.79A"),
"o3hb-opt": ("O 3 5006.84A", "H 1 4861.33A"),
"He21-opt": ("He 2 4685.70A", "Blnd 5875.66A"),
}
def sb_ratio_table(model, ratios):
result = {"b": model.sb["b"]}
for key, value in ratios.items():
result[key] = model.sb[value[0]] / model.sb[value[1]]
return Table(result)
# %%timeit -n 1 -r 1
for m in m1, m2, m3, m4, m5, m6, m7, m8:
m.sbratios = sb_ratio_table(m, ratio_dict)
m4.sbratios.to_pandas().describe()
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(ratio_dict),
cmap_range=(0.1, 0.9),
return_fmt='hex'
)
for m, ax in zip([m4, m7, m8], axes):
radius = m.sbratios["b"] * u.cm.to(u.pc)
rlabels = m.sbratios.colnames[1:]
for rlabel, color in zip(rlabels, colors):
ratio = m.sbratios[rlabel]
ratio_norm = np.percentile(ratio[np.isfinite(ratio)], 90)
ax.plot(radius, ratio / ratio_norm, label=f"{rlabel} ({ratio_norm:.2f})", color=color)
ax.set(
yscale="linear",
ylim=[0.0, 2],
xlabel="Radius, pc",
ylabel="Ratio",
)
ax.legend(ncol=5, fontsize="x-small")
axes[0].set_title("Constant pressure, n = 10, Rmax = 8 pc")
axes[1].set_title("Constant pressure, n = 50, Rmax = 8 pc")
axes[2].set_title("Density law $r^{-1}$, n = 10, Rmax = 8 pc")
sns.despine()
fig.tight_layout();
# +
fig, axes = plt.subplots(3, 1, figsize=(15, 12), sharex=True)
# Take N colors from named colormap in [0.15, 0.85] range in HEX
colors = cmr.take_cmap_colors(
'cmr.chroma_r',
len(ratio_dict),
cmap_range=(0.1, 0.9),
return_fmt='hex'
)
for m, ax in zip([m1, m2, m3], axes):
radius = m.sbratios["b"] * u.cm.to(u.pc)
rlabels = m.sbratios.colnames[1:]
for rlabel, color in zip(rlabels, colors):
ratio = m.sbratios[rlabel]
ratio_norm = np.percentile(ratio[np.isfinite(ratio)], 90)
ax.plot(radius, ratio / ratio_norm, label=f"{rlabel} ({ratio_norm:.1e})", color=color)
ax.set(
yscale="linear",
ylim=[0.0, 2],
xlabel="Radius, pc",
ylabel="Ratio / norm",
)
ax.legend(ncol=5, fontsize="x-small")
axes[0].set_title("Constant density, n = 10")
axes[1].set_title("Constant pressure, n = 10")
axes[2].set_title("Constant pressure, n = 30")
sns.despine()
fig.tight_layout();
# -
# So these are looking pretty different from the observed ratios, with the exception of the 25/15 micron continuum ratio, which is around 10 in both the observations and the model.
#
# Note that I lnow longer have the 15 micron because I do not trust the nuFnu output. But 24/12 behaves very similarly.
#
# One big difference with the observations is that S43 is much higher in the models, showing values > 4 in the bow shock.
# Median value of S43 is 0.25 in the model that includes the ionization front.
m1.sbratios.to_pandas().describe()
# In the observations