%matplotlib inline

from pandas import Series

# get the data set

import requests

url = "http://datadryad.org/bitstream/handle/10255/dryad.95403/piezo.json?sequence=1"
r = requests.get(url)

# how many records?
# there are supposed to 941
len(r.json())

# look at one data element
r.json()[0]

r0 = r.json()[0]

rows = r.json()

s = Series([row.get('eij_max') for row in rows])

"""
Explanation: Piezoelectric textbook (LBL)
Computing A Textbook of Crystal Physics | Berkeley Lab

Researchers at Berkeley Lab and the University of California (UC) Berkeley have developed a methodology that enabled them to compute piezoelectric constants for nearly 1,000 inorganic compounds.
“We don’t collect experimental data – but we compare calculations with reported experimental piezoelectric constants,” says Persson. “For new materials that have not been measured before, it’s up to the community to test the data – by growing a film or a single crystal – and comparing with Materials Project computations.”

"data publication": A database to enable discovery and design of piezoelectric materials : Scientific Data
doi:10.1038/sdata.2015.53
-> https://dx.doi.org/10.1038/sdata.2015.53
http://www.nature.com/articles/sdata201553
http://www.nature.com/articles/sdata201553#contributions:

M.d.J. performed piezoelectric constant-calculations, developed the algorithm and the code, worked on data analysis and verification and wrote the paper. W.C. performed piezoelectric constant-calculations, developed the HT implementation and worked on data analysis and verification. H.G. contributed to the data analysis and verification. M.A. was involved in supervising and planning the work and its integration with the Materials Project effort. K.P. was involved in supervising and planning the work and its integration with the Materials Project effort.

http://www.nature.com/articles/sdata201553#data-citations:
De Jong, M., Chen, W., Geerlings, H., Asta, M., & Persson, K. Dryad http://dx.doi.org/10.5061/dryad.n63m4 (2015).
http://datadryad.org/resource/doi:10.5061/dryad.n63m4  --> have to read off the URL for the file:
http://datadryad.org/bitstream/handle/10255/dryad.95403/piezo.json?sequence=1
End of explanation
"""


from collections import Counter

# distribution of point groups

Counter([row['meta']['point_group'] for row in rows])

# look at histography of eij_max > 2
s[s < 2].hist(bins=30)

"""
Explanation: Figure 6
Can we reproduce Figure 6?:
End of explanation
"""


