News:

alphaMELTS 2.3 standalone & for MATLAB/Python is now open source and available on GitHub (https://github.com/magmasource/alphaMELTS).
alphaMELTS 1.9 is available at the legacy download and information site.
For news of all MELTS software see the MELTS Facebook page.

Main Menu

KeyError: 'plagioclase_2' in MELTS_Matlab/Python

Started by Cambrian, October 02, 2023, 01:24:31 AM

Previous topic - Next topic

Cambrian

Hi,  Paula:
When I run the tutorial.py file in package folder of MELTS_Matlab/Python, the terminal prompts an error as shown in the following. How should I modify the Python code to make it work.
Thanks.


Current state of the system recorded in _tbl.txt files.
Successful run.  No errors.
Setting calculation mode to rhyolite-MELTS 1.0.2.
MELTS:libraryAlreadyInitialized. Could not re-initialize MELTS library! Please check stderr (console or terminal). If there are any error messages, please save your work and reload Python; otherwise you should be able to continue, with caution...
Traceback (most recent call last):
  File "/home/wanghai/alphaMELTS/MELTS_Matlab-master/package/tutorial.py", line 122, in <module>
    melts.engine.calcEndMemberProperties(phaseList, plag[:, indices])
  File "/home/wanghai/alphaMELTS/MELTS_Matlab-master/package/meltsengine.py", line 890, in calcEndMemberProperties
    self.activity[phaseName] = None
KeyError: 'plagioclase_2'

Paula

Make sure you have the latest version of everything. The copy of tutorial.py that's up there at the moment has a comment on line 122, so it sounds like you have a slightly older version.

More generally a key error may mean you've tried to get the properties of a phase that isn't present, so you can try wrapping the relevant code in an if block or a try.. except block. The MELTS:libraryAlreadyInitialized message is more of a caution than a critical error.

Paula

Cambrian

Thank you for your prompt reply, I will try again after all the updates.