def get_poly_position(self): position = plane.Position() if self.caom_version >= 23: v0 = shape.Vertex(0.0, 0.0, shape.SegmentType.MOVE) v1 = shape.Vertex(1.0, 2.0, shape.SegmentType.LINE) v2 = shape.Vertex(2.0, 3.0, shape.SegmentType.LINE) v3 = shape.Vertex(3.0, 4.0, shape.SegmentType.LINE) v4 = shape.Vertex(0.0, 0.0, shape.SegmentType.CLOSE) vl = [v0, v1, v2, v3, v4] samples = shape.MultiPolygon(vertices=vl) p1 = shape.Point(0.0, 0.0) p2 = shape.Point(1.0, 2.0) p3 = shape.Point(2.0, 3.0) p4 = shape.Point(3.0, 4.0) p = [p1, p2, p3, p4] polygon = shape.Polygon(points=p, samples=samples) position.bounds = polygon position.dimension = wcs.Dimension2D(10, 20) position.resolution = 0.5 position.sample_size = 1.1 position.time_dependent = False return position
def build_position(db_content, field_index, md_name): result_ra, result_dec = _get_ra_dec(md_name) # HK 19-08-19 # Looking at the ALMA web archive listing, it claims a 'FOV' (field of # view) of 53.38 arcsec, which would presumably be the diameter of the # observed area. That corresponds to a radius of 26.69, which is a # little larger than the value of 24 given in caom2. fov = db_content['Field of view'][field_index] radius = ((fov / 2.0) * units.arcsec).to(units.degree) bounds = shape.Circle(center=shape.Point(result_ra, result_dec), radius=radius.value) # HK 17-10-19 # Position: resolution: should not be null. For the sample dataset that # we've been iterating on, the alma web query lists a value of 0.4 # arcsec (the 'Ang. res.' parameter). While this number in principle # varies a little bit for the different spectral windows, I am not seeing # an easy way to extract more precise values using msmd. Since the # achievable angular resolution actually depends a bit on how different # baselines are weighted during imaging, there isn't an exact fixed value # no matter what, so I think it would be fine to just use the ALMA web # query value as being 'good enough'. resolution = db_content['Spatial resolution'][field_index] return Position(bounds=bounds, sample_size=None, time_dependent=False, resolution=resolution)
def test_open_polygon(): p1 = shape.Point(-117.246094, 52.942018) p2 = shape.Point(-101.601563, 56.535258) p3 = shape.Point(-97.382813, 44.809122) p4 = shape.Point(-111.445313, 37.405074) # SphericalPolygon requires p1 == p5 for a closed polygon p5 = shape.Point(-117.246094, 52.942018) too_few_points = [p1, p2] min_closed_points = [p1, p2, p3] closed_points = [p1, p2, p3, p4, p5] counter_clockwise_points = [p4, p3, p2, p1] # should detect that the polygons is not clockwise with pytest.raises(AssertionError) as ex: validate_polygon(shape.Polygon(counter_clockwise_points)) assert('not in clockwise direction' in str(ex.value)) # should detect that polygon is requires a minimum of 4 points with pytest.raises(AssertionError) as ex: validate_polygon(shape.Polygon(too_few_points)) assert('invalid polygon: 2 points' in str(ex.value)) # polygon default constructor validate_polygon(shape.Polygon()) # should detect that polygon is closed validate_polygon(shape.Polygon(min_closed_points)) validate_polygon(shape.Polygon(closed_points)) # should detect that multipolygon is not closed v0 = shape.Vertex(-126.210938, 67.991108, shape.SegmentType.MOVE) v1 = shape.Vertex(-108.984375, 70.480896, shape.SegmentType.LINE) v2 = shape.Vertex(-98.789063, 66.912834, shape.SegmentType.LINE) v3 = shape.Vertex(-75.234375, 60.217991, shape.SegmentType.LINE) v4 = shape.Vertex(-87.890625, 52.241256, shape.SegmentType.LINE) v5 = shape.Vertex(-110.742188, 54.136696, shape.SegmentType.LINE) v6 = shape.Vertex(0.0, 0.0, shape.SegmentType.CLOSE) v7 = shape.Vertex(24.609375, 62.895218, shape.SegmentType.MOVE) v8 = shape.Vertex(43.593750, 67.322924, shape.SegmentType.LINE) v9 = shape.Vertex(55.898438, 62.734601, shape.SegmentType.LINE) v10 = shape.Vertex(46.757813, 56.145550, shape.SegmentType.LINE) v11 = shape.Vertex(26.015625, 55.354135, shape.SegmentType.LINE) v12 = shape.Vertex(0.0, 0.0, shape.SegmentType.CLOSE) closed_vertices = [ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12] # should detect that multipolygon is closed validate_multipolygon(shape.MultiPolygon(closed_vertices))
def get_circle_position(self): position = plane.Position() position.bounds = shape.Circle(shape.Point(1.1, 2.2), 3.0) position.dimension = wcs.Dimension2D(10, 20) position.resolution = 0.5 position.sample_size = 1.1 position.time_dependent = False return position
def get_circle_position(self): position = plane.Position() position.bounds = shape.Circle(shape.Point(1.1, 2.2), 3.0) position.dimension = wcs.Dimension2D(10, 20) position.resolution = 0.5 position.sample_size = 1.1 position.time_dependent = False if self.caom_version >= 24: position.resolution_bounds = shape.Interval(1.0, 2.0) return position
def test_polygon_self_intersection(): # should detect self segment intersection of the polygon not near a # Pole p1 = shape.Point(-115.488281, 45.867063) p2 = shape.Point(-91.230469, 36.075742) p3 = shape.Point(-95.800781, 54.807017) p4 = shape.Point(-108.457031, 39.951859) p5 = shape.Point(0.0, 0.0) points_with_self_intersecting_segments = [p1, p2, p3, p4, p5] with pytest.raises(AssertionError) as ex: poly = shape.Polygon(points_with_self_intersecting_segments) validate_polygon(poly) assert('self intersecting' in str(ex.value)) # should detect self segment intersection of the polygon near the # South Pole, with the Pole outside the polygon p1 = shape.Point(0.6128286003, -89.8967940441) p2 = shape.Point(210.6391743183, -89.9073892376) p3 = shape.Point(90.6405151921, -89.8972874698) p4 = shape.Point(270.6114701911, -89.90689353) p5 = shape.Point(0.0, 0.0) points_with_self_intersecting_segments = [p1, p2, p3, p4, p5] with pytest.raises(AssertionError) as ex: poly = shape.Polygon(points_with_self_intersecting_segments) validate_polygon(poly) assert('self intersecting' in str(ex.value)) # should detect self segment intersection of the polygon near the # South Pole, with the Pole inside the polygon p1 = shape.Point(0.6128286003, -89.8967940441) p2 = shape.Point(130.6391743183, -89.9073892376) p3 = shape.Point(90.6405151921, -89.8972874698) p4 = shape.Point(270.6114701911, -89.90689353) p5 = shape.Point(0.0, 0.0) points_with_self_intersecting_segments = [p1, p2, p3, p4, p5] with pytest.raises(AssertionError) as ex: poly = shape.Polygon(points_with_self_intersecting_segments) validate_polygon(poly) assert('self intersecting' in str(ex.value)) # should detect self segment intersection of the polygon which # intersects with meridian = 0 p1 = shape.Point(-7.910156, 13.293411) p2 = shape.Point(4.042969, 7.068185) p3 = shape.Point(4.746094, 18.030975) p4 = shape.Point(-6.855469, 6.369894) p5 = shape.Point(0.0, 0.0) points_with_self_intersecting_segments = [p1, p2, p3, p4, p5] with pytest.raises(AssertionError) as ex: poly = shape.Polygon(points_with_self_intersecting_segments) validate_polygon(poly) assert('self intersecting' in str(ex.value))
def get_target_position(self): point = shape.Point(1.0, 2.0) target_position = observation.TargetPosition(point, "coordsys") target_position.equinox = 3.0 return target_position