How to use storable - 1 common examples

To help you get started, we’ve selected a few storable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tschoonj / xraylib / data / anomalous-scattering / henke.py View on Github external
import sys, os
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import utils
import numpy as np
import xraylib as xrl

from storable import retrieve # to read Perl storables

def check_energy(energy):
	return energy
	for i in range(1, energy.size):
		if (energy[i] == energy[i-1]):
			energy[i] += 1E-6
	return energy

data = retrieve('henke.db')

with open('../fi.dat', 'w') as fi, open('../fii.dat', 'w') as fii:
	for Z in range(1, 93):
		print('Processing {Z}'.format(Z=Z))
		symbol = xrl.AtomicNumberToSymbol(Z).lower()
		energy = check_energy(np.array(data[symbol]['energy'], dtype=np.float64))
		f1 = np.array(data[symbol]['f1'], dtype=np.float64)
		f1dd = utils.deriv(energy, utils.deriv(energy, f1))
		f1dd[np.where(np.logical_or(f1dd < -1, f1dd > 1))] = 0.0
		f2 = np.array(data[symbol]['f2'], dtype=np.float64)
		f2dd = utils.deriv(energy, utils.deriv(energy, f2))
		f2dd[np.where(np.logical_or(f2dd < -1, f2dd > 1))] = 0.0
		npoints = energy.size
		fi.write('{n}\n'.format(n=npoints))
		fii.write('{n}\n'.format(n=npoints))
		for point in range(npoints):

storable

Python Perl Storable module

(Libpng OR Zlib)
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular storable functions

Similar packages