Combine rebinning schemes
In case you want to combine several rebinning schemes one can proceed as follows:
rebin_data(id, 0); % reset all binning lo = get_rmf_data_grid(get_data_info(id).rmfs).bin_lo; % get original data grid w = where(lo>_A(50), &nw); % get where grid is larger than 50keV and complement, ATTENTION: do not apply _A() to 'lo', this will change the order 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 % set combined binning, the array has to be in angstrom grid so pay attention to the ordering rebin_data(id, [-sign(opt[nw]*min10[w][-1])*min10[w], opt[nw]]); % swap sign to keep regions distinct
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.