Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:49

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 import sys, os, json, numpy as np, logging
0023 log = logging.getLogger(__name__)
0024 
0025 tx_load = lambda _:list(map(str.strip, open(_).readlines()))
0026 js_load = lambda _:json.load(open(_))
0027 
0028 class Mesh(object):
0029     """
0030     Loads the logical volume names from GItemList/GMeshLib.txt
0031     """
0032     def __init__(self, kd):
0033         log.debug("Mesh for kd : %s " % kd )
0034         lvnames = tx_load(os.path.join(kd, "GItemList/GMeshLib.txt"))
0035         name2idx = dict(zip( lvnames, range(len(lvnames)) ))
0036         idx2name = dict(zip( range(len(lvnames)), lvnames ))   
0037         self.keydir = kd
0038         self.name2idx = name2idx
0039         self.idx2name = idx2name
0040 
0041 
0042 if __name__ == '__main__':
0043     logging.basicConfig(level=logging.INFO)
0044 
0045     from opticks.ana.key import keydir
0046     kd = keydir(os.environ["OPTICKS_KEY"]) 
0047 
0048     mh = Mesh(kd)
0049     args = sys.argv[1:]
0050 
0051     iargs = map(int, args) if len(args) > 0 else mh.idx2name.keys()
0052     for idx in iargs:
0053         print("%3d : %s " % ( idx, mh.idx2name[idx] ))
0054     pass
0055 
0056      
0057 
0058