Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:49:17

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
0019 #
0020 
0021 """
0022 """
0023 import logging, os, numpy as np
0024 from collections import OrderedDict
0025 from opticks.ana.dae import DAE, tag_, array_
0026 
0027 class XMatLib(dict):
0028     def __init__(self, daepath="$OPTICKS_DAEPATH"):
0029         dict.__init__(self)
0030         self.dae = DAE(os.path.expandvars(daepath))
0031         self.init()
0032 
0033     def init(self):
0034         xms = self.dae.elems_("material")
0035         for xm in xms:
0036             matname = DAE.deref(xm.attrib['id'])
0037             props = xm.findall(".//%s" % tag_("matrix"))
0038             pd = OrderedDict()
0039             for prop in props:
0040                 propname = DAE.deref(prop.attrib['name'])
0041                 pd[propname] = array_(prop).reshape(-1,2)
0042             pass
0043             self[matname] = pd 
0044 
0045 
0046 
0047 if __name__ == '__main__':
0048 
0049     #xma = XMatLib("/tmp/test.dae")    
0050     xma = XMatLib()    
0051     print xma['MineralOil']['GROUPVEL']
0052 
0053 
0054 
0055 
0056 
0057