{"id":19459545,"url":"https://github.com/elcarrillo/magma-project","last_synced_at":"2025-10-05T07:57:13.661Z","repository":{"id":183868021,"uuid":"461656074","full_name":"elcarrillo/magma-project","owner":"elcarrillo","description":"python scripts to analyze and plot petrological data","archived":false,"fork":false,"pushed_at":"2024-07-02T03:54:29.000Z","size":1494,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T21:51:09.057Z","etag":null,"topics":["computational-science","magma","python3","volcanoes","volcanology"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elcarrillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-21T00:37:09.000Z","updated_at":"2024-08-02T23:15:48.000Z","dependencies_parsed_at":"2025-05-31T10:46:02.414Z","dependency_job_id":"beac76b1-eb5d-4a90-a025-e591a46eaaba","html_url":"https://github.com/elcarrillo/magma-project","commit_stats":null,"previous_names":["elcarrillo/magma-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elcarrillo/magma-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcarrillo%2Fmagma-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcarrillo%2Fmagma-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcarrillo%2Fmagma-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcarrillo%2Fmagma-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elcarrillo","download_url":"https://codeload.github.com/elcarrillo/magma-project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcarrillo%2Fmagma-project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264092853,"owners_count":23556399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-science","magma","python3","volcanoes","volcanology"],"created_at":"2024-11-10T17:33:00.246Z","updated_at":"2025-10-05T07:57:08.629Z","avatar_url":"https://github.com/elcarrillo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magma Project \n\n\nThis repository contains scripts and data for plotting chemical compositions of various lava samples. The scripts load data from Excel files, process it, and generate scatter plots to visualize the liquid lines of descent for different samples.\n\n\n\n![Lava Flow](images/stock_volcano.jpg)\n\n\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Project Structure](#project-structure)\n- [Sample Usage](#scripts)\n- [Sample Data](#data)\n- [License](#license)\n\n## Installation\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/elcarrillo/magma-project.git\n    cd magma-project\n    ```\n\n## Project Structure\n\n```\nmagma-project/\n│\n├── README.md                                # Project documentation\n├── vol_mol_conv.py                          # Volume to mole conversion script\n├── p2_plots.py                              # Main script for plotting chemical compositions\n├── hat_creek.py                             # Auxiliary script for plotting Hat Creek data\n├── lit_data.xlsx                            # Excel file containing compiled data\n├── EES4891-Spr2022-M\u0026E-Problem2-Literature_data.xlsx  # Compiled data from various sources\n├── EES4891-Spr2022-M\u0026E-Problem2-Hat_Creek.xlsx        # Compiled data for Hat Creek\n├── EES4891-Spr2022-M\u0026E-Problem2-problem1.xlsx         # Equations and parameters\n├── crystal_dynamics_in_melts.pdf            # Crystal dynamics in melts report\n├── p_v.py                                   # Script for pressure vs volume calculations\n└── sample_plots/                            # Directory containing sample plots\n    ├── sample1.png                            # Example plot 1\n    ├── sample2.png                            # Example plot 2\n    └── sample3.png                            # Example plot 3\n\n```\n\n## Sample Usage \n\n\nTo generate the plots, simply run the `p2_plots.py` script:\n```bash\npython p2_plots.py\n```\n\nMake sure the `lit_data.xlsx` file is in the same directory as the script or update the file path accordingly.\n\n### p2_plots.py\n\nThis script performs the following steps:\n1. Loads data from multiple sheets in an Excel file.\n2. Extracts relevant chemical composition data for each sample.\n3. Generates scatter plots to visualize the liquid lines of descent.\n\n#### Functions:\n\n- `load_data(sheet_name)`: Loads data from the specified sheet in the Excel file.\n- `extract_columns(df)`: Extracts relevant columns from the dataframe, handling missing columns.\n\n#### Usage:\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\ndef load_data(sheet_name):\n    \"\"\"Load data from the specified sheet in the Excel file.\"\"\"\n    return pd.read_excel('lit_data.xlsx', sheet_name=sheet_name)\n\ndef extract_columns(df):\n    \"\"\"Extract relevant columns from the dataframe, handling missing columns.\"\"\"\n    columns = ['SiO2', 'TiO2', 'Al2O3', 'FeO', 'MgO', 'MnO', 'CaO', 'Na2O', 'K2O']\n    extracted = {col: df[col] for col in columns}\n    if 'FeO/MgO' in df.columns:\n        extracted['FeO/MgO'] = df['FeO/MgO']\n    else:\n        extracted['FeO/MgO'] = pd.Series([np.nan] * len(df), index=df.index)\n    return extracted\n\n# Load data from all sheets\nsheets = ['Sheet0', 'Sheet1', 'Sheet2', 'Sheet3', 'Sheet4', 'Sheet5']\ndata_frames = {sheet: extract_columns(load_data(sheet)) for sheet in sheets}\n\n# Plot settings\nlabels = ['hat', 'seg', 'thing', 'new(TNC)', 'new(CA)', 'aug']\ncolors = ['b', 'g', 'r', 'c', 'm', 'y']\nelements = ['TiO2', 'Al2O3', 'MnO', 'MgO', 'FeO', 'CaO', 'FeO/MgO', 'Na2O', 'K2O']\n\nfigure, axis = plt.subplots(4, 2, figsize=(10, 10))\n\n# Plot data\nfor idx, (ax, element) in enumerate(zip(axis.flatten(), elements)):\n    for label, color, (sheet, df) in zip(labels, colors, data_frames.items()):\n        if not df[element].isnull().all():\n            ax.scatter(df['SiO2'], df[element], label=label if idx == 0 else \"\", color=color, alpha=0.5)\n            ax.set_ylabel(f\"{element} %\")\n    if idx \u003e= len(elements) - 2:\n        ax.set_xlabel(\"SiO2 %\")\n    ax.grid()\n\n# Add legend to the first subplot only\naxis[0, 0].legend(loc='upper right')\n\nplt.suptitle(\"Liquid lines of descent\", fontsize=15)\nfigure.tight_layout()\nplt.show()\n```\n\n## Sample Data\n\n### lit_data.xlsx\n\nThis Excel file contains the chemical composition data for different lava samples. Each sheet in the file corresponds to a different sample set:\n- `Sheet0`: Hat Creek data\n- `Sheet1`: Seguam data\n- `Sheet2`: Thing data\n- `Sheet3`: New (TNC) data\n- `Sheet4`: New (CA) data\n- `Sheet5`: Aug data\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcarrillo%2Fmagma-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felcarrillo%2Fmagma-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcarrillo%2Fmagma-project/lists"}