def get_data(self): result_table = Simbad() # Extended timeout to search for 1000 rows result_table.TIMEOUT = 120 result_table.ROW_LIMIT = 1000 result_table.add_votable_fields( "flux(V)", "mt", "otype", "ra", "dec", "dim", "flux(U)", "flux(B)", "flux(R)", "flux(I)", "flux(J)", "flux(H)", "flux(K)", "flux(u)", "flux(g)", "flux(r)", "flux(i)", "flux(z)", *self.args ) result_table = result_table.query_object(self.name, **self.kwargs) return result_table
def simbad_object(): customSimbad=Simbad() customSimbad.TIMEOUT=5 customSimbad.add_votable_fields('ra(d)','dec(d)','flux(V)') customSimbad.remove_votable_fields('coordinates') result_table=customSimbad.query_object(request.form["Name"]) return result_table
def simbad_region(coord): customSimbad=Simbad() customSimbad.TIMEOUT=5 customSimbad.add_votable_fields('ra(d)','dec(d)','flux(V)') customSimbad.remove_votable_fields('coordinates') result_table = customSimbad.query_region(coord, radius='0d2m0s') return result_table
def test_query_region(self, temp_dir): simbad = Simbad() # TODO: rewise once ROW_LIMIT is working simbad.TIMEOUT = 100 simbad.cache_location = temp_dir result = simbad.query_region(ICRS_COORDS_M42, radius=2 * u.deg, equinox=2000.0, epoch='J2000') assert isinstance(result, Table)
def test_query_region_async(self, temp_dir): simbad = Simbad() # TODO: rewise once ROW_LIMIT is working simbad.TIMEOUT = 100 simbad.cache_location = temp_dir response = simbad.query_region_async( ICRS_COORDS_M42, radius=2 * u.deg, equinox=2000.0, epoch='J2000') assert response is not None
def do_simbad_novae(catalog): task_str = catalog.get_current_task_str() simbad_mirrors = ['http://simbad.harvard.edu/simbad/sim-script', 'http://simbad.u-strasbg.fr/simbad/sim-script'] customSimbad = Simbad() customSimbad.ROW_LIMIT = -1 customSimbad.TIMEOUT = 120 for mirror in simbad_mirrors: customSimbad.SIMBAD_URL = mirror try: table = customSimbad.query_criteria('maintype=No* | maintype="No?"') except: continue else: break if not table: catalog.log.warning('SIMBAD unable to load, probably offline.') for name in pbar(catalog.entries, task_str): try: nova_name = "V* " + get_nova_name(name) aliases = customSimbad.query_objectids(nova_name) except: #THROW WARNING HERE tprint("Could not find " + nova_name) continue table = customSimbad.query_object(nova_name) name = catalog.add_entry(name) bibcode = table[0]['COO_BIBCODE'].decode() ra = str(table[0]['RA']) dec = str(table[0]['DEC']) source = catalog.entries[name].add_source(name='SIMBAD astronomical database', bibcode=bibcode, url="http://simbad.u-strasbg.fr/", secondary=True) catalog.entries[name].add_quantity(NOVA.RA, ra, source) catalog.entries[name].add_quantity(NOVA.DEC, dec, source) for i in range(len(aliases)): try: alias = aliases[i][0].decode() except: alias = str(aliases[i][0]) catalog.entries[name].add_quantity(NOVA.ALIAS, alias, source) catalog.journal_entries()
def simbad_object_skycoord(target): """Return a SkyCoord object for a target""" cs = Simbad() cs.ROW_LIMIT = 1 cs.TIMEOUT = 5 result = cs.query_object(target) try: assert len(result) == 1 except: raise LookupError("Simbad Object Query failed") result = result[0] return SkyCoord(result['RA'], result['DEC'], unit=(u.hourangle, u.degree))
def do_simbad(catalog): task_str = catalog.get_current_task_str() keys = list(catalog.entries.keys()) customSimbad = Simbad() customSimbad.ROW_LIMIT = -1 customSimbad.TIMEOUT = 120 customSimbad.add_votable_fields('otype', 'sptype', 'sp_bibcode', 'id') warnings.filterwarnings("ignore") Mnames, Mradec = [], [] for oname in pbar(keys, task_str): # Some events may be merged in cleanup process, skip them if # non-existent. try: name = catalog.add_entry(oname) except Exception: catalog.log.warning( '"{}" was not found, suggests merge occurred in cleanup ' 'process.'.format(oname)) continue if (FASTSTARS.RA not in catalog.entries[name] or FASTSTARS.DEC not in catalog.entries[name]): continue else: Mnames.append(name) radec = str(catalog.entries[name][FASTSTARS.RA][0]['value']) + str( catalog.entries[name][FASTSTARS.DEC][0]['value']) c = coord(radec, unit=(un.hourangle, un.deg), frame='icrs') cnttry = 0 foundstar = False while foundstar == False and cnttry < 10: try: cnttry += 1 time.sleep(0.1) result = customSimbad.query_region(c, radius='0d0m5s') aliases = re.sub(r'b\'(.*)\'', r'\1', str(result['ID'].tolist()[0])).split(',') except TypeError: #print(radec,cnttry) continue foundstar = True if foundstar == True: source = (catalog.entries[name].add_source( name='SIMBAD astronomical database', bibcode="2000A&AS..143....9W", url="http://simbad.u-strasbg.fr/", secondary=True)) for alias in aliases: ali = single_spaces( re.sub(r'\[[^)]*\]', '', alias).strip()) if is_number(ali.replace(' ', '')): continue if ali[:4] == "HVS ": continue ali = name_clean(ali) catalog.entries[name].add_quantity(FASTSTARS.ALIAS, ali, source) catalog.journal_entries() return
import base64 from alerce.core import Alerce # whether to report photozs to TNS and skyportal report_photoz_TNS = False report_photoz_skyportal = False # add redshift to Simbad query customSimbad = Simbad() customSimbad.add_votable_fields('z_value') customSimbad.add_votable_fields('rv_value') customSimbad.add_votable_fields('rvz_type') customSimbad.add_votable_fields('rvz_error') customSimbad.add_votable_fields('rvz_qual') customSimbad.TIMEOUT = 5 # 5 seconds # timeout for Ned customNed = Ned() customNed.TIMEOUT = 5 class alerce_tns(Alerce): 'module to interact with alerce api to send TNS report' def __init__(self, **kwargs): super().__init__(**kwargs) ## fix API address #my_config = { # "ZTF_API_URL": "https://dev.api.alerce.online"
def do_simbad(catalog): # Simbad.list_votable_fields() # Some coordinates that SIMBAD claims belong to the SNe actually belong to # the host. task_str = catalog.get_current_task_str() simbadmirrors = ['http://simbad.harvard.edu/simbad/sim-script', 'http://simbad.u-strasbg.fr/simbad/sim-script'] simbadbadcoordbib = ['2013ApJ...770..107C'] simbadbadnamebib = ['2004AJ....127.2809W', '2005MNRAS.364.1419Z', '2015A&A...574A.112D', '2011MNRAS.417..916G', '2002ApJ...566..880G'] simbadbannedcats = ['[TBV2008]', 'OGLE-MBR'] customSimbad = Simbad() customSimbad.ROW_LIMIT = -1 customSimbad.TIMEOUT = 120 customSimbad.add_votable_fields('otype', 'sptype', 'sp_bibcode', 'id') table = [] for mirror in simbadmirrors: customSimbad.SIMBAD_URL = mirror try: table = customSimbad.query_criteria('maintype=No* | maintype="No?"') except: continue else: break if not table: catalog.log.warning('SIMBAD unable to load, probably offline.') # 2000A&AS..143....9W for brow in pbar(table, task_str): row = {x: re.sub(r'b\'(.*)\'', r'\1', str(brow[x])) for x in brow.colnames} # Skip items with no bibliographic info aside from SIMBAD, too # error-prone if row['OTYPE'] == 'Candidate_No*' and not row['SP_TYPE']: continue if (not row['COO_BIBCODE'] and not row['SP_BIBCODE'] and not row['SP_BIBCODE_2']): continue if any([x in row['MAIN_ID'] for x in simbadbannedcats]): continue if row['COO_BIBCODE'] and row['COO_BIBCODE'] in simbadbadnamebib: continue name = single_spaces(re.sub(r'\[[^)]*\]', '', row['MAIN_ID']).strip()) if name == 'SN': continue if is_number(name): continue name = catalog.add_entry(name) source = (catalog.entries[name] .add_source(name='SIMBAD astronomical database', bibcode="2000A&AS..143....9W", url="http://simbad.u-strasbg.fr/", secondary=True)) aliases = row['ID'].split(',') for alias in aliases: if any([x in alias for x in simbadbannedcats]): continue ali = single_spaces(re.sub(r'\[[^)]*\]', '', alias).strip()) if is_number(ali): continue ali = name_clean(ali) catalog.entries[name].add_quantity(NOVA.ALIAS, ali, source) if row['COO_BIBCODE'] and row['COO_BIBCODE'] not in simbadbadcoordbib: csources = ','.join( [source, catalog.entries[name].add_source( bibcode=row['COO_BIBCODE'])]) catalog.entries[name].add_quantity(NOVA.RA, row['RA'], csources) catalog.entries[name].add_quantity(NOVA.DEC, row['DEC'], csources) if row['SP_BIBCODE']: ssources = uniq_cdl([source, catalog.entries[name] .add_source(bibcode=row['SP_BIBCODE'])] + ([catalog.entries[name] .add_source(bibcode=row['SP_BIBCODE_2'])] if row['SP_BIBCODE_2'] else [])) catalog.entries[name].add_quantity( NOVA.CLAIMED_TYPE, (row['SP_TYPE'] .replace('SN.', '') .replace('SN', '') .replace('(~)', '') .strip(': ')), ssources) catalog.journal_entries() return
def main(): # VIZIER whole catalog Vizier.ROW_LIMIT = -1 cat = ['V/50', 'V/36B'] catalogs = Vizier.get_catalogs(cat) catalog = catalogs[0] catalog_compl = catalogs[2] # Operating with the data data = catalog.as_array() data_compl = catalog_compl.as_array() # Print available data data.dtype data_compl.dtype # Filtering the SpType sptype = list(data['SpType'].data) sptype_compl = list(data_compl['SpType'].data) # indexes = np.where(conc_flux[0] > 0) indexes = [] for i in range(len(sptype)): sptyp = sptype[i].decode('UTF-8') if len(sptyp) != 0: if sptyp[0] == 'O': if ('V' in sptyp) is True: if ('I' in sptyp) is False: if ('Hg' in sptyp) is False: if ('Mn' in sptyp) is False: indexes.append(i) indexes_compl = [] for i in range(len(sptype_compl)): sptyp_compl = sptype_compl[i].decode('UTF-8') if len(sptyp_compl) != 0: if sptyp_compl[0] == 'O': if ('V' in sptyp_compl) is True: if ('I' in sptyp_compl) is False: if ('Hg' in sptyp_compl) is False: if ('Mn' in sptyp_compl) is False: indexes_compl.append(i) # ============================================================================== # Selecting the data with the B stars selected_data = data[indexes] sptyp_selected = list(selected_data['SpType']) name_selected = selected_data['Name'] hd_selected = selected_data['HD'] plx = selected_data['Parallax'] bmv = selected_data['B-V'] err_bmv = selected_data['u_B-V'] umb = selected_data['U-B'] err_umb = selected_data['u_U-B'] rmi = selected_data['R-I'] vsini = selected_data['RotVel'] err_vsini = selected_data['u_RotVel'] companions = selected_data['MultCnt'] selected_data_compl = data_compl[indexes_compl] sptyp_selected_compl = list(selected_data_compl['SpType']) hd_selected_compl = selected_data_compl['HD'] plx_compl = selected_data_compl['Plx'] bmv_compl = selected_data_compl['B-V'] umb_compl = selected_data_compl['U-B'] rmi_compl = selected_data_compl['R-I'] vsini_compl = selected_data_compl['vsini'] err_vsini_compl = selected_data_compl['u_vsini'] # ============================================================================== # Checking if there are IUE data customSimbad = Simbad() customSimbad.TIMEOUT = 2000 # sets the timeout to 2000s # see which fields are currently set customSimbad.get_votable_fields() # To set other fields customSimbad.add_votable_fields('measurements') # ============================================================================== # Selecting the stars with IUE data data = data[indexes] obs_iue_date = [] stars = [] indexes = [] print('selected stars: %d' % len(hd_selected)) for i in range(len(hd_selected)): try: star = "HD " + str(hd_selected[i]) result_table = customSimbad.query_object(star) obs_date = result_table['IUE_ObsDate'] if len(obs_date.item()) != 0: print(num_spa * '-') print('\n' + star) print('%0.2f perc. concluded' % (100 * i / len(hd_selected))) print(obs_date) obs_iue_date.append(obs_date.item()) stars.append(star) indexes.append(i) except: pass data_compl = data_compl[indexes_compl] obs_iue_date_compl = [] stars_compl = [] indexes_compl = [] print('selected stars compl: %d' % len(hd_selected_compl)) for i in range(len(hd_selected_compl)): try: star = "HD " + str(hd_selected_compl[i]) result_table = customSimbad.query_object(star) obs_date = result_table['IUE_ObsDate'] if len(obs_date.item()) != 0: print(num_spa * '-') print('\n' + star) print('%0.2f perc. concluded' % (100 * i / len(hd_selected))) print(obs_date) obs_iue_date_compl.append(obs_date.item()) stars_compl.append(star) indexes_compl.append(i) except: pass # ============================================================================== # Selecting the data with the B stars in IUE database selected_data = data[indexes] sptyp_selected = list(selected_data['SpType']) name_selected = selected_data['Name'] hd_selected = selected_data['HD'] plx = selected_data['Parallax'] bmv = selected_data['B-V'] err_bmv = selected_data['u_B-V'] umb = selected_data['U-B'] err_umb = selected_data['u_U-B'] rmi = selected_data['R-I'] vsini = selected_data['RotVel'] err_vsini = selected_data['u_RotVel'] companions = selected_data['MultCnt'] selected_data_compl = data_compl[indexes_compl] sptyp_selected_compl = list(selected_data_compl['SpType']) hd_selected_compl = selected_data_compl['HD'] plx_compl = selected_data_compl['Plx'] bmv_compl = selected_data_compl['B-V'] umb_compl = selected_data_compl['U-B'] rmi_compl = selected_data_compl['R-I'] vsini_compl = selected_data_compl['vsini'] err_vsini_compl = selected_data_compl['u_vsini'] # ============================================================================== # Plotting correlations # Plot B-V vs U-B plt.clf() plt.scatter(bmv, umb, label='V/50', marker='o') plt.scatter(bmv_compl, umb_compl, label='V/36B', color='red', marker='o') plt.xlabel(r'(B-V) [mag]') plt.ylabel(r'(U-B) [mag]') plt.legend() plt.savefig(folder_fig + 'bmvVSumb.png') # ------------------------------------------------------------------------------ # Plot R-I vs U-B plt.clf() plt.scatter(rmi, umb, label='V/50', marker='o') plt.scatter(rmi_compl, umb_compl, label='V/36B', color='red', marker='o') plt.xlabel(r'(R-I) [mag]') plt.ylabel(r'(U-B) [mag]') plt.legend() plt.savefig(folder_fig + 'rmiVSumb.png') # ------------------------------------------------------------------------------ # Plot B-V vs R-I plt.clf() plt.scatter(bmv, rmi, label='V/50', marker='o') plt.scatter(bmv_compl, rmi_compl, label='V/36B', color='red', marker='o') plt.xlabel(r'(B-V) [mag]') plt.ylabel(r'(R-I) [mag]') plt.legend() plt.savefig(folder_fig + 'bmvVSrmi.png') # ------------------------------------------------------------------------------ # Plot B-V vs vsini plt.clf() plt.scatter(bmv, vsini, label='V/50', marker='o') plt.scatter(bmv_compl, vsini_compl, label='V/36B', color='red', marker='o') plt.xlabel(r'(B-V) [mag]') plt.ylabel(r'$v \sin i$ [km/s]') plt.legend() plt.savefig(folder_fig + 'bmvVSvsini.png') # ============================================================================== create_txt_file(a=hd_selected, b=bmv, c=umb, d=rmi, e=vsini, f=err_bmv, g=err_umb, h=err_vsini, i=companions.data, j=obs_iue_date, l=sptyp_selected, file_name=commum_folder + 'selected_oe_stars.txt') create_txt_file_compl(a=hd_selected_compl, b=bmv_compl, c=umb_compl, d=rmi_compl, e=vsini_compl, f=err_vsini_compl, g=obs_iue_date_compl, h=sptyp_selected_compl, file_name=commum_folder + 'selected_oe_stars_compl.txt') # ============================================================================== # example if False: R = np.array((data['Vc'] * 1e5)**2 / 10**data['logg'] / phc.Rsun.cgs) L = phc.sigma.cgs * np.array(data['Teff'], dtype=float)**4 * 4 *\ np.pi * (R * phc.Rsun.cgs)**2 * phc.Lsun.cgs M = np.array((data['Vc'] * 1e5)**2 * (R * phc.Rsun.cgs) / phc.G.cgs / phc.Msun.cgs)
def do_simbad(catalog): # Simbad.list_votable_fields() # Some coordinates that SIMBAD claims belong to the SNe actually belong to # the host. task_str = catalog.get_current_task_str() simbadmirrors = ['http://simbad.harvard.edu/simbad/sim-script', 'http://simbad.u-strasbg.fr/simbad/sim-script'] simbadbadcoordbib = ['2013ApJ...770..107C'] simbadbadtypebib = ['2014ApJ...796...87I', '2015MNRAS.448.1206M', '2015ApJ...807L..18N'] simbadbadnamebib = ['2004AJ....127.2809W', '2005MNRAS.364.1419Z', '2015A&A...574A.112D', '2011MNRAS.417..916G', '2002ApJ...566..880G'] simbadbannedcats = ['[TBV2008]', 'OGLE-MBR'] simbadbannednames = ['SN'] customSimbad = Simbad() customSimbad.ROW_LIMIT = -1 customSimbad.TIMEOUT = 120 customSimbad.add_votable_fields('otype', 'sptype', 'sp_bibcode', 'id') table = [] print(customSimbad.SIMBAD_URL) for mirror in simbadmirrors: customSimbad.SIMBAD_URL = mirror try: table = customSimbad.query_criteria('maintype=SN | maintype="SN?"') except Exception: continue else: if not table: continue break if not table: catalog.log.warning('SIMBAD unable to load, probably offline.') # 2000A&AS..143....9W for brow in pbar(table, task_str): row = {x: re.sub(r'b\'(.*)\'', r'\1', str(brow[x])) for x in brow.colnames} # Skip items with no bibliographic info aside from SIMBAD, too # error-prone if row['OTYPE'] == 'Candidate_SN*' and not row['SP_TYPE']: continue if (not row['COO_BIBCODE'] and not row['SP_BIBCODE'] and not row['SP_BIBCODE_2']): continue if any([x in row['MAIN_ID'] for x in simbadbannedcats]): continue if row['COO_BIBCODE'] and row['COO_BIBCODE'] in simbadbadnamebib: continue name = single_spaces(re.sub(r'\[[^)]*\]', '', row['MAIN_ID']).strip()) if name in simbadbannednames: continue if is_number(name.replace(' ', '')): continue name = catalog.add_entry(name) source = (catalog.entries[name] .add_source(name='SIMBAD astronomical database', bibcode="2000A&AS..143....9W", url="http://simbad.u-strasbg.fr/", secondary=True)) aliases = row['ID'].split(',') for alias in aliases: if any([x in alias for x in simbadbannedcats]): continue ali = single_spaces(re.sub(r'\[[^)]*\]', '', alias).strip()) if is_number(ali.replace(' ', '')): continue if ali in simbadbannednames: continue ali = name_clean(ali) catalog.entries[name].add_quantity(SUPERNOVA.ALIAS, ali, source) if row['COO_BIBCODE'] and row['COO_BIBCODE'] not in simbadbadcoordbib: csources = ','.join( [source, catalog.entries[name].add_source( bibcode=row['COO_BIBCODE'])]) catalog.entries[name].add_quantity(SUPERNOVA.RA, row['RA'], csources) catalog.entries[name].add_quantity(SUPERNOVA.DEC, row['DEC'], csources) if row['SP_BIBCODE'] and row['SP_BIBCODE'] not in simbadbadtypebib: ssources = uniq_cdl([source, catalog.entries[name] .add_source(bibcode=row['SP_BIBCODE'])] + ([catalog.entries[name] .add_source(bibcode=row['SP_BIBCODE_2'])] if row['SP_BIBCODE_2'] else [])) catalog.entries[name].add_quantity( SUPERNOVA.CLAIMED_TYPE, (row['SP_TYPE'] .replace('SN.', '') .replace('SN', '') .replace('(~)', '') .strip(': ')), ssources) catalog.journal_entries() return
# Extinction laws listFile = '../Tables/CsengeriList.dat' sourCoor = ascii.read(listFile, format='fixed_width') result_dir = '../Tables/' outfile = result_dir + 'simbadStats.dat' simStats = open(outfile, 'w') fmt = '%18s %6i \n' pfmt = '%6i %18s %6i %6.2f%% finished.' Simbad.TIMEOUT = 1000000 customSimbad = Simbad() customSimbad.add_votable_fields('ra(d)', 'dec(d)', 'otype') customSimbad.remove_votable_fields('coordinates') customSimbad.TIMEOUT = 100000 start = time.time() for isou in range(len(sourCoor)): ra = sourCoor['ra'][isou] dec = sourCoor['dec'][isou] c = coords.SkyCoord(ra, dec, unit=('deg', 'deg'), frame='icrs') source = sourCoor['Name'][isou] radius = sourCoor['amaj'][isou] / 2.0 result = customSimbad.query_region(c, radius=radius * u.arcsec) lenSF = 0 if result: for isim in range(len(result)): if (result['OTYPE'][isim] == 'Radio(cm)' or result['OTYPE'][isim] == 'Radio' or result['OTYPE'][isim] == 'HII' or result['OTYPE'][isim] == 'IR'
rcParams['xtick.major.pad'] = '6' rcParams['xtick.major.size'] = '8' rcParams['xtick.major.width'] = '3' rcParams['ytick.major.size'] = '8' rcParams['ytick.major.width'] = '3' rcParams['lines.markersize'] = '10' rcParams['lines.linewidth'] = '2' rcParams['axes.unicode_minus'] = False ######################################################## # QUERY STUFF # ######################################################## custom_query = Simbad() custom_query.add_votable_fields('id(HIP|1)', 'coo(s)', 'flux(V)') custom_query.remove_votable_fields('main_id', 'coordinates') custom_query.TIMEOUT = 2 defaultDate = str(datetime.utcnow()).split()[0] def set_date(newDefaultDate): global defaultDate defaultDate = newDefaultDate def get_observatory(observatory='Mount Graham', date=None): if observatory == 'Mount Graham': #lbt=lookup('Mount Graham International Observatory, Arizona') lbt = ephem.Observer() lbt.lon = '-109:53:51.0' lbt.lat = '32:41:56.9'
rcParams['xtick.major.pad'] = '6' rcParams['xtick.major.size'] = '8' rcParams['xtick.major.width'] = '3' rcParams['ytick.major.size'] = '8' rcParams['ytick.major.width'] = '3' rcParams['lines.markersize'] = '10' rcParams['lines.linewidth'] = '2' rcParams['axes.unicode_minus'] = False ######################################################## # QUERY STUFF # ######################################################## custom_query=Simbad() custom_query.add_votable_fields('id(HIP|1)','coo(s)','flux(V)') custom_query.remove_votable_fields('main_id','coordinates') custom_query.TIMEOUT = 2 defaultDate=str(datetime.utcnow()).split()[0] def set_date(newDefaultDate): global defaultDate defaultDate=newDefaultDate def get_observatory(observatory='Mount Graham', date=None): if observatory == 'Mount Graham': #lbt=lookup('Mount Graham International Observatory, Arizona') lbt=ephem.Observer() lbt.lon='-109:53:51.0' lbt.lat='32:41:56.9' else:
def do_simbad(catalog): # Simbad.list_votable_fields() # Some coordinates that SIMBAD claims belong to the SNe actually belong to # the host. task_str = catalog.get_current_task_str() simbadmirrors = [ 'http://simbad.harvard.edu/simbad/sim-script', 'http://simbad.u-strasbg.fr/simbad/sim-script' ] simbadbadcoordbib = [ '2013ApJ...770..107C', ] simbadbadtypebib = [ '2014ApJ...796...87I', '2015MNRAS.448.1206M', '2015ApJ...807L..18N' ] simbadbadnamebib = [ '2004AJ....127.2809W', '2005MNRAS.364.1419Z', '2015A&A...574A.112D', '2011MNRAS.417..916G', '2002ApJ...566..880G', 'url:CBAT', 'url:GPSA', ] badurlbibname = ['url:TNS', 'url:ASASSN', 'url:Lasair', 'url:AAVSO'] simbadbannedcats = ['[TBV2008]', 'OGLE-MBR'] simbadbannednames = ['SN'] customSimbad = Simbad() customSimbad.ROW_LIMIT = -1 customSimbad.TIMEOUT = 120 customSimbad.add_votable_fields('otype', 'sptype', 'sp_bibcode', 'id') table = [] print(customSimbad.SIMBAD_URL) for mirror in simbadmirrors: customSimbad.SIMBAD_URL = mirror try: table = customSimbad.query_criteria( 'maintypes=CV* | maintypes="CV?" | maintypes=No* | maintypes="No?"' ) except Exception: continue else: if not table: continue break if not table: catalog.log.warning('SIMBAD unable to load, probably offline.') # 2000A&AS..143....9W for brow in pbar(table, task_str): row = { x: re.sub(r'b\'(.*)\'', r'\1', str(brow[x])) for x in brow.colnames } # Skip items with no bibliographic info aside from SIMBAD, too # error-prone # print(row) if (not row['COO_BIBCODE'] and not row['SP_BIBCODE'] and not row['SP_BIBCODE_2'] and not row['OTYPE'] == 'Nova' and not row['OTYPE'] == 'DwarfNova'): continue if any([x in row['MAIN_ID'] for x in simbadbannedcats]): continue if row['COO_BIBCODE'] and row['COO_BIBCODE'] in simbadbadnamebib: continue name = single_spaces(re.sub(r'\[[^)]*\]', '', row['MAIN_ID']).strip()).replace('*', '_') if name in simbadbannednames: continue if is_number(name.replace(' ', '')): continue name = catalog.add_entry(name) source = (catalog.entries[name].add_source( name='SIMBAD astronomical database', bibcode="2000A&AS..143....9W", url="http://simbad.u-strasbg.fr/", secondary=True)).replace('*', '_') if row['COO_BIBCODE'] == 'url:TNS': source = ','.join([ source, catalog.entries[name].add_source( name='Transient Name Server', url='https://wis-tns.weizmann.ac.il/') ]) if row['COO_BIBCODE'] == 'url:ASASSN': source = ','.join([ source, catalog.entries[name].add_source( name='ASAS-CV Transients', bibcode="2014ApJ...788...48S", url= 'http://www.astronomy.ohio-state.edu/~assassin/transients.html' ) ]) if row['COO_BIBCODE'] == 'url:Lasair': source = ','.join([ source, catalog.entries[name].add_source( name='lASAIR Transients and Variables', bibcode="2019RNAAS...3...26S", url='https://lasair.roe.ac.uk/') ]) aliases = row['ID'].split(',') for alias in aliases: if any([x in alias for x in simbadbannedcats]): continue ali = single_spaces(re.sub(r'\[[^)]*\]', '', alias).strip()).replace('*', '_') if is_number(ali.replace(' ', '')): continue if ali in simbadbannednames: continue ali = name_clean(ali) catalog.entries[name].add_quantity(CATACLYSMIC.ALIAS, ali, source) catalog.entries[name].add_quantity( CATACLYSMIC.CLAIMED_TYPE, (row['OTYPE'].replace('CV.', 'CV').replace('CV', 'CV').replace( '(~)', '').replace('CV?', 'Candidate').replace( '*', '').replace('No?', 'Candidate Nova').strip(': ')), source) if row['COO_BIBCODE'] and row['COO_BIBCODE'] not in simbadbadcoordbib: csources = source if row['COO_BIBCODE'] not in badurlbibname: csources = ','.join([ source, catalog.entries[name].add_source( bibcode=row['COO_BIBCODE']) ]) catalog.entries[name].add_quantity(CATACLYSMIC.RA, row['RA'], csources) catalog.entries[name].add_quantity(CATACLYSMIC.DEC, row['DEC'], csources) catalog.entries[name].add_quantity( CATACLYSMIC.CLAIMED_TYPE, (row['OTYPE'].replace('CV.', 'CV').replace('CV', 'CV').replace( '(~)', '').replace('CV?', 'Candidate').replace( '*', '').replace('No?', 'Candidate Nova').strip(': ')), csources) if row['SP_BIBCODE'] and row['SP_BIBCODE'] not in simbadbadtypebib: ssources = source if row['SP_BIBCODE'] and row['SP_BIBCODE_2'] not in badurlbibname: ssources = uniq_cdl([ source, catalog.entries[name].add_source( bibcode=row['SP_BIBCODE']) ] + ([ catalog.entries[name].add_source( bibcode=row['SP_BIBCODE_2']) ] if row['SP_BIBCODE_2'] else [])) catalog.entries[name].add_quantity( CATACLYSMIC.CLAIMED_TYPE, (row['OTYPE'].replace('CV.', 'CV').replace('CV', 'CV').replace( '(~)', '').replace('CV?', 'Candidate').replace( '*', '').replace('No?', 'Candidate Nova').strip(': ')), ssources) if row['OTYPE'] == 'Nova' and row['SP_BIBCODE'] == '' and row[ 'COO_BIBCODE'] == '': catalog.entries[name].add_quantity(CATACLYSMIC.RA, row['RA'], source) catalog.entries[name].add_quantity(CATACLYSMIC.DEC, row['DEC'], source) catalog.entries[name].add_quantity(CATACLYSMIC.CLAIMED_TYPE, (row['OTYPE']), source) if row['OTYPE'] == 'DwarfNova' and row['SP_BIBCODE'] == '' and row[ 'COO_BIBCODE'] == '': catalog.entries[name].add_quantity(CATACLYSMIC.RA, row['RA'], source) catalog.entries[name].add_quantity(CATACLYSMIC.DEC, row['DEC'], source) catalog.entries[name].add_quantity(CATACLYSMIC.CLAIMED_TYPE, (row['OTYPE']), source) catalog.journal_entries() return