Combine rebinning schemes

From Remeis-Wiki
Revision as of 16:18, 12 February 2021 by Stierhof (talk | contribs) (Created page with "In case you want to combine several rebinning schemes one can proceed as follows: <syntaxhighlight lang="c"> rebin_data(id, 0); % reset all binning lo = get_data(id).bin_lo;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In case you want to combine several rebinning schemes one can proceed as follows:

rebin_data(id, 0); % reset all binning
lo = get_data(id).bin_lo; % data grid
w = where(lo>_A(50), &nw); % get where grid is larger than 50keV and complement
rebin_data(id, 10); % rebin to at least 10 counts per bin
min10 = get_data_info(id).rebin; % store the binning
rebin_dataset_optimal(id); % rebin optimal
opt = get_data_info(id).rebin; % store binning
rebin_data(id, [opt[nw],sign(opt[-1]*min10[0])*min10[w]]); % set binning, connection region should have 10 or more counts this way

In this case rebin_dataset_optimal is used together with the 'standard' rebinning to at least n counts per bin. It is to say that rebin_dataset_optimal uses a numerically optimized way to reduce data size vs data loss and should *not* be changed for analyses purposes. But, e.g., for plotting the resulting spectrum might not look nice. Note also that this only works for schemes and data that where not rebinned on a new grid. In that case the original binning can not be restored.