class PointingFit: def __init__(self, expectation_key, data_key): self.fit_chain = ProcessingChain(silent=True) # self.fit_chain.add(self) self.configured = False self.params = [] self.expectation_key = expectation_key self.data_key = data_key def addFitModule(self, module): self.params += module.parameters.values() self.fit_chain.add(module) def _configure(self): if not self.configured: self.aggregator = Aggregate([self.expectation_key, self.data_key]) self.fit_chain.add(self.aggregator) self.configured = True def compute_exp(self, x=None): if x is not None: for i, xp in enumerate(x): self.params[i].val = xp if not self.configured: self._configure() self.fit_chain.run() self.fit_chain.config_run = True exp = self.aggregator.aggr[self.expectation_key][0] self.data = self.aggregator.aggr[self.data_key][0] self.aggregator.clear() return exp def __call__(self, x): print(x) exp = self.compute_exp(x) # m = self.data>0 chi2 = 0 for expv, datav in zip(exp.items(), self.data.items()): chi2 += np.sum((expv[1][1] - datav[1][1]) ** 2 / datav[1][1]) # chi2 = np.sum((exp - self.data) ** 2/self.data) print(chi2) return chi2
def get_your_data(runfile): data_proc = pchain.ProcessingChain() path = '/data/CHECS-data/astri_onsky/slowsignal/' + str(runfile) + '.hdf5' reader = Reader(path) data_proc.add(reader) frame_cleaner = PFCleaner() data_proc.add(frame_cleaner) aggr = Aggregate(["raw_resp"]) data_proc.add(aggr) data_proc.run() data = aggr.aggr["raw_resp"][0] dt = data.time - data.time[0] return (data, dt)
# ============================================================================= # # Read in raw data # ============================================================================= # Pick runfile runfile = "Run13637_ss" # initializing our process chain data_proc = pchain.ProcessingChain() path = '/data/CHECS-data/astri_onsky/slowsignal/'+str(runfile)+'.hdf5' reader = Reader(path) data_proc.add(reader) #This module removes incomplete frames and marks bad and unstable pixels frame_cleaner = PFCleaner() data_proc.add(frame_cleaner) #The Aggregate module collects the computed object from the frame aggr = Aggregate(["raw_resp"]) data_proc.add(aggr) # Simple visualization of the chain print(data_proc) #Execute the chain data_proc.run() data = aggr.aggr["raw_resp"][0] dt = data.time - data.time[0] ############################################################################# # Remove eventally new broken pixels new_good_pix = np.ones(data.data.shape,dtype = "bool") new_good_pix[np.nan_to_num(data.data) == 0] = False new_good_pix[:,1404] = False new_good_pix[:,1426] = False
Reader, ClusterCleaning, ClusterReduction, SmoothSlowSignal, ) data_proc = ProcessingChain() reader = Reader("VegaTrack15minFlatNSB10Hz.hdf") reader.out_raw_resp = "raw_resp" reader.out_time = "time" c_cleaner = ClusterCleaning(270.0, 140.0) c_cleaner.in_data = reader.out_raw_resp c_cleaner.out_cleaned = "cluster_cleaned" data_smoother = SmoothSlowSignal(n_readouts=30) clust_red = ClusterReduction() aggr = Aggregate([reader.out_raw_resp, c_cleaner.out_cleaned, reader.out_time]) data_proc.add(reader) data_proc.add(data_smoother) data_proc.add(c_cleaner) data_proc.add(clust_red) data_proc.add(aggr) print(data_proc) data_proc.run() from ssm.star_cat.hipparcos import load_hipparcos_cat from ssm.models import pixel_model from ssm.models.calibration import RateCalibration from ssm.fit import fit, fitmodules from astropy.coordinates import SkyCoord
] #dumm = ['Run13769_ss'] dumm = ["Run13312"] for runfile in dumm: print(runfile) data_proc = pchain.ProcessingChain() path = '/data/CHECS-data/astri_onsky/slowsignal/' + str(runfile) + '.hdf5' reader = Reader(path) data_proc.add(reader) #This module removes incomplete frames and marks bad and unstable pixels frame_cleaner = PFCleaner() data_proc.add(frame_cleaner) #The Aggregate module collects the computed object from the frame aggr = Aggregate(["raw_resp"]) data_proc.add(aggr) # Simple visualization of the chain print(data_proc) #Execute the chain data_proc.run() data = aggr.aggr["raw_resp"][0] dt = data.time - data.time[0] property_path = os.path.join(current_path + '/' + runfile, "CAL_with_Run13638") with open(property_path, 'rb') as handle: readout = pickle.load(handle)
def _configure(self): if not self.configured: self.aggregator = Aggregate([self.expectation_key, self.data_key]) self.fit_chain.add(self.aggregator) self.configured = True