orsopy.slddb package
Package for a database of Scattering Length Density data (SLD) for neutron and x-ray scattering. The query to the DB includes recalculation of SLD for needed radiation.
Part of ORSO initiative, see: https://www.reflectometry.org/
- Contributers:
Artur Glavic <artur.glavic@psi.ch>
Subpackages
Submodules
orsopy.slddb.comparators module
Classes to represent comparisons in SQLite queries.
- class orsopy.slddb.comparators.Comparator(value, key=None)[source]
Bases:
ABC
- class orsopy.slddb.comparators.GenericComparator(value, key=None)[source]
Bases:
ComparatorComparator used for the generic case. Makes a simple comparison based on the type of the argument.
- class orsopy.slddb.comparators.ExactString(value, key=None)[source]
Bases:
ComparatorPerform an exact string comparison.
- class orsopy.slddb.comparators.FormulaComparator(value, key=None)[source]
Bases:
ComparatorCompare to formula string.
- class orsopy.slddb.comparators.FuzzyFloat(value, key=None)[source]
Bases:
ComparatorCompare a float value against a range or +/-10% of given value.
orsopy.slddb.constants module
Physical constants and conversion factors used in the package.
The values given here have been taken from the CODATA Internationally recommended 2018 values of the Fundamental Physical Constants provided at https://physics.nist.gov/cuu/Constants/index.html
orsopy.slddb.converters module
Classes for conversion of specific data into sqlite types and back.
- class orsopy.slddb.converters.Converter[source]
Bases:
ABCBase class for all other converters, can’t be used stand alone.
- sql_type = 'TEXT'
- html_list = False
- comparator
alias of
GenericComparator
- html_title = None
- class orsopy.slddb.converters.CFormula[source]
Bases:
Converter- comparator
alias of
FormulaComparator
- class orsopy.slddb.converters.CUrl[source]
Bases:
ValidatedString- regex = re.compile('^https?://(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|localhost|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})(?::\\d+)?(?:/?|[/?]\\S+)$', re.IGNORECASE)
- placeholder = 'http://www.your_website.net'
- class orsopy.slddb.converters.Cdoi[source]
Bases:
ValidatedString- regex = re.compile('^https://doi.org/(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|localhost|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})(?::\\d+)?(?:/?|[/?]\\S+)$', re.IGNORECASE)
- placeholder = 'https://doi.org/your/ref'
- class orsopy.slddb.converters.Ccas[source]
Bases:
ValidatedString- regex = re.compile('\\b[1-9][0-9]{1,5}-\\d{2}-\\d\\b', re.IGNORECASE)
- placeholder = 'xxxxxxx-yy-z'
- class orsopy.slddb.converters.CArray(shape=None, ndim=None)[source]
Bases:
Converter- sql_type = 'BLOB'
- class orsopy.slddb.converters.CLimited(fromtype, db_type, low_lim=None, up_lim=None, db_repstr=None)[source]
Bases:
CType
orsopy.slddb.database module
Manage database creation, insertion and access.
orsopy.slddb.dbconfig module
Configure the database file as well as parameters for DB tables used.
orsopy.slddb.importers module
Functions to create database compatible entries from other file formats.
orsopy.slddb.material module
Class to hold information for one material and allow calculation of x-ray and neutron SLDs for different applications.
- class orsopy.slddb.material.PolymerSequence[source]
Bases:
strUsed to represent a chain of amino acids. Currently, no checking is done and this is just a string containing the appropriate letters.
- class orsopy.slddb.material.Material(elements, dens=None, fu_volume=None, rho_n=None, mu=0.0, xsld=None, xE=None, fu_dens=None, M=None, ID=None, name=None, extra_data=None)[source]
Bases:
objectUnits used: b: fm fu_volume: ų fu_dens: 1/ų dens: g/cm³ roh_n: Å^{-2} roh_m: Å^{-2} mu: muB/FU M: kA/m = emu/cm³
- property fu_volume
- property rho_n
- property rho_m
- property M
- property dens
- property fu_mass
- property fu_b
- property has_ndata
- property formula
- property deuterated
- deuterate(fraction)[source]
Return a partially deuterated molecule with fraction of D instead of H.
- property edeuterated
- property exchanged
- property not_exchanged
- exchange(D_fraction, D2O_fraction, exchange=0.9)[source]
Return a partially deuterated modlecule within H2O/D2O solution given amount of exchange.
- property match_point
orsopy.slddb.webapi module
- class orsopy.slddb.webapi.SLD_API[source]
Bases:
objectPython API for users of the SLDDB data.
Allows to query the online database for materials, calculate SLDs and add new materials. If connection to the server fails, a local copy of the database is used, instead.
- Usage:
from orsopy.slddb import api res=api.search(formula=”Fe2O3”) res[0][‘density’] => ….
m=api.material(res[0][‘ID’]) # retrieve all data for the given material, see Material class. sldn=m.rho_n # get nuclear neutron SLD (complex number) sldm=m.rho_m # get magnetic neutron SLD (real number) sldx=m.f_of_E(E=8.047823) # get x-ray SLD (complex number) for given energy, default is Cu-Kalpha
# custom material just for SLD calculation, requires either dens, fu_volume, rho_n or xsld+xE m=api.custom(formula=’Au’, dens=19.3)
- Units of results/queries:
density: g/cm³ roh_n: Å^{-2} roh_m: Å^{-2} sldx: Å^{-2} fu_volume: ų
- db_suburl = 'download_db'
- max_age = 1
- search(**opts)[source]
Search for a particular material using a combination of provided search keys.
- Examples:
api.search(formula=”Fe2O3”) api.search(density=5.242) api.search(name=’iron’)
- material(ID)[source]
Returns the material object for a certain database entry specified by its unique ID.
- Example:
res=api.search(formula=’Fe’) material=api.material(res[0][‘ID’]) print(material.dens, material.rho_n, material.f_of_E(8.0))