|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "source": [ |
| 6 | + "<a href=\"https://colab.research.google.com/github/Exabyte-io/api-examples/blob/dev/other/material/import_material_from_jarvis_db_entry.ipynb\" target=\"_parent\">\n", |
| 7 | + "<img alt=\"Open in Google Colab\" src=\"https://user-images.githubusercontent.com/20477508/128780728-491fea90-9b23-495f-a091-11681150db37.jpeg\" width=\"150\" border=\"0\">\n", |
| 8 | + "</a>" |
| 9 | + ], |
| 10 | + "metadata": { |
| 11 | + "collapsed": false |
| 12 | + }, |
| 13 | + "id": "3c567b6400249971" |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "markdown", |
| 17 | + "source": [ |
| 18 | + "## Install Packages\n", |
| 19 | + "First, install `express-py` which includes `jarvis-tools` as dependency." |
| 20 | + ], |
| 21 | + "metadata": { |
| 22 | + "collapsed": false |
| 23 | + }, |
| 24 | + "id": "8b00ab6854f2263b" |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "code", |
| 28 | + "execution_count": null, |
| 29 | + "outputs": [], |
| 30 | + "source": [ |
| 31 | + "!pip install express-py==2024.1.25.post7" |
| 32 | + ], |
| 33 | + "metadata": { |
| 34 | + "collapsed": false |
| 35 | + }, |
| 36 | + "id": "b1288bc79ee2c828" |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "markdown", |
| 40 | + "source": [ |
| 41 | + "## Get Materials Data From JARVIS\n", |
| 42 | + "Then, let's get the dataset containing 2D materials from JARVIS and wrap it into a pandas dataframe." |
| 43 | + ], |
| 44 | + "metadata": { |
| 45 | + "collapsed": false |
| 46 | + }, |
| 47 | + "id": "f418c51a7f794f9f" |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": null, |
| 52 | + "outputs": [], |
| 53 | + "source": [ |
| 54 | + "import pandas as pd\n", |
| 55 | + "from jarvis.db.figshare import data, get_jid_data\n", |
| 56 | + "\n", |
| 57 | + "dft_2d=data('dft_2d')\n", |
| 58 | + "df = pd.DataFrame(dft_2d)" |
| 59 | + ], |
| 60 | + "metadata": { |
| 61 | + "collapsed": false |
| 62 | + }, |
| 63 | + "id": "b1ee775d1476f884" |
| 64 | + }, |
| 65 | + { |
| 66 | + "cell_type": "markdown", |
| 67 | + "source": [ |
| 68 | + "## Extract Structure and Convert to ESSE\n", |
| 69 | + "Next, we extract an entry from the JARVIS dataset and convert it into ESSE format ready to be uploaded to Mat3ra.com." |
| 70 | + ], |
| 71 | + "metadata": { |
| 72 | + "collapsed": false |
| 73 | + }, |
| 74 | + "id": "15fe5f9de299c935" |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "code", |
| 78 | + "execution_count": null, |
| 79 | + "outputs": [], |
| 80 | + "source": [ |
| 81 | + "import json\n", |
| 82 | + "## Note: JVASP-670 is an entry for MoTe2\n", |
| 83 | + "jarvis_db_entry = json.dumps(json.loads(df[(df['jid']=='JVASP-670')].to_json(orient='records'))[0])\n", |
| 84 | + "\n", |
| 85 | + "kwargs = {\n", |
| 86 | + " \"structure_string\": jarvis_db_entry,\n", |
| 87 | + " \"cell_type\": \"original\",\n", |
| 88 | + " \"structure_format\": \"jarvis-db-entry\"\n", |
| 89 | + "}\n", |
| 90 | + "\n", |
| 91 | + "handler = ExPrESS(\"structure\", **kwargs)\n", |
| 92 | + "data = handler.property(\"material\", **kwargs)\n", |
| 93 | + "\n", |
| 94 | + "# To preview resulting JSON data\n", |
| 95 | + "print(json.dumps(data, indent=4))" |
| 96 | + ], |
| 97 | + "metadata": { |
| 98 | + "collapsed": false |
| 99 | + }, |
| 100 | + "id": "c41fb68c6d25fe48" |
| 101 | + }, |
| 102 | + { |
| 103 | + "cell_type": "markdown", |
| 104 | + "source": [ |
| 105 | + "## Upload to Mat3ra.com\n", |
| 106 | + "Finally, we can upload the material to Mat3ra.com using the REST API: follow the explanation in another example notebook [here](../../examples/material/create_material.ipynb)." |
| 107 | + ], |
| 108 | + "metadata": { |
| 109 | + "collapsed": false |
| 110 | + }, |
| 111 | + "id": "a4a48479c7ea090f" |
| 112 | + } |
| 113 | + ], |
| 114 | + "metadata": { |
| 115 | + "kernelspec": { |
| 116 | + "display_name": "Python 3", |
| 117 | + "language": "python", |
| 118 | + "name": "python3" |
| 119 | + }, |
| 120 | + "language_info": { |
| 121 | + "codemirror_mode": { |
| 122 | + "name": "ipython", |
| 123 | + "version": 2 |
| 124 | + }, |
| 125 | + "file_extension": ".py", |
| 126 | + "mimetype": "text/x-python", |
| 127 | + "name": "python", |
| 128 | + "nbconvert_exporter": "python", |
| 129 | + "pygments_lexer": "ipython2", |
| 130 | + "version": "2.7.6" |
| 131 | + } |
| 132 | + }, |
| 133 | + "nbformat": 4, |
| 134 | + "nbformat_minor": 5 |
| 135 | +} |
0 commit comments