Giter Site home page Giter Site logo

rjfarmer / mesaplot Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 4.0 11.85 MB

Library of python routines to read MESA ouput files and plot MESA quantites

License: GNU General Public License v2.0

Python 99.98% Makefile 0.02%
python mesa stars kippenhan-plot profile-plots history-data profile-data history

mesaplot's Introduction

DOI

mesaplot

Library of python routines to read MESA ouput files and plot MESA quantites

Installation instructions:

git clone the repo then call

python3 setup.py install 

Depending on choice of python version, --user can also be passed to install locally

make

Can be called as well

Testing

pytest

To run tests for current python version

tox

will run tests for several python versions

Contributing

Bug reports should go to githubs issue tracker.

Requests for new features should also got to the issue tracker.

If you wish to submit your own fix/new feature please send a pull request.

Reading data:

import mesaPlot as mp
m=mp.MESA()

Now m contains all the useful stuff

History files

m.loadHistory()

This loads up the history file data by default it will look for LOGS/history.data. But if you have a different folder to look at then you can either

m.log_fold='new_folder/LOGS/'
m.loadHistory()

or

m.loadHistory(f='new_folder/LOGS/')

Note this will automatically clean the history data of retries, backups and restarts. To write that data back to disk

m.scrubHistory()

Which will create a file "LOGS/history.data.scrubbed" if you don't want that then:

m.scrubHistory(fileOut='newFile')

Data can be accessed as m.hist.data['COLUMN_NAME'] or m.hist.COLUMN_NAME. The second option is also tab completable. The header information is either m.hist.head['COLUMN_NAME'] or m.hist.COLUMN_NAME.

Profile files

To load a profile file its:

m.loadProfile()

Again you change the LOGS folder either with log_fold or f=. To choose which file to load, either:

m.loadProfile(num=MODEL_NUMBER)
or
m.loadProfile(prof=PROFILE_NUMBER)

Where MODEL_NUMBER is a MESA model number and PROFILE_NUMBER is the number in the profile file name. You can also set a mode

m.loadProfile(num=MODEL_NUMBER,mode='first|lower|upper|nearest')

This is for when the model you want isn't in the data. Either we load the first model, the model just before the one you want, the model just after the one you want or the nearest (above or below) the model you want. There are also two special model numbers 0 for first model and a negative number that counts backwards (-1 is the last model, -2 is last but one etc)

Data can be accessed as m.prof.data['COLUMN_NAME'] or m.prof.COLUMN_NAME. The second option is also tab completable. The header information is either m.prof.head['COLUMN_NAME'] or m.prof.COLUMN_NAME.

NOTE: To speed up repeated readings of the LOG data, mesaPlot saves a binary version of the data (taking care to regenerate this file if the history/profile is updated). This binary file SHOULD NOT be depended upon for long term storage. The file format may change between versions and is not backward compatable. For long term storage allways keep the plain text history/profile file (possibly compressed to save space).

Plotting

Here we'll show the basics of plotting, there are more complex examples for each section. Commands will assume you are in a MESA work folder, such that the data is in a LOGS/ folder.

History data

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotHistory(m,xaxis='star_age',y1='log_center_T',y2='he_core_mass')

Profile data

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotProfile(m,xaxis='mass',y1='logT',y2='ye')

HR

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotHR(m)

Kippenhan's

Kippenhan plot with model number vs mass. Note all Kippenhan plots require your history file to have both mixing_regions X and burning_regions Y set in your history_columns.list file, where X and Y are integers that specify the maximum number of mixing/burning zones in your model, values around 20 will usually suffice. Models going to core collapse may want to increase this limit to 40.

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotKip(m,show_mass_loc=True)

Kippenhan plot with star age vs mass

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotKip2(m)

Generic kippenhan plotter

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotKip3(m,show_mass_loc=True)

Kippenhan plotKip3 SAGB star

New way of doing plotKip2 (star age vs mass)

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotKip3(m,xaxis='star_age',age_lookback=True,age_log=True)

Kippenhan plotKip3 SAGB star 2

Profile based kippenhans

import mesaPlot as mp

m=mp.MESA()
m.loadHistory()
m.loadProfile(num=1)
p=mp.plot()
p.plotKip3(m,plot_type='profile',xaxis='model_number',yaxis='mass',zaxis='logRho',mod_min=1,mod_max=3000)

Kippenhan plotKip3 SAGB star 3

Abundances

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotAbun(m)

Basic abundance plot

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotAbunByA(m)

Production plot

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
m2=mp.MESA()
m2.log_fold='../some/other/mesa/result'
m2.loadprofile(num=-1)
p.plotAbunByA(m,m2=m2)
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
p.set_solar('ag89')
m.loadProfile(num=-1)
#Plot the mass fractions relative to solar
p.plotAbunByA(m,stable=True)
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
p.set_solar('ag89')
m.loadProfile(num=-1)
m2=mp.MESA()
m2.log_fold='../some/other/mesa/result'
m2.loadprofile(num=-1)
#Plot the mass fractions relative to solar relative to 2nd model
p.plotAbunByA(m,m2=m2,stable=True)
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
#Use the data in the history file at model_number==model
p.plotAbunByA(m,plot_type='history',model=1000,prefix='log_center_')
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
p.set_solar('ag89')
m.loadHistory()
#Use the data in the history file, plotting relative to another model number after decaying the isotopes to thier stable versions
p.plotAbunByA(m,plot_type='history',model=1000,model2=1,prefix='surface_',stable=True)
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotAbunPAndN(m)

Nuclear abundances plot

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotAbunPAndN(m,plot_type='history',model=1000,prefix='log_center_')
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotAbunHist(m)

Burn data

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotBurn(m)
import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotBurnHist(m)

Dynamos

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotDynamo(m)

Dynamo  50M_z2m2_high_rotation

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotDyanmo2(m)

Dyanmo 2 50M_z2m2_high_rotation

Angular momentum mixing

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadProfile(num=-1)
p.plotAngMom(m)

Time series Profile plots

import mesaPlot as mp

m=mp.MESA()
m.loadHistory()
m.loadProfile(num=1)
p=mp.plot()
p.plotSliderProf(m,'plotAbun')

Passing in a string for the name of a plotting function, (only ones based on profile data). This will show that plot with a slider that can be used to iterate over the available profile files plotSliderProf will take any extra arguments passed to it and pass them to the plotting function.

Stacked plots

Multi profile plots

Grid plotting

mesaplot's People

Contributors

rjfarmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mesaplot's Issues

Latex typesetting: roman subscript in Teff.

Expected Behavior

Typesetting of the axis label for the effective temperature T_eff should probably follow common practice for typesetting and use the subscript in roman: $T_{\rm eff}$

Actual Behavior

The "eff" is now typeset in italic ( latex for e times f times f). The \rm is probably missing.
image

Steps to Reproduce the Problem

  1. Load history file
  2. p.plotHistory(m,xaxis='star_age',y1='log_center_T',y2='he_core_mass')

Specifications

  • Version: Latest
  • Platform: OSX

Link to history/profile file(s)

`model_number` misspelling in _plotAbunByA

Function _plotAbunByA has defined the model number as an input called model_number=-1, but when calling setTitle at line 1760, it uses model instead, raising an error.

Changing parametrs

Hi:

I would like to thank Dr. Farmer for giving us this great tool, it helps me a lot !

I have two questions:

About the Kippenhahn diagrams: Is it possible to change the label (sign(eps_nuc .....) How i can delete and make the helium abundance or other element ? In other words having a Kipp plot withount nuclear burning regions.

Second question about HR diagram, i copied the code on the GitHub page but i how i change the settings: make big scale, change color ...

Thanks
Abdel

plotAbunSummary() not working

Trying to call plotAbunSummary() raises the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/mesaPlot/__init__.py", line 2143, in plotAbunSummary
ValueError: need more than 0 values to unpack

which comes from calling self._listAbun(m.hist) at line 2143 of __init__.py, because the prefix is left to be the default value empty string, which for profile files works but not for history files and therefore it returns an empty list.

plotCenterAbun() does work because it assumes the prefix to be "center_". The two functions are not much different, so the best solution would probably be a single function plotAbunSummary() with the prefix as one of the inputs (setting a default to "center_", "surface_", "total_mass_"...). #

mesa plot

Hi all:
examples.tar.gz

When i try to compile writing: python3 abundances.py i get error. the path was correct but i did not know where is the issue.
screenshot from 2017-10-01 10-09-57

Thanks for your support

Kao

pip install can't find unittest

Description of problem

I just tried to install tulips and encountered this error when I tried to pip install it:

$ python3 -m pip install astro-tulips --user
...
ERROR: Could not find a version that satisfies the requirement unittest (from mesaPlot>=1.1.0->astro-tulips) (from versions: none)
ERROR: No matching distribution found for unittest (from mesaPlot>=1.1.0->astro-tulips)

I confirmed that the error is because mesaPlot requires unittest:

$ python3 -m pip install mesaPlot --user
...
ERROR: Could not find a version that satisfies the requirement unittest (from mesaPlot) (from versions: none)
ERROR: No matching distribution found for unittest (from mesaPlot)

as appears in setup.cfg:

unittest

I presume the problem is that unittest is part of the standard library and not available via PyPI.

I was able to workaround this by installing with --no-deps and installing the other dependencies manually where necessary.

Steps to Reproduce the Problem

  1. python3 -m pip install mesaplot --user

Specifications

  • Versions: mesaPlot 2.0.0, Python 3.9.7
  • Platform: Fedora 33

PS: I hope my issue is sufficiently clear without following the template...

age_lookback is broken

----> 1 p.plotKip3(m,xaxis='star_age',age_lookback=True)

File ~/.local/lib/python3.11/site-packages/mesaPlot/plot.py:5482, in plot.plotKip3(self, m, plot_type, xaxis, yaxis, zaxis, xmin, xmax, mod_min, mod_max, yrng, xstep, xlabel, ylabel, title, show, reloadHistory, ax, fig, show_mix, mix, show_burn, show_outer_mass, cmin, cmax, cmap, colorbar, cbar_label, show_mass_loc, show_mix_labels, mix_alpha, cmap_merge, age_lookback, age_log, age_reverse, age_units, end_time, age_zero, y2, y2rng, mod_index, zlog, zone_frac, num_zones, mix_hatch, hatch_color, hatch_func, zaxis_norm, yaxis_norm, y2label, y2log, zaxis_contour, zaxis_levels, y1log, dbg, cbar_ax, cpad, cbar_extend, zrng)
   5478 if show_burn:
   5479     data_z = self._getHistBurnData(
   5480         m, data_x, data_y, modInd, burn_prefix, radius
   5481     )
-> 5482     data_z = self._rebinKipDataX(data_z, data_x[modInd], lin_x)
   5483     if dbg:
   5484         print(np.nanmin(data_z), np.nanmax(data_z))

File ~/.local/lib/python3.11/site-packages/mesaPlot/plot.py:5998, in plot._rebinKipDataX(self, data, x, lin_x, nan, nan_value)
   5995 sorter = np.argsort(x)
   5996 ind = np.searchsorted(x, lin_x, sorter=sorter, side="left")
-> 5998 data = data[sorter[ind], :]
   5999 if nan:
   6000     data[data < nan_value] = np.nan

IndexError: index 6825 is out of bounds for axis 0 with size 6825

plotAbunPAndN not calling setTitle

I realized that the P and N abundance plots do not show model number or age even with show_title_age/model=True, and I could not find any call to setTitle() when checking the code.

Kippenhan in radius

Hello,

I am having an issue when trying to represent the Kippenhan diagram in radius instead of mass.
I understand that I have to add "burn_relr_regions 40" inside the history_columns.list file, but it seems to me that MESA doesn't recognise the burn_relr_regions parameter in the history_columns.list file, and returns:

bad history list name: burn_relr_regions
bad history list name: 40

Do you have an idea to solve this issue ?
Thank you very much

Specifications

  • Version:Release 11554 - Mesa

IndexError in _rebinKipqDataNoModInd

Reported by @kao25 against commit 9227dc8


I downloaded the zip file and changed the LOGS file by my results.
I had 60 columns and 60 000 lines.

When i run the code like plotKip.py i had this kind of error :

Traceback (most recent call last):
File "plotKip.py", line 11, in
p.plotKip(m,fig=fig,ax=ax,show=False)
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1849, in plotKip
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1941, in plotKip3
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 2112, in _getHistBurnData
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 2149, in _rebinKipqData
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 2159, in _rebinKipqDataNoModInd
IndexError: list index out of range

How i can fixe that please ?

Thanks


Kipp plots

Hi all: we can read more about
I am trying to plot Kippenhahn plots but (Mass VS age or time).

I took the code from:
https://github.com/rjfarmer/mesaplot

If we go down under a section Kippenhahns we can see many examples, so i created a new text file and past the following:

import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotKip2(m)
My question is how to plot a kipp plot : Mass VS Age

test.txt

#PLOT 1
oFHersheySerif
Tlx mesaPlot as mp
Tlx matplotlib.pyplot as plt
plot: an unrecognized command 0xa' was encountered in the input plot: the input file plotKip.py' could not be parsed

Thanks
Kao

setup.py can't read README.md, UTF-8 vs. ascii issue

Dear Mr. Farmer,

I am trying to install mesaPlot on my Macbook Pro, OS 10.12.6 (Sierra). I get the following error message:

[petrus-martenss-macbook-pro:~/Desktop/MESA/mesaplot-master] martens% make
python3 setup.py install --user
Traceback (most recent call last):
File "setup.py", line 13, in
long_description=read('README.md'),
File "setup.py", line 7, in read
return open(os.path.join(os.path.dirname(file), fname)).read()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
make: *** [all] Error 1

I checked the encoding of the file README.dm: it is UTF-8, and it seems setup.py expects ascii.
I tried to convert README.dm to ascii, but produces an error as well:

[petrus-martenss-macbook-pro:~/Desktop/MESA/mesaplot-master] martens% iconv -f UTF-8 -t us-ascii README.md
iconv: README.md:1:0: cannot convert

Can you help?

Thanks you very much,

Best regards,

Piet Martens

_plotAbunPAndN mass_frac_rng unexpected behaviour

I have seen that P vs N plots do not distinguish between the elements with abundances over max_col and with abundances under min_col, as all the values that are not inside mass_frac_rng are represented with an empty square. Is this behaviour intentional?

I wold expect different behaviours for elements over mass_frac_rng and beneath mass_frac_rng like being filled in black and being empty respectively or something like that.

Forgotten 'prot' check in line 1900

At _plotAbunPAndN when checking for 'neut' at line 1900, a check for 'prot' is missing. Changing the line for the following one worked for me:

if (i == 'neut' or i == 'prot'):

Failing to install

Expected Behavior

Install mesaplot

Actual Behavior

Failure:

Traceback (most recent call last):
File "setup.py", line 13, in
long_description=read('README.md'),
File "setup.py", line 7, in read
return open(os.path.join(os.path.dirname(file), fname),'r', encoding='utf-8').read()
TypeError: 'encoding' is an invalid keyword argument for this function

Steps to Reproduce the Problem

Specifications

  • Version:
  • Platform:

Link to history/profile file(s)

Typo in plotAngMom() subroutine

Calling subroutine plotAngMom() gives the error:

>>> p.plotAngMom(m)  
Traceback (most recent call last):  
  File "<stdin>", line 1, in <module>  
  File "build/bdist.linux-x86_64/egg/mesaPlot/__init__.py", line 1912, in plotAngMom  
NameError: global name 'log' is not defined

It seems to be a typo in line 1912 of "mesaPlot/__init__.py" where there is a xlog=log instead of xlog=xlog.

Array index out of bounds when generating Kippenhahn plot

Expected Behavior

Using the syntax from the documentation to read in the history.data file for a 1Msun star, I tried making a Kippenhahn plot. The code I used (Python 3.7):

import mesaPlot as mp
fig,ax = plt.subplots(figsize=(7.5*1.5,7.5))

m=mp.MESA()
m.loadHistory(f='M_1.0/LOGS1/')

p=mp.plot()


p.plotKip3(m,cmin=-1,cmax=7.5,show_mix=True, age_lookback=True, cbar_label=r'$\log\epsilon_{\rm burn}$',show_mass_loc=True, xaxis='star_age', fig=fig,ax=ax,show=False)

plt.show()

Actual Behavior

One of the indices seems to be out of bounds. The exact error message I get is:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-6-79f5c25f411a> in <module>
     
     17     # p.plotKip3(m,xaxis='star_age',age_lookback=True,age_log=True)
---> 18     p.plotKip3(m,cmin=-1,cmax=7.5,show_mix=True, age_lookback=True, cbar_label=r'$\log\epsilon_{\rm burn}$',show_mass_loc=True, xaxis='star_age', fig=fig,ax=ax,show=False)
     19 
     20     ax.set_ylim((0,ax.get_ylim()[1]))

/usr/local/lib/python3.7/dist-packages/mesaPlot-0.0-py3.7.egg/mesaPlot/plot.py in plotKip3(self, m, plot_type, xaxis, yaxis, zaxis, xmin, xmax, mod_min, mod_max, yrng, xstep, xlabel, ylabel, title, show, reloadHistory, ax, fig, show_mix, mix, show_burn, show_outer_mass, cmin, cmax, cmap, colorbar, cbar_label, show_mass_loc, show_mix_labels, mix_alpha, age_lookback, age_log, age_reverse, age_units, end_time, age_zero, y2, y2rng, mod_index, zlog, zone_frac, num_zones, mix_hatch, hatch_color, zaxis_norm, yaxis_norm, zaxis_contour, zaxis_levels, y1log, dbg)
   2093             if show_burn:
   2094                 data_z=self._getHistBurnData(m,data_x,data_y,modInd,burn_prefix,radius)
-> 2095                 data_z=self._rebinKipDataX(data_z,data_x[modInd],lin_x)
   2096                 if dbg:
   2097                     print(np.nanmin(data_z),np.nanmax(data_z))

/usr/local/lib/python3.7/dist-packages/mesaPlot-0.0-py3.7.egg/mesaPlot/plot.py in _rebinKipDataX(self, data, x, lin_x, nan, nan_value)
   2473         ind=np.searchsorted(x,lin_x,sorter=sorter,side='left')
   2474 
-> 2475         data=data[sorter[ind],:]
   2476         if nan:
   2477             data[data<nan_value]=np.nan

IndexError: index 8711 is out of bounds for axis 0 with size 8711

Steps to Reproduce the Problem

  1. Download attached history.data file in .zip
  2. Adapt the provided code to read in said file
  3. Run the code

Specifications

  • Version: master
  • Platform: Python 3.7, Jupyter lab, ubuntu 19.04

Link to history/profile file(s)

history.zip

hr plot broken

Expected Behavior

Actual Behavior

The HR part of mesaPlot doesn't seem to work:

AttributeError: 'AxesSubplot' object has no attribute 'set_prop_cycle

Steps to Reproduce the Problem

Specifications

  • Version:
  • Platform:

Link to history/profile file(s)

Plotting error

Dear Mr. Farmer:

I am trying to make a kipp plot from the python code you did. I am having trouble after compilation.

Traceback (most recent call last):
File "Abundances.py", line 5, in
p.plotKip3(m,show_mass_loc=True)
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1914, in plotKip3
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1025, in _addMixLabelsAxis
AttributeError: 'plot' object has no attribute 'mix_names'

Traceback (most recent call last):
File "plotKip.py", line 14, in
p.plotKip(m,fig=fig,ax=ax,show=False)
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1877, in plotKip
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1914, in plotKip3
File "build/bdist.linux-x86_64/egg/mesaPlot/plot.py", line 1025, in _addMixLabelsAxis
AttributeError: 'plot' object has no attribute 'mix_names'

I don't know why ? i added this lines in history column list

   mixing_regions 40
   burning_regions 40

    mx1_top
    mx1_bot
    mx2_top
    mx2_bot
    mixing_regions 20
    burning_regions 20
    mix_relr_regions 40

Thanks in advance for your help.
Kao

Docs directory missing?

Expected Behavior

The README.md has links, for example to “More on history plots”. This should be opening https://github.com/rjfarmer/mesaplot/blob/master/docs/history.md

Actual Behavior

Clicking the link gives a 404 error. It looks like the docs file and its content are not part of the repo.

Steps to Reproduce the Problem

  1. go to online version of Readme.md 1 as shown on https://github.com/rjfarmer/mesaplot
  2. click on link “More on history plots” (or any of the others)

Specifications

  • Platform: Mac, using Chrome

Bug in _listAbun() function

I checked how did _listAbun() worked trying to sort out issue #3 and i came across the following problem:

>>> p._listAbun(m.hist,prefix='center_')
['center_h1', 'center_he4', 'center_c12', 'center_n14', 'center_o16', 'center_ne20', 
'center_si28', 'center_s32', 'center_ar36', 'center_ca40', 'center_ti44', 'center_ti50', 
'center_ti52', 'center_cr48', 'center_cr54', 'center_cr56', 'center_fe52', 'center_fe54', 
'center_fe56', 'center_fe58', 'center_fe60', 'center_ni56', 'center_ni58', 'center_ni60', 
'center_ni62', 'center_ni64', 'center_zn68', 'center_ge72']
>>> p._listAbun(m.hist,prefix='surface_')
['surface_he4', 'surface_c12', 'surface_n14', 'surface_o16', 'surface_c13', 'surface_o17', 
'surface_o18', 'surface_f19', 'surface_e4', 'surface_e20', 'surface_i28', 'surface_r36', 
'surface_a40', 'surface_i44', 'surface_i50', 'surface_i52', 'surface_r48', 'surface_r54', 
'surface_r56', 'surface_e52', 'surface_e54', 'surface_e56', 'surface_e58', 'surface_e60', 
'surface_i56', 'surface_i58', 'surface_i60', 'surface_i62', 'surface_i64', 'surface_n68', 
'surface_e72']

As it can be seen, my file has both surface_element and center_element columns and getting the ones with prefix "center_" gives no problem but when the prefix is surface, the second letters of the elements that have two letters and its atomic mass are taken as an element ('e4' for 'he4', 'e20' for 'ne20'...).

Is there a reason why something similar to the following code that checks if the label is a stable isotope is not used?

...
names=data.data_names
for j in names:
    i=j[len(prefix):]
    isAbun=False
    if i in self.stable_isos:
        isAbun=True
    if isAbun and j[:len(prefix)]==prefix:
        abun_list.append(j)
...

plotAbun xaxis error

I tried to plot abundance profiles using log(1-q) as the xaxis value using plotAbun() and I encountered an error. I then tried the same commands on the profile17.data found in the examples/ directory with the following result:

>>> import mesaPlot as mp
>>> m=mp.MESA()
>>> p=mp.plot()
>>> m.loadProfile(num=-1)
LOGS//profile17.data
>>> p.plotAbun(m,xaxis='logxq')
/usr/local/lib/python2.7/dist-packages/mesaPlot-0.0-py2.7.egg/mesaPlot/__init__.py:1287: RuntimeWarning: divide by zero encountered in log10
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/mesaPlot/__init__.py", line 1455, in plotAbun
  File "build/bdist.linux-x86_64/egg/mesaPlot/__init__.py", line 1306, in _plotAnnotatedLine
  File "build/bdist.linux-x86_64/egg/mesaPlot/__init__.py", line 911, in _annotateLine
  File "/usr/lib/python2.7/dist-packages/scipy/interpolate/polyint.py", line 54, in __call__
    y = self._evaluate(x)
  File "/usr/lib/python2.7/dist-packages/scipy/interpolate/interpolate.py", line 448, in _evaluate
    out_of_bounds = self._check_bounds(x_new)
  File "/usr/lib/python2.7/dist-packages/scipy/interpolate/interpolate.py", line 475, in _check_bounds
    raise ValueError("A value in x_new is below the interpolation "
ValueError: A value in x_new is below the interpolation range.

I took a look at the code and I thought the problem would be because of the negative values in the x axis so I tried the following:

p.plotAbun(m,xaxis='logxq',xmin=0,xmax=-5)

Inverting the axis did not raise ValueError any longer but the result had no longer annotated lines:
abun_logxq
I changed the axis to [50,-150] too to check that they actually were not there and no only not visible.

fix show mass loc

c_core_mass and friends got renamed so they need updating in show_mass_loc.

codes running

Hello guys:

I have 2 questions:

I used the KIpps plot and worked perfectly, but the only issue is for the section plotting:

The error concerning the abundances.py


Traceback (most recent call last):
File "abundances.py", line 9, in
m.loadHistory()
File "build/bdist.linux-x86_64/egg/mesaPlot/file_reader.py", line 171, in loadHistory
File "build/bdist.linux-x86_64/egg/mesaPlot/file_reader.py", line 87, in loadFile
File "build/bdist.linux-x86_64/egg/mesaPlot/file_reader.py", line 114, in _filelines
IOError: [Errno 2] No such file or directory: '/home/ibiza/mesaplot-master/examples/LOGS/history.data'


The code for the abundances:

#import mesaPlot as mp
import matplotlib.pyplot as plt
m=mp.MESA()
m.log_fold='/home/ibiza/mesaplot-master/examples/LOGS/'
m.loadHistory()
m.loadProfile(num=-1)
p=mp.plot()
#Simply plot
p.plotAbun(m)
#Advanced
fig=plt.figure(figsize=(12,12))
ax=fig.add_subplot(111)
p.plotAbun(m,num_labels=6,rand_col=True,y1rng=[-6.5,0.5],show_title_model=True,show_title_age=True,fig=fig,ax=ax,
xmax=5.0)

Abundace as function of atomic mass

fig=plt.figure(figsize=(12,12))
ax=fig.add_subplot(111)
p.plotAbunByA(m,mass_range=[0.0,5.0],fig=fig,ax=ax)

Abundance as a function of proton and neutron number

fig=plt.figure(figsize=(12,12))
ax=fig.add_subplot(111)
p.plotAbunPAndN(m,mass_range=[0.0,5.0],mass_frac_rng=[10**-5,1.0],fig=fig,ax=ax).

Under the section Plotting we have : History data and It contains this code:


import mesaPlot as mp
m=mp.MESA()
p=mp.plot()
m.loadHistory()
p.plotHistory(m,xaxis='star_age',y1='log_center_T',y2='he_core_mass')


I paste it in a text file and when i run it, i got a good plot but i can not change anything, no colors or scale.

How i can do it ? and can we save the plots on a pdf or JPEG because i did not saw save button
age

Thanks so much for sharing with the community this tools.

Best regards
Zabana

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.