def _store_param_dict(self): """ Store Parameter objects for channel """ # Dictionary of the channel Parameter objects self._param_dict = { "det_per_waf": self._store_param("Num Det per Wafer"), "waf_per_ot": self._store_param("Num Waf per OT"), "ot": self._store_param("Num OT"), "yield": self._store_param("Yield"), "pix_sz": self._store_param("Pixel Size"), "wf": self._store_param("Waist Factor") } # Dictionary of the detector Parameter objects # These are evaluated at the detector object level self.det_dict = { "bc": self._store_param("Band Center"), "fbw": self._store_param("Fractional BW"), "det_eff": self._store_param("Det Eff"), "psat": self._store_param("Psat"), "psat_fact": self._store_param("Psat Factor"), "n": self._store_param("Carrier Index"), "tc": self._store_param("Tc"), "tc_frac": self._store_param("Tc Fraction"), "nei": self._store_param("SQUID NEI"), "bolo_r": self._store_param("Bolo Resistance"), "read_frac": self._store_param("Read Noise Frac") } # Newly added parameters to BoloCalc # checked separately for backwards compatibility if "FLINK" in self._inp_dict.keys(): self.det_dict["flink"] = self._store_param("Flink") else: self.det_dict["flink"] = pr.Parameter(self._log, "NA", name="Flink") if "G" in self._inp_dict.keys(): self.det_dict["g"] = self._store_param("G") else: self.det_dict["g"] = pr.Parameter(self._log, "NA", name="G") if "RESPFACTOR" in self._inp_dict.keys(): self.det_dict["sfact"] = self._store_param("Resp Factor") else: self.det_dict["sfact"] = pr.Parameter(self._log, "NA", name="Resp Factor") # Dictionary for ID-ing parameters for changing self._param_names = { param.caps_name: pid for pid, param in self._param_dict.items() } self._det_param_names = { param.caps_name: pid for pid, param in self.det_dict.items() } return
def __init__(self, file): #Store input variables self.file = file #Parse file for layer parameters layers, thicks, indexes, lossTans = np.loadtxt(self.file, comments='+-', skiprows=2, delimiter='|', dtype=np.str, unpack=True)[1:-1] #Build dictionaries of dielectric layers self.layers = cl.OrderedDict({}) for i in range(len(layers)): self.layers[layers[i]] = {"Thickness": pm.Parameter("Thickness", thicks[i], unit=un.mm_to_m, min=0.0, max=np.inf), "Index": pm.Parameter("Index", indexes[i], min=0.0, max=np.inf), "LossTan": pm.Parameter("LossTan", lossTans[i], unit=1.e-04, min=0.0, max=np.inf)}
def _store_param_dict(self): """ Store Parameter objects for telescope """ # Check that the telescope parameter file exists self._tel_file = os.path.join(self._config_dir, 'telescope.txt') if not os.path.isfile(self._tel_file): self._log.err( "Telescope file '%s' does not exist" % (self._tel_file)) # Load telescope file into a dictionary self._inp_dict = self._load.telescope(self._tel_file) # Dictionary of the telescope Parameter objects self._log.log( "Storing telescope parameters for %s" % (self.dir)) self._param_dict = { "site": self._store_param("Site"), "elev": self._store_param("Elevation"), "pwv": self._store_param("PWV"), "tobs": self._store_param("Observation Time"), "fsky": self._store_param("Sky Fraction"), "obs_eff": self._store_param("Observation Efficiency"), "net_mgn": self._store_param("NET Margin")} # New parameters, added separately for backwards compatibility if "SKYTEMPERATURE" in self._inp_dict.keys(): self._param_dict["sky_temp"] = self._store_param("Sky Temperature") else: self._param_dict["sky_temp"] = pr.Parameter( self._log, "NA", name="Sky Temperature") # Dictionary for ID-ing parameters for changing self._param_names = { param.caps_name: pid for pid, param in self._param_dict.items()} return
def _store_param(self, name): """ Helper method to store param dict """ cap_name = name.replace(" ", "").strip().upper() if cap_name in self.std_params.keys(): return pr.Parameter(self.log, self._inp_dict[cap_name], std_param=self.std_params[cap_name]) else: self.log.err("Passed parameter in simulationInputs.txt '%s' not " "recognized in _store_param()" % (name))
def _store_param(self, name): """ Store src.Parameter objects for this channel """ cap_name = name.replace(" ", "").strip().upper() if cap_name in self._std_params.keys(): return pr.Parameter(self._log, self._inp_dict[cap_name], std_param=self._std_params[cap_name]) else: self._log.err("Passed parameter in channel.txt '%s' not " "recognized" % (name))
def _store_param(self, name): """ Generate src.Parameter object and return it """ cap_name = name.replace(" ", "").strip().upper() if cap_name in self._std_params.keys(): return pr.Parameter(self._log, self._inp_dict[cap_name], std_param=self._std_params[cap_name]) else: self._log.err("Passed parameter in foregrounds.txt '%s' not " "recognized" % (name))
def _store_param_dict(self): """ Store input parameters in dictionary """ # Check whether the simulation file exists if not os.path.isfile(self._sim_file): self.log.err("Simulation file '%s' does not exist" % (self._sim_file)) # Load the simulation file to a parameter dictionary self._inp_dict = self.load.sim(self._sim_file) # Store dictionary of Parameter objects self._param_dict = { "nexp": self._store_param("Experiments"), "nobs": self._store_param("Observations"), "ndet": self._store_param("Detectors"), "fres": self._store_param("Resolution"), "infg": self._store_param("Foregrounds"), "corr": self._store_param("Correlations"), } # On 2020-06-01, "Percentile" was replaced with "Percentile Lo" # and "Percentile Hi" if self._input_param_exists("Percentile"): self._param_dict.update({"pct": self._store_param("Percentile")}) elif (self._input_param_exists("Percentile Lo") and self._input_param_exists("Percentile Hi")): # Store the list entries manually pct_lo = str(self._retrieve_input_param("Percentile Lo")).strip() pct_hi = str(self._retrieve_input_param("Percentile Hi")).strip() pct_val = "[%s, %s]" % (pct_lo, pct_hi) self._param_dict.update({ "pct": pr.Parameter(self.log, pct_val, std_param=self.std_params["PERCENTILE"]) }) else: self.log.err( "Neither 'Percentile' not 'Percentile Lo' and 'Percentile Hi " "were found in 'simulationInputs.txt") return
def _store_param(self, name): """ Store Parameter objects for this optic """ cap_name = name.replace(" ", "").strip().upper() if cap_name in self._std_params.keys(): param = pr.Parameter(self._log, self._inp_dict[cap_name], std_param=self._std_params[cap_name], band_ids=self._band_ids) # Check that the number of bands is either equal # to the number of channels or a single value data = param.fetch(band_ind=None) for dat in data: corr_len = self._check_param_len(dat) if not corr_len: self._log.err("Wrong parameter list length for input '%s' " "for optic parameter '%s'" % (str(dat), param.name)) else: continue return param else: self._log.err("Passed parameter in optics.txt '%s' not " "recognized" % (name))
def __init__(self, layerFile=None, simFile=None): #Generate layers instance if layerFile is None: self.layerFile = os.path.abspath( __file__ ) + '..' + os.sep + 'config' + os.sep + 'layers' + os.sep + 'layers.txt' else: self.layerFile = layerFile self.fhandle = self.layerFile.split('.')[0].split('/')[-1] self.layers = ly.Layers(self.layerFile) #Save input parameters if simFile is None: self.simFile = os.path.abspath( __file__ ) + '..' + os.sep + 'config' + os.sep + 'simulation' + os.sep + 'simInputs.txt' else: self.simFile = simFile #Load simulation input parameters params, values = np.loadtxt(self.simFile, unpack=True, usecols=[1, 3], comments='+-', delimiter='|', dtype=np.str) params = [param.strip() for param in params] values = [value.strip() for value in values] self.simInputs = { "Inc Angle": pm.Parameter("Inc Angle", values[params.index("Inc Angle")], min=-90., max=90., unit=un.deg_to_rad), "Inc Pol Angle": pm.Parameter("Inc Pol Angle", values[params.index("Inc Pol Angle")], min=-np.inf, max=np.inf, unit=un.deg_to_rad), "Low Freq": pm.Parameter("Low Freq", values[params.index("Low Freq")], min=0.0, max=np.inf, unit=un.GHz_to_Hz), "High Freq": pm.Parameter("High Freq", values[params.index("High Freq")], min=0.0, max=np.inf, unit=un.GHz_to_Hz), "Freq Step": pm.Parameter("Freq Step", values[params.index("Freq Step")], min=1.e-4, max=1.e12, unit=un.GHz_to_Hz), "Num Trials": int(values[params.index("Num Trials")]), "Sim Method": str(values[params.index("Sim Method")]), "Band Centers": pm.Parameter("Band Centers", values[params.index("Band Centers")], min=0.0, max=np.inf, unit=un.GHz_to_Hz), "Bandwidths": pm.Parameter("Bandwidths", values[params.index("Bandwidths")], min=0.0, max=2.0) } #Set frequency array self.freqs = np.arange( self.simInputs["Low Freq"].getAvg(), self.simInputs["High Freq"].getAvg() + self.simInputs["Freq Step"].getAvg(), self.simInputs["Freq Step"].getAvg())