vcstools modules

analyse_psf

Scripts to analyise the output PSFs

vcstools.analyse_psf.plot_imaging_psf(fits_file, output_name='imaging_psf.png', normalise=False, vmin=None, centre_size=None, fft_abs=False, fft_angle=False, centre=False)[source]

Plots the imaging PSF (from WSCLEAN for example).

Parameters:
fits_filestr

The PSF fits file gained from imaging (WSCLEAN).

output_namestr, optional

Output plot name.
Default: imaging_psf.png.

normaliseboolean, optional

Normalise the PSF.
Default: False.

vminfloat, optional

Minimum value of plot.
Default: None.

centre_sizeint, optional

The radius in pixels to plot from the centre.
Default: None.

fft_absboolean, optional

Take the fft of the PSF and plot the amplitude.
Default: False.

fft_angleboolean, optional

Take the fft of the PSF and plot the phase.
Default: False.

vcstools.analyse_psf.plot_pabeam(dat_file, output_name='pabeam_psf.png')[source]

Makes a polar plot over the sky response with the data file output from pabeam.py

Parameters:
dat_filestr

The data file output from pabeam.py.

output_namestr, optional

Output plot name.
Default: pabeam_psf.png.

vcstools.analyse_psf.plot_pabeam_ra_dec(dat_file, output_name='pabeam_psf.png', normalise=False, vmin=None)[source]

Plots the PSF data file output pabeam.py when using the –ra_dec_projection option.

Parameters:
dat_filestr

The PSF data file output pabeam.py when using the –ra_dec_projection option

output_namestr, optional

Output plot name.
Default: pabeam_psf.png.

normaliseboolean, optional

Normalise the PSF.
Default: False.

vminfloat, optional

Minimum value of plot.
Default: None.

vcstools.analyse_psf.plot_psf_comparison(imaging_psf, pabeam_psf, c_pabeam_psf)[source]

Compare the PSFs FWHM along RA and declination from imaging, pabeam.py and vcsbeam’s mwa_tied_array_beam_psf. Outputs a plot called comparing_psf_cuts.png.

Parameters:
imaging_psfstr

The PSF fits file gained from imaging (WSCLEAN).

pabeam_psfstr

The PSF data file output from pabeam.py.

c_pabeam_psfstr

The PSF data file output from vcsbeam’s mwa_tied_array_beam_psf.

vcstools.analyse_psf.plot_track_beam_response(response_file, output_name='vcsbeam_response.png', time_max=-1)[source]

Plot the data file output from vcsbeam’s mwa_track_primary_beam_response

Parameters:
response_filestr

The PSF data file output from vcsbeam’s mwa_track_primary_beam_response.

output_namestr, optional

Output plot name.
Default: vcsbeam_psf.png.

time_maxint, optional

Maximum number of seconds to process.
Default: -1.

vcstools.analyse_psf.plot_vcsbeam_psf(psf_file, output_name='vcsbeam_psf.png', normalise=False, vmin=None)[source]

Plot the PSF data file output from vcsbeam’s mwa_tied_array_beam_psf

Parameters:
psf_filestr

The PSF data file output from vcsbeam’s mwa_tied_array_beam_psf.

output_namestr, optional

Output plot name.
Default: vcsbeam_psf.png.

normaliseboolean, optional

Normalise the PSF.
Default: False.

vminfloat, optional

Minimum value of plot.
Default: None.

vcstools.analyse_psf.read_pabeam_ra_dec(dat_file)[source]

Read in the PSF data file output from pabeam.py when using the –ra_dec_projection option.

Parameters:
dat_filestr

The PSF data file output from pabeam.py

Returns:
ranumpy.array, (Nx, Ny)

The RA (degrees) in the meshgrid format

decnumpy.array, (Nx, Ny)

The declination (degrees) in the meshgrid format

powernumpy.array, (Nx, Ny)

The the data values of the fits file in the meshgrid format

vcstools.analyse_psf.read_psf_fits(fits_file, centre_size=None)[source]

Read in an imaging PSF fits file (from WSCLEAN for example).

Parameters:
fits_filestr

The PSF fits file gained from imaging (WSCLEAN).

centre_sizeint, optional

The radius in pixels to plot from the centre.
Default: None.

Returns:
ravnumpy.array, (Nx, Ny)

The RA (degrees) in the meshgrid format.

decvnumpy.array, (Nx, Ny)

The declination (degrees) in the meshgrid format.

fits_datanumpy.array, (Nx, Ny)

The the data values of the fits file in the meshgrid format.

vcstools.analyse_psf.read_vcsbeam_psf(psf_file)[source]

Read in the PSF data file output from vcsbeam’s mwa_tied_array_beam_psf

Parameters:
psf_filestr

The PSF data file output from vcsbeam’s mwa_tied_array_beam_psf.

Returns:
ranumpy.array, (Ny, Nx)

The RA (degrees) in the meshgrid format.

decnumpy.array, (Ny, Nx)

The declination (degrees) in the meshgrid format.

powernumpy.array, (Ny, Nx)

The the data values of the fits file in the meshgrid format.

beam_calc

Functions used to calculate or simulate the MWA tile beam.

vcstools.beam_calc.beam_enter_exit(powers, duration, dt=296, min_z_power=0.3)[source]

Calculates when the source enters and exits the beam

Parameters:
powerslist, (ntimes, nfreqs)

Powers for the duration every dt and freq.

durationint

Duration of the observation according to the metadata in seconds.

dtint, optional

The time interval of how often powers are calculated. Default: 296.

min_z_powerfloat, optional

Zenith normalised power cut off.
Default: 0.3.

Returns:
dect_beg_norm, dect_end_normfloat

Fraction of the observation when the source enters and exits the beam respectively.

vcstools.beam_calc.field_of_view(obsid, common_metadata=None, dur=None)[source]

Will find the field-of-view of the observation (including the drift) in square degrees.

Parameters:
obsidint

The MWA observation ID.

common_metadatalist, optional

The list of common metadata generated from vcstools.metadb_utils.get_common_obs_metadata()

durint, optional

Duration of observation to calculate for in seconds. By default will use the entire observation duration.

Returns:
areafloat

The field-of-view of the observation in square degrees.

vcstools.beam_calc.find_sources_in_obs(obsid_list, names_ra_dec, obs_for_source=False, dt_input=300, beam='hyperbeam', min_z_power=0.3, cal_check=False, all_volt=False, degrees_check=False, metadata_list=None)[source]

Either creates text files for each MWA obs ID of each source within it or a text file for each source with each MWA obs is that the source is in.

Parameters:
obsid_listlist

List of MWA observation IDs.

names_ra_declist

An array in the format [[source_name, RAJ, DecJ]]

obs_for_sourceboolean, optional

If True creates a text file for each source with each MWA observation that the source is in. If False creates text files for each MWA obs ID of each source within it.
Default: False.

dt_inputint, optional

The time interval in seconds of how often powers are calculated.
Default: 300.

beamstr, optional

The primary beam model to use out of [hyperbeam].
Default: hyperbeam.

min_z_powerfloat, optional

Zenith normalised power cut off.
Default: 0.3.

cal_checkboolean, optional

Checks the MWA pulsar database if there is a calibration suitable for the observation ID.

all_voltboolean, optional

Included observations with missing or incorrect voltage files.
Default: False.

degrees_checkboolean, optional

If true assumes RAJ and DecJ are in degrees.
Default: False.

metadata_listlist

List of the outputs of vcstools.metadb_utils.get_common_obs_metadata. If not provided, will make the metadata calls to find the data.
Default: None.

Returns:
output_datadict

The format of output_data is dependant on obs_for_source.
If obs_for_source is True :
output_data = {jname:[[obsid, duration, enter, exit, max_power],
[obsid, duration, enter, exit, max_power]]}
If obs_for_source is False :
ouput_data = {obsid:[[jname, enter, exit, max_power],
[jname, enter, exit, max_power]]}

obsid_metalist

A list of the output of get_common_obs_metadata for each obsid

vcstools.beam_calc.from_power_to_gain(power, cfreq, n, coh=True)[source]

Estimate the gain from the tile beam power.

Parameters:
powerfloat

The tile beam power at the source position.

cfreqfloat

The centre frequency of the observation in Hz

nint

The number of non-flagged MWA tiles.

cohboolean, optional

True if the observation is coherent (tied-array beam) or False if it’s incoherent.
Default: True.

Returns:
gainfloat

Gain in K/Jy.

vcstools.beam_calc.get_Trec(obsfreq, trcvr_file=None)[source]

Get receiver temperature from the temperature receiver file.

Parameters:
obsfreqfloat

The observing frequency in MHz.

trcvr_filestr, optional

The Trec file location to read in. If none is supplied, will use the Trec file in the data directory.

Returns:
Trecfloat

The receiver temperature in K.

vcstools.beam_calc.get_beam_power_over_time(names_ra_dec, common_metadata=None, dt=296, centeronly=True, verbose=False, option='hyperbeam', degrees=False, start_time=0)[source]

Calculates the zenith normalised power for each source over time.

Parameters:
names_ra_declist

An array in the format [[source_name, RAJ, DecJ]]

common_metadatalist, optional

The list of common metadata generated from vcstools.metadb_utils.get_common_obs_metadata()

dtint, optional

The time interval of how often powers are calculated.
Default: 296.

centeronlyboolean, optional

Only calculates for the centre frequency.
Default: True.

verboseboolean, optional

If True will not supress the output.
Default: False.

optionstr, optional

The primary beam model to use out of [hyperbeam].
Default: hyperbeam.

degreesboolean, optional

If true assumes RAJ and DecJ are in degrees.
Default: False.

start_timeint, optional

The time in seconds from the begining of the observation to start calculating at.
Default: 0.

Returns:
Powersnumpy.array, (len(names_ra_dec), ntimes, nfreqs)

The zenith normalised power for each source over time.

vcstools.beam_calc.makeUnpolInstrumentalResponse(j1, j2)[source]

Form the visibility matrix in instrumental response from two Jones matrices assuming unpolarised sources (hence the brightness matrix is the identity matrix) Input: j1,j2: Jones matrices of dimension[za][az][2][2] Returns: [za][az][[xx,xy],[yx,yy]] where “X” and “Y” are defined by the receptors of the Dipole object used in the ApertureArray. Hence to get “XX”, you want result[za][az][0][0] and for “YY” you want result[za][az][1][1]

vcstools.beam_calc.pixel_area(ra_min, ra_max, dec_min, dec_max)[source]

Calculate the area of a pixel on the sky from the pixel borders

Parameters:
ra_minfloat

The Right Acension minimum in degrees.

ra_maxfloat

The Right Acension maximum in degrees.

dec_minfloat

The Declination minimum in degrees.

dec_maxfloat

The Declination maximum in degrees.

Returns:
areafloat

Area of the pixel in square degrees.

vcstools.beam_calc.source_beam_coverage(obs_list, names_ra_dec, common_metadata_list=None, dt_input=300, beam='hyperbeam', min_z_power=0.3)[source]

For a list of MWA observations and sources will find if the sources are in the beam and when they enter and exit.

Parameters:
obs_listlist

A list of MWA Observation IDs.

names_ra_declist

An array in the format [[source_name, RAJ, DecJ]]

common_metadata_listlist of list, optional

A list of lists where each list is the common metadata generated from vcstools.metadb_utils.get_common_obs_metadata() for each obs in the obs_list.

dt_inputint, optional

The time interval in seconds of how often powers are calculated.
Default: 300.

beamstr, optional

The primary beam model to use out of [hyperbeam].
Default: hyperbeam.

min_z_powerfloat, optional

Zenith normalised power cut off.
Default: 0.3.

Returns:
beam_coveragedict

A dictionary where the first key is the observation ID and the second is the pulsar names like so:
beam_coverage[obsid][name] = [dect_beg_norm, dect_end_norm, np.amax(source_ob_power)] dect_beg_norm : float

Fraction of the observation when the source enters the beam.

dect_end_normfloat

Fraction of the observation when the source enters and exits the beam respectively.

vcstools.beam_calc.source_beam_coverage_and_times(obsid, pulsar, p_ra=None, p_dec=None, obs_beg=None, obs_end=None, files_beg=None, files_end=None, min_z_power=0.3, dt_input=100, common_metadata=None, query=None, beam='hyperbeam')[source]

Finds the normalised time that a pulsar is in the beam for a given obsid. If pulsar is not in beam, returns None, None

Parameters:
obsidint

The observation ID

pulsarstr

The pulsar’s J name

p_ra, p_decstr, optional

The target’s right ascension and declination in sexidecimals. If not supplied will use the values from the ANTF.

obs_beg, obs_endint, optional

Beginning and end GPS time of the observation. If not supplied will use vcstools.metadb_utils.obs_max_min() to find it.

files_beg, files_endint, optional

Beginning and end GPS time of the (fits of VCS) files. If not supplied will assume the full observation is available.

min_z_powerfloat, optional

Zenith normalised power cut off.
Default: 0.3.

common_metadatalist, optional

The list of common metadata generated from vcstools.metadb_utils.get_common_obs_metadata()

querypsrqpy object, optional

A previous psrqpy query. Can be supplied to prevent performing a new query.

beamstr, optional

The primary beam model to use out of [hyperbeam].
Default: hyperbeam.

Returns:
enter_filesfloat

A float between 0 and 1 that describes the normalised time that the pulsar enters the beam

exit_filesfloat

A float between 0 and 1 that describes the normalised time that the pulsar exits the beam

beam_sim

catalogue_utils

vcstools.catalogue_utils.get_psrcat_dm_period(pulsar_list=None, query=None)[source]

Uses PSRCAT to return a list of pulsar names, periods and dispersion measures.

Parameters:
pulsar_listlist, optional

List of the pulsar Jnames to search the catalogue for. If no pulsar_list is given then returns all pulsar on the catalogue.
Default: None.

querypsrqpy object, optional

A previous psrqpy.QueryATNF query. Can be supplied to prevent performing a new query.

Returns:
pulsar_dm_p: list

[[Jname, DM, period]]

Jnamestr

The Jname of the pulsar.

DMfloat

The Dispersion Measure of the pulsar.

periodfloat

The period of the puslsar in seconds.

vcstools.catalogue_utils.get_psrcat_ra_dec(pulsar_list=None, max_dm=5000.0, include_dm=False, query=None)[source]

Uses PSRCAT to return a list of pulsar names, ras and decs. Not corrected for proper motion. Removes pulsars without any RA or DEC recorded

Parameters:
pulsar_listlist, optional

List of the pulsar Jnames to search the catalogue for. If no pulsar_list is given then returns all pulsar on the catalogue.
Default: None.

max_dmfloat, optional

The maximum dispersion measure of pulsars to include in the output.
Default: 250.

include_dmboolean, optional

If True will also return the pulsars’ dispersion measure.
Default: False,

querypsrqpy object, optional

A previous psrqpy.QueryATNF query. Can be supplied to prevent performing a new query.

Returns:
pulsar_ra_declist

[[Jname, RAJ, DecJ]]

Jnamestr

The Jname of the pulsar.

RAJstr

The Right Acension in the format “HH:MM:SS.SS”.

DecJstr

The Declination in the format “DD:MM:SS.SS”.

vcstools.catalogue_utils.get_rFRB_info(name=None)[source]

Gets repeating FRB info from the csv file we maintain.

Parameters:
namelist, optional

A list of repeating FRB names to get info for. The default is None which gets all rFRBs in the catalogue.

Returns:
outputlist

[[name, RAJ, DecJ, dm, dm_error]]

namestr

The name of the source.

RAJstr

The Right Acension in the format “HH:MM:SS.SS”.

DecJstr

The Declination in the format “DD:MM:SS.SS”.

dmfloat

The Dispersion Measure of the pulsar.

dm_errorfloat

The uncertainty of the Dispersion Measure of the pulsar.

vcstools.catalogue_utils.grab_source_alog(source_type='Pulsar', pulsar_list=None, max_dm=5000.0, include_dm=False, query=None)[source]

Will search different source catalogues and extract all the source names, RAs, Decs and, if requested, DMs

Parameters:
source_typestr

The type of source you would like to get the catalogue for. Your choices are: [‘Pulsar’, ‘FRB’, ‘rFRB’, ‘POI’ ‘RRATs’, ‘Fermi’]
Default: ‘Pulsar’

pulsar_list: list

List of sources you would like to extract data for. If None is given then it will search for all available sources
Default: None

max_dmfloat

If the source_type is ‘Pulsar’ then you can set a maximum dm and the function will only return pulsars under that value.
Default: 1000.

include_dm: Bool

If True the function will also return the DM if it is available at the end of the list
Default: False

Returns:
name_ra_declist

[[name, RAJ, DecJ, (DM)]]

namestr

The name of the source.

RAJstr

The Right Acension in the format “HH:MM:SS.SS”.

DecJstr

The Declination in the format “DD:MM:SS.SS”.

DMfloat

The Dispersion Measure of the pulsar. Only included if include_dm is True.

check_files

config

data_load

Loads all the data required by vcstools from the data directory.

general_utils

Creates a symbolic link product_dir/link that points to data_dir/target_dir.

Parameters:
data_dirstr

The absolute path to the base directory of the true location of the files. For our uses this is often a scratch partition like /astro on Galaxy

target_dirstr

The folder you would like to be linked to

product_dirstr

The absolute path of the link you would like to create

linkstr

The name of the link you would like to create. Often the same as target_dir

vcstools.general_utils.is_number(s)[source]

Simple is check to see if a string can be converted to an interger.

Parameters:
sstr

String to check.

Returns:
resultboolean

Boolean if it can be converted to an int.

vcstools.general_utils.mdir(path, description, gid=34858)[source]

Simple function to create directories with the correct group permissions (771).

Parameters:
pathstr

The path of the directory we want to create.

descriptionstr

The description of the directory to be printed to logger.

gidint, optional

The group ID to apply to the directory.
Default: 34858 which the mwavcs.

vcstools.general_utils.setup_logger(logger, log_level=20)[source]

Setup the logger with the format we prefer and apply it to all import vcstools modules.

Parameters:
loggerlogger object

The logger object to modify.

log_levellogging class

The logging level to apply.
Default: logging.INFO

Returns:
loggerlogger object

The modified logger object.

vcstools.general_utils.sfreq(freqs)[source]

Sore te coarse frequency channel IDs into the strange MWA format that reverses the order of channels above 128.

Parameters:
freqslist

List of coarse frequency channel IDs.

Returns:
freqslist

List of coarse frequency channel IDs in the new order.

vcstools.general_utils.split_remove_remainder(array, nchunks)[source]

Split an array into nchunks and remove any remaining elements.

Parameters:
arraynp.array, (N)

A single dimension array.

nchunks :`int`

The number of sub arrays to split array into.

Returns:
array_chunkslist

A list containing nhcunks arrays of equal size.

gfit

job_submit

metadb_utils

vcstools.metadb_utils.calc_ta_fwhm(freq, array_phase='P2C')[source]

Calculates the approximate FWHM of the tied-array beam in degrees.

Parameters:
freqfloat

Frequency in MHz.

array_phasestr, optional

The different array phase (from P1, P2C, P2E) to work out the maximum baseline length.
Default = ‘P2C’.

Returns:
fwhmfloat

FWHM in degrees.

vcstools.metadb_utils.combined_deleted_check(obsid, begin=None, end=None)[source]

Check if the combined files are deleted (or do not exist).

Parameters:
obsidint

The MWA Observation ID.

begint, optional

Beginning of the observation GPS time to check.

endint, optional

End of the observation GPS time to check.

Returns:
comb_del_checkbool

True if all combined files are deleted or if they do not exist.

vcstools.metadb_utils.ensure_metafits(data_dir, obsid, metafits_file)[source]

Ensure that the metafits file is in the directory, if not download it.

Parameters:
data_dirstr

The directory to check the metafits file is in.

obsidint

The MWA Observation ID.

metafits_filestr

The metafits file name.

vcstools.metadb_utils.files_available(obsid, files_meta_data=None)[source]

Query the database and return a list of all files available (remote archived and not deleted) and a list of all files

Parameters:
obsidint

The MWA Observation ID.

full_metadatadict, optional

The dictionary of metadata generated from vcstools.metadb_utils.getmeta()

Returns:
available_fileslist

All files that have been archived and ready for download.

all_fileslist

All files that are expected, once all files have been transfered/archived.

vcstools.metadb_utils.find_obsids_meta_pages(params=None, pagesize=50)[source]

Loops over pages for each page for MWA metadata calls

Parameters:
paramsdict

The dictionary of constraints used to search for suitable observations as explained here: https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Findobservations
Default: {‘mode’:’VOLTAGE_START’}

Returns:
obsid_listlist

List of the MWA observation IDs.

vcstools.metadb_utils.get_ambient_temperature(obsid, full_metadata=None)[source]

Queries the metadata to find the ambient temperature of the MWA tiles in K. If none recorded then assume 22.4 C.

Parameters:
obsidint

The MWA observation ID.

full_metadatadict, optional

The dictionary of metadata generated from vcstools.metadb_utils.getmeta().

Returns:
t_0float

The ambient temperature of the MWA tiles in K.

vcstools.metadb_utils.get_best_cal_obs(obsid)[source]

For the input MWA observation ID find all calibration observations within 2 days that have the same observing channels and list them from closest in time to furthest.

Parameters:
obsidint

The MWA Observation ID.

Returns:
cal_idslist

[[obsid, mins_away, cal_target]]

obsidint

The MWA calibration observation ID.

mins_awayfloat

The mins away the calibration observation is away from the target observation.

cal_targetstr

The calibration target name.

vcstools.metadb_utils.get_channels(obsid, channels=None)[source]

Gets the channels ids from the observation’s metadata. If channels is not None assumes the channels have already been aquired so it doesn’t do an unnecessary database call.

Parameters:
obsidint

The MWA Observation ID.

channelslist, optional

The list of the coarse channel frequency IDs.

Returns:
channelslist

The list of the coarse channel frequency IDs.

vcstools.metadb_utils.get_common_obs_metadata(obsid, return_all=False, full_metadata=None)[source]

Gets needed common meta data from http://ws.mwatelescope.org/metadata/

Parameters:
obsidint

The MWA observation ID.

return_allboolean, optional

If True will also return the full meta data dictionary.
Default: False.

full_metadatadict, optional

The dictionary of metadata generated from vcstools.metadb_utils.getmeta()

Returns:
common_metadatalist

[obsid, ra, dec, dura, [xdelays, ydelays], centrefreq, channels]

obsidint

The MWA observation ID.

rastr

The Right Acension in the format “HH:MM:SS.SS”.

decstr

The Declination in the format “DD:MM:SS.SS”.

duraint

The duration of the observation in seconds.

xdelays, ydelayslist

The analogue delays for each antena od the tile for both the x and y polarisations.

centrefreqfloat

The centre observing frequency in MHz.

channelslist

The list of observing frequency coarse channel IDs.

vcstools.metadb_utils.get_files(obsid, files_meta_data=None)[source]

Queries the metadata to find all the file names.

Parameters:
obsidint

The MWA Observation ID.

full_metadatadict, optional

The dictionary of metadata generated from vcstools.metadb_utils.getmeta()

Returns:
fileslist

A list of all the file names.

vcstools.metadb_utils.get_obs_array_phase(obsid)[source]

For the input obsid will work out the observations array phase in the form of P1 for phase 1, P2C for phase 2 compact or P2E for phase to extended array and OTH for other.

Parameters:
obsidint

The MWA Observation ID.

vcstools.metadb_utils.getmeta(servicetype='metadata', service='obs', params=None, retries=3, retry_http_error=False)[source]

Function to call a JSON web service to perform an MWA metadata call. Taken verbatim from http://mwa-lfd.haystack.mit.edu/twiki/bin/view/Main/MetaDataWeb.

Parameters:
servicetypestr

Either the ‘observation’ which makes human readable html pages or ‘metadata’ which returns data.
Default: metadata.

servicestr

The meta data service from (Defaul: obs):

obs:

Returns details about a single observation as explained in https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Getobservation/scheduledataforanobservation

find:

Search the database for observations that satisfy given criteria as explained in https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Findobservations

con:

Finds the configuration information for an observation as explained in https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Gettelescopeconfigurationforagivenobservation

paramsdict

A dictionary of the options to use in the metadata call which is dependent on the service. Examples can be found https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Usingthegetmeta()function

retriesint, optional

The number of times to retry timeout errors.

Returns:
resultdict

The result for that service.

vcstools.metadb_utils.mwa_alt_az_za(obsid, ra=None, dec=None, degrees=False)[source]

Calculate the altitude, azumith and zenith for an obsid

Parameters:
obsidint

The MWA Observation ID.

rastr

The Right Acension in the format “HH:MM:SS.SS”.

decstr

The Declination in the format “DD:MM:SS.SS”.

degreesboolean

If True the ra and dec is given in degrees.
Default: False.

Returns:
Altfloat

The altitude angle in degrees.

Azfloat

The azimuth angle in degrees.

Zafloat

The zenith angle in degrees.

vcstools.metadb_utils.obs_max_min(obsid, files_meta_data=None)[source]

Small function to query the database and return the times of the first and last file.

Parameters:
obsidint

The MWA Observation ID.

full_metadatadict, optional

The dictionary of metadata generated from vcstools.metadb_utils.getmeta()

Returns:
obs_startint

Beginning of the observation GPS time.

obs_endint

End of the observation GPS time.

Used to find all obsids within a box around the source to make searching through obs_ids more efficient.

Parameters:
rafloat

Right Acension of the source in degrees

decfloat

Declination of the source in degrees. By default will use the enitre declination range to account for grating lobes

box_sizefloat

Radius of the search box. Default: 45

paramsdict

The dictionary of constraints used to search for suitable observations as explained here: https://wiki.mwatelescope.org/display/MP/Web+Services#WebServices-Findobservations
Default: {‘mode’:’VOLTAGE_START’}

Returns:
obsid_listlist

List of the MWA observation IDs.

pointing_utils

vcstools.pointing_utils.deg2sex(ra, dec)[source]

Convert decimal coordingates into sexagesimal strings.

Parameters:
rafloat

The Right Acension in degrees.

decfloat

The Declination in degrees.

Returns:
rastr

The Right Acension in the format “HH:MM:SS.SS”.

decstr

The Declination in the format “DD:MM:SS.SS”.

vcstools.pointing_utils.format_ra_dec(ra_dec_list, ra_col=0, dec_col=1)[source]

Will format a list of lists containing RAs and Decs to uniform strings. eg 00:00:00.00 -00:00:00.00. Will not work for numpy arrays so make sure they’re list of lists An example input: format_ra_dec([[name,ra,dec]], ra_col = 1, dec_col = 2)

Parameters:
ra_dec_listlist of lists

A list of lists where each row is a different source with an RA and declination.

ra_colint, optional

The coloumn ID that contains the RA.
Default: 0.

dec_colint, optional

The coloumn ID that contains the Declination.
Default: 1.

Returns:
ra_dec_listlist of lists

The formated ra_dec_list.

Examples

>>> format_ra_dec([["J2351+8533", "23:51:03", "+85:33:20.6"]], ra_col = 1, dec_col = 2)
[["J2351+8533", "23:51:03.00", "+85:33:20.60"]]
vcstools.pointing_utils.getTargetAZZA(ra, dec, time, lat=-26.7033, lon=116.671, height=377.827, units=(Unit('hourangle'), Unit('deg')))[source]

Function to get the target position in alt/az at a given EarthLocation and Time. The default lat,lon,height is the centre of MWA.

Parameters:
rastr

The target right ascension in astropy-readable format.

decstr

The target declination in astropy-readable format.

timestr

The time of observation in UTC (i.e. a string on form: yyyy-mm-dd hh:mm:ss.ssss)

latfloat, optional

The observatory latitude in degrees.
Default: -26.7033.

lonfloat, optional

The observatory longitude in degrees.
Default: 116.671.

heightfloat, optional

The observatory height from sea level in meters.
Default: 377.827.

unitstuple, optional

The astropy units of the ra and dec.
Default: (u.hourangle, u.deg)

Returns:
azfloat

Target azimuth in radians.

zafloat

Target zenith angle in radians.

azdegfloat

Target azimuth in degrees.

zadegfloat

Target zenith angle in degrees.

vcstools.pointing_utils.getTargetRADec(az, za, time, lat=-26.7033, lon=116.671, height=377.827, units=(Unit('deg'), Unit('deg')))[source]

Function to get the target position in ra dec at a given EarthLocation and Time. The default lat,lon,height is the centre of MWA.

Parameters:
azstr

The target azimuth in astropy-readable format.

zastr

The target zenith angle in astropy-readable format.

timestr

The time of observation in UTC (i.e. a string on form: yyyy-mm-dd hh:mm:ss.ssss)

latfloat, optional

The observatory latitude in degrees.
Default: -26.7033.

lonfloat, optional

The observatory longitude in degrees.
Default: 116.671.

heightfloat, optional

The observatory height from sea level in meters.
Default: 377.827.

unitstuple, optional

The astropy units of the ra and dec.
Default: (u.deg, u.deg)

Returns:
rafloat

Target right ascension in radians.

decfloat

Target declination in radians.

radegfloat

Target right ascension in degrees.

decdegfloat

Target declination in degrees.

vcstools.pointing_utils.sex2deg(ra, dec)[source]

Convert sexagesimal coordinates to degrees.

Parameters:
rastr

The Right Acension in the format “HH:MM:SS.SS”.

decstr

The Declination in the format “DD:MM:SS.SS”.

Returns:
rafloat

The Right Acension in degrees.

decfloat

The Declination in degrees.

prof_utils

progress_bar

vcstools.progress_bar.progress_bar(it, prefix='', size=60, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

I stole this code from here: https://stackoverflow.com/questions/3160699/python-progress-bar

Parameters:
itlist

The list to iterate over.

prefixstr

The prefix do display in the progress bar.
Default: “”.

sizeint

The length of the progress bar to display in characters.
Default: 60.

filestdout

The output of the progress bar.
Default: sys.stdout.

Examples

>>> for i in progressbar(range(15), "Computing: ", 40):

rm_synth

RM module that implements 1-D RM Synthesis/RMCLEAN.

MIT License

Copyright (c) 2017 George Heald

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class vcstools.rm_synth.PolObservation(freq, IQU, IQUerr=None, verbose=True)[source]

Class to describe an observation & perform polarimetry operations

Methods

get_fdf_peak([verbose])

Obtain the peak of the FDF and its Faraday depth This will fit the peak of the FSF and report results if requested.

plot_fdf([display, save, rescale, plot_rmsf])

Plot the FDF and RMSF

plot_stokesi([display, save])

Plot Stokes I

print_rmstats()

Print some stats about the results

rmclean([niter, gain, cutoff, mask, verbose])

Perform RMCLEAN

rmsynthesis(phi[, norm_mod, norm_vals, ...])

Perform RM Synthesis.

get_fdf_peak(verbose=True)[source]

Obtain the peak of the FDF and its Faraday depth This will fit the peak of the FSF and report results if requested. Values that are calculated and reported are:
Absolute value at peak, PA at peak, peak RM value This is done for the dirty FDF. If RMCLEAN has been performed then this is also done for the deconvolved Faraday spectrum.

Parameters:
verboseboolean, optional (default True)

Print some output?

plot_fdf(display=True, save=None, rescale=False, plot_rmsf=True)[source]

Plot the FDF and RMSF

The plot will show the RMSF in black, and the FDF in red. If RMCLEAN has already been performed then the cleaned spectrum will be shown in blue, and the clean model in green.

Parameters:
displayboolean, optional (default True)

Show plot on screen?

savestr, optional (default None)

Save figure to disk? Provide filename if desired.

rescaleboolean, optional (default False)

Rescale RMSF peak to match that of FDF?

plot_rmsfboolean, optional (default True)

Plot RMSF?

plot_stokesi(display=True, save=None)[source]

Plot Stokes I

The plot will show the Stokes I values (and errors if available).

Parameters:
displayboolean, optional (default True)

Show plot on screen?

savestr, optional (default None)

Save figure to disk? Provide filename if desired.

print_rmstats()[source]

Print some stats about the results

Some basic statistics will be reported to the terminal:

mean of RM clean components, dispersion of RM clean components

rmclean(niter=1000, gain=0.1, cutoff=2.0, mask=False, verbose=True)[source]

Perform RMCLEAN

The FDF will be deconvolved using the RMSF.

Parameters:
niterint, optional (default 1000)

Maximum number of clean iterations

gainfloat, optional (default 0.1)

Clean gain

cutofffloat, optional (default 2)

Clean cutoff, in units of S/N The default stops at 2*sigma above the mean

maskboolean (default False)

If True, all clean components must be within an RMSF FWHM of the first peak

verboseboolean, optional (default True)

Print some output?

rmsynthesis(phi, norm_mod=False, norm_vals=False, double=True, clip=None, pclip=None, weightmode='none', verbose=True)[source]

Perform RM Synthesis. This function performs RM Synthesis on the provided IQU data and computes the RMSF. It can adopt weights based on the IQU errors if they are provided.

Parameters:
phiarray

RM values to use (should be contiguous and regularly spaced)

norm_modboolean, optional (default False)

Normalise QU values with the Stokes I fitted power-law model?

norm_valsboolean, optional (default False)

Normalise QU values with the Stokes I data points per channel?

doubleboolean, optional (default True)

Create the RMSF double the length along the RM axis? This should be kept as True unless you are not planning to RMCLEAN.

clipfloat, optional (default -inf)

Ignore channels with Stokes I S/N ratio < clip

pclipfloat, optional (default -inf)

Ignore channels with sqrt(Q**2+U**2) S/N ratio < pclip

weightmodestr, optional (default ‘none’)

How to do weighting in the Fourier transform. Options are:
‘none’ = no weighting (uniform weights)
‘varwt’ = inverse variance weights based on Stokes I noise Further options may be added later.

verboseboolean, optional (default True)

Print some output?

rm_synth_utils

sn_flux_utils

stickel