{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Configuration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "See the current settings by printing the configuration class:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.............................sun2024\n", "Kd Fe-Mg ol-melt........................toplis2005\n", "Melt thermometer....................putirka2008_15\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "import MagmaPandas as mp\n", "\n", "print(mp.configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print the configuration options to see all optional settings and models currently implemented in MagmaPandas" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "############################ MagmaPandas #############################\n", "######################################################################\n", "Configuration options_________________________________________________\n", "fO2 buffers....................................................QFM, IW\n", "Melt Fe3+/Fe2+ models.............armstrong2019, borisov2018, deng2020\n", " fixed, hirschmann2022, jayasuriya2004\n", " kress_carmichael1991, oneill2006\n", " oneill2018, putirka2016_6b\n", " putirka2016_6c, sun2024, zhang2017\n", "\n", "Ol-melt Fe-Mg Kd models..............blundy2020, fixed, putirka2016_8a\n", " putirka2016_8b, putirka2016_8c\n", " putirka2016_8d, saper2022, sun2020\n", " toplis2005\n", "\n", "Melt thermometers.......................putirka2008_13, putirka2008_14\n", " putirka2008_15, putirka2008_16\n", " putirka2008_22, shea2022\n", " sugawara2000_3, sugawara2000_6a\n", " sun2020\n", "\n", "Volatile solubility models.............allison2022, iaconomarziano2012\n", " shiskina2014\n", "\n", "Volatile species.......................................co2, h2o, mixed\n", "######################################################################\n" ] } ], "source": [ "mp.configuration.available_models()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change settings by setting attribute values:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################ MagmaPandas ################\n", "#############################################\n", "General settings_____________________________\n", "fO2 buffer................................QFM\n", "ΔfO2........................................0\n", "Melt Fe3+/Fe2+................kressCarmichael\n", "Kd Fe-Mg ol-melt.......................blundy\n", "Melt thermometer...............putirka2008_15\n", "Volatile solubility model......IaconoMarziano\n", "Volatile species........................mixed\n", "#############################################\n", "\n" ] } ], "source": [ "mp.configuration.dfO2 = 0\n", "mp.configuration.Fe3Fe2_model = 'kress_carmichael1991'\n", "mp.configuration.Kd_model = 'blundy2020'\n", "\n", "print(mp.configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "MagmaPandas raises an error when invalid values are used and shows the valid options:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "ename": "ValueError", "evalue": "'some thermometer' is not recognised, please choose from: ('putirka2008_13', 'putirka2008_14', 'putirka2008_15', 'putirka2008_16', 'shea2022', 'sugawara2000_3', 'sugawara2000_6a', 'sun2020')", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconfiguration\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmelt_thermometer\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msome thermometer\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", "File \u001b[0;32m~/Dropbox/research/python/packages/MagmaPandas/src/MagmaPandas/parse_io/validate.py:60\u001b[0m, in \u001b[0;36m_check_setter..decorator..wrapper\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(var, \u001b[38;5;28mstr\u001b[39m):\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m var \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m allowed_values:\n\u001b[0;32m---> 60\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 61\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvar\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m is not recognised, please choose from: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;241m*\u001b[39mallowed_values,\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 62\u001b[0m )\n\u001b[1;32m 63\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(\u001b[38;5;241m*\u001b[39margs)\n", "\u001b[0;31mValueError\u001b[0m: 'some thermometer' is not recognised, please choose from: ('putirka2008_13', 'putirka2008_14', 'putirka2008_15', 'putirka2008_16', 'shea2022', 'sugawara2000_3', 'sugawara2000_6a', 'sun2020')" ] } ], "source": [ "mp.configuration.melt_thermometer = \"some thermometer\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For ol-melt Fe-mg Kd and melt Fe3+/Fe2+, fixed values can also be used instead of models . For setting these, you need to provide a list, or tuple, with the value and its associated error. Note that if you don't intend to use the error, you can set it to 0. The input list (or tuple) should look like `['fixed', value, error]` with positive integers or floats for `value` and `error`, e.g. `['fixed', 0.33, 0.02]` for a fixed Kd of 0.33 with a 0.02 error. When done correctly, the printed configuration shows the inputted values." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.....................fixed 0.25±0.05\n", "Kd Fe-Mg ol-melt...................fixed 0.33±0.02\n", "Melt thermometer....................putirka2008_15\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "mp.configuration.Kd_model = [\"fixed\", 0.33, 0.02]\n", "mp.configuration.Fe3Fe2_model = (\"fixed\", 0.25, 0.05)\n", "print(mp.configuration)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Reset to default values:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "################## MagmaPandas ###################\n", "##################################################\n", "General settings__________________________________\n", "fO2 buffer.....................................QFM\n", "ΔfO2.............................................1\n", "Melt Fe3+/Fe2+.............................sun2024\n", "Kd Fe-Mg ol-melt........................toplis2005\n", "Melt thermometer....................putirka2008_15\n", "Volatile solubility model.......iaconomarziano2012\n", "Volatile species.............................mixed\n", "##################################################\n", "\n" ] } ], "source": [ "mp.configuration.reset()\n", "print(mp.configuration)" ] } ], "metadata": { "kernelspec": { "display_name": "py310", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.17" } }, "nbformat": 4, "nbformat_minor": 2 }