Skip to content

Commit 2eaa45b

Browse files
committed
Added test data and example, independize from mesa.py
1 parent f4e4c4d commit 2eaa45b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+73256
-37
lines changed

LOGS/history.data

+1,870
Large diffs are not rendered by default.

LOGS/profile1.data

+1,185
Large diffs are not rendered by default.

LOGS/profile10.data

+1,097
Large diffs are not rendered by default.

LOGS/profile11.data

+1,196
Large diffs are not rendered by default.

LOGS/profile12.data

+1,430
Large diffs are not rendered by default.

LOGS/profile13.data

+1,479
Large diffs are not rendered by default.

LOGS/profile14.data

+1,496
Large diffs are not rendered by default.

LOGS/profile15.data

+1,534
Large diffs are not rendered by default.

LOGS/profile16.data

+1,544
Large diffs are not rendered by default.

LOGS/profile17.data

+1,674
Large diffs are not rendered by default.

LOGS/profile18.data

+1,680
Large diffs are not rendered by default.

LOGS/profile19.data

+1,690
Large diffs are not rendered by default.

LOGS/profile2.data

+1,020
Large diffs are not rendered by default.

LOGS/profile20.data

+1,729
Large diffs are not rendered by default.

LOGS/profile21.data

+1,777
Large diffs are not rendered by default.

LOGS/profile22.data

+1,808
Large diffs are not rendered by default.

LOGS/profile23.data

+1,851
Large diffs are not rendered by default.

LOGS/profile24.data

+1,815
Large diffs are not rendered by default.

LOGS/profile25.data

+1,795
Large diffs are not rendered by default.

LOGS/profile26.data

+1,813
Large diffs are not rendered by default.

LOGS/profile27.data

+1,820
Large diffs are not rendered by default.

LOGS/profile28.data

+1,846
Large diffs are not rendered by default.

LOGS/profile29.data

+1,864
Large diffs are not rendered by default.

LOGS/profile3.data

+952
Large diffs are not rendered by default.

LOGS/profile30.data

+1,840
Large diffs are not rendered by default.

LOGS/profile31.data

+1,833
Large diffs are not rendered by default.

LOGS/profile32.data

+1,827
Large diffs are not rendered by default.

LOGS/profile33.data

+1,808
Large diffs are not rendered by default.

LOGS/profile34.data

+1,773
Large diffs are not rendered by default.

LOGS/profile35.data

+1,819
Large diffs are not rendered by default.

LOGS/profile36.data

+1,940
Large diffs are not rendered by default.

LOGS/profile37.data

+2,019
Large diffs are not rendered by default.

LOGS/profile38.data

+2,073
Large diffs are not rendered by default.

LOGS/profile39.data

+2,122
Large diffs are not rendered by default.

LOGS/profile4.data

+951
Large diffs are not rendered by default.

LOGS/profile40.data

+2,118
Large diffs are not rendered by default.

LOGS/profile41.data

+2,056
Large diffs are not rendered by default.

LOGS/profile42.data

+1,978
Large diffs are not rendered by default.

LOGS/profile43.data

+1,989
Large diffs are not rendered by default.

LOGS/profile44.data

+1,936
Large diffs are not rendered by default.

LOGS/profile5.data

+969
Large diffs are not rendered by default.

LOGS/profile6.data

+1,009
Large diffs are not rendered by default.

LOGS/profile7.data

+1,029
Large diffs are not rendered by default.

LOGS/profile8.data

+1,051
Large diffs are not rendered by default.

LOGS/profile9.data

+1,079
Large diffs are not rendered by default.

LOGS/profiles.index

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
44 models. lines hold model number, priority, and profile number.
2+
1 2 1
3+
50 1 2
4+
98 2 3
5+
100 1 4
6+
150 1 5
7+
200 1 6
8+
230 2 7
9+
250 1 8
10+
300 1 9
11+
350 1 10
12+
400 1 11
13+
446 2 12
14+
450 1 13
15+
500 1 14
16+
550 1 15
17+
561 2 16
18+
600 1 17
19+
626 2 18
20+
650 1 19
21+
700 1 20
22+
750 1 21
23+
800 1 22
24+
850 1 23
25+
900 1 24
26+
950 1 25
27+
1000 2 26
28+
1050 1 27
29+
1100 1 28
30+
1150 1 29
31+
1200 1 30
32+
1250 1 31
33+
1300 1 32
34+
1350 1 33
35+
1400 1 34
36+
1450 1 35
37+
1500 1 36
38+
1550 1 37
39+
1600 1 38
40+
1650 1 39
41+
1700 1 40
42+
1750 1 41
43+
1800 1 42
44+
1850 1 43
45+
1864 3 44

example.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
import mkipp
3+
import matplotlib.pyplot as plt
4+
mkipp.decorated_kipp_plot(logs_dir = "LOGS", profile_numbers = range(1,45,1), contour_plots = ["eps_nuc"], core_masses = ["He","C","O"], \
5+
xaxis = "model_number", time_units = "Myr", save_file = False, mass_tolerance = 1e-10)

mkipp.py

+22-37
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
"""
22
Kippenhahn plotter based on SimpleMesaKippy.py and Kippy.py
33
Prehistory: SimpleMesaKippy.py, Author: Alfred Gautschy /23.VIII.2012
4+
45
Kippy.py, Author: Pablo Marchant /13.V.2013
6+
57
MKippi.py, Author: Matteo Cantiello /V.2013 (Added LOSSES. Color/Line Style inspired by convplot.pro IDL routine of A.Heger)
68
/VI.2013 (Added RADIUS, TIME and NORMALIZE Options. OMEGA Allows to plot w-contours)
79
/VII.2013 (Tentatively added Rotational diff. coefficients,conv. velocities and Equipartition B-field)
10+
11+
(most of these were removed and replaced with flexible plotting options)
12+
813
mkipp.py, Author: Pablo Marchant /II.2014 (full rewrite, code cleanup and now works as a module, not a script)
914
/III.2014 (enhancement of mixing regions ploting to deal with holes and merging regions)
1015
/IV.2015 stopped listing enhancements
11-
Requirements: mesa.py. Also needs history.data and profiles.data containing
12-
History (star_age,model_number, mixing_regions, mix_relr_regions)
13-
Profile (star_mass,photosphere_r,q,radius,eps_nuc,non_nuc_neu,logRho,
14-
conv_vel_div_csound,omega,am_log_D_ST,am_log_D_ES,am_log_D_DSI,log_conv_vel,initial_mass,initial_z,version_number)
16+
17+
Requirements: history.data and profiles.data containing
18+
History (star_age,model_number,star_mass,photosphere_r,mixing_regions,mix_relr_regions)
19+
Profile (mass,radius,eps_nuc)
1520
"""
1621
import numpy as np
17-
import mesa as ms
1822
from math import log10, pi
23+
from mesa_data import *
1924

2025
#matplotlib specifics
2126
import matplotlib.pyplot as plt
@@ -145,6 +150,10 @@ def default_extractor(identifier, scale, prof):
145150
return np.log10(abs(prof.get(identifier))+1e-99)
146151
else:
147152
print "Unrecognized scale: " + scale
153+
154+
###################################################
155+
########END SUPPORT CLASSES AND FUNCTIONS##########
156+
###################################################
148157

149158
#returns a list of matplotlib path objects with the mixing regions
150159
def get_mixing_zones(logs_dir, history_names, yaxis_normalize, xaxis, yaxis, \
@@ -156,7 +165,7 @@ def get_mixing_zones(logs_dir, history_names, yaxis_normalize, xaxis, yaxis, \
156165
history_names = [logs_dir + "/" + "history.data"]
157166
for history_name in history_names:
158167
print history_name
159-
histories.append(ms.history_data(".", slname = history_name, clean_starlog = False))
168+
histories.append(Mesa_Data(history_name))
160169
x_coords = []
161170
for history in histories:
162171
x_coords.extend(history.get(xaxis) / xaxis_divide)
@@ -249,10 +258,6 @@ def get_mixing_zones(logs_dir, history_names, yaxis_normalize, xaxis, yaxis, \
249258

250259
return zones, mix_types, x_coords, y_coords, histories
251260

252-
###################################################
253-
########END SUPPORT CLASSES AND FUNCTIONS##########
254-
###################################################
255-
256261
#kipp_plot: Plots a Kippenhahn diagram into the matplotlib axis given. No decoration
257262
# done (i.e. axis labeling or colorbars). Returns
258263
def kipp_plot(
@@ -349,10 +354,10 @@ def kipp_plot(
349354
min_x_coord = 1e99
350355
for i,profile_name in enumerate(profile_names):
351356
try:
352-
prof=ms.mesa_profile(profile_name[0], profile_name[1], num_type='profile_num')
353-
except IOError as e:
354-
print "Couldn't open profile number " + str(profile_name[1]) + " in folder " + profile_name[0]
355-
x_coord = prof.header_attr.get(xaxis) / xaxis_divide
357+
prof = Mesa_Data(profile_name[0]+"/profile"+str(profile_name[1])+".data")
358+
except Exception as e:
359+
print "Couldn't read profile number " + str(profile_name[1]) + " in folder " + profile_name[0]
360+
x_coord = prof.header[xaxis] / xaxis_divide
356361
if x_coord < max_x_coord:
357362
print "Profiles are not ordered in X coordinate!!!"
358363
max_x_coord = max(max_x_coord, x_coord)
@@ -362,7 +367,7 @@ def kipp_plot(
362367
if yaxis_normalize:
363368
max_y = star_mass = star_radius = 1.0
364369
elif yaxis == "mass":
365-
star_mass = prof.header_attr.get('star_mass')
370+
star_mass = prof.header['star_mass']
366371
max_y = star_mass
367372
elif yaxis == "radius":
368373
star_radius = prof.header_attr.get('photosphere_r')
@@ -461,13 +466,7 @@ def kipp_plot(
461466
#Special extractors for default plots
462467
def nucneu_extractor(identifier, scale, prof):
463468
eps_nuc = prof.get('eps_nuc')
464-
eps_neu = prof.get('eps_neu')
465-
return np.log10(eps_nuc - eps_neu)
466-
def Bfield_extractor(identifier, scale, prof):
467-
log_conv_vel = prof.get('log_conv_vel')
468-
conv_vel = 10**(log_conv_vel)
469-
density = prof.get('logRho')
470-
return ((10**density)**0.5)*((2.0*pi)**0.5)*conv_vel
469+
return np.log10(eps_nuc)
471470

472471
#full_kipp_plot: Uses kipp_plot but adds default decorations and default plotting options.
473472
# All options except for "contour_plots", "core_masses", "save_file" and "save_filename"
@@ -542,13 +541,6 @@ def decorated_kipp_plot(
542541
contour_cmaps = []
543542
settings = {
544543
"eps_nuc" : ["eps_nuc", default_extractor, "log", "log", "Blues"],
545-
"eps_neu" : ["eps_neu", default_extractor, "log", "log", "Purples"],
546-
"eps_nuc-eps_neu" : ["eps_nuc-eps_neu", nucneu_extractor, "log", "log", "Blues"],
547-
"Bfield" : ["Bfield", Bfield_extractor, "log", "log", "Purples"],
548-
"conv_vel" : ["log_conv_vel", default_extractor, "linear", "log", "Oranges"],
549-
"D_ST" : ["am_log_D_ST", default_extractor, "linear", "log", "Greens"],
550-
"D_DSI" : ["am_log_D_DSI", default_extractor, "linear", "log", "Oranges"],
551-
"D_ES" : ["am_log_D_ES", default_extractor, "linear", "log", "Reds"],
552544
}
553545
for contour_plot in contour_plots:
554546
identifiers.append(settings[contour_plot][0])
@@ -595,14 +587,7 @@ def decorated_kipp_plot(
595587

596588
#add colorbars
597589
labels = {
598-
"eps_nuc" : 'Nuclear Energy generation, Log (erg/g/s)',
599-
"eps_neu" :'Neutrino Losses, Log (erg/g/s)',
600-
"eps_nuc-eps_neu" : '$\epsilon_{nuc}-\epsilon_{\\nu}$, Log (erg/g/s)',
601-
"Bfield" : 'Equipartition B-Field, Log B (G)',
602-
"log_conv_vel" : 'convection velocity Log (cm/sec)',
603-
"am_log_D_ST" : 'Spruit-Tayler Dynamo, Log D (cm$^2$/s)',
604-
"am_log_D_DSI" : 'Dynamical Shear, Log D (cm$^2$/s)',
605-
"am_log_D_ES" : 'Eddington-Sweet, Log D (cm$^2$/s)'
590+
"eps_nuc" : '$\epsilon_{nuc}-\epsilon_{\\nu}$, Log (erg/g/s)',
606591
}
607592
for key, plot in plots.iteritems():
608593
bar = plt.colorbar(plot,pad=0.05)

0 commit comments

Comments
 (0)