How to use mocpy - 7 common examples

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 ggreco77 / GWsky / GWsky / moc_region.py View on Github external
def create_moc(self):
        """Creating a MOC map from the contour_ipix table."""
        
        self.moc = MOC.from_table(self.contour_ipix, 'RA[deg]', 'DEC[deg]',
                                  self.moc_order)

        return self.moc
github astropy / astroquery / astroquery / cds / core.py View on Github external
pass

            # return an `astropy.table.Table` object created from columns_l
            return Table(columns_l)

        """
        The user will get `mocpy.MOC` object.
        """
        # remove
        empty_order_removed_d = {}
        for order, ipix_l in result.items():
            if len(ipix_l) > 0:
                empty_order_removed_d.update({order: ipix_l})

        # return a `mocpy.MOC` object. See https://github.com/cds-astro/mocpy and the MOCPy's doc
        return MOC.from_json(empty_order_removed_d)
github ggreco77 / GWsky / GWsky / coverage.py View on Github external
airmass_start = [1, 2, 3, 4]
        airmass_end = [2, 3, 4, 5.8]
        snaps = ['s1', 's2', 's3','s4']

        aladin.md( "airmass@"+str(time_update))
        
        for i,j, snap in zip(airmass_start, airmass_end, snaps):
   
            snap = contour_ipix[(contour_ipix['airmass'] >= i) & (contour_ipix['airmass'] < j) ]
            moc_order = self.moc.moc_order(nside)

            #snap['RA[deg]'].unit = 'deg'
            #snap['DEC[deg]'].unit = 'deg'

            moc = MOC.from_lonlat( snap['RA[deg]'].T*u.deg, snap['DEC[deg]'].T*u.deg,
                                  moc_order )                # moc creation
            moc.write( 'snap', format = 'fits', )     # fits file

            if len(snap)!=0:
                aladin.send_file('snap')
                aladin.set_planeID(' '+str(i)+"
github ggreco77 / GWsky / GWsky / coverage.py View on Github external
meta = {'ipix': 'ipix table'})             # astropy table       

        mask = (contour_ipix['airmass']) >= 1 # clearing
        obs1 = contour_ipix[mask]

        mask2 = (obs1['airmass']) <= float(self.entry_airmass.get())  # airmass user values
        obs = obs1[mask2]

        #obs['RA[deg]'].unit = 'deg'
        #obs['DEC[deg]'].unit = 'deg'        
        
        nside = self.user.get_nside()

        #if len(obs)!=0:
        moc_order = self.moc.moc_order(nside)
        moc = MOC.from_lonlat( obs['RA[deg]'].T*u.deg, obs['DEC[deg]'].T*u.deg,
                              moc_order )                # moc creation
            
        moc.write( 'obs_airmass_', format = 'fits',)     # fits file

        if len(obs)!=0:
           aladin.send_file('obs_airmass_')
         
        return obs, moc
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) + \
github ggreco77 / GWsky / GWsky / coverage.py View on Github external
contour_ipix = self.from_ipixs_to_moc(self.obs_time)
        
        airmass_start = [1, 2, 3, 4]
        airmass_end = [2, 3, 4, 5.8]

        aladin.md( "airmass@"+str(self.obs_time))
        
        for i,j in zip(airmass_start, airmass_end):
         
            snap_1 = contour_ipix[(contour_ipix['airmass'] >= i) & (contour_ipix['airmass'] < j) ]
            moc_order = self.moc.moc_order(nside)

            #snap_1['RA[deg]'].unit = 'deg'
            #snap_1['DEC[deg]'].unit = 'deg'

            moc = MOC.from_lonlat( snap_1['RA[deg]'].T*u.deg, snap_1['DEC[deg]'].T*u.deg,
                                  moc_order )                # moc creation
            
            moc.write( 'snap_airmass_'+'initial', format = 'fits',)     # fits file

            if len(snap_1)!=0:
                aladin.send_file('snap_airmass_'+'initial')
                aladin.rename(str(i)+"=

mocpy

MOC parsing and manipulation in Python

BSD-3-Clause
Latest version published 13 days ago

Package Health Score

78 / 100
Full package analysis