-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
portal: add screening_inorganic_pv notebook
- Loading branch information
Showing
1 changed file
with
147 additions
and
0 deletions.
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
mpcontribs-portal/notebooks/contribs.materialsproject.org/screening_inorganic_pv.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os, json\n", | ||
"from pathlib import Path\n", | ||
"from pandas import DataFrame\n", | ||
"from mpcontribs.client import Client" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"client = Client()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Load raw data**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"name = \"screening_inorganic_pv\"\n", | ||
"indir = Path(\"/Users/patrick/gitrepos/mp/mpcontribs-data/ThinFilmPV\")\n", | ||
"files = {\n", | ||
" \"summary\": \"SUMMARY.json\",\n", | ||
" \"absorption\": \"ABSORPTION-CLIPPED.json\",\n", | ||
" \"dos\": \"DOS.json\",\n", | ||
" \"formulae\": \"FORMATTED-FORMULAE.json\"\n", | ||
"}\n", | ||
"data = {}\n", | ||
"\n", | ||
"for k, v in files.items():\n", | ||
" path = indir / v\n", | ||
" with path.open(mode=\"r\") as f:\n", | ||
" data[k] = json.load(f)\n", | ||
" \n", | ||
"for k, v in data.items():\n", | ||
" print(k, len(v))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Prepare contributions**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"config = {\n", | ||
" \"SLME_500_nm\": {\"path\": \"SLME.500nm\", \"unit\": \"%\"},\n", | ||
" \"SLME_1000_nm\": {\"path\": \"SLME.1000nm\", \"unit\": \"%\"},\n", | ||
" \"E_g\": {\"path\": \"ΔE.corrected\", \"unit\": \"eV\"},\n", | ||
" \"E_g_d\": {\"path\": \"ΔE.direct\", \"unit\": \"eV\"},\n", | ||
" \"E_g_da\": {\"path\": \"ΔE.dipole-allowed\", \"unit\": \"eV\"},\n", | ||
" \"m_e\": {\"path\": \"mᵉ\", \"unit\": \"mₑ\"},\n", | ||
" \"m_h\": {\"path\": \"mʰ\", \"unit\": \"mₑ\"}\n", | ||
"}\n", | ||
"contributions = []\n", | ||
"\n", | ||
"for mp_id, d in data[\"summary\"].items():\n", | ||
" print(mp_id)\n", | ||
" formula = data[\"formulae\"][mp_id].replace(\"<sub>\", \"\").replace(\"</sub>\", \"\")\n", | ||
" contrib = {\"project\": name, \"identifier\": mp_id, \"data\": {\"formula\": formula}, \"tables\": []}\n", | ||
"\n", | ||
" for k, v in config.items():\n", | ||
" contrib[\"data\"][v[\"path\"]] = f'{d[k]} {v[\"unit\"]}'\n", | ||
" \n", | ||
" df = DataFrame(data=data[\"absorption\"][mp_id])\n", | ||
" df.columns = [\"hν [eV]\", \"α [cm⁻¹]\"]\n", | ||
" df.set_index(\"hν [eV]\", inplace=True)\n", | ||
" #df.columns.name = columns_name # legend name\n", | ||
" df.attrs[\"name\"] = \"absorption\" # -> used as title by default\n", | ||
" #df.attrs[\"title\"] = f'{title_prefix} of {doping_type}-type {titles[nm]}'\n", | ||
"# df.attrs[\"labels\"] = {\n", | ||
"# \"value\": f'{nm}({doping_type}) [{u}]', # y-axis label\n", | ||
"# #\"variable\": columns_name # alternative for df.columns.name\n", | ||
"# }\n", | ||
" contrib[\"tables\"].append(df)\n", | ||
"\n", | ||
"# # df = DataFrame(data=dos_data[mp_id])\n", | ||
"# # df.columns = ['E [eV]', 'DOS [eV⁻¹]']\n", | ||
"\n", | ||
" contributions.append(contrib)\n", | ||
" break\n", | ||
" \n", | ||
"len(contributions)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Submit contributions**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"client.submit_contributions(contributions)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.8.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |