Skip to main content

An alpha version for OpenMindat package

Project description

[!Caution] Due to the recent changes in the Mindat API, the OpenMindat package is currently undergoing updates. Some functionalities may not work as expected. We are actively working on resolving these issues and appreciate your patience.

OpenMindat: A Python Package for Geomaterial Data Analysis and Retrieval from Mindat API

The OpenMindat Python package is designed to facilitate querying and retrieving data on minerals and geomaterials from the Mindat API. It provides classes for detailed queries based on various attributes like IMA status, keywords, and specific geomaterial properties.

GitHub Repository: OpenMindat Python Package

Table of Contents

Get Started

Install via Pip

foo@bar:~$ pip install openmindat

Import the Package in Python

import openmindat

Endpoint Descriptions

Endpoint Classes Description
Dana8 - DanaRetriever() Search query to return information about the Dana-8 classification standard.
Geomaterials - GeomaterialRetriever()
- GeomaterialIdRetreiver()
- GeomaterialDictRetriever()
Search query to return information about mindat database items such as id, name, group id etc.
Geomaterial_search - GeomaterialSearchRetriever() Query to search for mindat database entries based on search keywords.
Localities - LocalitiesRetriever()
- LocalitiesIdRetriever()
Search query to return information about different localities, for examples the main elements present in the Jegdalek ruby deposit in Afghanistan
Localities_Age - LocalitiesAgeRetriever()
- LocalitiesAgeIdRetriever()
Search query to return locality age details.
Localities_Statues - LocalitiesStatusRetriever()
- LocalitiesStatusIdRetriever()
Search query to return information about the status type of localities. For example, abandoned is a status type.
Localities_Type - LocalitiesTypeRetriever()
- LocalitiesTypeIdRetriever()
Search query to return information about the type of localities. For example, a Mining Field is a locality type.
LocGeoregion2 - GeoRegionRetriever() Gives information about GeoRegion boundaries
LocObject - LocobjectRetriever() N/A
Minerals-IMA - MineralsIMARetriever()
- MineralsIdRetriever()
Search query to return IMA details for a mineral. For example the year it's IMA status was approved.
Nickel_Strunz - StrunzRetriever() Search query to return information about the Nickel-Strunz-10 classification standard.
Photo_Count - PhotoCountRetriever() N/A

Use Cases

0. Setup

Setting API Key in Alternative Ways

import os

os.environ["MINDAT_API_KEY"] = 'Your_Mindat_API_Key'

If you do not have a Mindat API key, please refer to How to Get My Mindat API Key or Token?

You can also set the API key by following the general queries.

Checking Available Methods

from openmindat import GeomaterialRetriever

gr = GeomaterialRetriever()
# Print out the available functions for a class
gr.available_methods()
from openmindat import GeomaterialRetriever

gr = GeomaterialRetriever()
# Typo check
gr.elements_in('Cu')
'''>>> AttributeError: 'GeomaterialRetriever' object has no attribute 'elements_in', 
Available methods: ['_init_params', 'available_methods', 'bi_max', 'bi_min', 'cleavagetype', 'color', 
'colour', 'crystal_system', 'density_max', 'density_min', 'diaphaneity', 'elements_exc', 'elements_inc', 
'entrytype', 'expand', 'fields', 'fracturetype', 'get_dict', 'groupid', 'hardness_max', 'hardness_min', 
'id__in', 'ima', 'ima_notes', 'ima_status', 'lustretype', 'meteoritical_code', 
'meteoritical_code_exists', 'name', 'non_utf', 'omit', 'optical2v_max', 'optical2v_min', 'opticalsign', 
'opticaltype', 'ordering', 'page', 'page_size', 'polytypeof', 'q', 'ri_max', 'ri_min', 'save', 'saveto', 
'streak', 'synid', 'tenacity', 'updated_at', 'varietyof']. Did you mean: 'elements_inc'?'''

1. Perform Detailed Queries on Geomaterials

from openmindat import GeomaterialRetriever

gr = GeomaterialRetriever()
gr.density_min(2.0).density_max(5.0).crystal_system("Hexagonal")
gr.elements_exc("Au,Ag")
gr.save()

2. Retrieve IMA-Approved Minerals

from openmindat import MineralsIMARetriever

mir = MineralsIMARetriever()
mir.fields("id,name,ima_formula,ima_year")
mir.saveto("./mindat_data", 'my_filename')

3. Search Geomaterials Using Keywords

from openmindat import GeomaterialSearchRetriever

gsr = GeomaterialSearchRetriever()
gsr.geomaterials_search("quartz, green, hexagonal")
gsr.save("filename")

# Alternatively, you can get the list object directly:
gsr = GeomaterialSearchRetriever()
gsr.geomaterials_search("ruby, red, hexagonal")
print(gsr.get_dict())

4. Retrieve Localities

from openmindat import LocalitiesRetriever

# Download Localities for certain state
lr = LocalitiesRetriever()
lr.country("USA").txt("Idaho")
lr.save()

# Alternatively, you can get the list object directly:
lr = LocalitiesRetriever()
lr.country("Canada").description("mine")
print(lr.get_dict())

5. Retrieve Type Localities for IMA-Approved Mineral Species

from openmindat import GeomaterialRetriever

gr = GeomaterialRetriever()
gr.ima(True).expand("type_localities")
gr.saveto("./mindat_data")

6. Retrieve Locality Occurrences for Single Mineral Species

Please consider using only one mineral species ID for querying localities occurrences since this query might result in many records and exceed the server limitation.

from openmindat import GeomaterialRetriever

gr = GeomaterialRetriever()
gr.expand("locality").id__in(str(id_value))
gr.saveto("./mindat_data")

Documentation and Links

To explore detailed class and method documentation within the OpenMindat package, use Python's built-in help() function. This provides direct access to docstrings, showcasing usage examples and parameter details. Example:

from openmindat import GeomaterialRetriever

help(GeomaterialRetriever)

The help() is also available for the specific functions:

from openmindat import MineralsIMARetriever

help(MineralsIMARetriever.fields)

Press q to exit the help interface.

Contact Us

For further assistance or feedback, feel free to contact the development team at jiyinz@uidaho.edu.

License

Project Licence: Apache

Mindat Data License: CC BY-NC-SA 4.0 DEED

The Mindat API is currently in beta test, and while access is free for all, please note that the data provided are not yet licensed for redistribution and are for private, non-commercial use only. Once launched, data will be available under an open-access license, but please always check the terms of use of the license before reusing these data.

Authors

Jiyin Zhang, Cory Clairmont, Xiaogang Ma

Citations

If you use the data or code from this repository, please cite it as indicated below.

@misc{OpenMindat,
  author = {Jiyin Zhang and Cory Clairmont and Xiaogang Ma},
  title = {OpenMindat: A Python Package for Geomaterial Data Analysis and Retrieval from Mindat API},
  year = {2024},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/ChuBL/OpenMindat}},
  note = {Version 0.0.8}
}

Additionally, you should also reference the following paper:

Ma, X., Ralph, J., Zhang, J., Que, X., Prabhu, A., Morrison, S.M., Hazen, R.M., Wyborn, L. and Lehnert, K., 2024. OpenMindat: Open and FAIR mineralogy data from the Mindat database. Geoscience Data Journal, 11(1), pp.94-104. https://doi.org/10.1002/gdj3.204.

Acknowledgments

  • This work is supported by NSF, Award #2126315.

Change Logs

View the full changelog here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openmindat-0.1.3.tar.gz (6.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openmindat-0.1.3-py3-none-any.whl (53.6 kB view details)

Uploaded Python 3

File details

Details for the file openmindat-0.1.3.tar.gz.

File metadata

  • Download URL: openmindat-0.1.3.tar.gz
  • Upload date:
  • Size: 6.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openmindat-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2d5b8bb26a53dc146d38c6850fb630c74285985e1a9870c727cfd13a78c479bb
MD5 e1fb707e3bb1914b19caf38b0f875db8
BLAKE2b-256 c540c64127345e57cad34b56a7fb738ddf3985e9d50516e797ff11ce84c525b7

See more details on using hashes here.

File details

Details for the file openmindat-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: openmindat-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 53.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openmindat-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cec207d698f892d93968aceeb74310c2d6d01213a02e7e8009d7665cce891f33
MD5 7659d0e23c1fafb772f45408a49768bd
BLAKE2b-256 cd4c616eaf9565ba1e68a2a244f161f22be83f77b028c7c23b16594d8a39401c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page