Search is not available for this dataset
text
stringlengths
75
104k
def compute_lst(self): """ Compute LST for observation """ if self.header[b'telescope_id'] == 6: self.coords = gbt_coords elif self.header[b'telescope_id'] == 4: self.coords = parkes_coords else: raise RuntimeError("Currently only Parkes and GBT suppor...
def compute_lsrk(self): """ Computes the LSR in km/s uses the MJD, RA and DEC of observation to compute along with the telescope location. Requires pyslalib """ ra = Angle(self.header[b'src_raj'], unit='hourangle') dec = Angle(self.header[b'src_dej'], unit='degree') ...
def blank_dc(self, n_coarse_chan): """ Blank DC bins in coarse channels. Note: currently only works if entire file is read """ if n_coarse_chan < 1: logger.warning('Coarse channel number < 1, unable to blank DC bin.') return None if not n_coarse_chan % ...
def info(self): """ Print header information """ for key, val in self.header.items(): if key == b'src_raj': val = val.to_string(unit=u.hour, sep=':') if key == b'src_dej': val = val.to_string(unit=u.deg, sep=':') if key == b'tsamp': ...
def generate_freqs(self, f_start, f_stop): """ returns frequency array [f_start...f_stop] """ fch1 = self.header[b'fch1'] foff = self.header[b'foff'] #convert input frequencies into what their corresponding index would be i_start = int((f_start - fch1) / foff) ...
def _calc_extent(self,plot_f=None,plot_t=None,MJD_time=False): """ Setup ploting edges. """ plot_f_begin = plot_f[0] plot_f_end = plot_f[-1] + (plot_f[1]-plot_f[0]) plot_t_begin = self.timestamps[0] plot_t_end = self.timestamps[-1] + (self.timestamps[1] - self.timestam...
def plot_spectrum(self, t=0, f_start=None, f_stop=None, logged=False, if_id=0, c=None, **kwargs): """ Plot frequency spectrum of a given file Args: t (int): integration number to plot (0 -> len(data)) logged (bool): Plot in linear (False) or dB units (True) if_id (in...
def plot_spectrum_min_max(self, t=0, f_start=None, f_stop=None, logged=False, if_id=0, c=None, **kwargs): """ Plot frequency spectrum of a given file Args: logged (bool): Plot in linear (False) or dB units (True) if_id (int): IF identification (if multiple IF signals in file) ...
def plot_waterfall(self, f_start=None, f_stop=None, if_id=0, logged=True, cb=True, MJD_time=False, **kwargs): """ Plot waterfall of data Args: f_start (float): start frequency, in MHz f_stop (float): stop frequency, in MHz logged (bool): Plot in linear (False) or dB ...
def plot_time_series(self, f_start=None, f_stop=None, if_id=0, logged=True, orientation='h', MJD_time=False, **kwargs): """ Plot the time series. Args: f_start (float): start frequency, in MHz f_stop (float): stop frequency, in MHz logged (bool): Plot in linear (Fal...
def plot_kurtosis(self, f_start=None, f_stop=None, if_id=0, **kwargs): """ Plot kurtosis Args: f_start (float): start frequency, in MHz f_stop (float): stop frequency, in MHz kwargs: keyword args to be passed to matplotlib imshow() """ ax = plt.gca()...
def plot_all(self, t=0, f_start=None, f_stop=None, logged=False, if_id=0, kurtosis=True, **kwargs): """ Plot waterfall of data as well as spectrum; also, placeholder to make even more complicated plots in the future. Args: f_start (float): start frequency, in MHz f_stop (float):...
def write_to_filterbank(self, filename_out): """ Write data to blimpy file. Args: filename_out (str): Name of output file """ print("[Filterbank] Warning: Non-standard function to write in filterbank (.fil) format. Please use Waterfall.") n_bytes = int(self.header...
def write_to_hdf5(self, filename_out, *args, **kwargs): """ Write data to HDF5 file. Args: filename_out (str): Name of output file """ print("[Filterbank] Warning: Non-standard function to write in HDF5 (.h5) format. Please use Waterfall.") if not HAS_HDF5: ...
def calibrate_band_pass_N1(self): """ One way to calibrate the band pass is to take the median value for every frequency fine channel, and divide by it. """ band_pass = np.median(self.data.squeeze(),axis=0) self.data = self.data/band_pass
def get_stokes(cross_dat, feedtype='l'): '''Output stokes parameters (I,Q,U,V) for a rawspec cross polarization filterbank file''' #Compute Stokes Parameters if feedtype=='l': #I = XX+YY I = cross_dat[:,0,:]+cross_dat[:,1,:] #Q = XX-YY Q = cross_dat[:,0,:]-cross_dat[:,1,...
def convert_to_coarse(data,chan_per_coarse): ''' Converts a data array with length n_chans to an array of length n_coarse_chans by averaging over the coarse channels ''' #find number of coarse channels and reshape array num_coarse = data.size/chan_per_coarse data_shaped = np.array(np.reshape...
def phase_offsets(Idat,Qdat,Udat,Vdat,tsamp,chan_per_coarse,feedtype='l',**kwargs): ''' Calculates phase difference between X and Y feeds given U and V (U and Q for circular basis) data from a noise diode measurement on the target ''' #Fold noise diode data and calculate ON OFF diferences for U and ...
def gain_offsets(Idat,Qdat,Udat,Vdat,tsamp,chan_per_coarse,feedtype='l',**kwargs): ''' Determines relative gain error in the X and Y feeds for an observation given I and Q (I and V for circular basis) noise diode data. ''' if feedtype=='l': #Fold noise diode data and calculate ON OFF differe...
def apply_Mueller(I,Q,U,V, gain_offsets, phase_offsets, chan_per_coarse, feedtype='l'): ''' Returns calibrated Stokes parameters for an observation given an array of differential gains and phase differences. ''' #Find shape of data arrays and calculate number of coarse channels shape = I.shape ...
def calibrate_pols(cross_pols,diode_cross,obsI=None,onefile=True,feedtype='l',**kwargs): ''' Write Stokes-calibrated filterbank file for a given observation with a calibrator noise diode measurement on the source Parameters ---------- cross_pols : string Path to cross polarization filte...
def fracpols(str, **kwargs): '''Output fractional linear and circular polarizations for a rawspec cross polarization .fil file. NOT STANDARD USE''' I,Q,U,V,L=get_stokes(str, **kwargs) return L/I,V/I
def write_stokefils(str, str_I, Ifil=False, Qfil=False, Ufil=False, Vfil=False, Lfil=False, **kwargs): '''Writes up to 5 new filterbank files corresponding to each Stokes parameter (and total linear polarization L) for a given cross polarization .fil file''' I,Q,U,V,L=get_stokes(str, **kwargs) obs = Wa...
def write_polfils(str, str_I, **kwargs): '''Writes two new filterbank files containing fractional linear and circular polarization data''' lin,circ=fracpols(str, **kwargs) obs = Waterfall(str_I, max_load=150) obs.data = lin obs.write_to_fil(str[:-15]+'.linpol.fil') #assuming file is named *....
def closest(xarr, val): """ Return the index of the closest in xarr to value val """ idx_closest = np.argmin(np.abs(np.array(xarr) - val)) return idx_closest
def rebin(d, n_x, n_y=None): """ Rebin data by averaging bins together Args: d (np.array): data n_x (int): number of bins in x dir to rebin into one n_y (int): number of bins in y dir to rebin into one Returns: d: rebinned data with shape (n_x, n_y) """ if d.ndim == 2: if ...
def unpack(data, nbit): """upgrade data from nbits to 8bits Notes: Pretty sure this function is a little broken! """ if nbit > 8: raise ValueError("unpack: nbit must be <= 8") if 8 % nbit != 0: raise ValueError("unpack: nbit must divide into 8") if data.dtype not in (np.uint8, n...
def unpack_2to8(data): """ Promote 2-bit unisgned data into 8-bit unsigned data. Args: data: Numpy array with dtype == uint8 Notes: DATA MUST BE LOADED as np.array() with dtype='uint8'. This works with some clever shifting and AND / OR operations. Data is LOADED as 8-bit, ...
def unpack_4to8(data): """ Promote 2-bit unisgned data into 8-bit unsigned data. Args: data: Numpy array with dtype == uint8 Notes: # The process is this: # ABCDEFGH [Bits of one 4+4-bit value] # 00000000ABCDEFGH [astype(uint16)] # 0000ABCDEFGH0000 [<< 4] # ...
def get_diff(dio_cross,feedtype,**kwargs): ''' Returns ON-OFF for all Stokes parameters given a cross_pols noise diode measurement ''' #Get Stokes parameters, frequencies, and time sample length obs = Waterfall(dio_cross,max_load=150) freqs = obs.populate_freqs() tsamp = obs.header['tsamp'] ...
def plot_Stokes_diode(dio_cross,diff=True,feedtype='l',**kwargs): ''' Plots the uncalibrated full stokes spectrum of the noise diode. Use diff=False to plot both ON and OFF, or diff=True for ON-OFF ''' #If diff=True, get ON-OFF. If not get ON and OFF separately if diff==True: Idiff,Qdif...
def plot_calibrated_diode(dio_cross,chan_per_coarse=8,feedtype='l',**kwargs): ''' Plots the corrected noise diode spectrum for a given noise diode measurement after application of the inverse Mueller matrix for the electronics chain. ''' #Get full stokes data for the ND observation obs = Waterfa...
def plot_phase_offsets(dio_cross,chan_per_coarse=8,feedtype='l',ax1=None,ax2=None,legend=True,**kwargs): ''' Plots the calculated phase offsets of each coarse channel along with the UV (or QU) noise diode spectrum for comparison ''' #Get ON-OFF ND spectra Idiff,Qdiff,Udiff,Vdiff,freqs = get_diff...
def plot_gain_offsets(dio_cross,dio_chan_per_coarse=8,feedtype='l',ax1=None,ax2=None,legend=True,**kwargs): ''' Plots the calculated gain offsets of each coarse channel along with the time averaged power spectra of the X and Y feeds ''' #Get ON-OFF ND spectra Idiff,Qdiff,Udiff,Vdiff,freqs = get_...
def plot_diode_fold(dio_cross,bothfeeds=True,feedtype='l',min_samp=-500,max_samp=7000,legend=True,**kwargs): ''' Plots the calculated average power and time sampling of ON (red) and OFF (blue) for a noise diode measurement over the observation time series ''' #Get full stokes data of ND measurement ...
def plot_fullcalib(dio_cross,feedtype='l',**kwargs): ''' Generates and shows five plots: Uncalibrated diode, calibrated diode, fold information, phase offsets, and gain offsets for a noise diode measurement. Most useful diagnostic plot to make sure calibration proceeds correctly. ''' plt.figure...
def plot_diodespec(ON_obs,OFF_obs,calflux,calfreq,spec_in,units='mJy',**kwargs): ''' Plots the full-band Stokes I spectrum of the noise diode (ON-OFF) ''' dspec = diode_spec(ON_obs,OFF_obs,calflux,calfreq,spec_in,**kwargs) obs = Waterfall(ON_obs,max_load=150) freqs = obs.populate_freqs() ch...
def cmd_tool(): '''Read input and output frequency, and output file name ''' parser = argparse.ArgumentParser(description='Dices hdf5 or fil files and writes to hdf5 or fil.') parser.add_argument('-f', '--input_filename', action='store', default=None, dest='in_fname', type=str, help='Name of file ...
def cmd_tool(args=None): """ Command line utility for creating HDF5 blimpy files. """ from argparse import ArgumentParser parser = ArgumentParser(description="Command line utility for creating HDF5 Filterbank files.") parser.add_argument('dirname', type=str, help='Name of directory to read') args = ...
def open_file(filename, f_start=None, f_stop=None,t_start=None, t_stop=None,load_data=True,max_load=1.): """Open a HDF5 or filterbank file Returns instance of a Reader to read data from file. ================== ================================================== Filename extension File type =======...
def _setup_selection_range(self, f_start=None, f_stop=None, t_start=None, t_stop=None, init=False): """Making sure the selection if time and frequency are within the file limits. Args: init (bool): If call during __init__ """ # This avoids resetting values if init i...
def _setup_dtype(self): """Calculating dtype """ #Set up the data type if self._n_bytes == 4: return b'float32' elif self._n_bytes == 2: return b'uint16' elif self._n_bytes == 1: return b'uint8' else: logger.warn...
def _calc_selection_size(self): """Calculate size of data of interest. """ #Check to see how many integrations requested n_ints = self.t_stop - self.t_start #Check to see how many frequency channels requested n_chan = (self.f_stop - self.f_start) / abs(self.header[b'foff...
def _calc_selection_shape(self): """Calculate shape of data of interest. """ #Check how many integrations requested n_ints = int(self.t_stop - self.t_start) #Check how many frequency channels requested n_chan = int(np.round((self.f_stop - self.f_start) / abs(self.header[...
def _setup_chans(self): """Setup channel borders """ if self.header[b'foff'] < 0: f0 = self.f_end else: f0 = self.f_begin i_start, i_stop = 0, self.n_channels_in_file if self.f_start: i_start = np.round((self.f_start - f0) / self.head...
def _setup_freqs(self): """Updating frequency borders from channel values """ if self.header[b'foff'] > 0: self.f_start = self.f_begin + self.chan_start_idx*abs(self.header[b'foff']) self.f_stop = self.f_begin + self.chan_stop_idx*abs(self.header[b'foff']) else: ...
def populate_timestamps(self,update_header=False): """ Populate time axis. IF update_header then only return tstart """ #Check to see how many integrations requested ii_start, ii_stop = 0, self.n_ints_in_file if self.t_start: ii_start = self.t_start ...
def populate_freqs(self): """ Populate frequency axis """ if self.header[b'foff'] < 0: f0 = self.f_end else: f0 = self.f_begin self._setup_chans() #create freq array i_vals = np.arange(self.chan_start_idx, self.chan_stop_idx) ...
def calc_n_coarse_chan(self, chan_bw=None): """ This makes an attempt to calculate the number of coarse channels in a given file. Note: This is unlikely to work on non-Breakthrough Listen data, as a-priori knowledge of the digitizer system is required. """ ...
def calc_n_blobs(self, blob_dim): """ Given the blob dimensions, calculate how many fit in the data selection. """ n_blobs = int(np.ceil(1.0 * np.prod(self.selection_shape) / np.prod(blob_dim))) return n_blobs
def isheavy(self): """ Check if the current selection is too large. """ selection_size_bytes = self._calc_selection_size() if selection_size_bytes > self.MAX_DATA_ARRAY_SIZE: return True else: return False
def read_header(self): """ Read header and return a Python dictionary of key:value pairs """ self.header = {} for key, val in self.h5['data'].attrs.items(): if six.PY3: key = bytes(key, 'ascii') if key == b'src_raj': self.header[k...
def _find_blob_start(self, blob_dim, n_blob): """Find first blob from selection. """ #Convert input frequencies into what their corresponding channel number would be. self._setup_chans() #Check which is the blob time offset blob_time_start = self.t_start + blob_dim[self...
def read_data(self, f_start=None, f_stop=None,t_start=None, t_stop=None): """ Read data """ self._setup_selection_range(f_start=f_start, f_stop=f_stop, t_start=t_start, t_stop=t_stop) #check if selection is small enough. if self.isheavy(): logger.warning("Selection ...
def read_blob(self,blob_dim,n_blob=0): """Read blob from a selection. """ n_blobs = self.calc_n_blobs(blob_dim) if n_blob > n_blobs or n_blob < 0: raise ValueError('Please provide correct n_blob value. Given %i, but max values is %i'%(n_blob,n_blobs)) #This prevents...
def read_header(self, return_idxs=False): """ Read blimpy header and return a Python dictionary of key:value pairs Args: filename (str): name of file to open Optional args: return_idxs (bool): Default False. If true, returns the file offset indexes ...
def read_data(self, f_start=None, f_stop=None,t_start=None, t_stop=None): """ Read data. """ self._setup_selection_range(f_start=f_start, f_stop=f_stop, t_start=t_start, t_stop=t_stop) #check if selection is small enough. if self.isheavy(): logger.warning("Selection...
def _find_blob_start(self): """Find first blob from selection. """ # Convert input frequencies into what their corresponding channel number would be. self._setup_chans() # Check which is the blob time offset blob_time_start = self.t_start # Check which is the b...
def read_blob(self,blob_dim,n_blob=0): """Read blob from a selection. """ n_blobs = self.calc_n_blobs(blob_dim) if n_blob > n_blobs or n_blob < 0: raise ValueError('Please provide correct n_blob value. Given %i, but max values is %i'%(n_blob,n_blobs)) # This prevent...
def read_all(self,reverse=True): """ read all the data. If reverse=True the x axis is flipped. """ raise NotImplementedError('To be implemented') # go to start of the data self.filfile.seek(int(self.datastart)) # read data into 2-D numpy array # data=n...
def read_row(self,rownumber,reverse=True): """ Read a block of data. The number of samples per row is set in self.channels If reverse=True the x axis is flipped. """ raise NotImplementedError('To be implemented') # go to start of the row self.filfile.seek(int(self.da...
def cmd_tool(args=None): """ Command line tool for plotting and viewing info on blimpy files """ from argparse import ArgumentParser parser = ArgumentParser(description="Command line utility for reading and plotting blimpy files.") parser.add_argument('filename', type=str, hel...
def read_data(self, f_start=None, f_stop=None,t_start=None, t_stop=None): """ Reads data selection if small enough. """ self.container.read_data(f_start=f_start, f_stop=f_stop,t_start=t_start, t_stop=t_stop) self.__load_data()
def __update_header(self): """ Updates the header information from the original file to the selection. """ #Updating frequency of first channel from selection if self.header[b'foff'] < 0: self.header[b'fch1'] = self.container.f_stop else: self.header[b'fc...
def info(self): """ Print header information and other derived information. """ print("\n--- File Info ---") for key, val in self.file_header.items(): if key == 'src_raj': val = val.to_string(unit=u.hour, sep=':') if key == 'src_dej': val...
def write_to_fil(self, filename_out, *args, **kwargs): """ Write data to .fil file. It check the file size then decides how to write the file. Args: filename_out (str): Name of output file """ #For timing how long it takes to write a file. t0 = time.time...
def __write_to_fil_heavy(self, filename_out, *args, **kwargs): """ Write data to .fil file. Args: filename_out (str): Name of output file """ #Note that a chunk is not a blob!! chunk_dim = self.__get_chunk_dimensions() blob_dim = self.__get_blob_dimensions(c...
def __write_to_fil_light(self, filename_out, *args, **kwargs): """ Write data to .fil file. Args: filename_out (str): Name of output file """ n_bytes = self.header[b'nbits'] / 8 with open(filename_out, "wb") as fileh: fileh.write(generate_sigproc_header...
def write_to_hdf5(self, filename_out, *args, **kwargs): """ Write data to HDF5 file. It check the file size then decides how to write the file. Args: filename_out (str): Name of output file """ #For timing how long it takes to write a file. t0 = time.tim...
def __write_to_hdf5_heavy(self, filename_out, *args, **kwargs): """ Write data to HDF5 file. Args: filename_out (str): Name of output file """ block_size = 0 #Note that a chunk is not a blob!! chunk_dim = self.__get_chunk_dimensions() blob_dim = sel...
def __write_to_hdf5_light(self, filename_out, *args, **kwargs): """ Write data to HDF5 file in one go. Args: filename_out (str): Name of output file """ block_size = 0 with h5py.File(filename_out, 'w') as h5: h5.attrs[b'CLASS'] = b'FILTERBANK' ...
def __get_blob_dimensions(self, chunk_dim): """ Sets the blob dimmentions, trying to read around 1024 MiB at a time. This is assuming a chunk is about 1 MiB. """ #Taking the size into consideration, but avoiding having multiple blobs within a single time bin. if self.selecti...
def __get_chunk_dimensions(self): """ Sets the chunking dimmentions depending on the file type. """ #Usually '.0000.' is in self.filename if np.abs(self.header[b'foff']) < 1e-5: logger.info('Detecting high frequency resolution data.') chunk_dim = (1,1,1048576) #1...
def grab_data(self, f_start=None, f_stop=None,t_start=None, t_stop=None, if_id=0): """ Extract a portion of data by frequency range. Args: f_start (float): start frequency in MHz f_stop (float): stop frequency in MHz if_id (int): IF input identification (req. when mu...
def cmd_tool(args=None): """ Command line tool for plotting and viewing info on guppi raw files """ from argparse import ArgumentParser parser = ArgumentParser(description="Command line utility for creating spectra from GuppiRaw files.") parser.add_argument('filename', type=str, help='Name of file to...
def read_header(self): """ Read next header (multiple headers in file) Returns: (header, data_idx) - a dictionary of keyword:value header data and also the byte index of where the corresponding data block resides. """ start_idx = self.file_obj.tell() key,...
def read_first_header(self): """ Read first header in file Returns: header (dict): keyword:value pairs of header metadata """ self.file_obj.seek(0) header_dict, pos = self.read_header() self.file_obj.seek(0) return header_dict
def get_data(self): """ returns a generator object that reads data a block at a time; the generator prints "File depleted" and returns nothing when all data in the file has been read. :return: """ with self as gr: while True: try: ...
def read_next_data_block_int8(self): """ Read the next block of data and its header Returns: (header, data) header (dict): dictionary of header metadata data (np.array): Numpy array of data, converted into to complex64. """ header, data_idx = self.read_header() ...
def read_next_data_block_int8_2x(self): """ Read the next block of data and its header Returns: (header, data) header (dict): dictionary of header metadata data (np.array): Numpy array of data, converted into to complex64. """ header, data_idx = self.read_header(...
def read_next_data_block(self): """ Read the next block of data and its header Returns: (header, data) header (dict): dictionary of header metadata data (np.array): Numpy array of data, converted into to complex64. """ header, data_idx = self.read_header() ...
def find_n_data_blocks(self): """ Seek through the file to find how many data blocks there are in the file Returns: n_blocks (int): number of data blocks in the file """ self.file_obj.seek(0) header0, data_idx0 = self.read_header() self.file_obj.seek(data_id...
def print_stats(self): """ Compute some basic stats on the next block of data """ header, data = self.read_next_data_block() data = data.view('float32') print("AVG: %2.3f" % data.mean()) print("STD: %2.3f" % data.std()) print("MAX: %2.3f" % data.max()) print("MI...
def plot_histogram(self, filename=None): """ Plot a histogram of data values """ header, data = self.read_next_data_block() data = data.view('float32') plt.figure("Histogram") plt.hist(data.flatten(), 65, facecolor='#cc0000') if filename: plt.savefig(filename...
def plot_spectrum(self, filename=None, plot_db=True): """ Do a (slow) numpy FFT and take power of data """ header, data = self.read_next_data_block() print("Computing FFT...") d_xx_fft = np.abs(np.fft.fft(data[..., 0])) d_xx_fft = d_xx_fft.flatten() # Rebin to max numbe...
def generate_filterbank_header(self, nchans=1, ): """ Generate a blimpy header dictionary """ gp_head = self.read_first_header() fb_head = {} telescope_str = gp_head.get("TELESCOP", "unknown") if telescope_str in ('GBT', 'GREENBANK'): fb_head["telescope_id"] = 6 ...
def find_header_size(filename): ''' Script to find the header size of a filterbank file''' # open datafile filfile=open(filename,'rb') # go to the start of the file filfile.seek(0) #read some region larger than the header. round1 = filfile.read(1000) headersize = round1.find('HEADER_END...
def cmd_tool(args=None): """ Command line tool to make a md5sum comparison of two .fil files. """ if 'bl' in local_host: header_loc = '/usr/local/sigproc/bin/header' #Current location of header command in GBT. else: raise IOError('Script only able to run in BL systems.') p = OptionPars...
def make_h5_file(filename,out_dir='./', new_filename = None, max_load = None): ''' Converts file to HDF5 (.h5) format. Default saves output in current dir. ''' fil_file = Waterfall(filename, max_load = max_load) if not new_filename: new_filename = out_dir+filename.replace('.fil','.h5').split('/...
def cmd_tool(args=None): """ Command line tool for converting guppi raw into HDF5 versions of guppi raw """ from argparse import ArgumentParser if not HAS_BITSHUFFLE: print("Error: the bitshuffle library is required to run this script.") exit() parser = ArgumentParser(description="Comm...
def foldcal(data,tsamp, diode_p=0.04,numsamps=1000,switch=False,inds=False): ''' Returns time-averaged spectra of the ON and OFF measurements in a calibrator measurement with flickering noise diode Parameters ---------- data : 2D Array object (float) 2D dynamic spectrum for data (any St...
def integrate_chans(spec,freqs,chan_per_coarse): ''' Integrates over each core channel of a given spectrum. Important for calibrating data with frequency/time resolution different from noise diode data Parameters ---------- spec : 1D Array (float) Spectrum (any Stokes parameter) to be i...
def integrate_calib(name,chan_per_coarse,fullstokes=False,**kwargs): ''' Folds Stokes I noise diode data and integrates along coarse channels Parameters ---------- name : str Path to noise diode filterbank file chan_per_coarse : int Number of frequency bins per coarse channel ...
def get_calfluxes(calflux,calfreq,spec_in,centerfreqs,oneflux): ''' Given properties of the calibrator source, calculate fluxes of the source in a particular frequency range Parameters ---------- calflux : float Known flux of calibrator source at a particular frequency calfreq : flo...
def get_centerfreqs(freqs,chan_per_coarse): ''' Returns central frequency of each coarse channel Parameters ---------- freqs : 1D Array (float) Frequency values for each bin of the spectrum chan_per_coarse: int Number of frequency bins per coarse channel ''' num_coarse ...
def f_ratios(calON_obs,calOFF_obs,chan_per_coarse,**kwargs): ''' Calculate f_ON, and f_OFF as defined in van Straten et al. 2012 equations 2 and 3 Parameters ---------- calON_obs : str Path to filterbank file (any format) for observation ON the calibrator source calOFF_obs : str ...
def diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in,average=True,oneflux=False,**kwargs): ''' Calculate the coarse channel spectrum and system temperature of the noise diode in Jy given two noise diode measurements ON and OFF the calibrator source with the same frequency and time resolution Par...
def get_Tsys(calON_obs,calOFF_obs,calflux,calfreq,spec_in,oneflux=False,**kwargs): ''' Returns frequency dependent system temperature given observations on and off a calibrator source Parameters ---------- (See diode_spec()) ''' return diode_spec(calON_obs,calOFF_obs,calflux,calfreq,spec_in...
def calibrate_fluxes(main_obs_name,dio_name,dspec,Tsys,fullstokes=False,**kwargs): ''' Produce calibrated Stokes I for an observation given a noise diode measurement on the source and a diode spectrum with the same number of coarse channels Parameters ---------- main_obs_name : str ...
def len_header(filename): """ Return the length of the blimpy header, in bytes Args: filename (str): name of file to open Returns: idx_end (int): length of header, in bytes """ with open(filename, 'rb') as f: header_sub_count = 0 eoh_found = False while not...