@@ -77,7 +77,8 @@ def __init__(self,
77
77
decorate_plot = True ,
78
78
show_plot = False ,
79
79
save_file = True ,
80
- save_filename = "Kippenhahn.png" ):
80
+ save_filename = "Kippenhahn.png" ,
81
+ xlims = None ):
81
82
"""Initializes properties for a Kippenhahn plot
82
83
83
84
Note:
@@ -124,12 +125,11 @@ def __init__(self,
124
125
show_plot (bool): If True, pyplot.show() is ran at the end
125
126
save_file (bool): If True, plot is saved after pyplot.show()
126
127
save_filename (str): Filename to save plot. Extension determines filetype.
128
+ xlims (Tuple(float)): range in x to which the loaded data is restricted. By default all data is loaded
127
129
128
130
"""
129
131
130
132
self .logs_dirs = logs_dirs
131
- self .profile_paths = profile_paths
132
- self .history_paths = history_paths
133
133
self .clean_data = clean_data
134
134
self .extra_history_cols = extra_history_cols
135
135
self .identifier = identifier
@@ -158,11 +158,26 @@ def __init__(self,
158
158
self .show_plot = show_plot
159
159
self .save_file = save_file
160
160
self .save_filename = save_filename
161
+ self .xlims = xlims
162
+
163
+ #Fill profile and history names if unspecified
164
+ self .profile_paths = profile_paths
165
+ if len (self .profile_paths ) == 0 :
166
+ self .profile_paths = get_profile_paths (logs_dirs = self .logs_dirs )
167
+
168
+ self .history_paths = history_paths
169
+ if len (self .history_paths ) == 0 :
170
+ self .history_paths = []
171
+ for log_dir in self .logs_dirs :
172
+ self .history_paths .append (log_dir + "/history.data" )
173
+
174
+ self .xyz_data = get_xyz_data (self .profile_paths , self , xlims = xlims )
175
+ self .mixing_zones = get_mixing_zones (self .history_paths , self , xlims = xlims )
161
176
162
177
163
178
#kipp_plot: Plots a Kippenhahn diagram into the matplotlib axis given. No decoration
164
179
# done (i.e. axis labeling or colorbars). Returns
165
- def kipp_plot (kipp_args , axis = None , xlims = None ):
180
+ def kipp_plot (kipp_args , axis = None ):
166
181
xaxis_divide = kipp_args .xaxis_divide
167
182
if kipp_args .xaxis == "star_age" :
168
183
if kipp_args .time_units == "1000 yr" :
@@ -176,17 +191,7 @@ def kipp_plot(kipp_args, axis=None, xlims = None):
176
191
fig = plt .figure ()
177
192
axis = fig .gca ()
178
193
179
- #Fill profile and history names if unspecified
180
- profile_paths = kipp_args .profile_paths
181
- if len (profile_paths ) == 0 :
182
- profile_paths = get_profile_paths (logs_dirs = kipp_args .logs_dirs )
183
- history_paths = kipp_args .history_paths
184
- if len (history_paths ) == 0 :
185
- history_paths = []
186
- for log_dir in kipp_args .logs_dirs :
187
- history_paths .append (log_dir + "/history.data" )
188
-
189
- xyz_data = get_xyz_data (profile_paths , kipp_args , xlims = xlims )
194
+ xyz_data = kipp_args .xyz_data
190
195
191
196
#only plot if there is data
192
197
if xyz_data .Z .size > 0 :
@@ -207,9 +212,7 @@ def kipp_plot(kipp_args, axis=None, xlims = None):
207
212
contour_plot = axis .contourf ([[None ,None ]], [[None ,None ]], [[None ,None ]], \
208
213
cmap = kipp_args .contour_colormap , antialiased = False )
209
214
210
-
211
- mixing_zones = get_mixing_zones (history_paths , kipp_args , xlims = xyz_data .xlims )
212
-
215
+ mixing_zones = kipp_args .mixing_zones
213
216
214
217
for i ,zone in enumerate (mixing_zones .zones ):
215
218
color = ""
@@ -289,8 +292,8 @@ def kipp_plot(kipp_args, axis=None, xlims = None):
289
292
else :
290
293
axis .set_ylabel (r'$m/M_\odot$' )
291
294
292
- if xlims != None :
293
- axis .set_xlim (xlims )
295
+ if kipp_args . xlims != None :
296
+ axis .set_xlim (kipp_args . xlims )
294
297
295
298
if kipp_args .show_plot :
296
299
plt .show ()
0 commit comments