with open ("gnames.txt", "w") as output: for name in gnames: output.write(name) output.write("\n") image_list = [] full_list = [] #print ('here') from astroquery.ned import Ned #print ('okay') output = open("download.txt", "w") #print (len(gnames)) for name in gnames: image_list = Ned.get_image_list(name, item = 'spectra') full_list += image_list print ("full_list done") for item in image_list: output.write(item) print ('at the end') #print (len(image_list)) output.close()
def find(self): """ This function ... :return: """ # Get the list urls = Ned.get_image_list(self.config.galaxy) images = [] # Print the list for url in urls: # Get the name name = fs.strip_extension(fs.strip_extension( fs.name(url))) # strip both the .gz as the .fits extension # Get the bibcode try: bibcode = url.split("img/")[1].split("/")[0] except IndexError: bibcode = None if ":" in name: splitted = name.split(":") if splitted[0].startswith("NGC_"): band = splitted[0].split("NGC_")[1][5:] try: filter = parse_filter(band) splitted = [ self.config.galaxy, None, band, splitted[1] ] except: pass if len(splitted) == 3: splitted = [ self.config.galaxy, None, splitted[1], splitted[2] ] elif len(splitted) == 2: info_and_band = splitted[0].split("NGC_")[1][5:] splitted = [ self.config.galaxy, None, info_and_band, splitted[1] ] galaxy_name = splitted[0] unknown = splitted[1] band = splitted[2] source = splitted[3] try: year = int(source[-4:]) if year < 1985: continue except ValueError: year = None images.append((band, year, bibcode, url)) elif "_" in name: splitted = name.split("_") band = splitted[-1] images.append((band, None, bibcode, url)) elif "." in name: splitted = name.split(".") galaxy_name = splitted[0] images.append((None, None, bibcode, url)) # Print for band, year, bibcode, url in images: if band is None: fltr = None elif "Ha" in band or "H-alpha" in band or "H_alph" in band: fltr = NarrowBandFilter("Ha") else: try: fltr = parse_filter(band) except ValueError: fltr = None #print(fltr, year, bibcode, url) if fltr is None: self.unknown.append((bibcode, year, url)) else: fltrstring = str(fltr) # Add to the images dictionary self.images[fltrstring].append((bibcode, year, url))
def find(self): """ This function ... :return: """ # Get the list urls = Ned.get_image_list(self.config.galaxy) images = [] # Print the list for url in urls: # Get the name name = fs.strip_extension(fs.strip_extension(fs.name(url))) # strip both the .gz as the .fits extension # Get the bibcode try: bibcode = url.split("img/")[1].split("/")[0] except IndexError: bibcode = None if ":" in name: splitted = name.split(":") if splitted[0].startswith("NGC_"): band = splitted[0].split("NGC_")[1][5:] try: filter = parse_filter(band) splitted = [self.config.galaxy, None, band, splitted[1]] except: pass if len(splitted) == 3: splitted = [self.config.galaxy, None, splitted[1], splitted[2]] elif len(splitted) == 2: info_and_band = splitted[0].split("NGC_")[1][5:] splitted = [self.config.galaxy, None, info_and_band, splitted[1]] galaxy_name = splitted[0] unknown = splitted[1] band = splitted[2] source = splitted[3] try: year = int(source[-4:]) if year < 1985: continue except ValueError: year = None images.append((band, year, bibcode, url)) elif "_" in name: splitted = name.split("_") band = splitted[-1] images.append((band, None, bibcode, url)) elif "." in name: splitted = name.split(".") galaxy_name = splitted[0] images.append((None, None, bibcode, url)) # Print for band, year, bibcode, url in images: if band is None: fltr = None elif "Ha" in band or "H-alpha" in band or "H_alph" in band: fltr = NarrowBandFilter("Ha") else: try: fltr = parse_filter(band) except ValueError: fltr = None #print(fltr, year, bibcode, url) if fltr is None: self.unknown.append((bibcode, year, url)) else: fltrstring = str(fltr) # Add to the images dictionary self.images[fltrstring].append((bibcode, year, url))
with open ("gnames.txt", "r") as myfile: mylist = myfile.readlines() #print (mylist[:10]) name = [] for item in mylist: name.append(item.rstrip("\n")) #print (name[:10]) from astroquery.ned import Ned image_list = {} url = [] for entry in name: url = Ned.get_image_list(entry, item = 'spectra') image_list.update({entry:url}) nomatch = [] import urllib for name, url in image_list: if url == []: nomatch.append(name) else: urllib.urlretrieve (url)
from astroquery.ned import Ned image_list = [] image_list += Ned.get_image_list('NGC_5128', item = 'spectra') print (image_list)
def test5(): image_list = Ned.get_image_list("m1") print image_list