dqrtasks.gspynettree.utils

Functions

collate_4_images(images[, image_shape])

Combine 4 input images in 2x2 grid

convert_value_to_string(value)

fig_to_img(fig[, height, width, xcrop, ...])

Render matplotlib figure and extract plot as image

forward_merc(a)

Forward Mercator transform function

generate_plot_filename(ifo, desc, start_gps, ...)

Generates a plot name using the convention {IFO}-{DESCRIPTOR}-{START_GPS}-{DURATION}{FMT}

get_label_probabilities(prediction)

Returns a list of lists [Class name, string representing probability visually, probability] representing the results that the CNN outputs.

get_logger(name)

Get logger according to commandline args

get_pvalue(prediction)

Returns the calculated p-value of an event, where 0 is "DQ issue identified" and 1 is "no DQ issue identified".

in_observing_mode(detector, start, end)

Checks if GPS time interval (start, end) at the specified detector is in observing mode

inverse_merc(a)

Inverse Mercator transform function

make_new_dir(dir)

Makes a directory if it doesn't already exist

plot_qtransform(detector, channel, gps_time)

Convert time series strain data to Q-transform spectrogram plot

set_args(new_args)

dqrtasks.gspynettree.utils.collate_4_images(images, image_shape=(140, 170))[source]

Combine 4 input images in 2x2 grid

Arguments: images – list of 4 images

Keyword arguments: image_shape – dimensions of input images (default: (140, 170))

dqrtasks.gspynettree.utils.fig_to_img(fig, height=1.78, width=2.39, xcrop=(20, 160), ycrop=(31, 201), greyscale=True)[source]

Render matplotlib figure and extract plot as image

dqrtasks.gspynettree.utils.forward_merc(a)[source]

Forward Mercator transform function

dqrtasks.gspynettree.utils.generate_plot_filename(ifo, desc, start_gps, duration, plot_fmt='.png')[source]

Generates a plot name using the convention {IFO}-{DESCRIPTOR}-{START_GPS}-{DURATION}{FMT}

dqrtasks.gspynettree.utils.get_label_probabilities(prediction)[source]

Returns a list of lists [Class name, string representing probability visually, probability] representing the results that the CNN outputs. Params: prediction - CNN output with probabilities per class

dqrtasks.gspynettree.utils.get_logger(name)[source]

Get logger according to commandline args

dqrtasks.gspynettree.utils.get_pvalue(prediction)[source]

Returns the calculated p-value of an event, where 0 is “DQ issue identified” and 1 is “no DQ issue identified”. The p-value is defined as 1 - maximum probability of all glitches. Params: prediction - CNN output with probabilities per class

dqrtasks.gspynettree.utils.in_observing_mode(detector, start, end)[source]

Checks if GPS time interval (start, end) at the specified detector is in observing mode

dqrtasks.gspynettree.utils.inverse_merc(a)[source]

Inverse Mercator transform function

dqrtasks.gspynettree.utils.make_new_dir(dir)[source]

Makes a directory if it doesn’t already exist

params: - dir (os.path or string): path to the directory of interest

return: n/a

dqrtasks.gspynettree.utils.plot_qtransform(detector, channel, gps_time, timeseries_path=None, plot_normalized_energy_range=[0, 25.5], plot_durations=[0.5, 1, 2, 4], frametype=None, framesource=None, qrange=(4, 64), frange=(10, 2048), cmap='Greys_r', yscale_kwargs={'base': 2, 'value': 'log'}, make_plots=False, tag='', output_dir=None, **kwargs)[source]

Convert time series strain data to Q-transform spectrogram plot

Arguments: detector – identifier for gravitational wave detector channel – identifier for data channel within gravitational wave detector gps_time – GPS time of interest

Keyword arguments: timeseries_path – path to cached gwpy.TimeSeries corresponding to event of interest

If not provided, gwpy.TimeSeries.get is used to get the data remotely

plot_normalized_energy_range – normalized energy range for Q-transform colourbar plot_durations – time windows centered around start_time to plot Q-transforms for qrange – Q range for Q-transform frange – frequency range for Q-transform cmap – matplotlib colour map to use for displaying Q-transform yscale_kwargs – keyword argument dictionary to pass into Axis.set_yscale make_plots – whether or not to make an overall plot combining individual Q-transforms tag – string tag to append to plot titles output_dir – directory to save plots to (default: plots are not saved)

Returns an array of pixel arrays corresponding to Q-transform plots, and additionally the Figure objects of the plotted figures if make_plots=True