Refractive index database into C incomplete draft.
Former-commit-id: fbfce8297f16400954fa3a1a1d24b980b67d0453
This commit is contained in:
parent
f04fd9496e
commit
f04ea1d600
|
@ -0,0 +1,31 @@
|
||||||
|
'''INCOMPLETE! This will read read the refractiveindex.info yaml files
|
||||||
|
and transforms the database into a C source.'''
|
||||||
|
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader, CDumper as Dumper
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader, Dumper
|
||||||
|
|
||||||
|
# Right now, we can process only the 'tabulated nk' data
|
||||||
|
searchfor = '- type: tabulated nk'
|
||||||
|
searchfor = re.compile(searchfor)
|
||||||
|
|
||||||
|
ridatadir = "/u/46/necadam1/unix/repo/refractiveindex.info-database/database/data"
|
||||||
|
|
||||||
|
nktables = dict()
|
||||||
|
|
||||||
|
def find_files_by_pattern (pattern, dir):
|
||||||
|
r = re.compile(pattern)
|
||||||
|
for parent, dnames, fnames in os.walk(ridatadir):
|
||||||
|
for fname in fnames:
|
||||||
|
filename = os.path.join(parent, fname)
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
with open(filename) as f:
|
||||||
|
text = f.read()
|
||||||
|
if r.search(text):
|
||||||
|
yield (
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue