• No results found

Utility functions

In document Periodic Table Documentation (Page 65-74)

2.15.1 periodictable.util

Helper functions

periodictable.util.cell_volume(a=None, b=None, c=None, alpha=None, beta=None, gamma=None)

Compute cell volume from lattice parameters.

Parameters

a, b, c [float | Γ…] Lattice spacings. a is required. b and c default to a.

alpha, beta, gamma [float |∘] Lattice angles. alpha defaults to 90∘. beta and gamma default to alpha.

Returns

V [float | Γ…3] Cell volume

Raises TypeError : missing or invalid parameters The following formula works for all lattice types:

𝑉 = π‘Žπ‘π‘βˆšοΈ€

1 βˆ’ cos2𝛼 βˆ’ cos2𝛽 βˆ’ cos2𝛾 + 2 cos 𝛼 cos 𝛽 cos 𝛾

periodictable.util.require_keywords(function)

Decorator which forces all keyword arguments to the function to be explicitly named.

For example:

>>> @require_keywords

... def fn(a, b, c=3): pass

>>> fn(1, 2, 3)

Traceback (most recent call last):

...

TypeError: name=value required for c

>>> fn(1, 2, c=6)

>>> fn(b=1, a=2, c=6)

Variable arguments are not currently supported:

>>> @require_keywords

... def fn(a, b, c=6, *args, **kw): pass Traceback (most recent call last):

...

NotImplementedError: only named arguments for now

Note: The call signature is not preserved.

We can’t preserve the function signature for the call since the only way we can count the number of non-keyword arguments is to use the *args, **kw call style. Python 3+ provides the β€˜*’ call signature element which will force all keywords after β€˜*’ to be named.

2.15. Utility functions 61

CHAPTER 3

Indices and Tables

β€’ genindex

β€’ modindex

63

Python Module Index

p

periodictable.activation,40 periodictable.constants,31 periodictable.core,19

periodictable.covalent_radius,30 periodictable.cromermann,59

periodictable.crystal_structure,31 periodictable.density,32

periodictable.fasta,34 periodictable.formulas,26 periodictable.magnetic_ff,38 periodictable.mass,39

periodictable.nsf,43 periodictable.plot,60 periodictable.util,61 periodictable.xsf,53

65

Index

A

absorption(periodictable.nsf.Neutron attribute),46 absorption_comparison_table() (in module

periodictable.nsf),51

absorption_units (periodictable.nsf.Neutron at-tribute),46

abundance(periodictable.core.Isotope attribute),20 abundance(periodictable.nsf.Neutron attribute),46 abundance()(in module periodictable.mass),40 abundance_units (periodictable.core.Element

at-tribute),21

abundance_units (periodictable.nsf.Neutron at-tribute),46

ActivationEnvironment (class in period-ictable.activation),41

ActivationResult (class in

period-ictable.activation),42

activity()(in module periodictable.activation),43 add_isotope()(periodictable.core.Element method),

21

atomic_mass_constant (in module period-ictable.constants),31

atoms(periodictable.formulas.Formula attribute),28 atstol()(periodictable.cromermann.CromerMannFormula

method),60

avogadro_number (in module

period-ictable.constants),31

B

b_c(periodictable.nsf.Neutron attribute),46 b_c_i(periodictable.nsf.Neutron attribute),46 b_c_units(periodictable.nsf.Neutron attribute),46 bm(periodictable.nsf.Neutron attribute),46

bm_i(periodictable.nsf.Neutron attribute),46 bm_units(periodictable.nsf.Neutron attribute),46 bp(periodictable.nsf.Neutron attribute),46

bp_i(periodictable.nsf.Neutron attribute),46 bp_units(periodictable.nsf.Neutron attribute),46

C

calculate_activation()

(period-ictable.activation.Sample method),42 cell_volume()(in module periodictable.util),61 change_table()(in module periodictable.core),26 change_table() (periodictable.formulas.Formula

method),26

charge(periodictable.core.Element attribute),21 charge(periodictable.formulas.Formula attribute),28 coherent(periodictable.nsf.Neutron attribute),46 coherent_comparison_table()(in module

peri-odictable.nsf),51

CromerMannFormula (class in

period-ictable.cromermann),59

crystal_structure(periodictable.core.Element at-tribute),21

D

D2O_SLD(in module periodictable.fasta),38 D2Omatch()(in module periodictable.fasta),37 D2Osld()(periodictable.fasta.Molecule method),37 D2Osld()(periodictable.fasta.Sequence method),37 decay_time() (periodictable.activation.Sample

method),42

default_table()(in module periodictable.core),26 define_elements()(in module periodictable.core),

25

delayed_load()(in module periodictable.core),25 demo()(in module periodictable.activation),43 density(periodictable.core.Element attribute),21 density(periodictable.core.Isotope attribute),20

67

density()(in module periodictable.density),33 density_units (periodictable.core.Element

at-tribute),22

E

electron_mass (in module periodictable.constants), 31

electron_radius (in module

period-ictable.constants),31

electron_volt (in module periodictable.constants), 31

Element(class in periodictable.core),21

emission_table()(in module periodictable.xsf ),57 energy_dependent_table() (in module

period-ictable.nsf),52

epithermal_reduction_factor (period-ictable.activation.ActivationEnvironment attribute),42

F

f0()(periodictable.xsf.Xray method),55

fasta_table()(in module periodictable.fasta),38 find_root()(in module periodictable.activation),43

formfactor_0() (in module

period-ictable.magnetic_ff),39

formfactor_n() (in module

period-ictable.magnetic_ff),39

Formula(class in periodictable.formulas),26 formula()(in module periodictable.formulas),28 formula_grammar() (in module

period-ictable.formulas),29

fxrayatq() (in module periodictable.cromermann), 60

fxrayatstol() (in module

period-ictable.cromermann),60

G

get_data_path()(in module periodictable.core),25

getCMformula() (in module

period-ictable.cromermann),60

H

H2O_SLD(in module periodictable.fasta),38 has_sld()(periodictable.nsf.Neutron method),45 hill(periodictable.formulas.Formula attribute),28

I

IAEA1987_isotopic_abundance() (in module periodictable.activation),42

incoherent(periodictable.nsf.Neutron attribute),46 incoherent_comparison_table() (in module

periodictable.nsf),51

incoherent_units (periodictable.nsf.Neutron at-tribute),46

index_of_refraction() (in module period-ictable.xsf),58

init()(in module periodictable.activation),43 init()(in module periodictable.covalent_radius),31 init()(in module periodictable.crystal_structure),32 init()(in module periodictable.density),34

init()(in module periodictable.magnetic_ff ),39 init()(in module periodictable.mass),40 init()(in module periodictable.nsf ),46 init()(in module periodictable.xsf ),56

init_spectral_lines() (in module period-ictable.xsf),56

interatomic_distance

(period-ictable.core.Element attribute),22

interatomic_distance() (in module period-ictable.density),34

interatomic_distance_units

(period-ictable.core.Element attribute),22 Ion(class in periodictable.core),20

is_energy_dependent (periodictable.nsf.Neutron attribute),46

isatom()(in module periodictable.core),26 iselement()(in module periodictable.core),26 ision()(in module periodictable.core),26 isisotope()(in module periodictable.core),26 Isotope(class in periodictable.core),20

isotope()(periodictable.core.PeriodicTable method), 24

isotope_substitution() (in module period-ictable.fasta),38

isotopes(periodictable.core.Element attribute),22

J

K_alpha(periodictable.core.Element attribute),21 K_alpha_units (periodictable.core.Element

at-tribute),21

K_beta1(periodictable.core.Element attribute),21 K_beta1_units (periodictable.core.Element

at-tribute),21

L

list()(periodictable.core.PeriodicTable method),24

Periodic Table Documentation, Release 1.5.3

load()(periodictable.fasta.Sequence static method),37 loadall() (periodictable.fasta.Sequence static

MagneticFormFactor (class in period-ictable.magnetic_ff),38

mass(periodictable.core.Element attribute),22 mass(periodictable.core.Ion attribute),20 mass(periodictable.core.Isotope attribute),20 mass(periodictable.formulas.Formula attribute),28 mass()(in module periodictable.mass),40

mass_fraction (periodictable.formulas.Formula at-tribute),28

mass_units(periodictable.core.Element attribute),22 mirror_reflectivity() (in module

period-ictable.xsf),59

mix_by_volume() (in module

period-ictable.formulas),29

mix_by_weight() (in module

period-ictable.formulas),29

molecular_mass (periodictable.formulas.Formula attribute),28

Molecule(class in periodictable.fasta),36

N

name()(periodictable.core.PeriodicTable method),24 natural_density (periodictable.formulas.Formula

attribute),28

natural_mass_ratio()

(period-ictable.formulas.Formula method),26 Neutron(class in periodictable.nsf ),44

neutron(periodictable.core.Element attribute),22 neutron(periodictable.core.Isotope attribute),21 neutron_activation (periodictable.core.Isotope

attribute),21

neutron_composite_sld() (in module period-ictable.nsf),50

neutron_energy()(in module periodictable.nsf ),46 neutron_mass(in module periodictable.constants),31 neutron_scattering() (in module

period-ictable.nsf),47

neutron_sld()(in module periodictable.nsf ),50 neutron_sld() (periodictable.formulas.Formula

method),26

neutron_sld_from_atoms() (in module period-ictable.nsf),53

neutron_wavelength() (in module period-ictable.nsf),46

neutron_wavelength_from_velocity() (in module periodictable.nsf),47

NIST2001_isotopic_abundance() (in module periodictable.activation),43

number_density (periodictable.core.Element at-tribute),23

number_density() (in module

period-ictable.density),34

number_density_units

(period-ictable.core.Element attribute),23

P

parse_formula() (in module

period-ictable.formulas),30

PeriodicTable(class in periodictable.core),23 periodictable.activation(module),40

plancks_constant (in module

period-ictable.constants),31

plot_xsf()(in module periodictable.xsf ),58

R

read_fasta()(in module periodictable.fasta),38 replace() (periodictable.formulas.Formula method),

27

require_keywords()(in module periodictable.util), 61

S

Sample(class in periodictable.activation),42

scattering()(periodictable.nsf.Neutron method),45 scattering_factors() (periodictable.xsf.Xray

method),56

scattering_factors_units

(period-ictable.xsf.Xray attribute),56 Sequence(class in periodictable.fasta),37 sftable(periodictable.xsf.Xray attribute),56

sftable_units(periodictable.xsf.Xray attribute),56

Index 69

show_table() (periodictable.activation.Sample method),42

sld()(periodictable.nsf.Neutron method),45 sld()(periodictable.xsf.Xray method),56 sld_plot()(in module periodictable.nsf ),50 sld_table()(in module periodictable.nsf ),53 sld_table()(in module periodictable.xsf ),58 sld_units(periodictable.xsf.Xray attribute),56 sorted_activity() (in module

period-ictable.activation),43

speed_of_light(in module periodictable.constants), 31

stollimit(periodictable.cromermann.CromerMannFormula attribute),60

symbol() (periodictable.core.PeriodicTable method), 25

T

table(periodictable.core.Element attribute),23 table_plot()(in module periodictable.plot),60 test()(in module periodictable.fasta),38 total(periodictable.nsf.Neutron attribute),46

total_comparison_table() (in module period-ictable.nsf),52

total_units(periodictable.nsf.Neutron attribute),46

V

volume() (periodictable.formulas.Formula method), 27

X

Xray(class in periodictable.xsf ),55

xray(periodictable.core.Element attribute),23 xray(periodictable.core.Ion attribute),20

xray_energy()(in module periodictable.xsf ),56 xray_sld()(in module periodictable.xsf ),57

xray_sld() (periodictable.formulas.Formula method),27

xray_sld_from_atoms() (in module period-ictable.xsf),57

xray_wavelength() (in module periodictable.xsf ), 57

In document Periodic Table Documentation (Page 65-74)

Related documents