#This utility is meant to read data from the CSV file containing RFI count and Total Count from the real-time BB RFI filtering in GWB #It reads the CSV file(generated useing rfi_counter_flagging_v6.py with third option (3.Average Percentage flagging for all antennae)) and provides bar charts containing Average percentage flagging of all antennae and polarization without non working antenna #After Running Code First:Enter number of not working antennas for observation : #Then : Enter number of not working antennas for observation : 1 #Then : Select the antenna number from following list : 3 #Rsults Is Ready #**************************************** Updated by Rahul on 05/04/2021***************************************************** #command to run this code python3 ./rfi_counter_flagging_v6_Average_All_Ant_v1.py.py #eg: python3 ./rfi_counter_flagging_v6_Average_All_Ant_v1.py.py test.out test.out import csv import math import sys import numpy as np from operator import truediv import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt import itertools import statistics import pandas import warnings #f_name=str("test.out") #Define system arguments #f_out=str("Test.out") #start=int(17) #stop=int(577) f_name=str(sys.argv[1]) #Define system arguments f_out=str(sys.argv[2]) #No_of_Ant =str(sys.argv[3]) #start=int(sys.argv[3]) #stop=int(sys.argv[4]) #Reading Input File df = pandas.read_csv(f_name,header=None,delimiter='\t') cha=df.iloc[:,1] chb=df.iloc[:,3] p=['C00','C01','C02','C03','C04','C05','C06','C08','C09','C10','C11','C12','C13','C14','E02','E03','E04','E05','E06','S01','S02','S03','S04','S06','W01','W02','W03','W04','W05','W06'] Ant_NA = int(input("Enter number of not working antennas for observation : ")) print("Select the antenna number from following list :\n ----------------------------------------------------------------\n C00 : 0 \t C01 : 1 \t C02 : 2 \t C03 : 3 \n C04 : 4 \t C05 : 5 \t C06 : 6 \t C08 : 7 \n C09 : 8 \t C10 : 9 \t C11 : 10 \t C12 : 11 \n C13 : 12 \t C14 : 13 \t E02 : 14 \t E03 : 15 \n E04 : 16 \t E05 : 17 \t E06 : 18 \t S01 : 19 \n S02 : 20 \t S03 : 21 \t S04 : 22 \t S06 : 23 \n W01 : 24 \t W02 : 25 \t W03 : 26 \t W04 : 27 \n W05 : 28 \t W06 : 29 \n ---------------------------------------------------------------- \n") # Table for selecting antenna number for i in range(0, Ant_NA): x = int(input(':')) #data.append(p[x]) #ant = int(input("Select the antenna number from following list :\n ----------------------------------------------------------------\n C00 : 0 \t C02 : 1 \t C04 : 2 \t C06 : 3 \n C09 : 4 \t C11 : 5 \t C13 : 6 \t E02 : 7 \n E04 : 8 \t E06 : 9 \t S02 : 10 \t S04 : 11 \n W01 : 12 \t W03 : 13 \t W05 : 14 \n ---------------------------------------------------------------- \n :")) # Table for selecting antenna number print (p[x]) print (cha[x],chb[x]) warnings.filterwarnings("ignore") #ignnore warnings cha[x]=(0.0); chb[x]=(0.0) warnings.filterwarnings("ignore") #ignnore warnings print (cha[x],chb[x]) No_of_Ant = 30 - Ant_NA print("NO. of Available Antennas",No_of_Ant) print("NO. of Not Working Antennas",Ant_NA) #Calculate Average #ch1 = cha.mean(axis=0) #ch2 = chb.mean(axis=0) ch1=sum(cha)/No_of_Ant ch2=sum(chb)/No_of_Ant #print(cha) import pandas as pd data = {'Ch1':[ch1], 'Ch2':[ch2]} # Create the pandas DataFrame df2 = pd.DataFrame(data) print("Average_Percentage_Flagging_of_All_Ant:",data) ####Writing into output file #with open(f_out, 'a') as f: #Writing into output file # writer = csv.writer(f, delimiter='\t') # writer.writerows(zip([ch1],[ch2])) plt.figure(figsize=(12,10)) df2.plot.bar() plt.ylabel('Percentage Flagging') plt.title('Average Percentage flagging of all antenna') plt.legend() #plt.savefig(f_out+'Average_Percentage_Flagging_of_All_Ant.jpg')#Save figure in jpg format plt.savefig('Average_Percentage_Flagging_of_All_Ant.jpg')#Save figure in jpg format plt.tight_layout()