PennyWieser / PySulfSat

Python tools for modelling sulfide saturation in magmas
MIT License
4 stars 2 forks source link

Running calculations on a single sample #7

Open kaylai opened 7 months ago

kaylai commented 7 months ago

Is it possible to run a calculation on a single sample rather than a pandas dataframe? I'd like to use PySulfSat in some code I am working on, in which an SCSS calculation is called periodically by other routines. Unless I am mistaken, the current implementation of PySulfSat would require that I put my sample composition into an appropriately styled pandas dataframe each time I want to do an SCSS calculation, which is a bit cumbersome. Is there a current implementation for single samples that I missed?

If the answer is that you must use a dataframe, is there a danger or loss of functionality passing in a self-made dataframe rather than importing a file (e.g., does the import of a file create an object that has other attributes)?

PennyWieser commented 7 months ago

That isnt supported at present - I used dataframes because at the time of making I was more focused on applying it to 1000s of rows of data vs. a single composition as needed for a degassing model.

The most straightforward thing to do for now would be to pass it into the dataframe format I use. If this creates a significant speed penalty I can try to edit the code.

The import function is called import_dataframe and is in the import_data.py file.

The code uses these columns (which can be filled with 0s if not present).

df_ideal_liq = pd.DataFrame(columns=['SiO2_Liq', 'TiO2_Liq', 'Al2O3_Liq', 'FeOt_Liq', 'MnO_Liq', 'MgO_Liq', 'CaO_Liq', 'Na2O_Liq', 'K2O_Liq', 'P2O5_Liq', 'H2O_Liq', 'Fe3Fet_Liq', 'Ni_Liq_ppm', 'Cu_Liq_ppm'])

Not all the models use all these columns.

Any other columns are kept but ignored. At present the output is appended onto the input dataframe, but that would be an easy fix to have an option to return a pandas.Series or even just a float if you wanted that instead