File indexing completed on 2025-01-30 09:14:57
0001
0002
0003
0004
0005
0006
0007
0008
0009 import json
0010 import sys
0011
0012
0013
0014
0015
0016
0017
0018
0019 if sys.version_info[0] < 3:
0020 print("Using Python 2")
0021 print("To obtain the proper ordering in the Json files Python 3 is recomanded")
0022
0023 if len(sys.argv) < 2:
0024 inFileName = "geometry-map.json"
0025 confFileName = "config-map.json"
0026
0027 if len(sys.argv) < 3:
0028 confFileName = "config-map.json"
0029
0030 else:
0031 inFileName = sys.argv[1]
0032 confFileName = sys.argv[2]
0033
0034
0035 with open(inFileName, "r+") as json_file:
0036 with open(confFileName, "r") as config_file:
0037 config = json.load(config_file)
0038 data = json.load(json_file)
0039
0040 for entry in data["Surfaces"]["entries"]:
0041 if "type" not in entry["value"]["bounds"]:
0042 entry["value"]["bounds"]["type"] = ""
0043
0044 if "layer" in entry:
0045 if "approach" not in entry:
0046 if "sensitive" not in entry:
0047 for conf in config["Surfaces"][str(entry["volume"])]:
0048 if (
0049 "layer" in conf
0050 and conf["layer"] == "X"
0051 and conf["value"]["bounds"]["type"]
0052 == entry["value"]["bounds"]["type"]
0053 ):
0054 entry["value"]["material"]["mapMaterial"] = conf[
0055 "value"
0056 ]["material"]["mapMaterial"]
0057 entry["value"]["material"]["mappingType"] = conf[
0058 "value"
0059 ]["material"]["mappingType"]
0060 ibin = 0
0061 for bin in entry["value"]["material"]["binUtility"][
0062 "binningdata"
0063 ]:
0064 bin["bins"] = conf["value"]["material"][
0065 "binUtility"
0066 ]["binningdata"][ibin]["bins"]
0067 ibin = ibin + 1
0068 continue
0069 continue
0070
0071 if "boundary" in entry:
0072 if "layer" not in entry:
0073 for conf in config["Surfaces"][str(entry["volume"])]:
0074 if (
0075 "boundary" in conf
0076 and conf["boundary"] == entry["boundary"]
0077 and conf["value"]["bounds"]["type"]
0078 == entry["value"]["bounds"]["type"]
0079 ):
0080 entry["value"]["material"]["mapMaterial"] = conf["value"][
0081 "material"
0082 ]["mapMaterial"]
0083 entry["value"]["material"]["mappingType"] = conf["value"][
0084 "material"
0085 ]["mappingType"]
0086 ibin = 0
0087 for bin in entry["value"]["material"]["binUtility"][
0088 "binningdata"
0089 ]:
0090 bin["bins"] = conf["value"]["material"]["binUtility"][
0091 "binningdata"
0092 ][ibin]["bins"]
0093 ibin = ibin + 1
0094 continue
0095 continue
0096
0097 if "approach" in entry:
0098 if "sensitive" not in entry:
0099 for conf in config["Surfaces"][str(entry["volume"])]:
0100 if (
0101 "approach" in conf
0102 and conf["approach"] == entry["approach"]
0103 and conf["value"]["bounds"]["type"]
0104 == entry["value"]["bounds"]["type"]
0105 ):
0106 entry["value"]["material"]["mapMaterial"] = conf["value"][
0107 "material"
0108 ]["mapMaterial"]
0109 entry["value"]["material"]["mappingType"] = conf["value"][
0110 "material"
0111 ]["mappingType"]
0112 ibin = 0
0113 for bin in entry["value"]["material"]["binUtility"][
0114 "binningdata"
0115 ]:
0116 bin["bins"] = conf["value"]["material"]["binUtility"][
0117 "binningdata"
0118 ][ibin]["bins"]
0119 ibin = ibin + 1
0120 continue
0121 continue
0122
0123 if "sensitive" in entry:
0124 if "approach" not in entry:
0125 for conf in config["Surfaces"][str(entry["volume"])]:
0126 if (
0127 "sensitive" in conf
0128 and conf["sensitive"] == "X"
0129 and conf["layer"] == entry["layer"]
0130 and conf["value"]["bounds"]["type"]
0131 == entry["value"]["bounds"]["type"]
0132 ):
0133 entry["value"]["material"]["mapMaterial"] = conf["value"][
0134 "material"
0135 ]["mapMaterial"]
0136 entry["value"]["material"]["mappingType"] = conf["value"][
0137 "material"
0138 ]["mappingType"]
0139 ibin = 0
0140 for bin in entry["value"]["material"]["binUtility"][
0141 "binningdata"
0142 ]:
0143 bin["bins"] = conf["value"]["material"]["binUtility"][
0144 "binningdata"
0145 ][ibin]["bins"]
0146 ibin = ibin + 1
0147 continue
0148 continue
0149 data["Volumes"] = config["Volumes"]
0150 json_file.seek(0)
0151 json.dump(data, json_file, indent=4)
0152 json_file.truncate()