Commit d1475a5c authored by Mohamed, Fawzi Roberto (fawzi)'s avatar Mohamed, Fawzi Roberto (fawzi)
Browse files

removing outdated query example

parent 79459f88
{
"beaker": "2",
"evaluators": [
{
"name": "HTML",
"plugin": "HTML",
"view": {
"cm": {
"mode": "htmlmixed"
}
}
},
{
"name": "JavaScript",
"plugin": "JavaScript",
"view": {
"cm": {
"mode": "javascript",
"background": "#FFE0F0"
}
},
"languageVersion": "ES2015"
},
{
"name": "IPython",
"plugin": "IPython",
"setup": "%matplotlib inline\nimport numpy\nimport matplotlib\nfrom matplotlib import pylab, mlab, pyplot\nnp = numpy\nplt = pyplot\nfrom IPython.display import display\nfrom IPython.core.pylabtools import figsize, getfigs\nfrom pylab import *\nfrom numpy import *\n",
"view": {
"cm": {
"mode": "python"
}
}
}
],
"cells": [
{
"id": "markdownT9rKmh",
"type": "markdown",
"body": [
"Warning: running the first cell of this notebook can take a long time(hours).",
"",
"One can run safely the second and third cell, that will analyze a precomputed result of the first cell (queryMgO.out).",
"",
"A more documented version of this notebook will be uploaded soon."
],
"evaluatorReader": false
},
{
"id": "sectionQ3dZWh",
"type": "section",
"title": "Query Example",
"level": 1,
"evaluatorReader": false,
"collapsed": false
},
{
"id": "markdownKIKNEj",
"type": "markdown",
"body": [
"*Warning*: running the first cell of this notebook can take a long time(hours), we are working to integrate the (much faster) flink query.",
"",
"One can run safely the second and third cell, that will analyze a precomputed result of the first cell (queryMgO.out).",
"",
"A more documented version of this notebook will be uploaded soon."
],
"evaluatorReader": false
},
{
"id": "sectionzKgCDS",
"type": "section",
"title": "Scan the whole NOMAD Archive",
"level": 2,
"evaluatorReader": false,
"collapsed": false
},
{
"id": "codecJWYiO",
"type": "code",
"evaluator": "IPython",
"input": {
"body": [
"from nomad_structure_tools import query",
"percentageOfArchives = 5",
"",
"def hasMgO(stats):",
" els = set(stats.get(\"elements\",{}).keys())",
" return stats and \"Mg\" in els and \"O\" in els and ((stats.get(\"nEigenvalues\", 0) > 0) or stats.get(\"nBands\", 0) > 0)",
"",
"def getVolumeAndGap(calc):",
" data = calc.json()",
" if not data:",
" print(calc,\"has no json\")",
" return None",
" gaps = []",
" volumes = {}",
" for sectionName1, section1 in data.get('sections', {}).items():",
" if sectionName1.startswith('section_run-'):",
" for sectionName2, section2 in section1.get('sections', {}).items():",
" if sectionName2.startswith('section_single_configuration_calculation-'):",
" gaps.append(gap.gapOfSingleConf(section2))",
" elif sectionName2.startswith('section_system-'):",
" cell = section2.get('simulation_cell')",
" atomLabels = section2.get('atom_labels')",
" atomPos = section2.get('atom_positions')",
" if atomLabels and cell:",
" hasMg = any(map(lambda x: stats.toSymbol(x) == 'Mg', atomLabels))",
" hasO = any(map(lambda x: stats.toSymbol(x) == 'O', atomLabels))",
" nAtoms = len(atomLabels)",
" if hasMg and hasO:",
" volume = abs(np.linalg.det(np.asarray(cell)))",
" volumes[section2['gIndex']] = volume/nAtoms",
" newGaps=[]",
" for g in gaps:",
" systemGIndex = g.get('systemGIndex')",
" if systemGIndex is not None:",
" vol = volumes.get(systemGIndex)",
" if vol:",
" g['volumePerAtom'] = vol",
" newGaps.append(g)",
" if newGaps:",
" return {\"calculationGid\": calc.gid, \"gaps\": newGaps }",
" else:",
" return None",
"",
"def methodToFile(outPath, archiveGroupIndexRange = query.archiveSplit(percentageOfArchives,101), calculationGroupIndexRange = query.calculationSplit(0,1)):",
" \"\"\"perform query, stores result to file\"\"\"",
" with open(outPath, \"w\", encoding=\"utf-8\") as outF:",
" nomadArch.queryCalcs(",
" statsFiltering = hasMgO,",
" calculationOp = getVolumeAndGap,",
" reduceOp = None,",
" f0 = outF,",
" closeOp = None,",
" archiveGroupIndexRange = archiveGroupIndexRange,",
" calculationGroupIndexRange = calculationGroupIndexRange,",
" parserFilter = None)",
"",
"methodToFile(\"/home/beaker/notebooks/data/querMg0.out\")",
""
]
},
"output": {
"state": {}
},
"evaluatorReader": true,
"lineCount": 58
},
{
"id": "sectionLNKIwc",
"type": "section",
"title": "Put data in a table",
"level": 2,
"evaluatorReader": false,
"collapsed": false
},
{
"id": "markdownqcviza",
"type": "markdown",
"body": [
"Organize results in a table, convert units (from SI)"
],
"evaluatorReader": false
},
{
"id": "codeCSQ8CP",
"type": "code",
"evaluator": "IPython",
"input": {
"body": [
"import json",
"import pandas as pd",
"#from nomadcore.unit_conversion.unit_conversion import convert_unit_function",
"def convert_unit_function(sourceUnits, targetUnits):",
" if sourceUnits == \"m^3\":",
" return lambda x: x*1.0e30",
" else:",
" return lambda x: x*6.242e+18",
"",
"with open(\"/home/beaker/notebooks/data/queryMgO.out\") as f:",
" d=json.load(f)",
"volumePerAtom=[]",
"calculationGid=[]",
"singleConfCalcGIndex=[]",
"gapAtGamma=[]",
"for v in d:",
" cId=v[\"calculationGid\"]",
" for el in v[\"gaps\"]:",
" gap=el.get(\"gapAtGamma\")",
" if gap:",
" volumePerAtom.append(el[\"volumePerAtom\"])",
" calculationGid.append(cId)",
" gapAtGamma.append(gap)",
" singleConfCalcGIndex.append(el[\"singleConfCalcGIndex\"])",
"df = pd.DataFrame({",
" \"volumePerAtom\": map(convert_unit_function(\"m^3\",\"angstrom^3\"),volumePerAtom),",
" \"calculationGid\": calculationGid,",
" \"singleConfCalcGIndex\":singleConfCalcGIndex,",
" \"gapAtGamma\":map(convert_unit_function(\"J\",\"eV\"),gapAtGamma)",
" })",
"df"
]
},
"output": {
"state": {
"datatablestate": {
"pagination": {
"use": true,
"rowsToDisplay": 25,
"fixLeft": 0,
"fixRight": 0
},
"columnNames": [
"calculationGid",
"gapAtGamma",
"singleConfCalcGIndex",
"volumePerAtom"
],
"actualtype": [
0,
"4.4",
2,
"4.4"
],
"actualalign": [
"L",
"R",
"R",
"R"
],
"colorder": [
0,
1,
2,
3,
4
],
"getCellSho": [
true,
true,
true,
true
],
"barsOnColumn": {},
"heatmapOnColumn": {},
"tableFilter": "",
"showFilter": false,
"columnSearchActive": false,
"columnFilter": [],
"columnWidth": []
}
},
"result": {
"columnNames": [
"Index",
"calculationGid",
"gapAtGamma",
"singleConfCalcGIndex",
"volumePerAtom"
],
"subtype": "TableDisplay",
"values": [
[
0,
"Pum1Gw6M0I-XY27eZ361mF3Og33Ls",
3.5723807314318754,
4,
10.669097153967916
],
[
1,
"PeXkmDvw1ryqkJw3f-9RIaS5h-IUZ",
3.5726807550088826,
4,
10.668897136382887
],
[
2,
"PpKa_jkQaEzsNGtWH9NsQQqPj1XEf",
3.4773732653794043,
0,
10.669097860428517
],
[
3,
"Pw5q80AyZsDnvRR2XIm3sbQxtARmO",
3.5281772577527257,
26,
10.812633398096658
],
[
4,
"P5rAKxyOryckkSO9Mz9P9e0vMYKRs",
3.477873304674417,
0,
10.668897556127115
],
[
5,
"Pskq-lvlnBdLinUF5X_HI35n3sjhS",
3.528477281329733,
26,
10.814984465235764
],
[
6,
"PMPKlIlfBFQgh7GqP50cIu2Mr11pX",
5.714649079126569,
4,
9.0983104851155
],
[
7,
"Pxw9VFrViNA06POt51W_QwqzgCXMm",
8.744287159751332,
59,
6.464116932201225
],
[
8,
"P2tG-Zpu-4Y1C73zWM8vOpkIjMbv0",
5.430826775277191,
0,
9.437173638876379
],
[
9,
"PD5Z0KXSzqQhZamMclJUTY8BJsU7Z",
5.69344741301802,
0,
9.098311176385998
],
[
10,
"PdIjoF-bt1wuVzPzNG_KP36a-8x5K",
3.905506909769535,
0,
10.628302791256772
],
[
11,
"PhlUe1bYGJ_7290uAUUbyLBCV_w9P",
3.90490686261552,
2,
10.628301957337763
],
[
12,
"P7FbfWoHB9S79SYhjpJWuBLT2YDF6",
4.246733724686406,
0,
10.510064122830263
],
[
13,
"PS-LapMKB-9QWR4OzTtBZqzOCsBEp",
5.158605383072114,
0,
8.55806595470939
],
[
14,
"Plt8aehRKEiYBf3sm2d3RSE_hQTJn",
3.7955982727256776,
12,
11.77601752956493
],
[
15,
"PGeHdwDvqwouKjHcSZz075FjJDiAQ",
4.288236986172485,
0,
10.34824311498097
],
[
16,
"Pcsyf2ofOmW9VWY91ot3c0EEH_XAW",
4.244333536070344,
4,
10.510066786089395
],
[
17,
"P-Vk81eS5lFTtEIVb2QJ_RCxRB3uG",
5.187207630746855,
4,
8.558065279397127
],
[
18,
"PXsQ4yo09MbNBXQVyqsM6IfsHpRGf",
3.990113558485735,
0,
10.4660287642818
],
[
19,
"P03FFhdUR5vkAb96ThKoDVrlafdG9",
0.03580281352293076,
0,
11.776016140489089
],
[
20,
"PVsYDkZqyDHpDwmrP71O0pQuS8mc9",
5.434527066060288,
0,
8.357625418831807
],
[
21,
"PlIhH0Y_3jCtmnqV-3JBjeHLWtaug",
6.394202481049236,
18,
8.206836525290566
],
[
22,
"PaMCKbapuodNOlsoTuNVnjvJRH6OJ",
5.435727160368319,
2,
9.437174012415559
],
[
23,
"POTVgJoFDkR-gnN6ig0vHhji1xuLq",
4.852881358101164,
26,
10.286068287119491
],
[
24,
"PTWczpMwiwl_G9vCyzP6HcJWWA6X8",
5.522433974123572,
0,
8.382567676960509
],
[
25,
"P-sgCsNtGMKv3zNrYBtNq5pSidEfK",
5.2582132106387025,
6,
8.593543823229208
],
[
26,
"PMkksic6a0O6GpanS61_WIcQuKv0A",
3.03563855216492,
15,
12.107584942228591
],
[
27,
"PCQhJw3VtB48VYaWfwFEXR7ZcD6xv",
4.834079880608676,
0,
10.286067635289657
],
[
28,
"PW-eYaIMigW1519FGffse3l3xghdD",
3.0225375226355795,
0,
12.107585358168555
],
[
29,
"PzaUcRnkMYOv-XEyqsLTfPnZcCF5R",
5.25581302202264,
0,
8.593545457077738
],
[
30,
"PN3dZ8IdhMK2BXVpb3jmPdpUsjUPA",
3.0054361787461357,
2,
10.674339323287906
],
[
31,
"PeGa7OE3ocfNHGvuB9ukClLAsB07_",
0.7761609937191789,
4,
11.012370193611627
],
[
32,
"P-mLGjDk--rXHOAq2ebRq2YtZD8qQ",
2.2935802383656285,
3,
12.252357455267548
],
[
33,
"PSzkCPVY30po_IKQG2N4cLiQwU2Cb",
2.999235691487974,
2,
10.690585111778612
],
[
34,
"P7qTVsgICMZq2MdlEr2HXm3fi8a_k",
2.113766107878954,
0,
11.181730695793195
],
[
35,
"P99S6QlD8u2Acy2ZGo_nMe1C7RMGK",
3.7248927164108405,
0,
16.74132941392552
],
[
36,
"PssP15XY8x9xbZZguxZAo7xsxzqFv",
7.622999044614181,
2,
11.586125003019424
],
[
37,
"PRF4R2FKvKtgMF4GkcT81lSAkQSnL",
3.1596482973281446,
2,
11.727137615588267
],
[
38,
"PkeQYbzoh1KTrCiniY-SwDT8tImcJ",
2.136867923308554,
2,
11.18173008169867
],
[
39,
"PQbt3s1AJrwxfxgAHnYLSWy-kQmVx",
12.207759332729378,
5,
11.330406188878966
],
[
40,
"PfiHANo0AiS1Y3k6axyNT_Qg6Mvp0",
3.588682012449299,
0,
9.757313887849342
],
[
41,
"P0YPG5Qtu-YIe7WMv0QcaZSeuFQEp",
3.197051236595117,
2,
11.42247876865802
],
[
42,
"Pj4vceX-zRu2oq7pVxHLj4lr6r8Ff",
5.709148646881427,
4,
12.825053992668336
],
[
43,
"PDj06dFQ6Q2qPWoGFUKUtPIveMfxl",
1.7286358428599407,
0,
10.566073512272744
],
[
44,
"PkkfkcUWDNknXmIQPZOams5TjEkoY",
7.864518024105463,
0,
11.244661495941914
],
[
45,
"PWdwsk5BfBKYZGpGQwrvVcldXiY5f",
2.75101618544352,
3,
10.594108429358492
],
[
46,
"PkpobuiWJp_oeaeovm4DcQ2QqGkIj",
1.6662309388423184,
0,
14.589886956541308
],
[
47,
"PP0tPrVa4_FE4VnAlxTvwArG5Z3FR",
3.1803499241416815,
0,
11.422478857640671
],
[
48,
"PS9-yPEP14ZYh8GyG2q-8A5egKcPn",
3.364664408283475,
5,
10.02966405761103
],
[
49,
"P27h19Av37xN3RcS3QylsLzxC78uB",
5.504832590939115,
2,
18.082105090347795
],
[
50,
"PzjTjAg1VdTTCdUIow3IWBaQDqVoT",
3.1288458767553435,
3,
12.105506104227311
],
[
51,
"ProuAlq5b36MiH9rmAF8MTCg-kQO9",
12.790205103560522,
2,
10.844322183872189
],
[
52,
"P0Nj-WcMjujpYtjcK3I8X8iBaTKSV",
1.4975176807049322,
0,
19.21591791338176
],
[
53,
"PWgHH_4Nhmgi0wx5mParoRnuSb37_",
2.7818186060163215,
4,
10.318313759736892
],
[
54,
"PWpvaaWAws_Q-HBmuj-k7VbLTUFao",
1.4327125880712477,
2,
13.73312769104289
],
[
55,
"P-beHCJtTujTsQds5OTl15_EyNUml",
0.7425583530943057,