Commits

Vincent Geers authored 44bf07329dc Merge
Pull request #1411: PIPE-2160: update documentation and typing for context and domain

Merge in PIPE/pipeline from PIPE-2160_update_documentation_context_domain to main * commit '7600bb45ddea7389408d0b11bd66b8d113d6bb1b': (32 commits) PIPE-2160: correction in ObservingRun docstring for 'org_directions'. PIPE-2160: correction in ObservingRun docstring. PIPE-2160: updates to address PR comments. PIPE-2160: update MeasurementSet to always define the "polarizations" attribute at init. PIPE-2160: update docstrings and type hints in callibrary.py. PIPE-2160: update minimum CASA version to 6.6.6-1. PIPE-2160: update pipeline.infrastructure.launcher.Pipeline.close method to use context save method for consistency. PIPE-2160: document removal of the dictionary-based implementation of the Pipeline calibration library. PIPE-2160: remove the unused dictionary-based implementation of the Pipeline calibration library (DictCalLibrary and DictCalState) from pipeline.infrastructure.callibrary. PIPE-2160: remove unused "sensitivities" attribute from pipeline.infrastructure.launcher.Context class. PIPE-2160: remove unused "logtype" attribute from pipeline.infrastructure.launcher.Context class. PIPE-2160: remove the "flagcmds" list attribute from the pipeline.domain.measurementset.MeasurementSet class. Unchanged since 2013, this attribute only had its value populated by hifa_fluxcalflag but never used in subsequent tasks. PIPE-2160: remove unused "reduction_intents" property from pipeline.domain.state.State class. PIPE-2160: remove unused "centre" property from pipeline.domain.antennaarray.AntennaArray class and removed last known import of casatasks.private.simutil. Likely originally added for concept of removing antenna(s) from MS entirely and re-computing the centre. PIPE-2160: remove unused "group_name" attribute from pipeline.domain.datadescription.DataDescription class. This was likely a remnant from an early implementation of a FrequencyGroup that got removed in 26e3bec6 for CAS-4813. PIPE-2160: remove unused "get_fields" method from pipeline.domain.observingrun.ObservingRun. PIPE-2160: remove unused "TemporalCollection" class from pipeline.domain.measures. This class was effectively unchanged since 2013 and originally introduced for the concept of a versioned dataset. PIPE-2160: update domain.observingrun.ObservingRun to always define "ms_datatable_name" and "ms_reduction_group" at init; replace/remove tests for existence of those attributes; consolidate two separate "contains-single-dish" tests. PIPE-2160: update callibrary.CalTo to update type hint and revert change in setters for 'spw' and 'antenna' to deal with case of single integer spw ID. PIPE-2160: fix type hints in callibrary after removing import. ...

pipeline/domain/antenna.py

Modified
1 -"""The antenna module defines the Antenna class.
2 -"""
1 +"""The antenna module defines the Antenna class."""
3 2 import pprint
4 3
5 4 from pipeline.infrastructure import casa_tools
6 5
7 6 _pprinter = pprint.PrettyPrinter()
8 7
9 8
10 9 class Antenna(object):
11 10 """
12 - Antenna is a logical representation of an antenna.
13 -
14 - An Antenna has the following properties:
15 -
16 - .. py:attribute:: id
17 -
18 - the numerical identifier of this antenna within the ANTENNA subtable
19 - of the measurement set
20 -
21 - .. py:attribute:: name
22 -
23 - the (potentially empty) name of this antenna
24 -
25 - .. py:attribute:: longitude
26 -
27 - the longitude of this antenna
28 -
29 - .. py:attribute:: latitude
30 -
31 - the latitude of this antenna
32 -
33 - .. py:attribute:: height
34 -
35 - the radial distance of this antenna from the Earth's centre
36 -
37 - .. py:attribute:: diameter
38 -
39 - the physical diameter of this antenna
40 -
41 - .. py:attribute:: direction
42 -
43 - the J2000 position on the sky to which this antenna points
11 + Antenna is a logical representation of an antenna.
12 +
13 + Attributes:
14 + id: The numerical identifier of this antenna within the ANTENNA subtable
15 + of the measurement set.
16 + name: The (potentially empty) name of the antenna.
17 + station: The station pad on which the antenna is situated.
18 + diameter: The physical diameter of the antenna in meters.
19 + position: Dictionary with longitude, latitude, and height of the antenna.
20 + offset: The offset position of the antenna relative to AntennaArray.position
21 + (the antenna array reference position).
22 + longitude: The longitude of the antenna.
23 + latitude: The latitude of the antenna.
24 + height: The radial distance of the antenna from the Earth's centre.
25 + direction: The J2000 position on the sky to which the antenna points.
44 26 """
45 - def __init__(self, antenna_id, name, station, position, offset, diameter):
27 + def __init__(self, antenna_id: int, name: str, station: str, position: dict, offset: dict, diameter: float) -> None:
28 + """
29 + Initialize an Antenna object.
30 +
31 + Args:
32 + antenna_id: The numerical identifier of the antenna.
33 + name: The name of the antenna.
34 + station: The station pad on which the antenna is situated.
35 + position: Dictionary with longitude, latitude, and height of the antenna.
36 + offset: The offset position of the antenna relative to AntennaArray.position
37 + (the antenna array reference position).
38 + diameter: The physical diameter of the antenna in meters.
39 + """
46 40 self.id = antenna_id
47 41
48 42 # work around NumPy bug with empty strings
49 43 # http://projects.scipy.org/numpy/ticket/1239
50 44 self.name = str(name)
51 45 self.station = str(station)
52 46
53 47 self.diameter = diameter
54 48 self.position = position
55 49 self.offset = offset
56 50
57 51 # The longitude, latitude and height of a CASA position are given in
58 52 # canonical units, so we don't need to perform any further conversion
59 53 self.longitude = position['m0']
60 54 self.latitude = position['m1']
61 55 self.height = position['m2']
62 56
63 57 mt = casa_tools.measures
64 58 self.direction = mt.direction(v0=self.longitude, v1=self.latitude)
65 59
66 - def __repr__(self):
60 + def __repr__(self) -> str:
67 61 return '{0}({1}, {2!r}, {3!r}, {4}, {5}, {6})'.format(
68 62 self.__class__.__name__,
69 63 self.id,
70 64 self.name,
71 65 self.station,
72 66 _pprinter.pformat(self.position),
73 67 _pprinter.pformat(self.offset),
74 68 self.diameter)
75 69
76 - def __str__(self):
70 + def __str__(self) -> str:
77 71 qt = casa_tools.quanta
78 72 lon = qt.tos(self.longitude)
79 73 lat = qt.tos(self.latitude)
80 74 return '<Antenna {id} (lon={lon}, lat={lat})>'.format(
81 75 id=self.identifier, lon=lon, lat=lat)
82 76
83 77 @property
84 - def identifier(self):
85 - '''
86 - A human-readable identifier for this Antenna.
87 - '''
88 - return self.name if self.name else '#{0}'.format(self.id)
89 -
78 + def identifier(self) -> str:
79 + """Return a human-readable identifier for this Antenna."""
80 + return self.name if self.name else f"#{self.id}"

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut