Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Word(nums + " "),
Word(nums + ".")
])
expr = lhs + Optional(Literal("=").suppress() + rhs)
expr.setParseAction(lambda s, l, tok: tuple(tok))
return ZeroOrMore(expr)
ds9_shape_in_comment_defs = dict(
text=wcs_shape(CoordOdd, CoordEven),
vector=wcs_shape(CoordOdd, CoordEven,
Distance, Angle),
composite=wcs_shape(CoordOdd, CoordEven, Angle),
ruler=wcs_shape(CoordOdd, CoordEven, CoordOdd, CoordEven),
compass=wcs_shape(CoordOdd, CoordEven, Distance),
projection=wcs_shape(CoordOdd, CoordEven, CoordOdd, CoordEven, Distance),
segment=wcs_shape(CoordOdd, CoordEven,
repeat=(0, 2))
)
class Ds9AttrParser(object):
def set_continued(self, s, l, tok):
self.continued = True
def __init__(self):
self.continued = False
ds9_attr_parser = get_ds9_attr_parser()
regionShape = define_shape_helper(ds9_shape_in_comment_defs)
quotedString,
QuotedString("{", endQuoteChar="}"),
paren + ZeroOrMore(paren),
Word(nums + " "),
Word(nums + ".")
])
expr = lhs + Optional(Literal("=").suppress() + rhs)
expr.setParseAction(lambda s, l, tok: tuple(tok))
return ZeroOrMore(expr)
ds9_shape_in_comment_defs = dict(
text=wcs_shape(CoordOdd, CoordEven),
vector=wcs_shape(CoordOdd, CoordEven,
Distance, Angle),
composite=wcs_shape(CoordOdd, CoordEven, Angle),
ruler=wcs_shape(CoordOdd, CoordEven, CoordOdd, CoordEven),
compass=wcs_shape(CoordOdd, CoordEven, Distance),
projection=wcs_shape(CoordOdd, CoordEven, CoordOdd, CoordEven, Distance),
segment=wcs_shape(CoordOdd, CoordEven,
repeat=(0, 2))
)
class Ds9AttrParser(object):
def set_continued(self, s, l, tok):
self.continued = True
def __init__(self):
self.continued = False
def convert_physical_to_imagecoord(shape, header):
arg_types = _generate_arg_types(len(shape.coord_list), shape.name)
new_coordlist = []
coord_list_iter = iter(zip(shape.coord_list, arg_types))
from .physical_coordinate import PhysicalCoordinate
pc = PhysicalCoordinate(header)
for coordinate, coordinate_type in coord_list_iter:
if coordinate_type == CoordOdd:
even_coordinate = next(coord_list_iter)[0]
xy0 = pc.to_image(coordinate, even_coordinate)
new_coordlist.extend(xy0)
elif coordinate_type == Distance:
new_coordlist.append(pc.to_image_distance(coordinate))
else:
new_coordlist.append(coordinate)
return new_coordlist
CoordCommand,
comment_shell_like, define_simple_literals)
from .ds9_attr_parser import Ds9AttrParser, get_attr
from .wcs_converter import (convert_to_imagecoord,
convert_physical_to_imagecoord)
ds9_shape_defs = dict(
circle=wcs_shape(CoordOdd, CoordEven, Distance),
rotbox=wcs_shape(CoordOdd, CoordEven, Distance, Distance, Angle),
box=wcs_shape(CoordOdd, CoordEven, Distance, Distance, Angle),
polygon=wcs_shape(CoordOdd, CoordEven, repeat=(0, 2)),
ellipse=wcs_shape(CoordOdd, CoordEven, Distance, Distance, Angle, repeat=(2, 4)),
annulus=wcs_shape(CoordOdd, CoordEven, Distance, repeat=(2, 3)),
panda=wcs_shape(CoordOdd, CoordEven, Angle, Angle, Integer, Distance, Distance, Integer),
pie=wcs_shape(CoordOdd, CoordEven,
Distance, Distance,
Angle, Angle),
epanda=wcs_shape(CoordOdd, CoordEven,
Angle, Angle, Integer,
Distance, Distance, Distance,
Distance, Integer, Angle),
bpanda=wcs_shape(CoordOdd, CoordEven,
Angle, Angle, Integer,
Distance, Distance, Distance,
Distance, Integer, Angle),
point=wcs_shape(CoordOdd, CoordEven),
line=wcs_shape(CoordOdd, CoordEven, CoordOdd, CoordEven),
vector=wcs_shape(CoordOdd, CoordEven, Distance, Angle),
text=wcs_shape(CoordOdd, CoordEven),
)
image_like_coordformats = ["image", "physical", "detector", "logical"]