How to use the mocpy.MOC function in mocpy

To help you get started, we’ve selected a few mocpy 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 / cds / spatial_constrains.py View on Github external
default to "overlaps"

        Returns
        -------
        moc_constrain : `~astroquery.cds.Moc`
            the MOC region

        """

        try:
            from mocpy import MOC
        except ImportError:
            raise ImportError("Could not import mocpy, which is a requirement for the CDS service."
                              "Please see https://github.com/cds-astro/mocpy to install it.")

        assert isinstance(mocpy_obj, MOC), TypeError("`mocpy_obj` must be of type mocpy.MOC")

        # dump the moc in json format in a temp file
        json_moc = mocpy_obj.write(format='json')

        moc_constrain = cls(intersect=intersect)

        moc_constrain.request_payload.update({'moc': str(json_moc)})
        return moc_constrain
github astropy / astroquery / astroquery / cds / core.py View on Github external
"""
        request_payload = dict()
        intersect = kwargs.get('intersect', 'overlaps')
        if intersect == 'encloses':
            intersect = 'enclosed'

        request_payload.update({'intersect': intersect,
                                'casesensitive': 'true',
                                'fmt': 'json',
                                'get': 'record',
                                })

        # Region Type
        if 'region' in kwargs:
            region = kwargs['region']
            if isinstance(region, MOC):
                self.path_moc_file = os.path.join(os.getcwd(), 'moc.fits')
                region.write(self.path_moc_file, format="fits")
                # add the moc region payload to the request payload
            elif isinstance(region, CircleSkyRegion):
                # add the cone region payload to the request payload
                request_payload.update({
                    'DEC': str(region.center.dec.to(u.deg).value),
                    'RA': str(region.center.ra.to(u.deg).value),
                    'SR': str(region.radius.to(u.deg).value),
                })
            elif isinstance(region, PolygonSkyRegion):
                # add the polygon region payload to the request payload
                polygon_payload = "Polygon"
                vertices = region.vertices
                for i in range(len(vertices.ra)):
                    polygon_payload += ' ' + str(vertices.ra[i].to(u.deg).value) + \

mocpy

MOC parsing and manipulation in Python

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

78 / 100
Full package analysis