How to use the pyregion.parser_helper.Shape function in pyregion

To help you get started, we’ve selected a few pyregion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / astroquery / astroquery / alma / utils.py View on Github external
-28.694332 266.555234 -28.687069 266.543232 -28.681216 266.536058
    -28.681414 266.530644 -28.685630 266.521788 -28.689453 266.519784
    -28.694332 266.521332 -28.699778'
    Some of them have *additional* polygons
    """
    if footprint[:7] != 'Polygon':
        raise ValueError("Unrecognized footprint type")

    from pyregion.parser_helper import Shape

    entries = footprint.split()
    polygons = [ii for ii, xx in enumerate(entries) if xx == 'Polygon']

    reglist = []
    for start, stop in zip(polygons, polygons[1:]+[None]):
        reg = Shape('polygon', [float(x) for x in entries[start+2:stop]])
        reg.coord_format = footprint.split()[1].lower()
        reg.coord_list = reg.params  # the coord_list attribute is needed somewhere
        reg.attr = ([], {'color': 'green', 'dash': '0 ', 'dashlist': '8 3',
                         'delete': '1 ', 'edit': '1 ', 'fixed': '0 ', 'font':
                         '"helvetica 10 normal roman"', 'highlite': '1 ',
                         'include': '1 ', 'move': '1 ', 'select': '1',
                         'source': '1', 'text': '', 'width': '1 '})
        reglist.append(reg)

    return reglist
github astropy / astroquery / docs / gallery-examples / example7_alma.py View on Github external
xhi=xhi,
                                                                  yhi=yhi))


    subwcs = mywcs[ylo:yhi, xlo:xhi]
    subhdr = subwcs.sub([wcs.WCSSUB_CELESTIAL]).to_header()
    subdata = data[ylo:yhi, xlo:xhi]

    mask = shapelist.get_mask(header=subhdr,
                              shape=subdata.shape)
    log.debug("Shapes: data={0}, subdata={2}, mask={1}".format(data.shape, mask.shape, subdata.shape))
    return (xlo, xhi, ylo, yhi), mask


for row, rad in zip(m83, primary_beam_radii):
    shape = Shape('circle', (row['RA'], row['Dec'], np.mean(rad).to(u.deg).value))
    shape.coord_format = 'fk5'
    shape.coord_list = (row['RA'], row['Dec'], np.mean(rad).to(u.deg).value)
    shape.attr = ([], {'color': 'green',  'dash': '0 ',  'dashlist': '8 3 ',
                       'delete': '1 ',  'edit': '1 ', 'fixed': '0 ',
                       'font': '"helvetica 10 normal roman"',  'highlite': '1 ',
                       'include': '1 ',  'move': '1 ',  'select': '1 ',
                       'source': '1',  'text': '', 'width': '1 '})
    if row['Release date']==b'' and row['Band']==3:
        (xlo, xhi, ylo, yhi), mask = pyregion_subset(shape, hit_mask_band3_private, mywcs)
        hit_mask_band3_private[ylo:yhi, xlo:xhi] += row['Integration']*mask
    elif row['Release date'] and row['Band']==3:
        (xlo, xhi, ylo, yhi), mask = pyregion_subset(shape, hit_mask_band3_public, mywcs)
        hit_mask_band3_public[ylo:yhi, xlo:xhi] += row['Integration']*mask
    elif row['Release date'] and row['Band']==6:
        (xlo, xhi, ylo, yhi), mask = pyregion_subset(shape, hit_mask_band6_public, mywcs)
        hit_mask_band6_public[ylo:yhi, xlo:xhi] += row['Integration']*mask
github astropy / pyregion / pyregion / ds9_region_parser.py View on Github external
        regionShape = regionShape.setParseAction(lambda s, l, tok: Shape(tok[0], tok[1:]))
github astropy / pyregion / pyregion / ds9_attr_parser.py View on Github external
def parse_check_shape(self, s):
        l = self.parser_with_shape.parseString(s)
        if l and isinstance(l[0], Shape):
            if self.continued:
                l[0].continued = True
            return l[0], l[1:]
        else:
            return None, l
github astropy / pyregion / pyregion / ds9_region_parser.py View on Github external
def filter_shape2(sss):
        r = [s1 for s1 in sss if isinstance(s1[0], Shape)]
        return zip(*r)
github astropy / pyregion / pyregion / ds9_attr_parser.py View on Github external
        regionShape = regionShape.setParseAction(lambda s, l, tok: Shape(tok[0], tok[1:]))
github astropy / pyregion / pyregion / wcs_converter.py View on Github external
def check_wcs(l):
    default_coord = "physical"

    for l1, c1 in l:
        if isinstance(l1, CoordCommand):
            default_coord = l1.text.lower()
            continue
        if isinstance(l1, Shape):
            if default_coord == "galactic":
                is_wcs, coord_list = check_wcs_and_convert(l1.params,
                                                           all_dms=True)
            else:
                is_wcs, coord_list = check_wcs_and_convert(l1.params)

            if is_wcs and (default_coord == "physical"):  # ciao format
                coord_format = "fk5"
            else:
                coord_format = default_coord

            l1n = copy.copy(l1)

            l1n.coord_list = coord_list
            l1n.coord_format = coord_format