scint_utils module¶
Astrophysical modelling¶
get_ssb_delay(mjds, raj, decj)
Get Romer delay to Solar System Barycentre (SSB) for correction of site arrival times to barycentric.
- Parameters:
- mjds (numpy 1D array) - list of modified Julian dates to calculate over
- raj (float) - right ascension (J2000) of the pulsar in degrees
- decj (float) - declination (J2000) of the pulsar in degrees
- Returns:
- List of Romer delays
get_earth_velocity(mjds, raj, decj)
Calculates the component of Earth’s velocity transverse to the line of sight, in RA and DEC
- Parameters:
- mjds (numpy 1D array) - list of modified Julian dates to calculate over
- raj (float) - right ascension (J2000) of the pulsar in degrees
- decj (float) - declination (J2000) of the pulsar in degrees
- Returns:
- List of Earth velocities in RA
- List of Earth velocities in dec
get_true_anomaly(mjds, pars)
Calculates true anomalies for an array of barycentric MJDs and a parameter dictionary
- Parameters:
- mjds (numpy 1D array) - list of modified Julian dates to calculate over
- pars (dict) - parameter file containing the orbital eccentricity (‘ECC’), binary period (‘PB’), MJD of binary period measurement (‘T0’), and binary period derivative, \(\dot P\) (‘PBDOT’).
- Returns:
- List of true anomalies
Reading and writing data¶
read_dynlist(file_path)
Reads list of dynamic spectra filenames from path
- Parameters:
- file_path (str) - file path containing the dynamic spectra files
- Returns:
- List of dynamic spectrum file paths
write_results(filename, dyn=None)
Appends dynamic spectrum information and parameters of interest to file
- Parameters:
- filename (str) - path of the file to write to
- dyn (Dynspec object) - Dynspec object
read_results(filename)
Reads a CSV results file written by write_results()
- Parameters:
- filename (str) - path of the file to read from
- Returns:
- Dictionary of parameters from file
float_array_from_dict(dictionary, key)
Convert an array stored in dictionary to a numpy array
- Parameters:
- dictionary (dict) - dictionary containing the array
- key (str) - key of the array
- Returns:
- numpy array from stored array
read_par(parfile)
Reads a parameter file and return a dictionary of parameter names and values
- Parameters:
- parfile (str) - path to parameter file for conversion
- Returns:
- resulting dictionary
pars_to_params(pars, params=None)
Converts a dictionary of parameter file parameters from
read_par()to anlmfitParameters()object to use in models. By default, parameters are not varied.
- Parameters:
- pars (dict) - dictionary of parameters
- params (lmfit Parameters() object, optional) -
lmfitParameters()object to append parameters to. If None, initializes new object.- Returns:
- appended
lmfitParameters()object
Other utilities¶
clean_archive(archive, template=None, bandwagon=0.99, channel_threshold=7, subint_threshold=5, output_directory=None)
Cleans a psrchive archive object using
coast_guard.
- Parameters:
- archive (psarchive archive object) - psarchive archive
- template (str, optional) -
- bandwagon (float, optional) - bandwagon value
- channel_threshold (float, optional) - channel threshold
- subint_threshold (float, optional) - sub-integration threshold
- output_directory (str) - directory to output the cleaned archive
is_valid(array)
Returns boolean array of values that are finite an not nan.
- Parameters:
- array (numpy ndarray) - input array
- Returns:
- Boolean ndarray
slow_FT(dynspec, freqs)
Slow FT of dynamic spectrum along points of t*(f / fref), account for phase scaling of f_D. Given a uniform t axis, this reduces to a regular FT.
Uses Olaf’s c-implemation if possible, otherwise reverts to a slow, pure Python/numpy method.
Reference freq is currently hardcoded to the middle of the band.
- Parameters:
- dynspec (numpy 2D array) - input dynamic spectrum
- freqs (numpy 1D array) - frequency axis of the dynamic spectrum in MHz
- Returns:
- Fourier-transformed dynamic spectrum
svd_model(arr, nmodes=1)
Take SVD of a dynamic spectrum, divide by the largest N modes
- Parameters:
- arr (numpy 2D array) - input dynamic spectrum
- nmodes (int, optional) - number of singular values to compute up to.
- Returns:
- Array divided by absolute value of SVD model
- SVD model
make_dynspec(archive, template=None, phasebin=1)
Creates a psrflux-format dynamic spectrum from an archive
$ psrflux -s [template] -e dynspec [archive]
- Parameters:
- archive (psarchive archive object) - psarchive archive
- template (str, optional) -
- phasebin (int, optional) -
remove_duplicates(dyn_files)
Filters out dynamic spectra from simultaneous observations.
- Parameters:
- dyn_files (list or numpy 1D array or str) - list of dynamic spectrum file paths
- Returns:
- Filtered list of dynamic spectrum file paths
make_pickle(dyn, process=True, sspec=True, acf=True, lamsteps=True)
Pickles a dynamic spectrum object.
- Parameters:
- dyn (Dynspec object) - dynamic spectrum Dynspec object.
- process (bool, optional) - perform default processing. Involves trimming the edges, refilling, correction, and calculation of the ACF and secondary spectrum.
- sspec (numpy 2D array, optional) - input secondary spectrum.
- acf (numpy 2D array, optional) - input autocorrelation function.
- lamsteps (bool, optional) - option to use wavelength steps instead of default frequency steps.