Skip to content

Commit

Permalink
merge old stash for notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Apr 5, 2024
1 parent 7113870 commit 29c0e49
Show file tree
Hide file tree
Showing 3 changed files with 413 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "civic-criterion",
"id": "aggressive-medication",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -90,11 +90,15 @@
" \"category\": {\"name\": \"workflow.category\", \"unit\": None}, # dynamic\n",
" \"distortion.dmax\": {\"name\": \"distortion.dmax.before\", \"unit\": \"\"},\n",
" \"calculated_max_distance\": {\"name\": \"distortion.dmax.after\", \"unit\": \"\"},\n",
" \"nonpolar_band_gap\": {\"name\": \"nonpolar.bandgap\", \"unit\": \"eV\"},\n",
"# \"distortion.delta\": {\"name\": \"distortion.delta\", \"unit\": \"\"},\n",
"# \"distortion.dav\": {\"name\": \"distortion.dav\", \"unit\": \"\"},\n",
"# \"distortion.s\": {\"name\": \"distortion.s\", \"unit\": \"\"},\n",
" \"bandgaps\": {\"name\": \"bandgap\", \"unit\": \"eV\"},\n",
"# \"nonpolar_band_gap\": {\"name\": \"nonpolar.bandgap\", \"unit\": \"eV\"},\n",
" \"nonpolar_icsd\": {\"name\": \"nonpolar.icsd\", \"unit\": \"\"},\n",
" \"nonpolar_id\": {\"name\": \"nonpolar.mpid\", \"unit\": None},\n",
" \"nonpolar_spacegroup\": {\"name\": \"nonpolar.spacegroup\", \"unit\": \"\"},\n",
" \"polar_band_gap\": {\"name\": \"polar.bandgap\", \"unit\": \"eV\"},\n",
"# \"polar_band_gap\": {\"name\": \"polar.bandgap\", \"unit\": \"eV\"},\n",
" \"polar_icsd\": {\"name\": \"polar.icsd\", \"unit\": \"\"},\n",
" \"polar_id\": {\"name\": \"polar.mpid\", \"unit\": None},\n",
" \"polar_spacegroup\": {\"name\": \"polar.spacegroup\", \"unit\": \"\"}, \n",
Expand Down Expand Up @@ -140,7 +144,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "normal-argentina",
"id": "restricted-influence",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -160,11 +164,12 @@
" conf = columns.get(k)\n",
" if conf:\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" contribs_distortions[key][\"data\"][name] = f\"{v} {unit}\" if unit else v\n",
"# elif isinstance(v, dict) and \"@class\" in v and v[\"@class\"] == \"Structure\":\n",
"# structure = Structure.from_dict(v)\n",
"# structure.name = k\n",
"# contribs_distortions[key][\"structures\"].append(structure)\n",
" dec = conf.get('dec', '')\n",
" contribs_distortions[key][\"data\"][name] = f\"{float(v):{dec}} {unit}\" if unit else v\n",
"# elif isinstance(v, dict) and \"@class\" in v and v[\"@class\"] == \"Structure\":\n",
"# structure = Structure.from_dict(v)\n",
"# structure.name = k\n",
"# contribs_distortions[key][\"structures\"].append(structure)\n",
" \n",
"# attm = Attachment.from_data(\"distortion\", distortion)\n",
"# contribs_distortions[key][\"attachments\"].append(attm)"
Expand All @@ -185,7 +190,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "leading-tanzania",
"id": "mediterranean-appointment",
"metadata": {
"lines_to_next_cell": 2
},
Expand Down Expand Up @@ -215,39 +220,44 @@
"# contrib[\"structures\"].append(structure)\n",
" \n",
" for k, v in flatten(wf, reducer=\"dot\").items():\n",
" if k.startswith('polarization') and isinstance(v, list):\n",
" conf = columns.get(k)\n",
" if conf:\n",
" name, fields = conf[\"name\"], conf[\"fields\"]\n",
" contrib[\"data\"].setdefault(name, {})\n",
" if not \"unit\" in conf:\n",
" vmax, unit = max(v), fields[\"max\"]\n",
" contrib[\"data\"][name]['max'] = f\"{vmax} {unit}\" \n",
" contrib[\"data\"][name]['index'] = v.index(vmax)\n",
" else:\n",
" unit = conf[\"unit\"]\n",
" contrib[\"data\"][name] = {\n",
" i: f\"{j} {unit}\"\n",
" for i, j in zip(conf[\"fields\"], v[0])\n",
" }\n",
" elif k == 'energies':\n",
" conf = columns.get(k)\n",
" if conf:\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" contrib[\"data\"][name] = f\"{v[-1]-v[0]} {unit}\"\n",
" \n",
" conf = columns.get(k)\n",
" if conf and k.startswith('polarization') and isinstance(v, list):\n",
" name, fields = conf[\"name\"], conf[\"fields\"]\n",
" contrib[\"data\"].setdefault(name, {})\n",
" if not \"unit\" in conf:\n",
" vmax, unit = max(v), fields[\"max\"]\n",
" contrib[\"data\"][name]['max'] = f\"{round(vmax, 3)} {unit}\" if unit else v\n",
" contrib[\"data\"][name]['index'] = v.index(vmax)\n",
" else:\n",
" unit = conf[\"unit\"]\n",
" contrib[\"data\"][name] = {\n",
" i: f\"{j} {unit}\"\n",
" for i, j in zip(conf[\"fields\"], v[0])\n",
" }\n",
" elif conf and k == 'energies_per_atom':\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" ediff = v[0] - v[-1]\n",
" contrib[\"data\"][name] = f\"{ediff:.3g} {unit}\" \n",
" elif conf and k == 'bandgaps':\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" contrib[\"data\"].setdefault(name, {})\n",
" contrib[\"data\"][name][\"nonpolar\"] = f\"{v[0]:.3g} {unit}\"\n",
" contrib[\"data\"][name][\"polar\"] = f\"{v[-1]:.3g} {unit}\"\n",
" elif k.startswith((\"_id\", \"cid\")) or isinstance(v, list) or k.startswith(structure_keys):\n",
" continue\n",
" else:\n",
" conf = columns.get(k)\n",
" if conf:\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" contrib[\"data\"][name] = f\"{v} {unit}\" if unit else v\n",
" elif conf:\n",
" name, unit = conf[\"name\"], conf[\"unit\"]\n",
" if name == \"polarization.norm\":\n",
" contrib[\"data\"][name] = f\"{v:.1g} {unit}\" if unit else v\n",
" else:\n",
" contrib[\"data\"][name] = f\"{v:.3g} {unit}\" if unit else v\n",
" \n",
"# attm = Attachment.from_data(\"workflow\", wf)\n",
"# contrib[\"attachments\"].append(attm)\n",
" contrib[\"data\"] = unflatten(contrib[\"data\"], splitter=\"dot\")\n",
" contributions.append(contrib)"
" contributions.append(contrib)\n",
" \n",
"len(contributions)"
]
},
{
Expand Down Expand Up @@ -284,6 +294,7 @@
"outputs": [],
"source": [
"#client.delete_contributions()\n",
"client.init_columns({})\n",
"client.init_columns(columns_map)"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 29c0e49

Please sign in to comment.