From d7c14d9a164fe19ae30861f918590988d0cfad99 Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Mon, 9 Aug 2021 20:24:25 +0200 Subject: [PATCH 1/9] Fixed some typos, adjusted the example files and fixed issues in the example notebooks and readme file, so loading is described correctly with the new format now. --- Data/iron.yml | 35 ------ Data/nickel.yml | 53 --------- Data/template.yml | 12 -- README.md | 29 +++-- docs/examples/simple_test.ipynb | 145 ++++++++++++++++++++--- docs/examples/test_material.yml | 73 ------------ docs/test_notebook.ipynb | 50 ++++++-- material_database/models/material.py | 2 +- material_database/parser/pyYamlParser.py | 4 +- 9 files changed, 188 insertions(+), 215 deletions(-) delete mode 100644 Data/iron.yml delete mode 100644 Data/nickel.yml delete mode 100644 Data/template.yml delete mode 100644 docs/examples/test_material.yml diff --git a/Data/iron.yml b/Data/iron.yml deleted file mode 100644 index 854a7ee..0000000 --- a/Data/iron.yml +++ /dev/null @@ -1,35 +0,0 @@ -meta: - name: iron - formula: Fe - description: pure crystallien iron in beta phase - comment: maybe there is something to say here - last_updated: 2020-04-28 - references: - @article{curtiss2013unicorn, - author = "Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others", - title = "Unicorn: A system for searching the social graph", - journal = "Proceedings of the VLDB Endowment", - volume = "6", - number = "11", - pages = "1150--1161", - year = "2013", - publisher = "VLDB Endowment", - doi = "10.14778/2536222.2536239" - } -data: - thermal_conductivity: - curtiss2013unicorn: - value: 80 - uncertainty: 1 - unit: J/m - comment: some value comment here - refractive_index: - curtiss2013unicorn: - value: - wavelength: - values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...] - arg_values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...] - arg_unit: nm - comment: maybe one can write a fit of the data here - unit: '' - comment: n = n' + i k \ No newline at end of file diff --git a/Data/nickel.yml b/Data/nickel.yml deleted file mode 100644 index 55d5e1c..0000000 --- a/Data/nickel.yml +++ /dev/null @@ -1,53 +0,0 @@ -Material name: nickel -References: -- https://de.wikipedia.org/wiki/Nickel -- https://refractiveindex.info/?shelf=main&book=Ni&page=Johnson -Comment: Testfile -Data: -- Parameter name: Thermal conductivity - Comment: '' - Reference number: 1 - Units: [W/(mK)] - Value names: [Thermal conductivity] - Values: - - [91.0] -- Parameter name: Molar volume - Comment: '' - Reference number: 1 - Units: [m^3/mol] - Value names: [''] - Values: - - [6.59e-06] -- Parameter name: Boiling point - Comment: '' - Reference number: 1 - Units: [K] - Value names: [Boiling point] - Values: - - [3003.0] -- Parameter name: Melting point - Comment: '' - Reference number: 1 - Units: [K] - Value names: [Melting point] - Values: - - [1728.0] -- Parameter name: Refractive index - Comment: '' - Reference number: 2 - Units: [µm, '-', '-'] - Value names: [wavelength, n, k] - Values: - - [0.188, 0.192, 0.195, 0.199, 0.203, 0.207, 0.212, 0.216, 0.221, 0.226, 0.231, - 0.237, 0.243, 0.249, 0.255, 0.262, 0.269, 0.276, 0.284, 0.292, 0.301, 0.311, 0.32, - 0.332, 0.342, 0.354, 0.368, 0.381, 0.397, 0.413, 0.431, 0.451, 0.471, 0.496, 0.521, - 0.549, 0.582, 0.617, 0.659, 0.704, 0.756, 0.821, 0.892, 0.984, 1.088, 1.216, 1.393, - 1.61, 1.937] - - [1.26, 1.29, 1.29, 1.28, 1.28, 1.29, 1.32, 1.34, 1.38, 1.43, 1.49, 1.57, 1.65, - 1.73, 1.82, 1.89, 1.96, 2.01, 2.03, 2.03, 2.02, 2.01, 1.93, 1.84, 1.78, 1.74, - 1.7, 1.72, 1.72, 1.7, 1.71, 1.73, 1.78, 1.82, 1.85, 1.92, 1.96, 1.99, 1.99, 2.06, - 2.13, 2.26, 2.4, 2.48, 2.65, 2.79, 2.96, 3.14, 3.47] - - [1.6, 1.64, 1.69, 1.75, 1.82, 1.89, 1.96, 2.02, 2.09, 2.15, 2.2, 2.25, 2.29, 2.31, - 2.32, 2.3, 2.29, 2.26, 2.23, 2.2, 2.18, 2.18, 2.19, 2.22, 2.26, 2.32, 2.4, 2.48, - 2.57, 2.69, 2.82, 2.95, 3.09, 3.25, 3.42, 3.61, 3.8, 4.02, 4.26, 4.5, 4.73, 4.97, - 5.23, 5.55, 5.93, 6.43, 7.08, 7.96, 9.09] diff --git a/Data/template.yml b/Data/template.yml deleted file mode 100644 index 18224e6..0000000 --- a/Data/template.yml +++ /dev/null @@ -1,12 +0,0 @@ -Material name: '' -References: -- '' -Comment: '' -Data: -- Parameter name: '' - Comment: '' - Reference number: 1 - Units: [] - Value names: [] - Values: - - [] diff --git a/README.md b/README.md index 24767e9..3ea208e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # MBI Material Database Concept -Due to the general demand for collecting, storing, and exchanging material parameters, we provide a text file based solution as well as several Python scripts and GUIs to read, change, and store material parameters. +Due to the general demand for collecting, storing, and exchanging material parameters, we provide a text-file-based solution, as well as several Python scripts and GUIs to read, change, and store material parameters. -Initially, we will only support [YAML](https://en.wikipedia.org/wiki/YAML) as data source, but the general design will allow also for other data sources, such as SQL databases or other file formats, e.g. XML or JSON. +Initially, we will only support the [YAML](https://en.wikipedia.org/wiki/YAML) format as a data source, but the general design will allow also for other data sources, such as SQL databases or other file formats, e.g. XML or JSON. ## YAML Format @@ -47,12 +47,12 @@ data: ``` First, there is `meta` section which holds meta-data of the material. -Most importantly, the must be references defined, in order to link paramters to them. -The `references` entrie must be a plain `bibtex` entry which can hold any type of reference and as many as necessary. +Most importantly, there must be references defined, in order to link paramters to them. +The `references` entry must be in plain `bibtex` format, which can hold any type of reference and as many as necessary. In the `data` section the actual physical parameters are declared. -It is possible to have multiple values stored for a single parameter, by indexing each by a `citation_key` which must be defined above in the `meta` section. -The actual parmaters, must have `value` and `unit` as well as optional `uncertainty` and `comment`. +It is possible to have multiple values stored for a single parameter, by indexing each by a `citation_key`, which must be defined above in the `meta` section. +The actual parmaters, must have `value` and `unit` and can optionally have `uncertainty` and `comment`. In case of a functional dependence of a parameter, the name of the `argument` must be given as new index. The actual parameter `values`, the `arg_values` and `arg_unit` are mandatory. The `comment` is optional. @@ -60,12 +60,11 @@ With this format even multiple functional dependencies are possible from one and ## Python Scripts -Although the YAML file format allows for human readability and does not require any programmatic access, we provide several Python modules in order to inteact with the material database. +The YAML file format allows for human readability and does not require any programmatic access. +However, we provide several Python (other languages such as MATLAB can be implemented in the future as well) modules in order to inteact with the material database: -We first stick to Python but other languages such as MATLAB can be implemented in the future as well. - -We divide the modules into a `Parser` module which is dedicated for reading and writing data from and to e.g. a YAML file. -The data must be provided as a `dict` in Python with a well defined structure. +The `Parser` module is dedicated for reading and writing data from and to e.g. a YAML file. +New data must be provided as a `dict` in Python with a well-defined structure. The `Material` module implements a class for `Material`, `Paramter`, and `References` and should allow for easy interaction in a Python script with the material database. @@ -76,11 +75,11 @@ An example of programmatic access to the database could look like this: ```python import material_database as md -parser = md.PyYamlParser('/my/path/to/yaml/files') +parser = md.parser.PyYamlParser(r'C:\Users\borchert\Documents\repos\MaterialDatabase\Data') -iron = md.Material(parser.read_from_file(iron.yaml)) +iron = md.Material(parser.load('fe'), log_level=10) -print(iron.thermal_conductivity) -.. 80 +print(iron.thermal_conductivity['curtisss2013unicorn'].value) +..80 ``` \ No newline at end of file diff --git a/docs/examples/simple_test.ipynb b/docs/examples/simple_test.ipynb index 79ce9a2..534a50b 100644 --- a/docs/examples/simple_test.ipynb +++ b/docs/examples/simple_test.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -23,9 +23,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: base path of PyYamlParser set to: ./\n" + ] + } + ], "source": [ "yaml_data_path = './'\n", "yaml_parser = md.parser.PyYamlParser(yaml_data_path, log_level=20)" @@ -33,48 +41,151 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: converted yaml file \"C:\\Users\\borchert\\Documents\\repos\\MaterialDatabase\\docs\\examples\\test_material.yaml\" to Python dictionary\n", + "INFO :: found 3 bibtex entries and converted them to Python dictionaries\n" + ] + } + ], "source": [ "material_data = yaml_parser.load('test_material')" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'year': '2013',\n", + " 'volume': '6',\n", + " 'title': 'Unicorn: A system for searching the social graph',\n", + " 'publisher': 'VLDB Endowment',\n", + " 'pages': '1150--1161',\n", + " 'number': '11',\n", + " 'journal': 'Proceedings of the VLDB Endowment',\n", + " 'doi': '10.14778/2536222.2536239',\n", + " 'author': 'Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others',\n", + " 'ENTRYTYPE': 'article'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "material_data['meta']['references']['curtiss2013unicorn']" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: added reference with key aad2015combined\n", + "INFO :: added reference with key cheng2015generalized\n", + "INFO :: added reference with key curtiss2013unicorn\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: added parameter with name thermal_conductivity\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: added parameter with name refractive_index\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: added parameter with name wavelength\n" + ] + } + ], "source": [ "test_material = md.Material(material_data, log_level=20)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "test_material.references['curtiss2013unicorn'].dump()" + "test_material.thermal_conductivity['curtiss2013unicorn'].value" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "82" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "test_material.parameters['thermal_conductivity'].dump()" + "test_material.thermal_conductivity['aad2015combined'].value" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -93,7 +204,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.5" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/docs/examples/test_material.yml b/docs/examples/test_material.yml deleted file mode 100644 index 6a8dd0f..0000000 --- a/docs/examples/test_material.yml +++ /dev/null @@ -1,73 +0,0 @@ -meta: - name: test material - last_updated: 7272181873150 - description: here is some text describing the material - comment: some comments - references: - '@article{aad2015combined, - author = {Aad, Georges and Abbott, B and Abdallah, J and Abdinov, O and Aben, R and Abolins, M and AbouZeid, OS and Abramowicz, H and Abreu, H and Abreu, R and others}, - journal = {Physical review letters}, - number = {19}, - pages = {191803}, - publisher = {APS}, - title = {Combined Measurement of the Higgs Boson Mass in p p Collisions at s= 7 and 8 TeV with the ATLAS and CMS Experiments}, - volume = {114}, - year = {2015} - } - - @article{cheng2015generalized, - author = {Cheng, Xinyue and Zou, Yangyang}, - journal = {Differential Geometry-Dynamical Systems}, - pages = {38--48}, - title = {The generalized unicorn problem in Finsler geometry}, - volume = {17}, - year = {2015} - } - - @article{curtiss2013unicorn, - author = {Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others}, - doi = {10.14778/2536222.2536239}, - journal = {Proceedings of the VLDB Endowment}, - number = {11}, - pages = {1150--1161}, - publisher = {VLDB Endowment}, - title = {Unicorn: A system for searching the social graph}, - volume = {6}, - year = {2013} - } - - ' - -data: - thermal_conductivity: - curtiss2013unicorn: - value: 80 - uncertainty: 1 - unit: J/m - comment: some value comment here - - aad2015combined: - value: 82 - uncertainty: 1 - unit: J/m - comment: this is the same parameter but with a difernt value from another reference - - refractive_index: - cheng2015generalized: - value: null - uncertainty: 0 - unit: '' - comment: it is a function of wavelength in nm. one needs to think also of a way how - to make this clear in general - lambda: [1, 2, 3, 4, 5, 6, 7, 8, 9] - n: [10, 20, 30, 40, 50, 60, 70] - k: [10, 20, 30, 40, 50, 60, 70] - - wavelength: - curtiss2013unicorn: - value: null - uncertainty: 0 - unit: '' - comment: '' - lambda: [10, 20, 304, 55] - diff --git a/docs/test_notebook.ipynb b/docs/test_notebook.ipynb index ba8b5ec..068944d 100644 --- a/docs/test_notebook.ipynb +++ b/docs/test_notebook.ipynb @@ -29,7 +29,7 @@ "metadata": {}, "outputs": [], "source": [ - "db_path = r'C:\\Users\\loc_steinbac\\Documents\\5-Code\\1-git_repos\\MaterialDatabase\\docs\\examples'\n", + "db_path = r'C:\\Users\\borchert\\Documents\\repos\\MaterialDatabase\\docs\\examples'\n", "material = 'test_material'" ] }, @@ -88,9 +88,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Reference cheng2015generalized: {'author': 'Cheng, Xinyue and Zou, Yangyang', 'journal': 'Differential Geometry-Dynamical Systems', 'pages': '38--48', 'title': 'The generalized unicorn problem in Finsler geometry', 'volume': '17', 'year': '2015', 'ENTRYTYPE': 'article'}\n", + "Reference aad2015combined: {'author': 'Aad, Georges and Abbott, B and Abdallah, J and Abdinov, O and Aben, R and Abolins, M and AbouZeid, OS and Abramowicz, H and Abreu, H and Abreu, R and others', 'journal': 'Physical review letters', 'pages': '191803', 'title': 'Combined Measurement of the Higgs Boson Mass in p p Collisions at s= 7 and 8 TeV with the ATLAS and CMS Experiments', 'volume': '114', 'year': '2015', 'ENTRYTYPE': 'article', 'publisher': 'APS', 'number': '19'}\n" + ] + } + ], "source": [ "print('Reference %s: %s'%(\"cheng2015generalized\",str(data.cheng2015generalized.dump())))\n", "print('Reference %s: %s'%(str(data.list_references()[0]),str(getattr(data,data.list_references()[0]).dump())))" @@ -105,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -131,9 +140,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Added parameter wavelength with reference curtiss2013unicorn correctly to database.\n" + ] + }, + { + "ename": "TypeError", + "evalue": "getattr(): attribute name must be string", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_parameter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnewPara\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\borchert\\documents\\repos\\materialdatabase\\material_database\\models\\material.py\u001b[0m in \u001b[0;36mvalidate\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 137\u001b[0m \u001b[0mref_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlist_references\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 138\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_list\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 139\u001b[1;33m \u001b[0mpar_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 140\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar_data\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_dict\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 141\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mpar_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mref_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: getattr(): attribute name must be string" + ] + } + ], "source": [ "newPara = md.Parameter('wavelength','curtiss2013unicorn')\n", "newPara.addValueList('lambda',[10,20,304,55])\n", @@ -159,6 +188,13 @@ "\n", "yaml_file = yaml_parser.dump(data_dict)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -177,7 +213,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.0" + "version": "3.7.6" } }, "nbformat": 4, diff --git a/material_database/models/material.py b/material_database/models/material.py index 5acb07e..d1ba440 100644 --- a/material_database/models/material.py +++ b/material_database/models/material.py @@ -85,7 +85,7 @@ def build_from_dict(self, material_data): tmp_par_dict = {} for sub_par_name, sub_par_data in par_data.items(): sub_name = name_to_identifer(sub_par_name) - tmp_par_dict[sub_name] = Parameter(name,sub_name, sub_par_data, log_level=self.log_level) + tmp_par_dict[sub_name] = Parameter(name, sub_name, sub_par_data, log_level=self.log_level) self.__dict__[name] = tmp_par_dict self.logger.info('added parameter with name {:s}'.format(name)) diff --git a/material_database/parser/pyYamlParser.py b/material_database/parser/pyYamlParser.py index e91fd8b..4fe1c8f 100644 --- a/material_database/parser/pyYamlParser.py +++ b/material_database/parser/pyYamlParser.py @@ -56,7 +56,7 @@ def load(self, material): """ full_file_name = path.join(path.abspath(self.base_path), - material + '.yml') + material + '.yaml') # read yaml file with open(full_file_name, 'r') as file: material_data = yaml.load(file, Loader=yaml.FullLoader) @@ -175,7 +175,7 @@ def dump(self, material_data): full_file_name = path.join(path.abspath(self.base_path), - meta_dict['name'].replace(' ','_') + '.yml') + meta_dict['name'].replace(' ','_') + '.yaml') # read yaml file f = open(full_file_name, "w") f.write(yamlFile) From 89ce02c0b5840e63db9b474c6f2787d8bc221552 Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Mon, 9 Aug 2021 20:35:39 +0200 Subject: [PATCH 2/9] renamed files --- Data/fe.yaml | 35 +++ Data/gd.yaml | 12 + Data/ni.yaml | 47 ++++ Data/template.yaml | 12 + .../test_notebook-checkpoint.ipynb | 185 +++++++++++++++ .../simple_test-checkpoint.ipynb | 212 ++++++++++++++++++ docs/examples/test_material.yaml | 73 ++++++ 7 files changed, 576 insertions(+) create mode 100644 Data/fe.yaml create mode 100644 Data/gd.yaml create mode 100644 Data/ni.yaml create mode 100644 Data/template.yaml create mode 100644 docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb create mode 100644 docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb create mode 100644 docs/examples/test_material.yaml diff --git a/Data/fe.yaml b/Data/fe.yaml new file mode 100644 index 0000000..89a08b1 --- /dev/null +++ b/Data/fe.yaml @@ -0,0 +1,35 @@ +meta: + name: iron + formula: Fe + description: pure crystallien iron in beta phase + comment: maybe there is something to say here + last_updated: 2020-04-28 + references: + '@article{curtiss2013unicorn, + author = "Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others", + title = "Unicorn: A system for searching the social graph", + journal = "Proceedings of the VLDB Endowment", + volume = "6", + number = "11", + pages = "1150--1161", + year = "2013", + publisher = "VLDB Endowment", + doi = "10.14778/2536222.2536239" + }' +data: + thermal_conductivity: + curtisss2013unicorn: + value: 80 + uncertainty: 1 + unit: J/m + comment: some value comment here + refractive_index: + curtiss2013unicorn: + value: + wavelength: + values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...] + arg_values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...] + arg_unit: nm + comment: maybe one can write a fit of the data here + unit: '' + comment: n = n' + i k \ No newline at end of file diff --git a/Data/gd.yaml b/Data/gd.yaml new file mode 100644 index 0000000..18224e6 --- /dev/null +++ b/Data/gd.yaml @@ -0,0 +1,12 @@ +Material name: '' +References: +- '' +Comment: '' +Data: +- Parameter name: '' + Comment: '' + Reference number: 1 + Units: [] + Value names: [] + Values: + - [] diff --git a/Data/ni.yaml b/Data/ni.yaml new file mode 100644 index 0000000..8cab292 --- /dev/null +++ b/Data/ni.yaml @@ -0,0 +1,47 @@ +meta: + name: nickel + formula: Ni + last_updated: 7272181873150 + description: + comment: + references: + '@online{wikipedia, + author = "Wikipedia", + title = "Nickel", + url = "https://de.wikipedia.org/wiki/Nickel" + } + + @online{ri, + author = "refractiveindex.info", + title = "Nickel", + url = "https://refractiveindex.info/?shelf=main&book=Ni&page=Johnson" + }' + +data: + thermal_conductivity: + wikipedia: + value: 91 + units: [W/(mK)] + molar_volume: + wikipedia: + value: 6.59e-06 + units: [m^3/mol] + boiling_point: + wikipedia: + value: 3003.0 + units: [K] + melting_point: + wikipedia: + value: 1728.0 + units: [K] + refractive_index: + ri: + arg: [0.188, 0.192, 0.195, 0.199, 0.203, 0.207, 0.212, 0.216, 0.221, + 0.226, 0.231, 0.237, 0.243, 0.249, 0.255, 0.262, 0.269, 0.276, 0.284, + 0.292, 0.301, 0.311, 0.32, 0.332, 0.342, 0.354, 0.368, 0.381, 0.397, + 0.413, 0.431, 0.451, 0.471, 0.496, 0.521, 0.549, 0.582, 0.617, 0.659, + 0.704, 0.756, 0.821, 0.892, 0.984, 1.088, 1.216, 1.393, 1.61, 1.937] + arg_name: 'Wavelength' + arg_unit: [µm] + value: 1+2i + diff --git a/Data/template.yaml b/Data/template.yaml new file mode 100644 index 0000000..18224e6 --- /dev/null +++ b/Data/template.yaml @@ -0,0 +1,12 @@ +Material name: '' +References: +- '' +Comment: '' +Data: +- Parameter name: '' + Comment: '' + Reference number: 1 + Units: [] + Value names: [] + Values: + - [] diff --git a/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb b/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb new file mode 100644 index 0000000..ba8b5ec --- /dev/null +++ b/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb @@ -0,0 +1,185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Import" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import material_database as md" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Path definitions" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "db_path = r'C:\\Users\\loc_steinbac\\Documents\\5-Code\\1-git_repos\\MaterialDatabase\\docs\\examples'\n", + "material = 'test_material'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Database" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "yaml_parser = md.parser.PyYamlParser(db_path)\n", + "\n", + "material_data = yaml_parser.load(material)\n", + "\n", + "data = md.Material(material_data)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## List Reference and parameter example" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "References in test_material database: ['aad2015combined', 'cheng2015generalized', 'curtiss2013unicorn']\n", + "Parameters in test_material database: [('thermal_conductivity', 'curtiss2013unicorn'), ('thermal_conductivity', 'aad2015combined'), ('refractive_index', 'cheng2015generalized'), ('wavelength', 'curtiss2013unicorn')]\n" + ] + } + ], + "source": [ + "print('References in %s database: %s'%(material,str(data.list_references())))\n", + "print('Parameters in %s database: %s'%(material,str(data.list_parameters())))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example to extract references" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('Reference %s: %s'%(\"cheng2015generalized\",str(data.cheng2015generalized.dump())))\n", + "print('Reference %s: %s'%(str(data.list_references()[0]),str(getattr(data,data.list_references()[0]).dump())))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example to extract parameters" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Parameter refractive_index: {'value': None, 'uncertainty': 0, 'unit': '', 'comment': 'it is a function of wavelength in nm. one needs to think also of a way how to make this clear in general', 'lambda': [1, 2, 3, 4, 5, 6, 7, 8, 9], 'n': [10, 20, 30, 40, 50, 60, 70], 'k': [10, 20, 30, 40, 50, 60, 70]}\n", + "Parameter thermal_conductivity: {'value': 80, 'uncertainty': 1, 'unit': 'J/m', 'comment': 'some value comment here'}\n" + ] + } + ], + "source": [ + "print('Parameter %s: %s'%(\"refractive_index\",str(data.refractive_index['cheng2015generalized'].dump())))\n", + "print('Parameter %s: %s'%(\"thermal_conductivity\",str(data.thermal_conductivity['curtiss2013unicorn'].dump())))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example to add new Parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "newPara = md.Parameter('wavelength','curtiss2013unicorn')\n", + "newPara.addValueList('lambda',[10,20,304,55])\n", + "data.add_parameter(newPara)\n", + "\n", + "data.validate()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Save database" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data_dict = data.dump()\n", + "\n", + "yaml_file = yaml_parser.dump(data_dict)" + ] + } + ], + "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.9.0" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb b/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb new file mode 100644 index 0000000..534a50b --- /dev/null +++ b/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb @@ -0,0 +1,212 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# configure to autoload all extension\n", + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import material_database as md\n", + "from os import path" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: base path of PyYamlParser set to: ./\n" + ] + } + ], + "source": [ + "yaml_data_path = './'\n", + "yaml_parser = md.parser.PyYamlParser(yaml_data_path, log_level=20)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: converted yaml file \"C:\\Users\\borchert\\Documents\\repos\\MaterialDatabase\\docs\\examples\\test_material.yaml\" to Python dictionary\n", + "INFO :: found 3 bibtex entries and converted them to Python dictionaries\n" + ] + } + ], + "source": [ + "material_data = yaml_parser.load('test_material')" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'year': '2013',\n", + " 'volume': '6',\n", + " 'title': 'Unicorn: A system for searching the social graph',\n", + " 'publisher': 'VLDB Endowment',\n", + " 'pages': '1150--1161',\n", + " 'number': '11',\n", + " 'journal': 'Proceedings of the VLDB Endowment',\n", + " 'doi': '10.14778/2536222.2536239',\n", + " 'author': 'Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others',\n", + " 'ENTRYTYPE': 'article'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "material_data['meta']['references']['curtiss2013unicorn']" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO :: added reference with key aad2015combined\n", + "INFO :: added reference with key cheng2015generalized\n", + "INFO :: added reference with key curtiss2013unicorn\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", + "INFO :: added parameter with name thermal_conductivity\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", + "INFO :: added parameter with name refractive_index\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: setting the value is not that simple\n", + "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", + "INFO :: added parameter with name wavelength\n" + ] + } + ], + "source": [ + "test_material = md.Material(material_data, log_level=20)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "80" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "test_material.thermal_conductivity['curtiss2013unicorn'].value" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "82" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "test_material.thermal_conductivity['aad2015combined'].value" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/examples/test_material.yaml b/docs/examples/test_material.yaml new file mode 100644 index 0000000..6a8dd0f --- /dev/null +++ b/docs/examples/test_material.yaml @@ -0,0 +1,73 @@ +meta: + name: test material + last_updated: 7272181873150 + description: here is some text describing the material + comment: some comments + references: + '@article{aad2015combined, + author = {Aad, Georges and Abbott, B and Abdallah, J and Abdinov, O and Aben, R and Abolins, M and AbouZeid, OS and Abramowicz, H and Abreu, H and Abreu, R and others}, + journal = {Physical review letters}, + number = {19}, + pages = {191803}, + publisher = {APS}, + title = {Combined Measurement of the Higgs Boson Mass in p p Collisions at s= 7 and 8 TeV with the ATLAS and CMS Experiments}, + volume = {114}, + year = {2015} + } + + @article{cheng2015generalized, + author = {Cheng, Xinyue and Zou, Yangyang}, + journal = {Differential Geometry-Dynamical Systems}, + pages = {38--48}, + title = {The generalized unicorn problem in Finsler geometry}, + volume = {17}, + year = {2015} + } + + @article{curtiss2013unicorn, + author = {Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others}, + doi = {10.14778/2536222.2536239}, + journal = {Proceedings of the VLDB Endowment}, + number = {11}, + pages = {1150--1161}, + publisher = {VLDB Endowment}, + title = {Unicorn: A system for searching the social graph}, + volume = {6}, + year = {2013} + } + + ' + +data: + thermal_conductivity: + curtiss2013unicorn: + value: 80 + uncertainty: 1 + unit: J/m + comment: some value comment here + + aad2015combined: + value: 82 + uncertainty: 1 + unit: J/m + comment: this is the same parameter but with a difernt value from another reference + + refractive_index: + cheng2015generalized: + value: null + uncertainty: 0 + unit: '' + comment: it is a function of wavelength in nm. one needs to think also of a way how + to make this clear in general + lambda: [1, 2, 3, 4, 5, 6, 7, 8, 9] + n: [10, 20, 30, 40, 50, 60, 70] + k: [10, 20, 30, 40, 50, 60, 70] + + wavelength: + curtiss2013unicorn: + value: null + uncertainty: 0 + unit: '' + comment: '' + lambda: [10, 20, 304, 55] + From 41313cc053f4e600361ad955e5117dc9196fe1f8 Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Mon, 9 Aug 2021 20:38:23 +0200 Subject: [PATCH 3/9] fixed accidental reference typo --- Data/fe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/fe.yaml b/Data/fe.yaml index 89a08b1..25dad7c 100644 --- a/Data/fe.yaml +++ b/Data/fe.yaml @@ -18,7 +18,7 @@ meta: }' data: thermal_conductivity: - curtisss2013unicorn: + curtiss2013unicorn: value: 80 uncertainty: 1 unit: J/m From ee5fb5e491e7b37c77fb29150c9601189216c82f Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Mon, 9 Aug 2021 20:42:19 +0200 Subject: [PATCH 4/9] Updated readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ea208e..b60f59b 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,9 @@ data: ``` First, there is `meta` section which holds meta-data of the material. -Most importantly, there must be references defined, in order to link paramters to them. +Most importantly, there must be `references` defined, in order to link paramters to them. The `references` entry must be in plain `bibtex` format, which can hold any type of reference and as many as necessary. +Further, one must include a `last_updated` field. In the `data` section the actual physical parameters are declared. It is possible to have multiple values stored for a single parameter, by indexing each by a `citation_key`, which must be defined above in the `meta` section. @@ -75,7 +76,7 @@ An example of programmatic access to the database could look like this: ```python import material_database as md -parser = md.parser.PyYamlParser(r'C:\Users\borchert\Documents\repos\MaterialDatabase\Data') +parser = md.parser.PyYamlParser('/my/path/to/yaml/files') iron = md.Material(parser.load('fe'), log_level=10) From 545a88a54a674fa2fc52141338bb3c38af13dbc8 Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Thu, 12 Aug 2021 17:25:04 +0200 Subject: [PATCH 5/9] adressed issues from previous commit, added functi onality for complex numbers with i OR j in yaml file --- Data/fe.yaml | 10 +- Data/ni.yaml | 36 ++++--- docs/examples/simple_test.ipynb | 118 +++-------------------- docs/examples/test_material.yaml | 2 +- docs/test_notebook.ipynb | 34 +++++-- material_database/parser/pyYamlParser.py | 37 ++++++- 6 files changed, 97 insertions(+), 140 deletions(-) diff --git a/Data/fe.yaml b/Data/fe.yaml index 25dad7c..f76a566 100644 --- a/Data/fe.yaml +++ b/Data/fe.yaml @@ -25,11 +25,9 @@ data: comment: some value comment here refractive_index: curtiss2013unicorn: - value: - wavelength: - values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...] - arg_values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...] - arg_unit: nm - comment: maybe one can write a fit of the data here + value: [1+2j, 2+4j] + arg_value: [800] + arg_unit: nm + comment: maybe one can write a fit of the data here unit: '' comment: n = n' + i k \ No newline at end of file diff --git a/Data/ni.yaml b/Data/ni.yaml index 8cab292..4f50236 100644 --- a/Data/ni.yaml +++ b/Data/ni.yaml @@ -5,43 +5,47 @@ meta: description: comment: references: - '@online{wikipedia, + '@article{wikipedia, author = "Wikipedia", title = "Nickel", url = "https://de.wikipedia.org/wiki/Nickel" } - @online{ri, + @online{ri_info, author = "refractiveindex.info", title = "Nickel", - url = "https://refractiveindex.info/?shelf=main&book=Ni&page=Johnson" + urls = "https://refractiveindex.info/?shelf=main&book=Ni&page=Johnson" }' data: thermal_conductivity: wikipedia: value: 91 - units: [W/(mK)] + units: W/(mK) + ri_info: + value: 90 + units: W/(mK) + molar_volume: wikipedia: value: 6.59e-06 - units: [m^3/mol] + units: m^3/mol + boiling_point: wikipedia: value: 3003.0 - units: [K] + units: K + melting_point: wikipedia: value: 1728.0 - units: [K] + units: K + refractive_index: - ri: - arg: [0.188, 0.192, 0.195, 0.199, 0.203, 0.207, 0.212, 0.216, 0.221, - 0.226, 0.231, 0.237, 0.243, 0.249, 0.255, 0.262, 0.269, 0.276, 0.284, - 0.292, 0.301, 0.311, 0.32, 0.332, 0.342, 0.354, 0.368, 0.381, 0.397, - 0.413, 0.431, 0.451, 0.471, 0.496, 0.521, 0.549, 0.582, 0.617, 0.659, - 0.704, 0.756, 0.821, 0.892, 0.984, 1.088, 1.216, 1.393, 1.61, 1.937] - arg_name: 'Wavelength' - arg_unit: [µm] - value: 1+2i + ri_info: + value: 1+2j + arg_value: 0.188 + arg_name: Wavelength + arg_unit: µm + diff --git a/docs/examples/simple_test.ipynb b/docs/examples/simple_test.ipynb index 534a50b..940c3dc 100644 --- a/docs/examples/simple_test.ipynb +++ b/docs/examples/simple_test.ipynb @@ -2,9 +2,18 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], "source": [ "# configure to autoload all extension\n", "%load_ext autoreload\n", @@ -13,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -23,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -39,107 +48,6 @@ "yaml_parser = md.parser.PyYamlParser(yaml_data_path, log_level=20)" ] }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO :: converted yaml file \"C:\\Users\\borchert\\Documents\\repos\\MaterialDatabase\\docs\\examples\\test_material.yaml\" to Python dictionary\n", - "INFO :: found 3 bibtex entries and converted them to Python dictionaries\n" - ] - } - ], - "source": [ - "material_data = yaml_parser.load('test_material')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'year': '2013',\n", - " 'volume': '6',\n", - " 'title': 'Unicorn: A system for searching the social graph',\n", - " 'publisher': 'VLDB Endowment',\n", - " 'pages': '1150--1161',\n", - " 'number': '11',\n", - " 'journal': 'Proceedings of the VLDB Endowment',\n", - " 'doi': '10.14778/2536222.2536239',\n", - " 'author': 'Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others',\n", - " 'ENTRYTYPE': 'article'}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "material_data['meta']['references']['curtiss2013unicorn']" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO :: added reference with key aad2015combined\n", - "INFO :: added reference with key cheng2015generalized\n", - "INFO :: added reference with key curtiss2013unicorn\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: added parameter with name thermal_conductivity\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: added parameter with name refractive_index\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: added parameter with name wavelength\n" - ] - } - ], - "source": [ - "test_material = md.Material(material_data, log_level=20)" - ] - }, { "cell_type": "code", "execution_count": 7, diff --git a/docs/examples/test_material.yaml b/docs/examples/test_material.yaml index 6a8dd0f..db7ec70 100644 --- a/docs/examples/test_material.yaml +++ b/docs/examples/test_material.yaml @@ -4,7 +4,7 @@ meta: description: here is some text describing the material comment: some comments references: - '@article{aad2015combined, + '@article{aad2015combined, author = {Aad, Georges and Abbott, B and Abdallah, J and Abdinov, O and Aben, R and Abolins, M and AbouZeid, OS and Abramowicz, H and Abreu, H and Abreu, R and others}, journal = {Physical review letters}, number = {19}, diff --git a/docs/test_notebook.ipynb b/docs/test_notebook.ipynb index 068944d..590bd2c 100644 --- a/docs/test_notebook.ipynb +++ b/docs/test_notebook.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -88,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -114,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -140,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -157,7 +157,7 @@ "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_parameter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnewPara\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd_parameter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnewPara\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[1;32mc:\\users\\borchert\\documents\\repos\\materialdatabase\\material_database\\models\\material.py\u001b[0m in \u001b[0;36mvalidate\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 137\u001b[0m \u001b[0mref_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlist_references\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 138\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_list\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 139\u001b[1;33m \u001b[0mpar_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 140\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar_data\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_dict\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 141\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mpar_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mref_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mTypeError\u001b[0m: getattr(): attribute name must be string" ] @@ -180,9 +180,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "TypeError", + "evalue": "getattr(): attribute name must be string", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdata_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdump\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0myaml_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0myaml_parser\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdump\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata_dict\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32mc:\\users\\borchert\\documents\\repos\\materialdatabase\\material_database\\models\\material.py\u001b[0m in \u001b[0;36mdump\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 96\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 97\u001b[0m \"\"\"\n\u001b[1;32m---> 98\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 99\u001b[0m \u001b[0mmat_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 100\u001b[0m \u001b[0mpar_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlist_parameters\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32mc:\\users\\borchert\\documents\\repos\\materialdatabase\\material_database\\models\\material.py\u001b[0m in \u001b[0;36mvalidate\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 137\u001b[0m \u001b[0mref_list\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlist_references\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 138\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_list\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 139\u001b[1;33m \u001b[0mpar_dict\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 140\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mpar_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpar_data\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mpar_dict\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 141\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mpar_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalidate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mref_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: getattr(): attribute name must be string" + ] + } + ], "source": [ "data_dict = data.dump()\n", "\n", diff --git a/material_database/parser/pyYamlParser.py b/material_database/parser/pyYamlParser.py index 4fe1c8f..84445a5 100644 --- a/material_database/parser/pyYamlParser.py +++ b/material_database/parser/pyYamlParser.py @@ -59,7 +59,7 @@ def load(self, material): material + '.yaml') # read yaml file with open(full_file_name, 'r') as file: - material_data = yaml.load(file, Loader=yaml.FullLoader) + material_data = yaml.unsafe_load(file) # add filename as ID to dict material_data['ID'] = material @@ -69,7 +69,29 @@ def load(self, material): bibtex = material_data['meta']['references'] # convert bibtex into list of dicts - bib_list = bibtexparser.loads(bibtex).entries + ## these two lines also allow for other types than the standard: + + # 'article', + # 'book', + # 'booklet', + # 'conference', + # 'inbook', + # 'incollection', + # 'inproceedings', + # 'manual', + # 'mastersthesis', + # 'misc', + # 'phdthesis', + # 'proceedings', + # 'techreport', + # 'unpublished' + + parser = bibtexparser.bparser.BibTexParser(common_strings=False) + parser.ignore_nonstandard_types = False + #parser.homogenise_fields = False + + bib_list = bibtexparser.loads(bibtex, parser).entries + # create dicts with bibtex ID as key bib_dict = {} for bibtex_entry in bib_list: @@ -80,6 +102,17 @@ def load(self, material): # replace bibtex string with dict material_data['meta']['references'] = bib_dict + # This part fixes the issue that pyYaml imports complex numbers as strings. + # Manually stepping throuh the whole array and turns strings into complex numbers + for prop_key, prop_value in material_data['data'].items(): + for cite_key, cite_value in prop_value.items(): + if type(cite_value['value']) == str: + self.logger.info(cite_value['value']) + material_data['data'][prop_key][cite_key]['value'] = complex(cite_value['value'].replace("i", "j").replace(" ", "")) + elif type(cite_value['value']) == list and type(cite_value['value'][0]) == str: + material_data['data'][prop_key][cite_key]['value'] = [complex(v.replace("i", "j").replace(" ", "")) for v in cite_value['value']] + else: + pass return material_data def dump(self, material_data): From c628f40dfd048daa8cd16474c8b1c308ab1f38cd Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Fri, 13 Aug 2021 11:49:35 +0200 Subject: [PATCH 6/9] added several lines to the gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f598309..bc087d6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,8 @@ _static _templates # ipython checkpoints -docs/source/**/.ipynb_checkpoints \ No newline at end of file +docs/source/**/.ipynb_checkpoints +docs/**/.ipynb_checkpoints +docs/**/.ipynb_checkpoints +docs/.ipynb_checkpoints +docs/examples/.ipynb_checkpoints \ No newline at end of file From ee09bf5e7dc947bdbb5f10bee78077744ace1cd1 Mon Sep 17 00:00:00 2001 From: EmCeBeh Date: Fri, 13 Aug 2021 11:58:56 +0200 Subject: [PATCH 7/9] actually removed the files manually from git as gitignore does not ignore them --- .../test_notebook-checkpoint.ipynb | 185 --------------- .../simple_test-checkpoint.ipynb | 212 ------------------ 2 files changed, 397 deletions(-) delete mode 100644 docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb delete mode 100644 docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb diff --git a/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb b/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb deleted file mode 100644 index ba8b5ec..0000000 --- a/docs/.ipynb_checkpoints/test_notebook-checkpoint.ipynb +++ /dev/null @@ -1,185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Import" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import material_database as md" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Path definitions" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "db_path = r'C:\\Users\\loc_steinbac\\Documents\\5-Code\\1-git_repos\\MaterialDatabase\\docs\\examples'\n", - "material = 'test_material'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Load Database" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "yaml_parser = md.parser.PyYamlParser(db_path)\n", - "\n", - "material_data = yaml_parser.load(material)\n", - "\n", - "data = md.Material(material_data)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## List Reference and parameter example" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "References in test_material database: ['aad2015combined', 'cheng2015generalized', 'curtiss2013unicorn']\n", - "Parameters in test_material database: [('thermal_conductivity', 'curtiss2013unicorn'), ('thermal_conductivity', 'aad2015combined'), ('refractive_index', 'cheng2015generalized'), ('wavelength', 'curtiss2013unicorn')]\n" - ] - } - ], - "source": [ - "print('References in %s database: %s'%(material,str(data.list_references())))\n", - "print('Parameters in %s database: %s'%(material,str(data.list_parameters())))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example to extract references" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print('Reference %s: %s'%(\"cheng2015generalized\",str(data.cheng2015generalized.dump())))\n", - "print('Reference %s: %s'%(str(data.list_references()[0]),str(getattr(data,data.list_references()[0]).dump())))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example to extract parameters" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Parameter refractive_index: {'value': None, 'uncertainty': 0, 'unit': '', 'comment': 'it is a function of wavelength in nm. one needs to think also of a way how to make this clear in general', 'lambda': [1, 2, 3, 4, 5, 6, 7, 8, 9], 'n': [10, 20, 30, 40, 50, 60, 70], 'k': [10, 20, 30, 40, 50, 60, 70]}\n", - "Parameter thermal_conductivity: {'value': 80, 'uncertainty': 1, 'unit': 'J/m', 'comment': 'some value comment here'}\n" - ] - } - ], - "source": [ - "print('Parameter %s: %s'%(\"refractive_index\",str(data.refractive_index['cheng2015generalized'].dump())))\n", - "print('Parameter %s: %s'%(\"thermal_conductivity\",str(data.thermal_conductivity['curtiss2013unicorn'].dump())))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example to add new Parameter" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "newPara = md.Parameter('wavelength','curtiss2013unicorn')\n", - "newPara.addValueList('lambda',[10,20,304,55])\n", - "data.add_parameter(newPara)\n", - "\n", - "data.validate()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Save database" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "data_dict = data.dump()\n", - "\n", - "yaml_file = yaml_parser.dump(data_dict)" - ] - } - ], - "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.9.0" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb b/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb deleted file mode 100644 index 534a50b..0000000 --- a/docs/examples/.ipynb_checkpoints/simple_test-checkpoint.ipynb +++ /dev/null @@ -1,212 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# configure to autoload all extension\n", - "%load_ext autoreload\n", - "%autoreload 2" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "import material_database as md\n", - "from os import path" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO :: base path of PyYamlParser set to: ./\n" - ] - } - ], - "source": [ - "yaml_data_path = './'\n", - "yaml_parser = md.parser.PyYamlParser(yaml_data_path, log_level=20)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO :: converted yaml file \"C:\\Users\\borchert\\Documents\\repos\\MaterialDatabase\\docs\\examples\\test_material.yaml\" to Python dictionary\n", - "INFO :: found 3 bibtex entries and converted them to Python dictionaries\n" - ] - } - ], - "source": [ - "material_data = yaml_parser.load('test_material')" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'year': '2013',\n", - " 'volume': '6',\n", - " 'title': 'Unicorn: A system for searching the social graph',\n", - " 'publisher': 'VLDB Endowment',\n", - " 'pages': '1150--1161',\n", - " 'number': '11',\n", - " 'journal': 'Proceedings of the VLDB Endowment',\n", - " 'doi': '10.14778/2536222.2536239',\n", - " 'author': 'Curtiss, Michael and Becker, Iain and Bosman, Tudor and Doroshenko, Sergey and Grijincu, Lucian and Jackson, Tom and Kunnatur, Sandhya and Lassen, Soren and Pronin, Philip and Sankar, Sriram and others',\n", - " 'ENTRYTYPE': 'article'}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "material_data['meta']['references']['curtiss2013unicorn']" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO :: added reference with key aad2015combined\n", - "INFO :: added reference with key cheng2015generalized\n", - "INFO :: added reference with key curtiss2013unicorn\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"aad2015combined\"\n", - "INFO :: added parameter with name thermal_conductivity\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"cheng2015generalized\"\n", - "INFO :: added parameter with name refractive_index\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: setting the value is not that simple\n", - "INFO :: we need to change the value also in the dict of the corresponding reference ID: \"curtiss2013unicorn\"\n", - "INFO :: added parameter with name wavelength\n" - ] - } - ], - "source": [ - "test_material = md.Material(material_data, log_level=20)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "80" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "test_material.thermal_conductivity['curtiss2013unicorn'].value" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "82" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "test_material.thermal_conductivity['aad2015combined'].value" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} From cd9b1b0a8ada836f32b56d2bebe49626a4fe14b3 Mon Sep 17 00:00:00 2001 From: Em Ce Beh Date: Mon, 16 Aug 2021 13:12:19 +0200 Subject: [PATCH 8/9] Set up github action to run flake8 --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..386a165 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,2 @@ +- name: Flake8 check action + uses: tonybajan/flake8-check-action@v1.2.0 From 87638aba88113c8b548bf19066390757483a3387 Mon Sep 17 00:00:00 2001 From: Em Ce Beh Date: Mon, 16 Aug 2021 13:21:39 +0200 Subject: [PATCH 9/9] Delete .github directory --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 386a165..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: Flake8 check action - uses: tonybajan/flake8-check-action@v1.2.0