-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add MP (train set) elem count heatmap for comparison with WBM (test s…
…et) heatmap
- Loading branch information
Showing
9 changed files
with
163 additions
and
77 deletions.
There are no files selected for viewing
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
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,95 @@ | ||
# %% | ||
import os | ||
|
||
import pandas as pd | ||
from pymatviz import count_elements, ptable_heatmap_plotly | ||
|
||
from matbench_discovery import ROOT, today | ||
|
||
module_dir = os.path.dirname(__file__) | ||
|
||
""" | ||
Compare MP and WBM elemental prevalence. Starting with WBM, MP below. | ||
""" | ||
|
||
|
||
# %% | ||
df_summary = pd.read_csv(f"{module_dir}/2022-10-19-wbm-summary.csv").set_index( | ||
"material_id" | ||
) | ||
elem_counts = count_elements(df_summary.formula).astype(int) | ||
|
||
elem_counts.to_json( | ||
f"{ROOT}/site/src/routes/about-the-test-set/{today}-wbm-element-counts.json" | ||
) | ||
|
||
|
||
# %% | ||
fig = ptable_heatmap_plotly( | ||
elem_counts, | ||
log=True, | ||
colorscale="YlGnBu", | ||
hover_props=dict(atomic_number="atomic number"), | ||
hover_data=elem_counts, | ||
font_size="1vw", | ||
) | ||
|
||
title = "WBM Elements" | ||
fig.update_layout( | ||
title=dict(text=title, x=0.35, y=0.9, font_size=20), | ||
xaxis=dict(fixedrange=True), | ||
yaxis=dict(fixedrange=True), | ||
paper_bgcolor="rgba(0,0,0,0)", | ||
) | ||
fig.show() | ||
|
||
|
||
# %% | ||
fig.write_image(f"{module_dir}/{today}-wbm-elements.svg", width=1000, height=500) | ||
# fig.write_html( | ||
# f"{module_dir}/{today}-wbm-elements.svelte", | ||
# include_plotlyjs=False, | ||
# full_html=False, | ||
# config=dict(showTips=False, displayModeBar=False, responsive=True), | ||
# ) | ||
|
||
|
||
# %% load MP training set | ||
df = pd.read_json(f"{module_dir}/../mp/2022-08-13-mp-energies.json.gz") | ||
elem_counts = count_elements(df.formula_pretty).astype(int) | ||
|
||
elem_counts.to_json( | ||
f"{ROOT}/site/src/routes/about-the-test-set/{today}-mp-element-counts.json" | ||
) | ||
elem_counts.describe() | ||
|
||
|
||
# %% | ||
fig = ptable_heatmap_plotly( | ||
elem_counts[elem_counts > 1], | ||
log=True, | ||
colorscale="YlGnBu", | ||
hover_props=dict(atomic_number="atomic number"), | ||
hover_data=elem_counts, | ||
font_size="1vw", | ||
) | ||
|
||
title = "MP Elements" | ||
fig.update_layout( | ||
title=dict(text=title, x=0.35, y=0.9, font_size=20), | ||
xaxis=dict(fixedrange=True), | ||
yaxis=dict(fixedrange=True), | ||
paper_bgcolor="rgba(0,0,0,0)", | ||
) | ||
fig.show() | ||
|
||
|
||
# %% | ||
fig.write_image(f"{module_dir}/{today}-mp-elements.svg", width=1000, height=500) | ||
|
||
# fig.write_html( | ||
# f"{module_dir}/{today}-mp-elements.svelte", | ||
# include_plotlyjs=False, | ||
# full_html=False, | ||
# config=dict(showTips=False, displayModeBar=False, responsive=True), | ||
# ) |
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
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
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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/// <reference types="mdsvex/globals" /> | ||
|
||
declare module '*.md' | ||
declare module '*package.json' |
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
1 change: 1 addition & 0 deletions
1
site/src/routes/about-the-test-set/2023-01-08-wbm-element-counts.json
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 @@ | ||
{"H":23584,"He":0,"Li":14313,"Be":1989,"B":21858,"C":13678,"N":27918,"O":150013,"F":57810,"Ne":0,"Na":13573,"Mg":25502,"Al":55485,"Si":47749,"P":25924,"S":43214,"Cl":26071,"Ar":0,"K":17952,"Ca":21697,"Sc":18533,"Ti":15680,"V":12107,"Cr":15394,"Mn":33133,"Fe":44576,"Co":38020,"Ni":47391,"Cu":43476,"Zn":32173,"Ga":45347,"Ge":49788,"As":27578,"Se":42190,"Br":22704,"Kr":0,"Rb":16884,"Sr":22328,"Y":19544,"Zr":18331,"Nb":13125,"Mo":3942,"Tc":1636,"Ru":26488,"Rh":38467,"Pd":37770,"Ag":15880,"Cd":18170,"In":44110,"Sn":43997,"Sb":20297,"Te":27842,"I":16387,"Xe":2,"Cs":14702,"Ba":21181,"La":18720,"Ce":16002,"Pr":17375,"Nd":17224,"Pm":1462,"Sm":17223,"Eu":10483,"Gd":9462,"Tb":19230,"Dy":18638,"Ho":17874,"Er":17707,"Tm":18983,"Yb":19848,"Lu":12650,"Hf":15081,"Ta":11155,"W":3761,"Re":4180,"Os":13551,"Ir":27121,"Pt":38649,"Au":28489,"Hg":10508,"Tl":16972,"Pb":20005,"Bi":12823,"Po":0,"At":0,"Rn":0,"Fr":0,"Ra":0,"Ac":1863,"Th":17945,"Pa":4051,"U":14301,"Np":10177,"Pu":13117,"Am":0,"Cm":0,"Bk":0,"Cf":0,"Es":0,"Fm":0,"Md":0,"No":0,"Lr":0,"Rf":0,"Db":0,"Sg":0,"Bh":0,"Hs":0,"Mt":0,"Ds":0,"Rg":0,"Cn":0,"Nh":0,"Fl":0,"Mc":0,"Lv":0,"Ts":0,"Og":0} |
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