Esempio n. 1
0
    def from_elliptical_cone(cls,
                             lon,
                             lat,
                             a,
                             b,
                             pa,
                             max_depth,
                             delta_depth=2):
        """
        Creates a MOC from an elliptical cone

        The ellipse is centered around the (`lon`, `lat`) position. `a` (resp. `b`) corresponds
        to the semi-major axis magnitude (resp. semi-minor axis magnitude). `pa` is expressed as a
        `~astropy.coordinates.Angle` and defines the position angle of the elliptical cone.

        Parameters
        ----------
        lon : `astropy.coordinates.Longitude` or its supertype `astropy.units.Quantity`
            The longitude of the center of the elliptical cone.
        lat : `astropy.coordinates.Latitude` or its supertype `astropy.units.Quantity`
            The latitude of the center of the elliptical cone.
        a : `astropy.coordinates.Angle`
            The semi-major axis angle of the elliptical cone.
        b : `astropy.coordinates.Angle`
            The semi-minor axis angle of the elliptical cone.
        pa : `astropy.coordinates.Angle`
            The position angle (i.e. the angle between the north and the semi-major axis, east-of-north).
        max_depth : int
            Maximum HEALPix cell resolution.
        delta_depth : int, optional
            To control the approximation, you can choose to perform the computations at a deeper
            depth using the `depth_delta` parameter.
            The depth at which the computations will be made will therefore be equal to
            `depth` + `depth_delta`.

        Returns
        -------
        result : `~mocpy.moc.MOC`
            The resulting MOC

        Examples
        --------
        >>> from mocpy import MOC
        >>> import astropy.units as u
        >>> from astropy.coordinates import Angle, Longitude, Latitude
        >>> moc = MOC.from_elliptical_cone(
        ...  lon=Longitude(0 * u.deg),
        ...  lat=Latitude(0 * u.deg),
        ...  a=Angle(10, u.deg),
        ...  b=Angle(5, u.deg),
        ...  pa=Angle(0, u.deg),
        ...  max_depth=10
        ... )
        """
        lon = lon if isinstance(lon, Longitude) else Longitude(lon)
        lat = lat if isinstance(lat, Latitude) else Latitude(lat)
        pix, depth, fully_covered_flags = cdshealpix.elliptical_cone_search(
            lon, lat, a, b, pa, max_depth, delta_depth, flat=False)
        return MOC.from_healpix_cells(pix, depth, fully_covered_flags)
Esempio n. 2
0
import cdshealpix

from cdshealpix import elliptical_cone_search
import astropy.units as u
from astropy.coordinates import Angle, SkyCoord, Longitude, Latitude
import numpy as np

ipix, depth, fully_covered = elliptical_cone_search(lon=Longitude(0, u.deg),
                                                    lat=Latitude(0, u.deg),
                                                    a=Angle(50, unit="deg"),
                                                    b=Angle(5, unit="deg"),
                                                    pa=Angle(30, unit="deg"),
                                                    depth=10)

from mocpy import MOC, World2ScreenMPL

moc = MOC.from_healpix_cells(ipix, depth, fully_covered)
# Plot the MOC using matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(111, figsize=(10, 10))
# Define a astropy WCS easily
with World2ScreenMPL(fig,
                     fov=100 * u.deg,
                     center=SkyCoord(0, 0, unit="deg", frame="icrs"),
                     coordsys="icrs",
                     rotation=Angle(0, u.degree),
                     projection="AIT") as wcs:
    ax = fig.add_subplot(1, 1, 1, projection=wcs)
    # Call fill with a matplotlib axe and the `~astropy.wcs.WCS` wcs object.
    moc.fill(ax=ax, wcs=wcs, alpha=0.5, fill=True, color="green")
    # Draw the perimeter of the MOC in black
Esempio n. 3
0
import cdshealpix

from cdshealpix import elliptical_cone_search
import astropy.units as u
from astropy.coordinates import Angle, SkyCoord
import numpy as np

ipix, depth, fully_covered = elliptical_cone_search(
    lon=0 * u.deg,
    lat=0 * u.deg,
    a=Angle(50, unit="deg"),
    b=Angle(5, unit="deg"),
    pa=Angle(30, unit="deg"),
    depth=10
)

from mocpy import MOC, WCS

moc = MOC.from_healpix_cells(ipix, depth, fully_covered)
# Plot the MOC using matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(111, figsize=(10, 10))
# Define a astropy WCS easily
with WCS(fig,
        fov=100 * u.deg,
        center=SkyCoord(0, 0, unit="deg", frame="icrs"),
        coordsys="icrs",
        rotation=Angle(0, u.degree),
        projection="AIT") as wcs:
    ax = fig.add_subplot(1, 1, 1, projection=wcs)
    # Call fill with a matplotlib axe and the `~astropy.wcs.WCS` wcs object.