MELTS Software Users

MELTS for Excel, rhyolite-MELTS (GUI) and alphaMELTS => alphaMELTS 2 Home => alphaMELTS for MATLAB/Python => Topic started by: Cambrian on October 02, 2023, 01:24:31 AM

Title: KeyError: 'plagioclase_2' in MELTS_Matlab/Python
Post by: Cambrian on October 02, 2023, 01:24:31 AM
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'
Title: Re: KeyError: 'plagioclase_2' in MELTS_Matlab/Python
Post by: Paula on October 02, 2023, 08:39:22 AM
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
Title: Re: KeyError: 'plagioclase_2' in MELTS_Matlab/Python
Post by: Cambrian on October 03, 2023, 06:10:11 PM
Thank you for your prompt reply, I will try again after all the updates.