Skip to content

Commit 497993e

Browse files
author
jgaff
committed
Additional helpers, some helper rewrites
Add helpers match_ids(), match_resource_types(), and fetch_datasets_from_results(), which all do basically what you'd think. Also add tests and tutorial examples for each. Some improvements to formatting in Forge (trying to keep lines of code <100 characters long, to better fit on most screens). Finally, rewrite some of the helpers that relied on commas to OR values together in field matches. The comma behavior, although functional, turned out to be technically undefined and therefore unreliable.
1 parent 0b0ea7c commit 497993e

4 files changed

Lines changed: 676 additions & 176 deletions

File tree

‎docs/tutorials/4 - General Helper Functions.ipynb‎

Lines changed: 158 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@
6161
"{'mdf': {'collection': 'AMCS',\n",
6262
" 'composition': 'Al4',\n",
6363
" 'elements': ['Al'],\n",
64-
" 'ingest_date': '2017-08-04T19:02:11.320513Z',\n",
64+
" 'ingest_date': '2017-08-04T19:07:56.890584Z',\n",
6565
" 'links': {'cif': {'http_host': 'http://rruff.geo.arizona.edu',\n",
66-
" 'path': '/AMS/xtal_data/CIFfiles/13122.cif'},\n",
66+
" 'path': '/AMS/xtal_data/CIFfiles/19141.cif'},\n",
6767
" 'dif': {'http_host': 'http://rruff.geo.arizona.edu',\n",
68-
" 'path': '/AMS/xtal_data/DIFfiles/13122.txt'},\n",
69-
" 'landing_page': 'http://rruff.geo.arizona.edu/AMS/minerals/Aluminium',\n",
68+
" 'path': '/AMS/xtal_data/DIFfiles/19141.txt'},\n",
69+
" 'landing_page': 'http://rruff.geo.arizona.edu/AMS/minerals/Aluminum#18135',\n",
7070
" 'parent_id': '5984c125f2c0043771d1507c'},\n",
71-
" 'mdf_id': '5984c4b3f2c0043771d180a3',\n",
71+
" 'mdf_id': '5984c60cf2c0043771d19753',\n",
7272
" 'metadata_version': '0.3.2',\n",
7373
" 'resource_type': 'record',\n",
74-
" 'scroll_id': 12327,\n",
74+
" 'scroll_id': 18135,\n",
7575
" 'source_name': 'amcs',\n",
76-
" 'tags': ['Aluminium', 'cif', 'dif'],\n",
77-
" 'title': 'AMCS - Aluminium'}}"
76+
" 'tags': ['Aluminum', 'cif', 'dif'],\n",
77+
" 'title': 'AMCS - Aluminum'}}"
7878
]
7979
},
8080
"execution_count": 4,
@@ -126,7 +126,7 @@
126126
{
127127
"data": {
128128
"text/plain": [
129-
"<mdf_forge.forge.Forge at 0x7f9b20472f98>"
129+
"<mdf_forge.forge.Forge at 0x7f27a81b61d0>"
130130
]
131131
},
132132
"execution_count": 6,
@@ -234,7 +234,9 @@
234234
{
235235
"cell_type": "code",
236236
"execution_count": 10,
237-
"metadata": {},
237+
"metadata": {
238+
"scrolled": false
239+
},
238240
"outputs": [
239241
{
240242
"data": {
@@ -463,6 +465,149 @@
463465
"mdf.show_fields(\"mdf\")"
464466
]
465467
},
468+
{
469+
"cell_type": "markdown",
470+
"metadata": {},
471+
"source": [
472+
"# Fetching Datasets"
473+
]
474+
},
475+
{
476+
"cell_type": "markdown",
477+
"metadata": {},
478+
"source": [
479+
"### fetch_datasets_from_results\n",
480+
"This method allows you to automatically collect all the datasets that have records returned from a search. In other words, if you search for `mdf.elements:Al` and a _record_ from OQMD is returned, you can pass that record to `fetch_datasets_from_results()` and get the OQMD _dataset_ entry back."
481+
]
482+
},
483+
{
484+
"cell_type": "code",
485+
"execution_count": 11,
486+
"metadata": {},
487+
"outputs": [],
488+
"source": [
489+
"records = mdf.search(\"mdf.tags:outcar AND mdf.resource_type:record\")"
490+
]
491+
},
492+
{
493+
"cell_type": "code",
494+
"execution_count": 12,
495+
"metadata": {},
496+
"outputs": [
497+
{
498+
"data": {
499+
"text/plain": [
500+
"{'mdf': {'author': [{'email': 'ddmorgan@wisc.edu',\n",
501+
" 'family_name': 'Morgan',\n",
502+
" 'full_name': 'Dane Morgan',\n",
503+
" 'given_name': 'Dane',\n",
504+
" 'institution': 'University of Wisconsin-Madison'},\n",
505+
" {'family_name': 'Mayeshiba',\n",
506+
" 'full_name': 'Tam Mayeshiba',\n",
507+
" 'given_name': 'Tam',\n",
508+
" 'institution': 'University of Wisconsin-Madison'}],\n",
509+
" 'citation': ['Mayeshiba, T. & Morgan, D. Strain effects on oxygen migration in perovskites. Physical chemistry chemical physics : PCCP 17, 2715-2721, doi:10.1039/c4cp05554c (2015).',\n",
510+
" 'Mayeshiba, T. & Morgan, D. Correction: Strain effects on oxygen migration in perovskites. Physical chemistry chemical physics : PCCP, doi:10.1039/c6cp90050j (2016).'],\n",
511+
" 'collection': 'Strain Effects on Oxygen Migration',\n",
512+
" 'data_contact': {'email': 'ddmorgan@wisc.edu',\n",
513+
" 'family_name': 'Morgan',\n",
514+
" 'full_name': 'Dane Morgan',\n",
515+
" 'given_name': 'Dane',\n",
516+
" 'institution': 'University of Wisconsin-Madison'},\n",
517+
" 'data_contributor': [{'email': 'jgaff@uchicago.edu',\n",
518+
" 'family_name': 'Gaff',\n",
519+
" 'full_name': 'Jonathon Gaff',\n",
520+
" 'github': 'jgaff',\n",
521+
" 'given_name': 'Jonathon',\n",
522+
" 'institution': 'The University of Chicago'}],\n",
523+
" 'description': 'This work reports on an ab initio prediction of strain effects on migration energetics for nine perovskite systems of the form LaBO3, where B = [Sc, Ti, V, Cr, Mn, Fe, Co, Ni, Ga].',\n",
524+
" 'ingest_date': '2017-08-04T19:44:08.493637Z',\n",
525+
" 'links': {'data_doi': 'http://hdl.handle.net/11256/701',\n",
526+
" 'landing_page': 'https://materialsdata.nist.gov/dspace/xmlui/handle/11256/701',\n",
527+
" 'publication': ['https://dx.doi.org/10.1039/c4cp05554c',\n",
528+
" 'https://dx.doi.org/10.1039/c6cp90050j']},\n",
529+
" 'mdf_id': '5984ce88f2c00438682feec5',\n",
530+
" 'metadata_version': '0.3.2',\n",
531+
" 'resource_type': 'dataset',\n",
532+
" 'source_name': 'strain_effects_oxygen',\n",
533+
" 'tags': ['dft', 'perovskites'],\n",
534+
" 'title': 'Strain effects on oxygen migration in perovskites: La[Sc, Ti, V, Cr, Mn, Fe, Co, Ni, Ga]O3',\n",
535+
" 'year': 2016}}"
536+
]
537+
},
538+
"execution_count": 12,
539+
"metadata": {},
540+
"output_type": "execute_result"
541+
}
542+
],
543+
"source": [
544+
"res = mdf.fetch_datasets_from_results(records)\n",
545+
"res[0]"
546+
]
547+
},
548+
{
549+
"cell_type": "markdown",
550+
"metadata": {},
551+
"source": [
552+
"If you don't want to keep the results at all, you can also use `fetch_datasets_from_results()` to execute a search and use those results instead of passing it your own results."
553+
]
554+
},
555+
{
556+
"cell_type": "code",
557+
"execution_count": 13,
558+
"metadata": {},
559+
"outputs": [
560+
{
561+
"data": {
562+
"text/plain": [
563+
"{'mdf': {'author': [{'email': 'qhong@alumni.caltech.edu',\n",
564+
" 'family_name': 'Hong',\n",
565+
" 'full_name': 'Qi-Jun Hong',\n",
566+
" 'given_name': 'Qi-Jun',\n",
567+
" 'institution': 'Brown University'},\n",
568+
" {'email': 'avdw@alum.mit.edu',\n",
569+
" 'family_name': 'van de Walle',\n",
570+
" 'full_name': 'Axel van de Walle',\n",
571+
" 'given_name': 'Axel',\n",
572+
" 'institution': 'Brown University'}],\n",
573+
" 'citation': ['Qi-Jun Hong, Axel van de Walle, A user guide for SLUSCHI: Solid and Liquid in Ultra Small Coexistence with Hovering Interfaces, Calphad, Volume 52, March 2016, Pages 88-97, ISSN 0364-5916, http://doi.org/10.1016/j.calphad.2015.12.003.'],\n",
574+
" 'collection': 'SLUSCHI',\n",
575+
" 'data_contact': {'email': 'qhong@alumni.caltech.edu',\n",
576+
" 'family_name': 'Hong',\n",
577+
" 'full_name': 'Qi-Jun Hong',\n",
578+
" 'given_name': 'Qi-Jun',\n",
579+
" 'institution': 'Brown University'},\n",
580+
" 'data_contributor': [{'email': 'jgaff@uchicago.edu',\n",
581+
" 'family_name': 'Gaff',\n",
582+
" 'full_name': 'Jonathon Gaff',\n",
583+
" 'github': 'jgaff',\n",
584+
" 'given_name': 'Jonathon',\n",
585+
" 'institution': 'The University of Chicago'}],\n",
586+
" 'description': 'Although various approaches for melting point calculations from first principles have been proposed and employed for years, their practical implementation has hitherto remained a complex and time-consuming process. The SLUSCHI code (Solid and Liquid in Ultra Small Coexistence with Hovering Interfaces) drastically simplifies this procedure into an automated package, by implementing the recently-developed small-size coexistence method and putting together a series of steps that lead to final melting point evaluation. Based on density functional theory, SLUSCHI employs Born–Oppenheimer molecular dynamics techniques under the isobaric–isothermal (NPT) ensemble, with interface to the first-principles code VASP.',\n",
587+
" 'ingest_date': '2017-08-04T19:43:39.345950Z',\n",
588+
" 'links': {'landing_page': 'http://blogs.brown.edu/qhong/?page_id=102',\n",
589+
" 'publication': ['https://doi.org/10.1016/j.calphad.2015.12.003']},\n",
590+
" 'mdf_id': '5984ce6bf2c004385fd54cd4',\n",
591+
" 'metadata_version': '0.3.2',\n",
592+
" 'resource_type': 'dataset',\n",
593+
" 'source_name': 'sluschi',\n",
594+
" 'tags': ['Melting temperature calculation',\n",
595+
" 'Density functional theory',\n",
596+
" 'Automated code'],\n",
597+
" 'title': 'Solid and Liquid in Ultra Small Coexistence with Hovering Interfaces',\n",
598+
" 'year': 2015}}"
599+
]
600+
},
601+
"execution_count": 13,
602+
"metadata": {},
603+
"output_type": "execute_result"
604+
}
605+
],
606+
"source": [
607+
"res = mdf.match_field(\"mdf.elements\", \"Al\").fetch_datasets_from_results()\n",
608+
"res[0]"
609+
]
610+
},
466611
{
467612
"cell_type": "markdown",
468613
"metadata": {},
@@ -487,7 +632,7 @@
487632
},
488633
{
489634
"cell_type": "code",
490-
"execution_count": 11,
635+
"execution_count": 14,
491636
"metadata": {},
492637
"outputs": [
493638
{
@@ -513,14 +658,14 @@
513658
},
514659
{
515660
"cell_type": "code",
516-
"execution_count": 12,
661+
"execution_count": 15,
517662
"metadata": {},
518663
"outputs": [
519664
{
520665
"name": "stderr",
521666
"output_type": "stream",
522667
"text": [
523-
"100%|██████████| 23269/23269 [01:10<00:00, 340.42it/s]"
668+
"100%|██████████| 23269/23269 [01:00<00:00, 375.08it/s]"
524669
]
525670
},
526671
{

0 commit comments

Comments
 (0)