def __init__(self, filename=None, f_start=None, f_stop=None,t_start=None, t_stop=None, load_data=True, max_load=1., header_dict=None, data_array=None): """ Class for loading and plotting blimpy data. This class parses the blimpy file and stores the header and data as objects: fb = Waterfall('filename_here.fil') fb.header # blimpy header, as a dictionary fb.data # blimpy data, as a numpy array Args: filename (str): filename of blimpy file. f_start (float): start frequency in MHz f_stop (float): stop frequency in MHz t_start (int): start integration ID t_stop (int): stop integration ID load_data (bool): load data. If set to False, only header will be read. max_load (float): maximum data to load in GB. Default: 1GB. e.g. 0.1 is 100 MB header_dict (dict): Create blimpy from header dictionary + data array data_array (np.array): Create blimpy from header dict + data array """ ##EE super(Waterfall, self).__init__() if filename: self.filename = filename self.ext = os.path.splitext(filename)[-1].lower() self.container = fw.open_file(filename, f_start=f_start, f_stop=f_stop, t_start=t_start, t_stop=t_stop, load_data=load_data, max_load=max_load) self.file_header = self.container.header self.header = self.file_header self.n_ints_in_file = self.container.n_ints_in_file self.file_shape = self.container.file_shape self.file_size_bytes = self.container.file_size_bytes self.selection_shape = self.container.selection_shape self.n_channels_in_file = self.container.n_channels_in_file # These values will be modified once code for multi_beam and multi_stokes observations are possible. self.freq_axis = 2 self.time_axis = 0 self.beam_axis = 1 # Place holder self.stokes_axis = 4 # Place holder self.__load_data() elif header_dict is not None and data_array is not None: self.filename = b'' self.header = header_dict self.data = data_array self.n_ints_in_file = 0 self._setup_freqs() else: self.filename = b''
def test_file_wrapper_open_file(): from blimpy.file_wrapper import open_file open_file('Voyager_data/Voyager1.single_coarse.fine_res.h5') open_file('Voyager_data/Voyager1.single_coarse.fine_res.fil') with pytest.raises(NotImplementedError): open_file('run_tests.sh')
def test_file_wrapper_open_file(): from blimpy.file_wrapper import open_file open_file(voyager_h5) open_file(voyager_fil) with pytest.raises(NotImplementedError): open_file(here + '/run_tests.sh')
def __init__(self, filename=None, f_start=None, f_stop=None, t_start=None, t_stop=None, load_data=True, max_load=1., header_dict=None, data_array=None): """ Class for loading and plotting blimpy data. This class parses the blimpy file and stores the header and data as objects: fb = Waterfall('filename_here.fil') fb.header # blimpy header, as a dictionary fb.data # blimpy data, as a numpy array Args: filename (str): filename of blimpy file. f_start (float): start frequency in MHz f_stop (float): stop frequency in MHz t_start (int): start integration ID t_stop (int): stop integration ID load_data (bool): load data. If set to False, only header will be read. max_load (float): maximum data to load in GB. Default: 1GB. e.g. 0.1 is 100 MB header_dict (dict): Create blimpy from header dictionary + data array data_array (np.array): Create blimpy from header dict + data array """ ##EE super(Waterfall, self).__init__() if filename: self.filename = filename self.ext = os.path.splitext(filename)[-1].lower() self.container = fw.open_file(filename, f_start=f_start, f_stop=f_stop, t_start=t_start, t_stop=t_stop, load_data=load_data, max_load=max_load) self.file_header = self.container.header self.header = self.file_header self.n_ints_in_file = self.container.n_ints_in_file self.file_shape = self.container.file_shape self.file_size_bytes = self.container.file_size_bytes self.selection_shape = self.container.selection_shape self.n_channels_in_file = self.container.n_channels_in_file # These values will be modified once code for multi_beam and multi_stokes observations are possible. self.freq_axis = 2 self.time_axis = 0 self.beam_axis = 1 # Place holder self.stokes_axis = 4 # Place holder self.__load_data() elif header_dict is not None and data_array is not None: self.filename = b'' self.header = header_dict self.data = data_array self.n_ints_in_file = 0 self._setup_freqs() else: self.filename = b''