CHIMEFRB / fitburst

An open-source package of utilities for direct modeling of radio dynamic spectra.
https://chimefrb.github.io/fitburst/
MIT License
11 stars 2 forks source link

add functionality to downsample data in frequency and/or time #11

Closed emmanuelfonseca closed 3 years ago

emmanuelfonseca commented 3 years ago

the current fitburst runs on the native resolution of CHIME/FRB data. add the appropriate functions and method (presumably to the DataReader object) to allow for downsampling in frequency and/or time, prior to least-squares fitting.

bwmeyers commented 3 years ago

For reference, probably the simplest way to do this for a 2D array is

def rebin(arr, new_shape):
    """Rebin 2D array arr to shape new_shape by averaging."""
    shape = (new_shape[0], arr.shape[0] // new_shape[0],
             new_shape[1], arr.shape[1] // new_shape[1])
    return arr.reshape(shape).mean(-1).mean(1)

so as long as you can figure out what the current vs. final desired shape is, this should work. The limitation being that the new_shape must exactly divide the old shape. And you can always just downsample in one dimension by keeping the other dimension the same as in arr.

emmanuelfonseca commented 3 years ago

see PR #22.