|
5 | 5 | from pymatviz import count_elements, ptable_heatmap_plotly
|
6 | 6 | from pymatviz.utils import save_fig
|
7 | 7 |
|
8 |
| -from matbench_discovery import ROOT, today |
| 8 | +from matbench_discovery import FIGS, today |
| 9 | +from matbench_discovery.data import df_wbm |
9 | 10 |
|
10 | 11 | module_dir = os.path.dirname(__file__)
|
11 | 12 |
|
|
15 | 16 |
|
16 | 17 |
|
17 | 18 | # %%
|
18 |
| -df_summary = pd.read_csv(f"{module_dir}/2022-10-19-wbm-summary.csv").set_index( |
19 |
| - "material_id" |
20 |
| -) |
21 |
| -elem_counts = count_elements(df_summary.formula).astype(int) |
| 19 | +wbm_elem_counts = count_elements(df_wbm.formula).astype(int) |
22 | 20 |
|
23 |
| -elem_counts.to_json( |
24 |
| - f"{ROOT}/site/src/routes/about-the-test-set/{today}-wbm-element-counts.json" |
25 |
| -) |
| 21 | +# wbm_elem_counts.to_json( |
| 22 | +# f"{ROOT}/site/src/routes/about-the-test-set/{today}-wbm-element-counts.json" |
| 23 | +# ) |
26 | 24 |
|
27 | 25 |
|
28 | 26 | # %%
|
29 |
| -fig = ptable_heatmap_plotly( |
30 |
| - elem_counts, |
| 27 | +wbm_fig = ptable_heatmap_plotly( |
| 28 | + wbm_elem_counts.drop("Xe"), |
31 | 29 | log=True,
|
32 |
| - colorscale="YlGnBu", |
| 30 | + colorscale="RdBu", |
33 | 31 | hover_props=dict(atomic_number="atomic number"),
|
34 |
| - hover_data=elem_counts, |
35 |
| - font_size="1vw", |
| 32 | + hover_data=wbm_elem_counts, |
36 | 33 | )
|
37 | 34 |
|
38 | 35 | title = "WBM Elements"
|
39 |
| -fig.update_layout( |
| 36 | +wbm_fig.update_layout( |
40 | 37 | title=dict(text=title, x=0.35, y=0.9, font_size=20),
|
41 | 38 | xaxis=dict(fixedrange=True),
|
42 | 39 | yaxis=dict(fixedrange=True),
|
43 | 40 | paper_bgcolor="rgba(0,0,0,0)",
|
44 | 41 | )
|
45 |
| -fig.show() |
| 42 | +wbm_fig.show() |
46 | 43 |
|
47 | 44 |
|
48 | 45 | # %%
|
49 |
| -fig.write_image(f"{module_dir}/{today}-wbm-elements.svg", width=1000, height=500) |
50 |
| -save_fig(fig, f"{module_dir}/{today}-wbm-elements.svelte") |
| 46 | +wbm_fig.write_image( |
| 47 | + f"{module_dir}/figs/{today}-wbm-elements.svg", width=1000, height=500 |
| 48 | +) |
| 49 | +save_fig(wbm_fig, f"{FIGS}/{today}-wbm-elements.svelte") |
51 | 50 |
|
52 | 51 |
|
53 | 52 | # %% load MP training set
|
54 | 53 | df = pd.read_json(f"{module_dir}/../mp/2022-08-13-mp-energies.json.gz")
|
55 |
| -elem_counts = count_elements(df.formula_pretty).astype(int) |
| 54 | +mp_elem_counts = count_elements(df.formula_pretty).astype(int) |
56 | 55 |
|
57 |
| -elem_counts.to_json( |
58 |
| - f"{ROOT}/site/src/routes/about-the-test-set/{today}-mp-element-counts.json" |
59 |
| -) |
60 |
| -elem_counts.describe() |
| 56 | +# mp_elem_counts.to_json( |
| 57 | +# f"{ROOT}/site/src/routes/about-the-test-set/{today}-mp-element-counts.json" |
| 58 | +# ) |
| 59 | +mp_elem_counts.describe() |
61 | 60 |
|
62 | 61 |
|
63 | 62 | # %%
|
64 |
| -fig = ptable_heatmap_plotly( |
65 |
| - elem_counts[elem_counts > 1], |
| 63 | +mp_fig = ptable_heatmap_plotly( |
| 64 | + mp_elem_counts[mp_elem_counts > 1], |
66 | 65 | log=True,
|
67 |
| - colorscale="YlGnBu", |
| 66 | + colorscale="RdBu", |
68 | 67 | hover_props=dict(atomic_number="atomic number"),
|
69 |
| - hover_data=elem_counts, |
70 |
| - font_size="1vw", |
| 68 | + hover_data=mp_elem_counts, |
71 | 69 | )
|
72 | 70 |
|
73 | 71 | title = "MP Elements"
|
74 |
| -fig.update_layout( |
| 72 | +mp_fig.update_layout( |
75 | 73 | title=dict(text=title, x=0.35, y=0.9, font_size=20),
|
76 | 74 | xaxis=dict(fixedrange=True),
|
77 | 75 | yaxis=dict(fixedrange=True),
|
78 | 76 | paper_bgcolor="rgba(0,0,0,0)",
|
79 | 77 | )
|
80 |
| -fig.show() |
| 78 | +mp_fig.show() |
81 | 79 |
|
82 | 80 |
|
83 | 81 | # %%
|
84 |
| -fig.write_image(f"{module_dir}/{today}-mp-elements.svg", width=1000, height=500) |
85 |
| -save_fig(fig, f"{module_dir}/{today}-mp-elements.svelte") |
| 82 | +mp_fig.write_image(f"{module_dir}/figs/{today}-mp-elements.svg", width=1000, height=500) |
| 83 | +# save_fig(mp_fig, f"{FIGS}/{today}-mp-elements.svelte") |
0 commit comments