Exemplo n.º 1
0
    def download_deepest_image(self,ra, dec, radius_arcmin=1, path=''):
        fov=CoordinateParser.getMinToDegree(radius_arcmin)
        size=fov / np.cos(np.array(dec) * np.pi / 180)
        imgTable = self._svc.search((ra, dec),  (size, fov), verbosity=2)
        imgTable=imgTable.votable.to_table()
        print("The full image list contains", len(imgTable), "entries")
        #sel0 = imgTable['obs_bandpass'].astype(str) == band
        #sel0 &
        sel =  ((imgTable['proctype'].astype(str) == 'Stack') & (
                    imgTable['prodtype'].astype(str) == 'image'))  # basic selection
        Table = imgTable[sel]  # select


        imageSource = None
        if (len(Table) > 0):
            imageSource = ImageSource(str(ra)+"_"+str(dec), "DES")

            for row in Table:
                band=row['obs_bandpass'].decode()

                if band=='':
                    band="stackbands"
                url = row['access_url'].decode()
                #image = io.fits.getdata(utils.data.download_file(url, cache=True, show_progress=False, timeout=120))
                #base64 = ImageUtils.imgNpArrayToBase64(image)
                local_path = path + "des_band_" + band + ".fits"
                imageSource.addFile(band, url, "fits", download=True, local_path=local_path,uncompress=False, thumbnail=True,external=False)

                #imageSource.addFile("band-" + band, url, "fits")
                thumbnail=imageSource.getFiles()
                pos =len(thumbnail)-1
                base64img=thumbnail[pos]["thumbnail"]
                imageSource.addCutout(base64img, 300, band)


            # if (len(Table) > 0):
            #     row = Table[np.argmax(Table['exptime'].data.data.astype('float'))]  # pick image with longest exposure time
            #     url = row['access_url'].decode()  # get the download URL
            #     print('downloading deepest stacked image...')
            #     image = io.fits.getdata(utils.data.download_file(url, cache=True, show_progress=False, timeout=120))
            #
            # else:
            #     print('No image available.')
            #     image = None

        return imageSource
Exemplo n.º 2
0
    def query(self, **kwargs):
        if "coordinates" in kwargs:
            self.__coordinates = kwargs["coordinates"]
        elif "ra" in kwargs and "dec" in kwargs:
            self.__coordinates = str(kwargs["ra"]) + "," + str(kwargs["dec"])
        radius = 1  # arcmin
        if "radius" in kwargs:
            radius = kwargs["radius"]

        self.__coordinates = CoordinateParser.validateCoordinates(
            self.__coordinates)
        self.__save_path = self.__save_path.format(
            str(self.__coordinates.ra.degree) + "_" +
            str(self.__coordinates.dec.degree))

        degrees_range = CoordinateParser.getMinToDegree(radius)

        ra_min = self.__coordinates.ra.degree - (degrees_range / 2)
        ra_max = self.__coordinates.ra.degree + (degrees_range / 2)
        dec_min = self.__coordinates.dec.degree - (degrees_range / 2)
        dec_max = self.__coordinates.dec.degree + (degrees_range / 2)
        query = self.__simple_rec_query.format(ra_min, ra_max, dec_min,
                                               dec_max)
        respond = self.getTapRequest(query=query)
        result = AstroSource(self.__coordinates)
        if len(respond) > 0:

            Utils.createPath(self.__save_path)
            catalog = CatalogSource("decals",
                                    "Search in radius " + str(radius))
            VOTableUtil.saveFromTable(respond,
                                      self.__save_path + "catalog.xml")
            catalog.addFile("decals", self.__save_path + "catalog.xml", "vo")

            result.addCatalog(catalog)

            index, loss = CoordinateParser.getNearPositionIndex(
                self.__coordinates.ra.degree, self.__coordinates.dec.degree,
                respond["ra"], respond["dec"])
            result.addSummaryParams("ra", respond["ra"][index])
            result.addSummaryParams("dec", respond["dec"][index])
            result.addSummaryParams("distance", loss)

            decals = WaveLenghtCover.decals()

            data = {
                "lambda": decals["g"],
                "ab": str(respond["mag_g"][index]),
                "err": -99
            }
            result.addSummaryParams("mag_g", data)

            data = {
                "lambda": decals["r"],
                "ab": str(respond["mag_r"][index]),
                "err": -99
            }
            result.addSummaryParams("mag_r", data)

            data = {
                "lambda": decals["z"],
                "ab": str(respond["mag_z"][index]),
                "err": -99
            }
            result.addSummaryParams("mag_z", data)

            result.addSummaryParams("flux_g", str(respond["flux_g"][index]))
            result.addSummaryParams("flux_r", str(respond["flux_r"][index]))
            result.addSummaryParams("flux_z", str(respond["flux_z"][index]))
            result.addSummaryParams("type", str(respond["type"][index]))

            image = ImageSource(result.getSummary()["id"],
                                self.__catalog_provider)

            bands = ["grz", "gz", "g"]
            mag_band = [
                result.getSummary()["mag_r"],
                result.getSummary()["mag_z"],
                result.getSummary()["mag_g"]
            ]

            for index in range(len(bands)):
                band = bands[index]
                mag = str(mag_band[index]["ab"]) + "+/-" + str(
                    mag_band[index]["err"])

                img = self.getImage(self.__coordinates, band)
                link = img["link"]
                image.addCutout(img["jpeg"], 256, band, mag, link)
                #image.addFile(band,img["fits"])

                local_path = self.__save_path + "decals_band_" + band + ".fits"
                image.addFile(band,
                              img["fits"],
                              "fits",
                              download=True,
                              local_path=local_path,
                              uncompress=False,
                              thumbnail=False,
                              external=False)

            result.addImage(image)

        return result
Exemplo n.º 3
0
    def query(self, **kwargs):
        if "coordinates" in kwargs:
            self.__coordinates = kwargs["coordinates"]
        elif "ra" in kwargs and "dec" in kwargs:
            self.__coordinates = str(kwargs["ra"]) + "," + str(kwargs["dec"])
        radius = 1  # arcmin
        if "radius" in kwargs:
            radius = kwargs["radius"]

        self.__coordinates = CoordinateParser.validateCoordinates(
            self.__coordinates)
        self.__save_path = self.__save_path.format(
            str(self.__coordinates.ra.degree) + "_" +
            str(self.__coordinates.dec.degree))

        degrees_range = CoordinateParser.getMinToDegree(radius)

        ra_min = self.__coordinates.ra.degree - (degrees_range / 2)
        ra_max = self.__coordinates.ra.degree + (degrees_range / 2)
        dec_min = self.__coordinates.dec.degree - (degrees_range / 2)
        dec_max = self.__coordinates.dec.degree + (degrees_range / 2)

        table = self.__service_provider["video"]["table"]
        query = self.__simple_rec_query.format(table, ra_min, ra_max, dec_min,
                                               dec_max)
        url = self.__service_provider["video"]["url"]
        respond = self.getTapRequest(url=url, query=query)
        program = "video"
        if len(respond) <= 0:
            table = self.__service_provider["viking"]["table"]
            query = self.__simple_rec_query.format(table, ra_min, ra_max,
                                                   dec_min, dec_max)
            url = self.__service_provider["viking"]["url"]
            respond = self.getTapRequest(url=url, query=query)
            program = "viking"

        if len(respond) <= 0:
            table = self.__service_provider["vhs"]["table"]
            query = self.__simple_rec_query.format(table, ra_min, ra_max,
                                                   dec_min, dec_max)
            url = self.__service_provider["vhs"]["url"]
            respond = self.getTapRequest(url=url, query=query)
            program = "vhs"

        result = AstroSource(self.__coordinates)
        if len(respond) > 0:
            vhs = WaveLenghtCover.vhs()
            Utils.createPath(self.__save_path)
            catalog = CatalogSource("vhs", "Search in radius " + str(radius))
            VOTableUtil.saveFromTable(respond,
                                      self.__save_path + "catalog.xml")
            catalog.addFile("vhs", self.__save_path + "catalog.xml", "vo")

            result.addCatalog(catalog)

            index, loss = CoordinateParser.getNearPositionIndex(
                self.__coordinates.ra.degree, self.__coordinates.dec.degree,
                respond["ra"], respond["dec"])

            result.addSummaryParams("ra", respond["ra"][index])
            result.addSummaryParams("dec", respond["dec"][index])
            result.addSummaryParams("distance", loss)
            mag = {
                "Y":
                str(respond["yAperMag3"][index]) + "+/-" +
                str(respond["yAperMag3Err"][index]),
                "J":
                str(respond["jAperMag3"][index]) + "+/-" +
                str(respond["jAperMag3Err"][index]),
                "H":
                str(respond["hAperMag3"][index]) + "+/-" +
                str(respond["hAperMag3Err"][index]),
                "Ks":
                str(respond["ksAperMag3"][index]) + "+/-" +
                str(respond["ksAperMag3Err"][index])
            }
            if program == "video" or program == "viking":
                result.addSummaryParams(
                    "magpetro_z", {
                        "lambda": vhs["z"],
                        "ab": str(respond["zPetroMag"][index]),
                        "err": str(respond["zPetroMagErr"][index])
                    })
                result.addSummaryParams(
                    "magAper_z", {
                        "lambda": vhs["z"],
                        "ab": str(respond["zAperMag3"][index]),
                        "err": str(respond["zAperMag3Err"][index])
                    })
                mag["Z"] = str(respond["zAperMag3"][index]) + "+/-" + str(
                    respond["zAperMag3Err"][index])

            result.addSummaryParams(
                "magpetro_y", {
                    "lambda": vhs["y"],
                    "ab": str(respond["yPetroMag"][index]),
                    "err": str(respond["yPetroMagErr"][index])
                })
            result.addSummaryParams(
                "magpetro_j", {
                    "lambda": vhs["j"],
                    "ab": str(respond["jPetroMag"][index]),
                    "err": str(respond["jPetroMagErr"][index])
                })
            result.addSummaryParams(
                "magpetro_h", {
                    "lambda": vhs["h"],
                    "ab": str(respond["hPetroMag"][index]),
                    "err": str(respond["hPetroMagErr"][index])
                })
            result.addSummaryParams(
                "magpetro_ks", {
                    "lambda": vhs["ks"],
                    "ab": str(respond["ksPetroMag"][index]),
                    "err": str(respond["ksPetroMagErr"][index])
                })

            result.addSummaryParams(
                "magAper_y", {
                    "lambda": vhs["y"],
                    "ab": str(respond["yAperMag3"][index]),
                    "err": str(respond["yAperMag3Err"][index])
                })
            result.addSummaryParams(
                "magAper_j", {
                    "lambda": vhs["j"],
                    "ab": str(respond["jAperMag3"][index]),
                    "err": str(respond["jAperMag3Err"][index])
                })
            result.addSummaryParams(
                "magAper_h", {
                    "lambda": vhs["h"],
                    "ab": str(respond["hAperMag3"][index]),
                    "err": str(respond["hAperMag3Err"][index])
                })
            result.addSummaryParams(
                "magAper_ks", {
                    "lambda": vhs["ks"],
                    "ab": str(respond["ksAperMag3"][index]),
                    "err": str(respond["ksAperMag3Err"][index])
                })

            result.addSummaryParams("type", str(respond["mergedClass"][index]))

            images = self.getImages(program)

            image = ImageSource(result.getSummary()["id"],
                                self.__catalog_provider)

            saved_path = {}

            for idx in range(len(images)):
                img = images[idx]
                band = img["band"]
                mag_val = mag[band]
                image.addCutout(img["image"], 256, band, mag_val)
                index_image = ""
                if band in saved_path:
                    saved_path[band] += 1
                    index_image = saved_path[band]
                else:
                    saved_path[band] = 0

                local_path = self.__save_path + "vhs_band_" + band + str(
                    index_image) + ".fits"
                image.addFile(band,
                              img["fits"],
                              "fits",
                              download=True,
                              local_path=local_path,
                              uncompress=True,
                              thumbnail=False,
                              external=False)

            result.addImage(image)

        return result
Exemplo n.º 4
0
    def query(self, **kwargs):

        # check for data release to use
        if "coordinates" in kwargs:
            self.__coordinates = kwargs["coordinates"]
        elif "ra" in kwargs and "dec" in kwargs:
            self.__coordinates = str(kwargs["ra"]) + "," + str(kwargs["dec"])
        else:
            raise ValueError(
                "Not valid coordinates found. Used coordinates key or ra dec keys"
            )

        self.__coordinates = CoordinateParser.validateCoordinates(
            self.__coordinates)

        self.__save_path = self.__save_path.format(
            str(self.__coordinates.ra.degree) + "_" +
            str(self.__coordinates.dec.degree))

        Utils.createPath(self.__save_path)

        radius = 1  # arcmin
        if "radius" in kwargs:
            radius = kwargs["radius"]

        #check for data release to use
        if "release" in kwargs:
            self.__data_release = kwargs["release"]

        respond = SDSS.query_region(self.__coordinates,
                                    spectro=True,
                                    photoobj_fields=[
                                        'ra', 'dec', 'objid', 'run', 'type',
                                        'rerun', 'camcol', 'field', 'u', 'g',
                                        'r', 'i', 'z', 'err_u', 'err_g',
                                        'err_r', 'err_i', 'err_z'
                                    ],
                                    specobj_fields=[
                                        'z', 'zErr', 'zWarning', 'plate',
                                        'mjd', 'fiberID', 'specobjid', 'run2d',
                                        'instrument', 'targetObjID'
                                    ],
                                    data_release=self.__data_release,
                                    radius=radius * u.arcmin)

        #sp=SDSS.get_spectra(matches=respond,data_release=self.__data_release)
        #im = SDSS.get_images(matches=respond,data_release=self.__data_release)

        # print(respond)
        # for col in respond.columns:
        #     print(respond[col])

        result = AstroSource(self.__coordinates)

        sdss = WaveLenghtCover.sdss()
        index, loss = CoordinateParser.getNearPositionIndex(
            self.__coordinates.ra.degree, self.__coordinates.dec.degree,
            respond["ra"], respond["dec"])
        if respond != None:
            Utils.createPath(self.__save_path)
            VOTableUtil.saveFromTable(respond,
                                      self.__save_path + "catalog.xml")
            catalog = CatalogSource("sdss",
                                    "Search in radius(arcmin) " + str(radius))
            catalog.addFile("sdss", self.__save_path + "catalog.xml", "vo")

            result.addSummaryParams("ra", respond["ra"][index])
            result.addSummaryParams("dec", respond["dec"][index])

            result.addSummaryParams("distance", loss)

            data = {
                "lambda": sdss["u"],
                "ab": str(respond["u"][index]),
                "err": str(respond["err_u"][index])
            }
            result.addSummaryParams("mag_u", data)

            data = {
                "lambda": sdss["g"],
                "ab": str(respond["g"][index]),
                "err": str(respond["err_g"][index])
            }
            result.addSummaryParams("mag_g", data)

            data = {
                "lambda": sdss["r"],
                "ab": str(respond["r"][index]),
                "err": str(respond["err_r"][index])
            }
            result.addSummaryParams("mag_r", data)

            data = {
                "lambda": sdss["i"],
                "ab": str(respond["i"][index]),
                "err": str(respond["err_i"][index])
            }
            result.addSummaryParams("mag_i", data)

            data = {
                "lambda": sdss["z"],
                "ab": str(respond["z"][index]),
                "err": str(respond["err_z"][index])
            }
            result.addSummaryParams("mag_z", data)

            result.addSummaryParams("type", str(respond["type"][index]))
            result.addSummaryParams("z", respond["z1"][index])
            result.addSummaryParams("zErr", str(respond["zErr"][index]))
            result.addSummaryParams("zWarning",
                                    str(respond["zWarning"][index]))

            image = ImageSource(result.getSummary()["id"],
                                self.__catalog_provider)

            bands = ["u", "g", "r", "i", "z"]
            displayUrl = self.__service_provider["display"]

            imagesList = self.downloadImages(respond["rerun"][index],
                                             respond["run"][index],
                                             respond["camcol"][index],
                                             respond["field"][index], bands)

            result.addCatalog(catalog)

            for img in imagesList:
                band = str(img["band"]).replace(" ", "")
                image.addFile(name="band-" + img["band"],
                              url=img["url"],
                              download=True,
                              local_path=img["local_path"],
                              uncompress=True,
                              thumbnail=True,
                              external=False)
                image.addCutout(self.getImageCutout(respond["ra"][index],
                                                    respond["dec"][index],
                                                    query="G" +
                                                    str(band).upper()),
                                300,
                                band,
                                magnitude=str(respond[band][index]) + "+/-" +
                                str(respond["err_" + band][index]),
                                link=displayUrl.format(respond["ra"][index],
                                                       respond["dec"][index]))

            result.addImage(image)

            if respond["specobjid"][index] != None:
                spec = self.getSpecImage(respond["specobjid"][index])
                spectra = SpectraSource(result.getSummary()["id"],
                                        self.__catalog_provider)
                spectra.addCutout(spec, 700, "visible")
                result.addSpectra(spectra)
        else:
            result.addSummaryParams("error",
                                    "Any results was found in SDSS Archive")

        return result
Exemplo n.º 5
0
    def query(self, **kwargs):
        if "coordinates" in kwargs:
            self.__coordinates = kwargs["coordinates"]
        elif "ra" in kwargs and "dec" in kwargs:
            self.__coordinates = str(kwargs["ra"]) + "," + str(kwargs["dec"])
        radius = 1  # arcmin
        if "radius" in kwargs:
            radius = kwargs["radius"]

        self.__coordinates = CoordinateParser.validateCoordinates(
            self.__coordinates)
        self.__save_path = self.__save_path.format(
            str(self.__coordinates.ra.degree) + "_" +
            str(self.__coordinates.dec.degree))

        width_survey = "w"
        deep_survey = "d"

        radius_degree = CoordinateParser.getMinToDegree(radius)

        query = self.__simple_rec_query.format(deep_survey,
                                               self.__coordinates.ra.degree,
                                               self.__coordinates.dec.degree,
                                               radius_degree)
        respond = self.getTapRequest(query=query)
        self.wide = False

        if len(respond) <= 0:
            query = self.__simple_rec_query.format(
                width_survey, self.__coordinates.ra.degree,
                self.__coordinates.dec.degree, radius_degree)
            respond = self.getTapRequest(query=query)
            self.wide = True

        result = AstroSource(self.__coordinates)
        if len(respond) > 0:
            Utils.createPath(self.__save_path)

            catalog = CatalogSource("cfht", "Search in radius " + str(radius))
            VOTableUtil.saveFromTable(respond,
                                      self.__save_path + "catalog.xml")
            catalog.addFile("allwise", self.__save_path + "catalog.xml", "vo")

            index, loss = CoordinateParser.getNearPositionIndex(
                self.__coordinates.ra.degree, self.__coordinates.dec.degree,
                respond["RAJ2000"], respond["DEJ2000"])

            result.addSummaryParams("ra", respond["RAJ2000"][index])
            result.addSummaryParams("dec", respond["DEJ2000"][index])

            result.addSummaryParams("distance", loss)
            result.addSummaryParams("survey", "wide" if self.wide else "deep")

            cfht = WaveLenghtCover.cfht()
            data = {
                "lambda": cfht["u"],
                "ab": str(respond["umag"][index]),
                "err": str(respond["e_umag"][index])
            }

            result.addSummaryParams("mag_u", data)

            data = {
                "lambda": cfht["g"],
                "ab": str(respond["gmag"][index]),
                "err": str(respond["e_gmag"][index])
            }
            result.addSummaryParams("mag_g", data)

            data = {
                "lambda": cfht["r"],
                "ab": str(respond["rmag"][index]),
                "err": str(respond["e_rmag"][index])
            }
            result.addSummaryParams("mag_r", data)

            data = {
                "lambda": cfht["i"],
                "ab": str(respond["imag"][index]),
                "err": str(respond["e_imag"][index])
            }
            result.addSummaryParams("mag_i", data)

            data = {
                "lambda": cfht["z"],
                "ab": str(respond["zmag"][index]),
                "err": str(respond["e_zmag"][index])
            }
            result.addSummaryParams("mag_z", data)

            result.addSummaryParams("flux_u", str(respond["uFpk"][index]))
            result.addSummaryParams("flux_g", str(respond["gFpk"][index]))
            result.addSummaryParams("flux_r", str(respond["rFpk"][index]))
            result.addSummaryParams("flux_i", str(respond["iFpk"][index]))
            result.addSummaryParams("flux_z", str(respond["zFpk"][index]))

            result.addCatalog(catalog)

            if self.wide:

                #img=self.getWideImages()
                url = self.__service_provider[
                    "width_cutout"] + "?lang=en&object=&ra={0}&dec={1}&size=256"
                url = url.format(self.__coordinates.ra.degree,
                                 self.__coordinates.dec.degree)
                images = self.delayRequest(url)
                image = ImageSource(result.getSummary()["id"],
                                    self.__catalog_provider)
                mag = {
                    "U":
                    str(respond["umag"][index]) + "+/-" +
                    str(respond["e_umag"][index]),
                    "G":
                    str(respond["gmag"][index]) + "+/-" +
                    str(respond["e_gmag"][index]),
                    "R":
                    str(respond["rmag"][index]) + "+/-" +
                    str(respond["e_rmag"][index]),
                    "I":
                    str(respond["imag"][index]) + "+/-" +
                    str(respond["e_imag"][index]),
                    "Z":
                    str(respond["zmag"][index]) + "+/-" +
                    str(respond["e_zmag"][index]),
                    "2":
                    -99
                }
                for idx in range(len(images)):
                    img = images[idx]
                    band = img["band"]
                    mag_val = mag[band]
                    image.addCutout(img["image"], 256, band, mag_val)

                    local_path = self.__save_path + "cfht_band_" + band + ".fits"
                    image.addFile(band,
                                  img["fits"],
                                  "fits",
                                  download=True,
                                  local_path=local_path,
                                  uncompress=False,
                                  thumbnail=True,
                                  external=False)

                result.addImage(image)

        return result
Exemplo n.º 6
0
    def getWideImages(self):

        #   parameters "?lang=en&object=&ra={0}&dec={1}&size=256"

        img_size = 256
        params = {
            'lang': 'en',
            'object': '',
            'ra': self.__coordinates.ra.degree,
            'dec': self.__coordinates.dec.degree,
            'size': img_size
        }

        r = requests.get(self.__service_provider["width_cutout"],
                         params=params)

        try:
            error = HtmlParser.getById(r.text, "url0")[0].contents[0]
            sr = re.search("Unable to determine", error.string).group(0)
            success = 300
        except AttributeError:
            success = 200

        tables = HtmlParser.findAllElements(r.text, "tr")
        pos = str(params["ra"]) + "," + str(params["deg"])
        image = ImageSource(pos, self.__catalog_provider)

        for index in range(len(tables[0].contents)):
            imgDescript = tables[0].contents[index]
            if type(imgDescript) == Tag:
                img_source = tables[1].contents[index].contents[0]
                links = []

                # image.addCutout("url":url,"size":size,"band":band,"magnitude")

                # image.addFile({"url": url, "name": name, "type": type})
                display_link = ""
                for tags in imgDescript.contents:
                    if type(tags) == Tag and tags.name == "a":
                        if "Display" == tags.contents[0]:
                            display_link = tags.attrs["href"]
                            if "http:" not in display_link:
                                display_link = "http:" + display_link
                        elif "FITS" == tags.contents[0]:
                            url_file = tags.attrs["href"]
                            if "http://ps1images.stsci.edu/" not in url_file:
                                url_file = "http://ps1images.stsci.edu/" + url_file

                            name_file = tags.attrs["title"]
                            type_file = "FITS"
                            # links.append({"title":tags.attrs["title"],"href":tags.attrs["href"]})

                            band = re.search('(y/i/g|g|r|i|z|y)',
                                             imgDescript.contents[0]).group(0)
                            name = imgDescript.contents[0]
                            # img={'name':re.search('(y/i/g|g|r|i|z|y)',imgDescript.contents[0]).group(0),
                            #     'link':links,
                            #     'img':img_source.attrs["src"]}
                            url_img = "http:" + img_source.attrs["src"] if "http:" not in img_source.attrs["src"] else \
                            img_source.attrs["src"]
                            local_path = self.__save_path + "cfht_band_" + band + ".fits"
                            image.addCutout(url_img, img_size, band, -99,
                                            display_link)
                            image.addFile(name_file,
                                          url_file,
                                          type_file,
                                          download=True,
                                          local_path=local_path,
                                          uncompress=False)

        return image
Exemplo n.º 7
0
    def query(self, **kwargs):

        # check for data release to use
        if "coordinates" in kwargs:
            self.__coordinates = kwargs["coordinates"]
        elif "ra" in kwargs and "dec" in kwargs:
            self.__coordinates = str(kwargs["ra"]) + "," + str(kwargs["dec"])
        else:
            raise ValueError("Not valid coordinates found. Used coordinates key or ra dec keys")

        radius = 1  # arcmin
        if "radius" in kwargs:
            radius = kwargs["radius"]

        self.__coordinates = CoordinateParser.validateCoordinates(self.__coordinates)

        large_suvey="II/319/las9"
        galactic_cluster_suvey = "II/319/gcs9"
        deep_suvey = "II/319/dxs9"
        galatic_plane_survey="II/316/gps6"

        radius_degree = CoordinateParser.getMinToDegree(radius)
        program_id="ALL"

        self.__save_path = self.__save_path.format(
            str(self.__coordinates.ra.degree) + "_" + str(self.__coordinates.dec.degree))

        query = self.__simple_rec_query.format(large_suvey, self.__coordinates.ra.degree, self.__coordinates.dec.degree,
                                               radius_degree)
        respond = self.getTapRequest(query=query)

        result = AstroSource(self.__coordinates)
        if len(respond) <= 0:
            query = self.__simple_rec_query.format(galactic_cluster_suvey, self.__coordinates.ra.degree,
                                                   self.__coordinates.dec.degree, radius_degree)
            respond = self.getTapRequest(query=query)
            program_id = "GCS"

        if len(respond) <= 0:
            query = self.__simple_rec_query.format(deep_suvey, self.__coordinates.ra.degree,
                                                   self.__coordinates.dec.degree, radius_degree)
            respond = self.getTapRequest(query=query)
            program_id = "DXS"

        if len(respond) <= 0:
            query = self.__simple_rec_query.format(galatic_plane_survey, self.__coordinates.ra.degree,
                                                   self.__coordinates.dec.degree, radius_degree)
            respond = self.getTapRequest(query=query)
            program_id = "GPS"

        if len(respond)>0:


            Utils.createPath(self.__save_path)
            catalog = CatalogSource("ukidss", "Search in radius " + str(radius))
            VOTableUtil.saveFromTable(respond, self.__save_path + "catalog.xml")
            catalog.addFile("ukidss", self.__save_path + "catalog.xml", "vo")

            result.addCatalog(catalog)

            index,loss = CoordinateParser.getNearPositionIndex(self.__coordinates.ra.degree, self.__coordinates.dec.degree,
                                                          respond["RAJ2000"], respond["DEJ2000"])

            ukidss = WaveLenghtCover.ukidss()
            result.addSummaryParams("ra", respond["RAJ2000"][index])
            result.addSummaryParams("dec", respond["DEJ2000"][index])
            result.addSummaryParams("distance", loss)

            magnitudes={"Y":-99,"J":-99,"H":-99,"K":-99,"Z":-99}

            try:
                data={"lambda": ukidss["h"], "ab": str(respond["Hmag"][index]), "err": str(respond["e_Hmag"][index])}
                result.addSummaryParams("mag_h", data)
                magnitudes["H"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_h found")

            try:
                data = {"lambda": ukidss["j"], "ab": str(respond["Jmag"][index]), "err": str(respond["e_Jmag"][index])}
                result.addSummaryParams("mag_j", data)
                magnitudes["J"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_j found")

            try:
                data = {"lambda": ukidss["j"], "ab": str(respond["Jmag1"][index]), "err": str(respond["e_Jmag1"][index])}
                result.addSummaryParams("mag_j1", data)
                magnitudes["J"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_j1 found")

            try:
                data = {"lambda": ukidss["j"], "ab": str(respond["Jmag2"][index]),"err": str(respond["e_Jmag2"][index])}
                result.addSummaryParams("mag_j2", data)
                magnitudes["J"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_j2 found")

            try:
                data = {"lambda": ukidss["j"], "ab": str(respond["pJmag"][index]),"err": str(respond["e_pJmag"][index])}
                result.addSummaryParams("pmag_j", data)
                magnitudes["J"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No pmag_j found")

            try:
                data = {"lambda": ukidss["k"], "ab": str(respond["pKmag"][index]),"err": str(respond["e_pKmag"][index])}
                result.addSummaryParams("pmag_k", data)
                magnitudes["K"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No pmag_k found")

            try:
                data = {"lambda": ukidss["k"], "ab": str(respond["Kmag"][index]),"err": str(respond["e_Kmag"][index])}
                result.addSummaryParams("mag_k", data)
                magnitudes["K"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_k found")

            try:
                data = {"lambda": ukidss["k"], "ab": str(respond["Kmag1"][index]), "err": str(respond["e_Kmag1"][index])}
                result.addSummaryParams("mag_k1", data)
                magnitudes["K"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_k1 found")
            try:
                data = {"lambda": ukidss["k"], "ab": str(respond["Kmag2"][index]),"err": str(respond["e_Kmag2"][index])}
                result.addSummaryParams("mag_k2", data)
                magnitudes["K"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_k2 found")

            try:
                data = {"lambda": ukidss["y"], "ab": str(respond["Ymag"][index]),"err": str(respond["e_Ymag"][index])}
                result.addSummaryParams("mag_y", data)
                magnitudes["Y"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_y found")
            try:
                data = {"lambda": ukidss["z"], "ab": str(respond["Zmag"][index]), "err": str(respond["e_Zmag"][index])}
                result.addSummaryParams("mag_z", data)
                magnitudes["Z"] = data["ab"] + "+/-" + data["err"]
            except KeyError:
                print("No mag_z found")

            images = Ukidss.get_image_list(self.__coordinates,waveband='all', frame_type='stack',
                                            image_width=radius * u.arcmin,
                                            database="UKIDSSDR10PLUS",programme_id=program_id)

            display_urls = [link.replace("getFImage", "getImage")for link in images]
            image_urls = [link.replace("getFImage", "getJImage") for link in images]

            image = ImageSource(result.getSummary()["id"], self.__catalog_provider)


            for index in range(len(images)):
                img= image_urls[index]
                band = str(img[img.find("band")+5:img.find("band")+6]).replace(" ","")
                mag=magnitudes[band]
                image.addCutout(image_urls[index],300, band, magnitude=mag,link=display_urls[index])

                local_path = self.__save_path + "ukidss_band_" + band + ".fits"
                image.addFile(name="band-" + band, url=images[index], download=True,
                              local_path=local_path, uncompress=False, thumbnail=True,external=False)

                #image.addFile("band-" + band,images[index] , "fits")

            result.addImage(image)

        return result