SEarch for Fringe-FindERS (for a given VLBI observation)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.9 KiB

#!/usr/bin/env python3
import argparse
import sys
import numpy as np
import math
import webbrowser
import requests
from os import path,remove
from stations import Station
from util_functions import *
from sources import Flux,Source,load_rfc_cat, get_up_sources
def print_sources(sources):
print("{:>2} {:4} {:12} {:11} {:}".format('#', 'Cal?', 'Source name', 'Other name', 'Flux Unresolved (at {}-band)'.format(rfcBand)))
for i,source in enumerate(sources):
if i > 9:
print("{:2} {:4} {:12} {:11} {:3.2f} {:3.2f}".format(i, 'Y' if source.isCal else 'N',, source.ivsname, source.flux[rfcBand].resolved, source.flux[rfcBand].unresolved))
#parse inputs
parser = argparse.ArgumentParser(description='Provide some options for sources to use as fringe finders.\nBased on RfC catalogue.')
parser.add_argument('timeStart', type=str, help="The start date/time of your experiment. Format ='DD/MM/YYYY HH:MM'")
parser.add_argument('duration', type=float, help="The duration of your experiment (in hours)")
parser.add_argument('-b', "--band", type=str, default='c', help="The band you are searching for, one of l, s, c, m, x, u, k, q.\nIf not specified will default to using C-band fluxes as priority.")
parser.add_argument('-e', "--min-el", type=int, default=20, help="The minimum elevation to consider a source being 'up'. Defaults to 20.")
parser.add_argument('-f', "--min-flux", type=float, default=1.0, help="The mimimum flux density of sources to consider. Defaults to 1.0 Jy")
parser.add_argument('stations',type=str, nargs='+', help="Space delimited list of stations")
args = parser.parse_args()
directory = path.dirname(path.realpath(__file__))
import wget
#need to get rfc catalogue if we don't have it
if not path.isfile(directory+"/rfc_2018c_cat.txt"):
print("RFC VLBI Source Position Catalogue not found, downloading.\nThis might take a moment...")
url = "", out=directory)
#rfc only has fluxes for bands, s, c, u, and k so pick the closest band to requested.
if in ['l', 's']:
rfcBand = 's'
elif in ['c','m']:
rfcBand = 'c'
elif == 'x':
rfcBand = 'x'
elif == 'u':
rfcBand = 'u'
elif in ['k','q']:
rfcBand = 'k'
#not a known band?
print("Error band {} is unknown.".format(
#load station information for all stations.
stationList = Station.stations_from_file(directory+'/station_location.txt')
stations = [stationList[station.upper()] for station in args.stations]
obsTimes = get_obs_times(get_time(args.timeStart), args.duration)
sourceCat = load_rfc_cat(directory+"/rfc_2018c_cat.txt", rfcBand, args.min_flux)
sources = get_up_sources(stations, sourceCat, obsTimes, minEl=args.min_el, minFluxBand=rfcBand)
#ask which source to plot
while True:
srcIndex = input("Please select the source to plot (0-9, q to quit): ")
if srcIndex == 'q':
try: srcIndex = int(srcIndex)
except ValueError:
print("Must be an int (or q)!")
if srcIndex in (list(range(10)) if len(sources) > 10 else list(range(len(sources)))):
print("Astrogeo calibrator link, has source maps, radplots:")
print(sources[srcIndex].get_astrogeo_link()), new=0, autoraise=True)
if len(links) > 0:
print("The following NMEs have included this source:")
for a,b in zip(links[::2], links[1::2]):
print ("{:55} {:55}".format(a, b))
print("No NME has included this source")
#plot the elevations for the selected source
sources[srcIndex].plot_elevation(stations, obsTimes)
print("Not in range")