-
Notifications
You must be signed in to change notification settings - Fork 1
/
mr-plotter.py
1534 lines (886 loc) · 51.8 KB
/
mr-plotter.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
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
############################
#@|++++++mr-plotter++++++#@|
############################
# In[ ]:
import os
import pyvo
import json
import argparse
import numpy as np
import pandas as pd
from scipy import interpolate
from astropy.constants import G
import matplotlib.pyplot as plt
import astropy.constants as const
from astropy.io.votable import parse
from configparser import ConfigParser
# In[ ]:
#@|+++++++++++++++++We load the dictionaries+++++++++++++++++++++++++
zeng_models_colors = json.load(open('misc/dicts/zeng_models_colors.txt'))
zeng_models_labels = json.load(open('misc/dicts/zeng_models_labels.txt'))
color_coding_labels = json.load(open('misc/dicts/color_coding_labels.txt'))
# In[ ]:
#@|++++Uncomment this for the mr-plotter.py version+++++++
parser = argparse.ArgumentParser()
parser.add_argument('config_file')
args = parser.parse_args()
config_file = args.config_file
# In[ ]:
#@|++++Uncomment this for the mr.plotter.ipynb version+++++
#config_file = 'example5.ini'
#@|++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# In[ ]:
path_models = 'theoretical_models/'
# In[ ]:
#|Turbet et al. (2020) theoretical M-R models
def turbet2020_MR():
global R_pl_turb, M_pl_turb, m_pure_iron, m_earth_like, m_pure_rock, r_pure_iron, r_earth_like, r_pure_rock
#@|M-R relationships of the core of the planet based on Zeng et al. (2019)
#@|Earth-like, pure iron, and pure rock
pure_iron_df = pd.read_csv('theoretical_models/zeng_2019_pure_iron', sep = "\t", header = None)
earth_like_df = pd.read_csv('theoretical_models/zeng_2019_earth_like', sep = "\t", header = None)
pure_rock_df = pd.read_csv('theoretical_models/zeng_2019_pure_rock', sep = "\t", header = None)
m_pure_iron, r_pure_iron = pure_iron_df[0].values, pure_iron_df[1].values
m_earth_like, r_earth_like = earth_like_df[0].values, earth_like_df[1].values
m_pure_rock, r_pure_rock = pure_rock_df[0].values, pure_rock_df[1].values
Cores_db = np.array(['earth', 'rock', 'iron']) #@|Cores database
R_db = np.array([r_earth_like, r_pure_rock, r_pure_iron], dtype=object) #@|Corresponding radius database
M_db = np.array([m_earth_like, m_pure_rock, m_pure_iron], dtype=object) #@|Corresponding masses database
R_Core, M_Core = [], []
for core in Core_turb2020:
idx = np.where(core==Cores_db)[0]
R_Core.extend(R_db[idx])
M_Core.extend(M_db[idx])
R_pl_turb, M_pl_turb = [], []
for i,frac in enumerate(WMFs_turb2020):
r_core = R_Core[i]
m_core = M_Core[i]
R_cons,M_h20, Pt = 8.314, 1.8e-2, 0.1 # fixed
g_core = G.value * m_core * const.M_earth.value / (r_core*const.R_earth.value)**2
g = G.value * M_turb2020 * const.M_earth.value / (R_turb2020*const.R_earth.value)**2
alpha_1, alpha_2, alpha_3, alpha_4, alpha_5, alpha_6 = -3.550, 1.310, 1.099, 4.683e-1, 7.664e-1, 4.224e-1
beta_1, beta_2, beta_3, beta_4, beta_5 = 2.846, 1.555e-1, 8.777e-2, 6.045e-2, 1.143e-2
beta_6, beta_7, beta_8, beta_9, beta_10 = 1.736e-2, 1.859e-2, 4.314e-2, 3.393e-2, -1.034e-2
X = (np.log10(frac)-alpha_1) / alpha_2
Y = (np.log10(g)-alpha_3) / alpha_4
Z = (np.log10(Seff_turb2020)-alpha_5)/alpha_6
X = (np.log10(frac)-alpha_1) / alpha_2
Y = (np.log10(g)-alpha_3) / alpha_4
Z = (np.log10(Seff_turb2020)-alpha_5)/alpha_6
Teff = 10**(beta_1+beta_2*X+beta_3*Y+beta_4*Z+beta_5*X*Y+beta_6*Y**2+beta_7*X**3+beta_8*X**2*Y+beta_9*X*Y**2+beta_10*Y**4)
#@|z_atm
a = np.log(frac / (1-frac) * g_core**2 / 4 / np.pi / G.value / Pt)
b = R_cons * Teff / M_h20 / g_core
c = 1 / (r_core*const.R_earth.value)
z_atm = (1 / a / b - c)**(-1)
#r_new = (r_earth_like.values*const.R_earth.value + z_atm) / const.R_earth.value
#m_new = m_earth_like.values / (1-frac)
r_pl = (r_core*const.R_earth.value + z_atm) / const.R_earth.value
m_pl = m_core / (1-frac)
r_pl = np.array(r_pl)
#@|####-Results-########
R_pl_turb.append(r_pl)
M_pl_turb.append(m_pl)
#@|####################
# In[ ]:
def aguich2021_MR():
global R_aguich2021, M_aguich2021
R_aguich2021, M_aguich2021 = [], []
for i in range(len(x_core_aguich2021)):
idxs_aguich2021 = np.where((df_aguichine_2021['x_core'] == x_core_aguich2021[i]) & (df_aguichine_2021['x_H2O'] == x_H2O_aguich2021[i]) & (df_aguichine_2021['T_irr'] == Tirr_aguich2021[i]) & (df_aguichine_2021['errcode'] == 0))[0] #@|only pick the errcode = 0 values
r_aguich2021 = (df_aguichine_2021['R_b'].values + df_aguichine_2021['R_a'].values)[idxs_aguich2021]
m_aguich2021 = (df_aguichine_2021['M_b'].values + df_aguichine_2021['M_a'].values)[idxs_aguich2021]
R_aguich2021.append(r_aguich2021)
M_aguich2021.append(m_aguich2021)
# In[ ]:
def lopez_fortney2014_MR():
global R_lf2014, M_lf2014
R_lf2014, M_lf2014 = [], []
for i in range(len(age_lf2014)):
df_lf2014 = pd.read_csv(f'{path_models}/Lopez&Fortney_2014_{age_lf2014[i]}_{opacity_lf2014[i]}', sep = " ")
idxs_flux_lf2014 = np.where(df_lf2014['Flux'].values == float(Seff_lf2014[1]))[0]
m_lf2014 = df_lf2014['Mass'][idxs_flux_lf2014].values
r_lf2014 = df_lf2014[f'{H_He[i]}'][idxs_flux_lf2014].values
R_lf2014.append(r_lf2014)
M_lf2014.append(m_lf2014)
# In[ ]:
def haldemann2024_MR():
global R_haldemann2024, M_haldemann2024
R_haldemann2024, M_haldemann2024 = [], []
for i in range(len(models_haldemann2024)):
df_haldemann2024 = pd.read_csv(f'{path_models}/Mass_Radius_{models_haldemann2024[i]}.dat', comment = '#', header = None)
if T_out_haldemann2024[i] == 50:
idx_R_haldemann2024 = 1
if T_out_haldemann2024[i] == 300:
idx_R_haldemann2024 = 2
if T_out_haldemann2024[i] == 800:
idx_R_haldemann2024 = 3
if T_out_haldemann2024[i] == 1500:
idx_R_haldemann2024 = 4
if T_out_haldemann2024[i] == 2000:
idx_R_haldemann2024 = 5
m_haldemann2024 = df_haldemann2024[0].values
r_haldemann2024 = df_haldemann2024[idx_R_haldemann2024].values
R_haldemann2024.append(r_haldemann2024)
M_haldemann2024.append(m_haldemann2024)
# In[ ]:
def seager2007_MR():
global R_seager2007, M_seager2007
R_seager2007, M_seager2007 = [], []
m_seager2007 = np.linspace(0, 20, 1000)
for i in range(len(models_seager2007)):
if models_seager2007[i] == 'iron':
k1, k2, k3 = -0.209490, 0.0804, 0.394
m1, r1 = 5.80, 2.52
if models_seager2007[i] == 'rock':
k1, k2, k3 = -0.209594, 0.0799, 0.413
m1, r1 = 10.55, 3.90
if models_seager2007[i] == 'water':
k1, k2, k3 = -0.209396, 0.0807, 0.375
m1, r1 = 5.52, 4.43
log_r_seager2007 = k1 + 1/3 * np.log10(m_seager2007/m1) - k2 * (m_seager2007/m1)**k3
r_seager2007 = 10**log_r_seager2007
r_seager2007 = r_seager2007 * r1
M_seager2007.append(m_seager2007)
R_seager2007.append(r_seager2007)
# In[ ]:
def otegi2020_MR():
global R_otegi_small, M_otegi_small, R_otegi_intermediate, M_otegi_intermediate
M_otegi_small = np.linspace(0, 10, 100)
M_otegi_intermediate = np.linspace(6, 138, 100)
R_otegi_small = 1.03 * M_otegi_small**0.29
R_otegi_intermediate = 0.70 * M_otegi_intermediate**0.63
# In[ ]:
def parc2024_MR():
global R_parc_small, M_parc_small, R_parc_intermediate, M_parc_intermediate, R_parc_giant, M_parc_giant
M_parc_small = np.linspace(0, 10, 100)
M_parc_intermediate = np.linspace(6, 138, 100)
M_parc_giant = np.linspace(138, 10000, 100)
R_parc_small = 1.02 * M_parc_small**0.28
R_parc_intermediate = 0.61 * M_parc_intermediate**0.67
R_parc_giant = 11.9 * M_parc_giant**0.01
# In[ ]:
def iso_density():
global Radii_iso, Masses_iso
#@|idodensity curves
radii = np.linspace(0, const.R_earth.value * 25, 10000)
Radii_iso, Masses_iso = [], []
for i in range(len(density)):
masses = density[i] * 4 / 3 * np.pi * radii**3
Radii_iso.append(radii / const.R_earth.value)
Masses_iso.append(masses / const.M_earth.value)
# In[ ]:
# In[ ]:
#@|Read the configuration file 'config.ini' into a config_object
config_object = ConfigParser()
config_object.read(f"config/{config_file}")
#@|Sections
try:
CATALOG_DATA = config_object['CATALOG_DATA']
except:
pass
try:
MY_DATA = config_object['MY_DATA']
except:
pass
try:
MODELS = config_object['MODELS']
except:
pass
try:
OPTIONAL_CONFIG = config_object['OPTIONAL_CONFIG']
except:
pass
# In[ ]:
# In[ ]:
#@|++++++Exoplanet catalog++++++++++
#@|NEA, Exoplanet.eu, or PlanetS
#@|++++++++++++++++++++++++++++++++++
catalog = CATALOG_DATA['catalog']
# In[ ]:
#@|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#@|Load data (df) from the NASA Exoplanet Archive (Confirmed planets)
#@|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if catalog == 'NEA':
try:
web_or_local = CATALOG_DATA['web_or_local']
except:
web_or_local = 'local'
try:
ps_or_composite = CATALOG_DATA['ps_or_composite']
except:
ps_or_composite = 'ps'
if web_or_local == 'web':
if ps_or_composite == 'ps':
print('Downloading the "Planetary Systems" table from the NASA Exoplanet Archive ... (this might take a while)')
if ps_or_composite == 'composite':
print('Downloading the "Planetary Systems Composite Data" table from the NASA Exoplanet Archive ... (this might take a while)')
request = pyvo.dal.TAPQuery('https://exoplanetarchive.ipac.caltech.edu/TAP', 'SELECT * FROM '+ps_or_composite)
table = pyvo.dal.TAPQuery.execute(request)
df = pd.DataFrame(table)
if web_or_local == 'local':
list_complete = sorted(os.listdir('catalog_data/NEA/'))
#list_complete
list_ps = []
list_composite = []
for item in list_complete:
if item[0:10] == 'PSCompPars':
list_composite.append(item)
else:
list_ps.append(item)
if ps_or_composite == 'ps':
df = pd.read_csv('catalog_data/NEA/'+list_ps[-1], comment = "#")
if ps_or_composite == 'composite':
df = pd.read_csv('catalog_data/NEA/'+list_composite[-1], comment = "#")
#@|+++++++++++++++++++++++++++++++++++++++++++
#@|Load data df from the Exoplanet.eu catalog
#@|+++++++++++++++++++++++++++++++++++++++++++
if catalog == 'Exoplanet.eu':
file = os.listdir('catalog_data/Exoplanet.eu/')[0]
df = pd.read_csv('catalog_data/Exoplanet.eu/'+file)
df = df.rename(columns={'orbital_period':'pl_orbper', 'semi_major_axis':'pl_orbsmax', 'eccentricity':'pl_orbeccen','discovered':'disc_year', 'temp_calculated':'pl_eqt_Exoplanet.eu', 'temp_measured':'pl_eqt', 'log_g':'st_logg','mag_v':'V Mag', 'mag_k':'K Mag','star_distance': 'sy_dist', 'star_metallicity':'st_met', 'star_mass':'st_mass', 'star_radius': 'st_rad', 'star_age': 'st_age', 'star_teff':'st_teff', 'mass':'pl_bmasse','mass_error_min':'pl_bmasseerr2', 'mass_error_max':'pl_bmasseerr1','radius':'pl_rade', 'radius_error_min':'pl_radeerr2','radius_error_max':'pl_radeerr1' })
#@|++++++++++++++++++++++++++++++++++++++
#@|Load data df from the PlanetS catalog
#@|++++++++++++++++++++++++++++++++++++++
if catalog == 'PlanetS':
votable_PlanetS = parse("catalog_data/PlanetS/PLANETS.vot")
table_PlanetS = votable_PlanetS.get_first_table().to_table()
df = table_PlanetS.to_pandas()
df = df.rename(columns={'Discovery Year':'disc_year', 'Discovery Method':'discoverymethod', 'Discovery Facility':'disc_facility','Orbital Period [days]':'pl_orbper', 'Orbit Semi-Major axis [au]':'pl_orbsmax','Eccentricity':'pl_orbeccen', 'Insolation Flux [Earth Flux]':'pl_insol', 'Insolation Flux [Earth Flux] - Computation':'pl_insol_PlanetS', 'Equilibrium Temperature [K]':'pl_eqt', 'Equilibrium Temperature [K] - Computation':'pl_eqt_PlanetS', 'Stellar Effective Temperature [K]':'st_teff','Teff [K] (Gaia DR3)':'st_teff_gaia', 'Stellar Radius [Rsun]':'st_rad','Stellar Mass [Msun]':'st_mass', 'Stellar Metallicity [dex]':'st_met','[Fe/H] [dex] (Gaia DR3)':'st_met_gaia', 'Stellar Surface Gravity [log(cm/s**2)]':'st_logg', 'log(g) [log(cm/s**2)] (Gaia DR3)':'st_logg_gaia','Distance [pc]':'sy_dist', 'V Mag':'sy_vmag','K Mag':'sy_kmag','Transmission Spectroscopy Metric (TSM) - Computation':'TSM', 'Emission Spectroscopy Metric (ESM) - Computation':'ESM', 'Measured Radial Velocity Semi-Amplitude [m/s]':'K_measured','Stellar Age [Gyr]':'st_age', 'Stellar Age [Gyr] (Gaia DR3)':'st_age_gaia','Stellar Luminosity [log(Lsun)]':'st_lum', 'Stellar Luminosity [log(Lsun)] (Gaia DR3)':'st_lum_gaia', 'Planet Mass [Mjup]':'pl_bmasse','Planet Mass - Upper Unc [Mjup]':'pl_bmasseerr1', 'Planet Mass - Lower Unc [Mjup]':'pl_bmasseerr2', 'Planet Radius [Rjup]':'pl_rade','Planet Radius - Upper Unc [Rjup]':'pl_radeerr1', 'Planet Radius - Lower Unc [Rjup]':'pl_radeerr2' })
# In[ ]:
# In[ ]:
#@|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#@|We remove those planets with a precision in mass and radius lower than precision_radius and precision_mass
#@|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
precision_radius = float(CATALOG_DATA['precision_radius'])
precision_mass = float(CATALOG_DATA['precision_mass'])
#@|mass precision better than thres
M_pl, M_pl_err = df['pl_bmasse'].values, (abs(df['pl_bmasseerr1'].values) + abs(df['pl_bmasseerr2'].values)) / 2
idxs_M_pl_thres = np.where(M_pl_err / M_pl < (precision_mass / 100))[0]
#print(str(len(idxs_M_pl_thres))+' of '+str(n_planets)+' planets ('+str(int(len(idxs_M_pl_thres) / n_planets * 100))+'%) have a mass measurement precision below '+str(int(thres*100))+'%.')
df = df.iloc[idxs_M_pl_thres]
#@|radius precision better than thres
R_pl, R_pl_err = df['pl_rade'].values,(abs(df['pl_radeerr1'].values) + abs(df['pl_radeerr2'].values)) / 2
idxs_R_pl_thres = np.where(R_pl_err / R_pl < (precision_radius / 100))[0]
#print(str(len(idxs_R_pl_thres))+' of '+str(n_planets)+' planets ('+str(int(len(idxs_R_pl_thres) / n_planets * 100))+'%) have a mass and radius precision below '+str(int(thres*100))+'%.')
df = df.iloc[idxs_R_pl_thres]
# In[ ]:
# In[ ]:
color_coding = CATALOG_DATA['color_coding']
#@|+++++Numerical and non-numerical color coding++++++++++
if color_coding == 'disc_facility' or color_coding == 'disc_year' or color_coding == 'discoverymethod':
numerical_color_coding = False
else:
numerical_color_coding = True
try:
groups = [str(x.strip()) for x in CATALOG_DATA['groups'].split(',')]
if color_coding == 'disc_year':
groups = np.array(groups).astype(int)
except:
pass
try:
colors_groups = [str(x.strip()) for x in CATALOG_DATA['colors_groups'].split(',')]
except:
pass
try:
plot_all_planets = CATALOG_DATA['plot_all_planets'] == 'True'
except:
plot_all_planets = True
# In[ ]:
# In[ ]:
#@|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#@|We remove the rows from the df that have no 'color_coding'
#@|----------Only in the numerical color coding-------------
#@|++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cols = df.columns.values
if numerical_color_coding:
if color_coding in cols:
idxs_not_nan = np.where(~np.isnan(df[color_coding]))[0]
df = df.iloc[idxs_not_nan]
print('Your sample contains '+str(len(df))+' planets')
else:
pass
# In[ ]:
# In[ ]:
#@|+++++++++++++++++++to be done++++++++++++++++++++++++++
#@|idxs_without_ttvs = np.where(df['ttv_flag'] == 0)
#@|df = df.iloc[idxs_without_ttvs]
#@print('Your sample contains '+str(len(df))+' planets')
# In[ ]:
# In[ ]:
#@|+++++++++++++++++++++++++++++++++++++++++++++++++++
#@|----Definition of the mass and radius arrays-----
#@|+++++++++++++++++++++++++++++++++++++++++++++++++++
#@|Note: The PlanetS catalog masses and radii are in Rjup. We convert them into Rearth.
if catalog == 'PlanetS' or catalog == 'Exoplanet.eu':
fac_R = const.R_jup.value / const.R_earth.value
fac_M = const.M_jup.value / const.M_earth.value
else:
fac_M, fac_R = 1, 1
R_catalog, R_catalog_err_up, R_catalog_err_down = df['pl_rade'].values, df['pl_radeerr1'].values, df['pl_radeerr2'].values
M_catalog, M_catalog_err_up, M_catalog_err_down = df['pl_bmasse'].values, df['pl_bmasseerr1'].values, df['pl_bmasseerr2'].values
R_catalog, R_catalog_err_up, R_catalog_err_down = R_catalog*fac_R, R_catalog_err_up*fac_R, R_catalog_err_down*fac_R
M_catalog, M_catalog_err_up, M_catalog_err_down = M_catalog*fac_M, M_catalog_err_up*fac_M, M_catalog_err_down*fac_M
#@|Mass and radius upper and lower errors in the same array (for the plots)
R_catalog_ERR = [(abs(R_catalog_err_down[i]), R_catalog_err_up[i]) for i in range(len(R_catalog))]
M_catalog_ERR = [(abs(M_catalog_err_down[i]), M_catalog_err_up[i]) for i in range(len(M_catalog))]
# In[ ]:
# In[ ]:
#@|#######--zeng et al. (2016,2019) config--##########
try:
models_zeng = MODELS['models_zeng']
models_zeng = [x.strip() for x in models_zeng.split(',')]
zeng = True
except:
zeng = False
# In[ ]:
#@|#######--marcus et al. 2010 config--##########
try:
models_marcus = MODELS['models_marcus']
models_marcus = [x.strip() for x in models_marcus.split(',')]
marcus = True
except:
marcus = False
# In[ ]:
#@|#######--turbet et al. 2020 config--##########
try:
M_turb2020 = float(MODELS['M_turb2020'])
R_turb2020 = float(MODELS['R_turb2020'])
Seff_turb2020 = float(MODELS['Seff_turb2020'])
WMFs_turb2020 = [float(x.strip()) for x in MODELS['WMFs_turb2020'].split(',')]
Core_turb2020 = [x.strip() for x in MODELS['Core_turb2020'].split(',')]
colors_turb2020 = [x.strip() for x in MODELS['colors_turb2020'].split(',')]
turb_2020 = True
turbet2020_MR()
except:
turb_2020 = False
# In[ ]:
#@|#######--aguichine et al. 2020 config--##########
try:
x_core_aguich2021 = [float(x.strip()) for x in MODELS['x_core_aguich2021'].split(',')]
x_H2O_aguich2021 = [float(x.strip()) for x in MODELS['x_H2O_aguich2021'].split(',')]
Tirr_aguich2021 = [float(x.strip()) for x in MODELS['Tirr_aguich2021'].split(',')]
colors_aguich2021 = [x.strip() for x in MODELS['colors_aguich2021'].split(',')]
df_aguichine_2021 = pd.read_csv('theoretical_models/aguichine_2021', comment = "#", sep = '\t')
aguich2021 = True
aguich2021_MR()
except:
aguich2021 = False
# In[ ]:
#@|#######--lopez & fortney et al. 2014 config--##########
try:
age_lf2014 = [x.strip() for x in MODELS['age_lf2014'].split(',')]
opacity_lf2014 = [x.strip() for x in MODELS['opacity_lf2014'].split(',')]
Seff_lf2014 = [x.strip() for x in MODELS['Seff_lf2014'].split(',')]
H_He = [x.strip() for x in MODELS['H_He'].split(',')]
colors_lf2014 = [x.strip() for x in MODELS['colors_lf2014'].split(',')]
lopez_fortney2014 = True
lopez_fortney2014_MR()
except:
lopez_fortney2014 = False
# In[ ]:
#@|#######----------haldemann et al. (2024) config---------##########
try:
models_haldemann2024 = [x.strip() for x in MODELS['models_haldemann2024'].split(',')]
T_out_haldemann2024 = [float(x.strip()) for x in MODELS['T_out_haldemann2024'].split(',')]
colors_haldemann2024 = [x.strip() for x in MODELS['colors_haldemann2024'].split(',')]
haldemann2024 = True
haldemann2024_MR()
except:
haldemann2024 = False
# In[ ]:
#@|#######----------seager et al. (2007) config---------##########
try:
models_seager2007 = [x.strip() for x in MODELS['models_seager2007'].split(',')]
colors_seager2007 = [x.strip() for x in MODELS['colors_seager2007'].split(',')]
seager2007 = True
seager2007_MR()
except:
seager2007 = False
# In[ ]:
#@|#######------otegi et al. 2020 config------##########
try:
models_otegi2020 = MODELS['relations_otegi2020']
models_otegi2020 = [x.strip() for x in models_otegi2020.split(',')]
otegi2020 = True
try:
colors_otegi2020 = MODELS['colors_otegi2020']
colors_otegi2020 = [x.strip() for x in colors_otegi2020.split(',')]
except:
colors_otegi2020[0] = 'k'
colors_otegi2020[1] = 'k'
try:
linestyles_otegi2020 = MODELS['linestyles_otegi2020']
linestyles_otegi2020 = [x.strip() for x in linestyles_otegi2020.split(',')]
except:
linestyles_otegi2020[0] = 'dashed'
linestyles_otegi2020[1] = 'dashed'
except:
otegi2020 = False
# In[ ]:
#@|#######------parc et al. 2024 config------##########
try:
models_parc2024 = MODELS['relations_parc2024']
models_parc2024 = [x.strip() for x in models_parc2024.split(',')]
parc2024 = True
try:
colors_parc2024 = MODELS['colors_parc2024']
colors_parc2024 = [x.strip() for x in colors_parc2024.split(',')]
except:
colors_parc2024[0] = 'k'
colors_parc2024[1] = 'k'
colors_parc2024[2] = 'k'
try:
linestyles_parc2024 = MODELS['linestyles_parc2024']
linestyles_parc2024 = [x.strip() for x in linestyles_parc2024.split(',')]
except:
linestyles_parc2024[0] = 'dashed'
linestyles_parc2024[1] = 'dashed'
linestyles_parc2024[2] = 'dashed'
except:
parc2024 = False
# In[ ]:
#@|#######--Isodensity config--##########
try:
density = [float(x.strip()) for x in MODELS['density'].split(',')]
for i in range(len(density)):
density[i] = density[i] * 1000
colors_density = [x.strip() for x in MODELS['colors_density'].split(',')]
isodensity = True
except:
isodensity = False
# In[ ]:
# In[ ]:
#@|optional configuration
#@|number of columns to make the plot (one or two)
try:
n_cols = OPTIONAL_CONFIG['n_cols']
except:
n_cols = 'one'
#@|#####--color_max and color_min--###########
if color_coding != 'none':
if numerical_color_coding:
try:
color_min = float(OPTIONAL_CONFIG['color_min'])
except:
five_per_cent = int(len(df[color_coding].values)*0.05)
color_min = np.median(np.sort(df[color_coding].values)[:five_per_cent])
try:
color_max = float(OPTIONAL_CONFIG['color_max'])
except:
if catalog == 'NEA':
five_per_cent = int(len(df[color_coding].values)*0.05)
color_max = np.median(np.sort(df[color_coding].values)[-five_per_cent:])
if catalog == 'PlanetS':
five_per_cent = int(len(df[color_coding_S].values)*0.05)
color_max = np.median(np.sort(df[color_coding_S].values)[-five_per_cent:])
else:
pass
#@|############--log_x and log_y--##########
try:
log_x = OPTIONAL_CONFIG['log_x'] == 'True'
except:
log_x = True
try:
log_y = OPTIONAL_CONFIG['log_y'] == 'True'
except:
log_y = True
#@|###########--xlim and ylim--###############
try:
x_lims = [float(x.strip()) for x in OPTIONAL_CONFIG['xlim'].split(',')]
except:
x_lims = [0.5, 21]
try:
y_lims = [float(x.strip()) for x in OPTIONAL_CONFIG['ylim'].split(',')]
except:
y_lims = [0.9, 2.8]
#@|###########--legend location-###############
try:
loc_legend = OPTIONAL_CONFIG['loc_legend']
except:
loc_legend = 'upper right'
#@|############--plot the low-density super-Earths region--###############
try:
low_d_sE = OPTIONAL_CONFIG['low_density_superEarths'] == 'True'
except:
low_d_sE = False
#@|############--Markersize of the NEA and my planets--###############
try:
size_catalog_planets = int(OPTIONAL_CONFIG['size_catalog_planets'])
except:
size_catalog_planets = 35
try:
size_my_planets = int(OPTIONAL_CONFIG['size_my_planets'])
except:
size_my_planets = 150
#@|############--Grey shade below the 100% iron model by Zeng et al. (2019)--###############
try:
shade_below_pure_iron = OPTIONAL_CONFIG['shade_below_pure_iron'] == 'True'
except:
shade_below_pure_iron = True
#@|############--Dark background--##########
try:
dark_background = OPTIONAL_CONFIG['dark_background'] == 'True'
except:
dark_background = False
#@|#########---linewidths of the models-----#############
try:
lw_models = float(OPTIONAL_CONFIG['lw_models'])
except:
lw_models = 1.6
#@|########-------numbers of columns in the legend--------######
try:
n_cols_legend = int(OPTIONAL_CONFIG['n_cols_legend'])
except:
n_cols_legend = 1
#@|###########----capsizes-------#############
try:
capsize = float(OPTIONAL_CONFIG['capsize'])
except:
capsize = 0
#@|###########----appearance-------#############
try:
appearance = str(OPTIONAL_CONFIG['appearance'])
except:
appearance = 'standard'
#@|###########----ec_catalog for the plots with no color code-------#############
try:
ec_catalog = str(OPTIONAL_CONFIG['ec_catalog'])
except:
ec_catalog = 'grey'
#@|###########----ec_catalog for the color coded plots-------#############
try:
ec_catalog_cc = str(OPTIONAL_CONFIG['ec_catalog_cc'])
except:
ec_catalog_cc = 'whitesmoke'
#@|###########--My planets--###############
text_boxes = False
mass_upper_limit = []
for i in range(1, 21):
try:
globals()['m_p'+str(i)] = float(MY_DATA['m_p'+str(i)])
globals()['r_p'+str(i)] = float(MY_DATA['r_p'+str(i)])
globals()['c_p'+str(i)] = MY_DATA['c_p'+str(i)]
except:
pass
#|@uncertainties
try:
globals()['m_p'+str(i)+'_err_up'] = float(MY_DATA['m_p'+str(i)+'_err_up'])
globals()['m_p'+str(i)+'_err_down'] = float(MY_DATA['m_p'+str(i)+'_err_down'])
globals()['r_p'+str(i)+'_err_up'] = float(MY_DATA['r_p'+str(i)+'_err_up'])
globals()['r_p'+str(i)+'_err_down'] = float(MY_DATA['r_p'+str(i)+'_err_down'])
mass_upper_limit.append(False)
except:
try:
globals()['m_p'+str(i)+'_err_down'] = float(MY_DATA['m_p'+str(i)+'_err_down'])
globals()['r_p'+str(i)+'_err_up'] = float(MY_DATA['r_p'+str(i)+'_err_up'])
globals()['r_p'+str(i)+'_err_down'] = float(MY_DATA['r_p'+str(i)+'_err_down'])
mass_upper_limit.append(True)
except:
pass
#@|text boxes
try:
globals()['name_p'+str(i)] = MY_DATA['name_p'+str(i)]
#@|location of the text boxes
globals()['dis_x_p'+str(i)] = float(MY_DATA['dis_x_p'+str(i)])
globals()['dis_y_p'+str(i)] = float(MY_DATA['dis_y_p'+str(i)])
text_boxes = True
except:
pass
mass_upper_limit = np.array(mass_upper_limit)
# In[ ]: