Beispiel #1
0
def getjpg(coord, imsize, dss_only=False):
    """
    Grab an SDSS or DSS image

    Args:
        coord (SkyCoord):
        imsize (Angle or Quantity):
            image size
        dss_only (bool, optional):
            Only pull from DSS

    Returns:
        PIL, bool:  Image, flag indicating if the image is B&W
    """
    sdss = survey_utils.load_survey_by_name('SDSS', coord, 0.02 * units.deg)
    # Dummy call to see if SDSS covers it
    if dss_only:
        cat = None
    else:
        cat = sdss.get_catalog()
    # Pull from DSS?
    if cat is None:
        print("No SDSS Image;  Querying DSS")
        BW = True
        url = dsshttp(coord, imsize)  # DSS
        img = images.grab_from_url(url)
    else:
        BW = False
        img, _ = sdss.get_cutout(imsize)
    # Return
    return img, BW
Beispiel #2
0
    def get_cutout(self, imsize=30 * u.arcsec, filt="irg", output_size=None):
        """
        Grab a color cutout (PNG) from Pan-STARRS

        Args:
            imsize (Quantity):  Angular size of image desired
            filt (str): A string with the three filters to be used
            output_size (int): Output image size in pixels. Defaults
                                to the original cutout size.
        Returns:
            PNG image, None (None for the header).
        """
        assert len(filt) == 3, "Need three filters for a cutout."
        #Sort filters from red to blue
        filt = filt.lower(
        )  #Just in case the user is cheeky about the filter case.
        reffilt = "yzirg"
        idx = np.argsort([reffilt.find(f) for f in filt])
        newfilt = ""
        for i in idx:
            newfilt += filt[i]
        #Get image url
        url = _get_url(self.coord,
                       imsize=imsize,
                       filt=newfilt,
                       output_size=output_size,
                       color=True,
                       imgformat='png')
        self.cutout = images.grab_from_url(url)
        self.cutout_size = imsize
        return self.cutout.copy(),
Beispiel #3
0
Datei: sdss.py Projekt: FRBs/FRB
    def get_cutout(self, imsize, scale=0.396127):
        """
        Grab a cutout from SDSS

        Args:
            imsize (Quantity):  Size of image desired

        Returns:
            PNG image, None: self.cutout and a None to match the image header (not provided by SDSS)


        """
        # URL
        sdss_url = get_url(self.coord, imsize=imsize.to('arcsec').value,
                           scale=scale)
        # Image
        self.cutout = images.grab_from_url(sdss_url)
        self.cutout_size = imsize

        # Return
        return self.cutout, None