pipeline.hsd.tasks.common package

Submodules

pipeline.hsd.tasks.common.common module

This module defines common single dish Results and task container Classes.

Classes and Methods:

absolute_path: A method to convert a path to an absolute path. SingleDishResults: Common single dish Results class. ParameterContainerJob: A container class to store task with parameters.

class pipeline.hsd.tasks.common.common.ParameterContainerJob(task: pipeline.infrastructure.basetask.StandardTaskTemplate, **parameters)[source]

Bases: object

A container class to store task class object with parameter values.

Variables
  • task – A task class object to execute.

  • parameters – A disctionary of task parameters (key: parameter name, value: parameter value) to invoke task.

execute(dry_run: bool = True)pipeline.infrastructure.basetask.Results[source]

Invoke task using given parameters.

Parameters

dry_run – Run task if False, or only display commands if True.

Retruns:

A Result object of the task.

class pipeline.hsd.tasks.common.common.SingleDishResults(task: Optional[pipeline.infrastructure.basetask.StandardTaskTemplate] = None, success: Optional[bool] = None, outcome: Any = None)[source]

Bases: pipeline.infrastructure.basetask.Results

Single Dish Results class.

This class inherits a common Results class, pipeline.infrastructre.basetask.Results. See the documentation of the super class for details. The class is usually used as a superclass of task specific Results class.

Variables
  • task – A task class associated with this class.

  • success – A boolean to indicate if the task execution was successful (True) or not (False).

  • outcome – Outcome of the task.

  • error – A set of strings to store error messages.

merge_with_context(context: pipeline.infrastructure.launcher.Context)[source]

Merge these results with the given context.

See the documenetation of super class for more details.

pipeline.hsd.tasks.common.common.absolute_path(name: str)str[source]

Return an absolute path of a given file.

pipeline.hsd.tasks.common.compress module

class pipeline.hsd.tasks.common.compress.CompressedIter(obj)[source]

Bases: object

class pipeline.hsd.tasks.common.compress.CompressedList[source]

Bases: list

class pipeline.hsd.tasks.common.compress.CompressedObj(obj, protocol=4, compresslevel=9)[source]

Bases: object

decompress()[source]
pipeline.hsd.tasks.common.compress.compress_object(obj, protocol=4, compresslevel=9)[source]
pipeline.hsd.tasks.common.compress.decompress_object(obj)[source]

pipeline.hsd.tasks.common.direction_utils module

pipeline.hsd.tasks.common.direction_utils.direction_convert(direction, mepoch, mposition, outframe)[source]
pipeline.hsd.tasks.common.direction_utils.direction_offset(direction, reference)[source]
pipeline.hsd.tasks.common.direction_utils.direction_recover(ra, dec, org_direction)[source]
pipeline.hsd.tasks.common.direction_utils.direction_shift(direction, reference, origin)[source]

pipeline.hsd.tasks.common.display module

class pipeline.hsd.tasks.common.display.CustomDateFormatter(fmt, tz=None)[source]

Bases: matplotlib.dates.DateFormatter

Customized date formatter that puts YYYY/MM/DD under usual tick labels at the beginning of tick and when date is changed.

class pipeline.hsd.tasks.common.display.PlotObjectHandler[source]

Bases: object

axhline(*args, **kwargs)[source]
axvspan(*args, **kwargs)[source]
clear()[source]
plot(*args, **kwargs)[source]
text(*args, **kwargs)[source]
class pipeline.hsd.tasks.common.display.SDCalibrationDisplay(inputs)[source]

Bases: object

Inputs

alias of SingleDishDisplayInputs

abstract doplot(result, stage_dir)[source]
plot()[source]
class pipeline.hsd.tasks.common.display.SDImageDisplay(inputs)[source]

Bases: object

Inputs

alias of SDImageDisplayInputs

property data
property edge
property id_spectral
property id_stokes
init()[source]
property mask
property num_valid_spectrum
property rms
class pipeline.hsd.tasks.common.display.SDImageDisplayInputs(context, result)[source]

Bases: pipeline.hsd.tasks.common.display.SingleDishDisplayInputs

property antenna
property antennaid_list
property contamination_plot
property fieldid_list
property imagename
property msid_list
property reduction_group

Retruns ReductionGroupDesc instance corresponding to the reduction group associated to the image

property source
property spw
property spwid_list
property stage_dir
property stage_number
property vis
class pipeline.hsd.tasks.common.display.SDSparseMapPlotter(nh, nv, step, brightnessunit, clearpanel=True, figure_id=None)[source]

Bases: object

property TickSize
add_channel_axis(frequency)[source]
property direction_reference
done()[source]
property nh
property nv
plot(map_data, averaged_data, frequency, fit_result=None, figfile=None)[source]
set_atm_transmission(transmission, frequency)[source]
set_channel_axis()[source]
set_deviation_mask(mask)[source]
set_global_scaling()[source]
setup_labels_absolute(ralist, declist)[source]
setup_labels_relative(refpix_list, refval_list, increment_list)[source]
setup_lines(lines_averaged, lines_map=None)[source]
setup_reference_level(level=0.0)[source]
unset_atm_transmission()[source]
unset_channel_axis()[source]
unset_global_scaling()[source]
class pipeline.hsd.tasks.common.display.SingleDishDisplayInputs(context, result)[source]

Bases: object

property isnro
class pipeline.hsd.tasks.common.display.SparseMapAxesManager(nh, nv, brightnessunit, ticksize, clearpanel=True, figure_id=None)[source]

Bases: pipeline.infrastructure.displays.pointing.MapAxesManagerBase

static MATPLOTLIB_FIGURE_ID()[source]
property axes_atm
property axes_chan
property axes_integsp
property axes_spmap
setup_labels(label_ra, label_dec)[source]
class pipeline.hsd.tasks.common.display.SpectralImage(imagename)[source]

Bases: object

property beam_size
property brightnessunit
direction_axis(idx, unit='deg')[source]
property nchan
property npol
property nx
property ny
spectral_axis(unit='GHz')[source]
to_velocity(frequency, freq_unit='GHz')[source]
class pipeline.hsd.tasks.common.display.TimeAxesManager[source]

Bases: object

init(start_time=None, end_time=None)[source]
pipeline.hsd.tasks.common.display.ch_to_freq(ch, frequency)[source]
pipeline.hsd.tasks.common.display.drop_edge(array)[source]
pipeline.hsd.tasks.common.display.form3(n)[source]
pipeline.hsd.tasks.common.display.form4(n)[source]
pipeline.hsd.tasks.common.display.get_base_frame(table)[source]
pipeline.hsd.tasks.common.display.get_base_frequency(table, freqid, nchan)[source]
pipeline.hsd.tasks.common.display.mjd_to_datedict(val, unit='d')[source]
pipeline.hsd.tasks.common.display.mjd_to_datestring(val, fmt='%Y/%m/%d')[source]
pipeline.hsd.tasks.common.display.mjd_to_datetime(val)[source]
pipeline.hsd.tasks.common.display.mjd_to_plotval(mjd_list)[source]
pipeline.hsd.tasks.common.display.utc_formatter(fmt='%H:%M')[source]
pipeline.hsd.tasks.common.display.utc_locator(start_time=None, end_time=None)[source]

pipeline.hsd.tasks.common.rasterutil module

class pipeline.hsd.tasks.common.rasterutil.MetaDataSet(timestamp, dtrow, field, antenna, ra, dec, srctype, pflag)

Bases: tuple

property antenna

Alias for field number 3

property dec

Alias for field number 5

property dtrow

Alias for field number 1

property field

Alias for field number 2

property pflag

Alias for field number 7

property ra

Alias for field number 4

property srctype

Alias for field number 6

property timestamp

Alias for field number 0

pipeline.hsd.tasks.common.rasterutil.anim_gen(ra, dec, idx_generator, dist_list, cmap)[source]

Generator for generate_animation.

Parameters
  • ra (ndarray) – list of RA

  • dec (ndarray) – list of Dec

  • idx_generator (generator) – generator yielding start and end indices indicating raster row

  • dist_list (ndarray) – distance list

  • cmap (ListedColorMap) – color map

Yield

position, color, and boolean flag to clear existing plot

Return type

tuple

pipeline.hsd.tasks.common.rasterutil.animate(i)[source]

Generate plot corresponding to single frame

Parameters

i (tuple) – position, color, and boolean flag to clear existing plot

Returns

lines for this frame

Return type

Lines2D

pipeline.hsd.tasks.common.rasterutil.distance(x0, y0, x1, y1)[source]

Compute distance between two points (x0, y0) and (x1, y1).

Parameters
  • x0 (float) – x-coordinate value for point 0

  • y0 (float) – y-coordinate value for point 0

  • x1 (float) – x-coordinate value for point 1

  • y1 (float) – y-coordinate value for point 1

Returns

distance between two points

Return type

float

pipeline.hsd.tasks.common.rasterutil.filter_data(metadata, field_id, antenna_id, onsource=True)[source]

Filter metadata.

Parameters
  • metadata (MetaDataSet) – input metadata

  • field_id (int) – field id

  • antenna_id (int) – antenna id

  • onsource (bool, optional) – take ON_SOURCE data only, defaults to True

Raises

RuntimeError – filter causes empty result

Returns

filtered metadata

Return type

MetaDataSet

pipeline.hsd.tasks.common.rasterutil.find_most_frequent(v)[source]

Return the most frequent number (mode) in v.

Parameters

v (ndarray) – data

Returns

most frequent number (mode)

Return type

int

pipeline.hsd.tasks.common.rasterutil.find_raster_gap(timestamp, ra, dec, time_gap=None)[source]

Find gaps between individual raster map. Returned list should be used in combination with gap_gen. Here is an example to plot RA/DEC data per raster map:

import maplotlib.pyplot as plt gap = find_raster_gap(timestamp, ra, dec) for s, e in gap_gen(gap):

plt.plot(ra[s:e], dec[s:e], ‘.’)

Parameters
  • timestamp (ndarray) – list of time stamp

  • ra (ndarray) – list of RA

  • dec (ndarray) – list of Dec

  • time_gap (ndarray, optional) – list of index of time gaps, defaults to None

Returns

list of index indicating boundary between raster maps

Return type

ndarray

pipeline.hsd.tasks.common.rasterutil.find_time_gap(timestamp)[source]

Find time gap. Condition for gap is

  • time interval > 3 * median(time interval) for small gap

  • time gap > 3 * median(time gap) for large gap

Parameters

timestamp (ndarray) – list of timestamp. no duplication. must be sorted in ascending order.

Returns

list of small and large time gaps

Return type

two-tuple of lists

pipeline.hsd.tasks.common.rasterutil.flag_incomplete_raster(meta, raster_gap, nd_raster, nd_row)[source]

flag incomplete raster map N: number of data per raster map M: number of data per raster row MN: median of N => typical number of data per raster map MM: median of M => typical number of data per raster row logic:

  • if N[x] < MN + MM then flag whole data in raster map x

  • if N[x] > MN + MM then flag whole data in raster map x and later

Parameters
  • meta (MetaDataSet) – metadata object

  • raster_gap (list) – gap list

  • nd_raster (int) – typical number of data per raster map (MN)

  • nd_row (int) – typical number of data per raster row (MM)

Returns

list of index for raster map

Return type

list

pipeline.hsd.tasks.common.rasterutil.flag_raster_map(metadata)[source]

Return list of index to be flagged by flagging heuristics for raster scan

Parameters

meta (MetaDataSet) – metadata

Returns

per-antenna list of index to be flagged

Return type

list

pipeline.hsd.tasks.common.rasterutil.flag_raster_map_per_field(metadata, field_id)[source]

Flag raster map based on two flagging heuristics for given field id.

Parameters
  • metadata (MetaDataSet) – metadata

  • field_id (int) – field id to process

Returns

per-antenna list of data ids to be flagged

Return type

list of ndarray

pipeline.hsd.tasks.common.rasterutil.flag_worm_eaten_raster(meta, raster_gap, nd_row)[source]

flag raster map if number of continuous flagged data exceeds upper limit given by nd_row M: number of data per raster row MM: median of M => typical number of data per raster row L: maximum length of continuous flagged data logic:

  • if L[x] > MM then flag whole data in raster map x

Parameters
  • meta (MetaDataSet) – metadata object

  • raster_gap (list) – gap list

  • nd_row (int) – typical number of data per raster row (MM)

Returns

list of index for raster map

Return type

list

pipeline.hsd.tasks.common.rasterutil.from_context(context_dir)[source]

read DataTable located in the context directory.

NOTE: only one DataTable will be loaded for multi-EB run

Parameters

context_dir (str) – path to the pipeline context directory

Returns

metadata

Return type

MetaDataSet

pipeline.hsd.tasks.common.rasterutil.gap_gen(gaplist, length=None)[source]

Generate range of data (start and end indices) from given gap list. Return values, s and e, can be used to arr[s:e] to extract the data from the original array, arr.

Parameters
  • gaplist (list) – list of indices indicating gap

  • length (int, optional) – total number of data, defaults to None

Yield

start and end indices

Return type

two tuple of integers

pipeline.hsd.tasks.common.rasterutil.generate_animation(ra, dec, gaplist, figfile='movie.gif')[source]

Generate animation GIF file to illustrate observing pattern.

Parameters
  • ra (ndarray) – list of RA

  • dec (ndarray) – list of Dec

  • gaplist (list) – list of gaps between raster rows

  • figfile (str, optional) – output file name, defaults to ‘movie.gif’

pipeline.hsd.tasks.common.rasterutil.get_angle(dx, dy, aspect_ratio=1)[source]

Compute tangential angle taking into account aspect ratio.

Parameters
  • dx (float) – length along x-axis

  • dy (float) – length along y-axis

  • aspect_ratio (float, optional) – aspect_ratio, defaults to 1

Returns

tangential angle

Return type

float

pipeline.hsd.tasks.common.rasterutil.get_aspect(ax)[source]

Compute aspect ratio of matplotlib figure.

Parameters

ax (Axes) – Axes object to examine

Returns

aspect ratio

Return type

float

pipeline.hsd.tasks.common.rasterutil.get_raster_distance(ra, dec, gaplist)[source]

Compute list of distances between raster rows. Origin of the distance is the first raster row. Representative position of each raster row is its midpoint (mean position).

Parameters
  • ra (ndarray) – list of RA

  • dec (ndarray) – list of Dec

  • gaplist (list) – list of indices indicating gaps between raster rows

Returns

list of distances between raster rows

Return type

ndarray

pipeline.hsd.tasks.common.rasterutil.get_raster_flag_list(flagged1, flagged2, raster_gap, ndata)[source]

Merge flag result and convert raster id to list of data index.

Parameters
  • flagged1 (list) – list of flagged raster id

  • flagged2 (list) – list of flagged raster id

  • raster_gap (list) – list of gaps between raster maps

  • ndata (int) – total number of data points

Returns

list of data ids to be flagged

Return type

ndarray

pipeline.hsd.tasks.common.rasterutil.get_science_target_fields(metadata)[source]

Get list of field ids for science targets.

Parameters

metadata (MetaDataSet) – metadata

Returns

list of field ids for science targets

Return type

ndarray

pipeline.hsd.tasks.common.rasterutil.read_datatable(datatable)[source]

extract necessary data from datatable instance.

Parameters

datatable (DataTableImpl) – datatable instance

Returns

metadata

Return type

MetaDataSet

pipeline.hsd.tasks.common.rasterutil.read_readonly_data(table)[source]
pipeline.hsd.tasks.common.rasterutil.read_readwrite_data(table)[source]
pipeline.hsd.tasks.common.rasterutil.squeeze_data(metadata)[source]

Make timestamp in input metadata unique.

Parameters

metadata (MetaDataSet) – input metadata

Returns

metadata without duplication of timestamp

Return type

MetaDataSet

pipeline.hsd.tasks.common.utils module

class pipeline.hsd.tasks.common.utils.EchoDictionary[source]

Bases: dict

class pipeline.hsd.tasks.common.utils.OnDemandStringParseLogger(logger)[source]

Bases: object

PRIORITY_MAP = {'warn': 'warning'}
critical(msg_template, *args, **kwargs)[source]
debug(msg_template, *args, **kwargs)[source]
error(msg_template, *args, **kwargs)[source]
info(msg_template, *args, **kwargs)[source]
static parse(msg_template, *args, **kwargs)[source]
todo(msg_template, *args, **kwargs)[source]
trace(msg_template, *args, **kwargs)[source]
warn(msg_template, *args, **kwargs)[source]
class pipeline.hsd.tasks.common.utils.ProgressTimer(length=80, maxCount=80, LogLevel='info')[source]

Bases: object

count(increment=1)[source]
class pipeline.hsd.tasks.common.utils.RGAccumulator[source]

Bases: object

append(field_id, antenna_id, spw_id, pol_ids=None, grid_table=None, channelmap_range=None)[source]
get_antenna_id_list()[source]
get_channelmap_range_list()[source]
get_field_id_list()[source]
get_grid_table_list()[source]
get_pol_ids_list()[source]
get_process_list(withpol=False)[source]
get_spw_id_list()[source]
iterate_all()[source]
iterate_id()[source]
class pipeline.hsd.tasks.common.utils.SpwDetailedView(spwid, name, num_channels, ref_frequency, min_frequency, max_frequency)[source]

Bases: object

class pipeline.hsd.tasks.common.utils.SpwSimpleView(spwid, name)[source]

Bases: object

pipeline.hsd.tasks.common.utils.TableSelector(name, query)[source]
pipeline.hsd.tasks.common.utils.asdm_name(scantable_object)[source]

Return ASDM name that target scantable belongs to. Assumptions are:

  • scantable is generated from MS

  • MS is generated from ASDM

  • MS name is <uid>.ms

pipeline.hsd.tasks.common.utils.asdm_name_from_ms(ms_domain)[source]

Return ASDM name that target ms originates from. Assumptions are:

  • MS is generated from ASDM

  • MS name is <uid>.ms

pipeline.hsd.tasks.common.utils.create_parallel_job(task_cls, task_args, context)[source]
pipeline.hsd.tasks.common.utils.create_serial_job(task_cls, task_args, context)[source]
pipeline.hsd.tasks.common.utils.get_brightness_unit(vis, defaultunit='Jy/beam')[source]
pipeline.hsd.tasks.common.utils.get_datacolumn_name(vis)[source]
pipeline.hsd.tasks.common.utils.get_index_list_for_ms(datatable, vis_list, antennaid_list, fieldid_list, spwid_list, srctype=None)[source]
pipeline.hsd.tasks.common.utils.get_index_list_for_ms2(datatable, group_desc, member_list, srctype=None)[source]
pipeline.hsd.tasks.common.utils.get_index_list_for_ms3(datatable_dict, group_desc, member_list, srctype=None)[source]
pipeline.hsd.tasks.common.utils.get_mask_from_flagtra(flagtra)[source]

Convert FLAGTRA (unsigned char) to a mask array (1=valid, 0=flagged)

pipeline.hsd.tasks.common.utils.get_parent_ms_idx(context, msname)[source]

Returns index of corresponding ms in context The method maps both work_data and original MS to a proper index The return value is -1 if no match found.

pipeline.hsd.tasks.common.utils.get_parent_ms_name(context, msname)[source]

Returns name of corresponding parent ms in context The method maps both work_data and original MS to a proper index The return value is “” if no match found.

pipeline.hsd.tasks.common.utils.get_restfrequency(vis, spwid, source_id)[source]
pipeline.hsd.tasks.common.utils.get_spw_names(vis)[source]
pipeline.hsd.tasks.common.utils.get_spw_properties(vis)[source]
pipeline.hsd.tasks.common.utils.get_valid_ms_members(group_desc, msname_filter, ant_selection, field_selection, spw_selection)[source]
pipeline.hsd.tasks.common.utils.get_valid_ms_members2(group_desc, ms_filter, ant_selection, field_selection, spw_selection)[source]
pipeline.hsd.tasks.common.utils.is_nro(context)[source]
pipeline.hsd.tasks.common.utils.iterate_group_member(group_desc, member_id_list)[source]
pipeline.hsd.tasks.common.utils.make_ddid_map(vis)[source]
pipeline.hsd.tasks.common.utils.make_polid_map(srcvis, dstvis)[source]
pipeline.hsd.tasks.common.utils.make_row_map(src_ms, derived_vis, src_tb=None, derived_tb=None)[source]

Make row mapping between source MS and associating MS

src_ms: measurement set domain object for source MS derived_vis: name of the MS that derives from source MS

returns: row mapping dictionary

pipeline.hsd.tasks.common.utils.make_row_map_for_baselined_ms(ms, table_container=None)[source]

Make row mapping between calibrated MS and baselined MS. Return value is a dictionary whose key is row number for calibrated MS and its corresponding value is the one for baselined MS.

ms: measurement set domain object

returns: row mapping dictionary

pipeline.hsd.tasks.common.utils.make_spwid_map(srcvis, dstvis)[source]
pipeline.hsd.tasks.common.utils.mjd_to_datestring(t, unit='sec')[source]

MJD —> date string

t: MJD unit: sec or day

pipeline.hsd.tasks.common.utils.parseEdge(edge)[source]
pipeline.hsd.tasks.common.utils.profiler(func)[source]
pipeline.hsd.tasks.common.utils.require_virtual_spw_id_handling(observing_run)[source]

Judge if spw ids vary across EBs. Return True if ids vary.

observing_run – domain.ObservingRun instance

pipeline.hsd.tasks.common.utils.sort_fields(context)[source]
pipeline.hsd.tasks.common.utils.to_bool(s)[source]
pipeline.hsd.tasks.common.utils.to_list(s)[source]
pipeline.hsd.tasks.common.utils.to_numeric(s)[source]

Module contents