def __call__(self, data, state): # get parameters C = state.get('compression') factor = state.get('compression_factor', 1) # decompress uc_data = uncompress(data, C, factor) uc_data.mask = state['mask'] # filter uc_data = tm.filter_median(uc_data, length=self.filter_length) tm.deglitch_l2mad(uc_data, state['model']) # define mask masking = tm.Masking(uc_data.mask) # update model state['deglitching_mask'] = uc_data.mask state['deglitching_mask_lo'] = masking state['model'] = masking * state['model'] state['deglitching_filter_length'] = self.filter_length return data
npixels_per_sample=5) multiplexing = CompressionAverageOperator(1) crosstalk = IdentityOperator() compression = CompressionAverageOperator(4) model = compression * crosstalk * multiplexing * projection * telescope # read the Tod off the disk tod40Hz = pacs.get_tod(flatfielding=True, subtraction_mean=True) # remove drift tod40Hz_filtered = filter_polynomial(tod40Hz, 6) drift = tod40Hz - tod40Hz_filtered tod40Hz = filter_median(tod40Hz_filtered, 10000) # second level deglitching tod40Hz.mask = deglitch_l2mad(tod40Hz, projection, nsigma=5) idetector=5 plot_tod((tod40Hz+drift)[idetector]) plot(drift[idetector], 'r') masking = MaskOperator(tod40Hz.mask) model40Hz = masking * projection map_naive40Hz = mapper_naive(tod40Hz, model40Hz) map_naive40Hz.imshow() # clim doesn't work anymore with AnnotatedImage #clim(-0.00002,0.00002)
tod = obs.get_tod() header = obs.get_map_header() header.update('CDELT1', resolution / 3600) header.update('CDELT2', resolution / 3600) npix = 5 good_npix = False projection = tm.Projection(obs, header=header, resolution=resolution, oversampling=False, npixels_per_sample=npix) model = projection #C = csh.averaging(tod.shape, factor=factor) compression_shape = [tod.size / factor, tod.size, ] C = tm.CompressionAverage(compression_factor=factor).aslinearoperator(compression_shape) C = lo.aslinearoperator(C) # compress data ctod = compress(tod, C, factor) # uncompress for preprocessing uctod = uncompress(ctod, C, factor) # XXX need mask ... uctod.mask = tod.mask # deglitching uctod = tm.filter_median(uctod, length=10) uctod.mask = tm.deglitch_l2mad(uctod, projection) masking = tm.Masking(uctod.mask) model = masking * projection # filtering ctod = tm.filter_median(ctod, length=filter_length / factor) cov = noise_covariance(ctod, obs) S = cov.aslinearoperator()
pacs = tm.PacsObservation(filename=filenames, fine_sampling_factor=1, keep_bad_detectors=False) # reset pacs header to have a shape multiple of 4 #header = pacs.get_map_header() #header['NAXIS1'] = 192 #header['NAXIS2'] = 192 #header['CRPIX1'] = 96 #header['CRPIX2'] = 96 # data tod = pacs.get_tod() # remove bad pixels (by updating mask !) #tod = remove_bad_pixels(tod) # deglitching #projection = tm.Projection(pacs, header=header, resolution=3., npixels_per_sample=6) projection = tm.Projection(pacs, resolution=3., npixels_per_sample=6) tm.deglitch_l2mad(tod, projection) # model masking = tm.Masking(tod.mask) model = masking * projection # remove drift tod = tm.filter_median(tod, length=999) model = masking * projection # naive map backmap = model.transpose(tod) # coverage map weights = model.transpose(tod.ones(tod.shape)) # mask on map mask = weights == 0 M = lo.mask(mask) # preconditionner
# compress data factor = 8 compression = tm.CompressionAverage(factor) C = lo.aslinearoperator( compression.aslinearoperator(shape=(tod.size / factor, tod.size))) ctod = compression.direct(tod) # uncompress for deglitching uctod = tod.copy(tod.shape) y0, t = lo.spl.cgs(C.T * C, C.T * ctod.flatten()) uctod[:] = y0.reshape(tod.shape) # deglitching projection = tm.Projection(pacs, header=header, resolution=3., npixels_per_sample=5) uctod.mask = tm.deglitch_l2mad(uctod, projection) ctod = compression.direct(uctod) # model masking = tm.Masking(uctod.mask) model = compression * masking * projection # remove drift #ctod = tm.filter_median(ctod, length=3000 / 8.) # first map M = lo.aslinearoperator(model.aslinearoperator()) #P = lo.aslinearoperator(projection.aslinearoperator()) #C = csh.averaging(tod.shape, factor=8) #I = lo.mask(uctod.mask) #M = C * I.T * I * P #M = C * P backmap = model.transpose(ctod) weights = model.transpose(ctod.ones(ctod.shape))
projection = pacs.get_projection_operator(resolution=3.2, npixels_per_sample=5) multiplexing = CompressionAverageOperator(1) crosstalk = IdentityOperator() compression = CompressionAverageOperator(4) model = compression * crosstalk * multiplexing * projection * telescope # read the Tod off the disk tod40Hz = pacs.get_tod(flatfielding=True, subtraction_mean=True) # remove drift tod40Hz_filtered = filter_polynomial(tod40Hz, 6) drift = tod40Hz - tod40Hz_filtered tod40Hz = filter_median(tod40Hz_filtered, 10000) # second level deglitching tod40Hz.mask = deglitch_l2mad(tod40Hz, projection, nsigma=5) idetector = 5 plot_tod((tod40Hz + drift)[idetector]) plot(drift[idetector], 'r') masking = MaskOperator(tod40Hz.mask) model40Hz = masking * projection map_naive40Hz = mapper_naive(tod40Hz, model40Hz) map_naive40Hz.imshow() # clim doesn't work anymore with AnnotatedImage #clim(-0.00002,0.00002)
fine_sampling_factor=1, keep_bad_detectors=False) # reset pacs header to have a shape multiple of 4 #header = pacs.get_map_header() #header['NAXIS1'] = 192 #header['NAXIS2'] = 192 #header['CRPIX1'] = 96 #header['CRPIX2'] = 96 # data tod = pacs.get_tod() # remove bad pixels (by updating mask !) #tod = remove_bad_pixels(tod) # deglitching #projection = tm.Projection(pacs, header=header, resolution=3., npixels_per_sample=6) projection = tm.Projection(pacs, resolution=3., npixels_per_sample=6) tm.deglitch_l2mad(tod, projection) # model masking = tm.Masking(tod.mask) model = masking * projection # remove drift tod = tm.filter_median(tod, length=999) model = masking * projection # naive map backmap = model.transpose(tod) # coverage map weights = model.transpose(tod.ones(tod.shape)) # mask on map mask = weights == 0 M = lo.mask(mask) # preconditionner