Created
January 28, 2020 20:26
-
-
Save thomasabbott/433bf076e2246aa4047c68fc1eae8861 to your computer and use it in GitHub Desktop.
Load and plot Galileo satellite phase centres from an Antex file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
import time | |
antexfilename='C:\\Users\\tabbott\\Desktop\\antex\\ngs14.atx' | |
def readuntil(atx,tofind): | |
comment='' | |
while comment!=tofind: | |
try: | |
lin=atx.readline() | |
if len(lin)==0: | |
print 'end of file ' | |
break | |
except: | |
print 'other error ',traceback.print_exc() | |
time.sleep(2) | |
exit(0) | |
comment=lin[60:-1].strip() | |
return comment,lin[:60] | |
atx=open(antexfilename,'r') | |
print 'opened file',atx.name | |
numstore=[] | |
neustore=np.empty((0,3)) | |
maxplots=5 | |
galcount=0 | |
lin=' ' | |
while (len(lin)>0): | |
comment,lin=readuntil(atx,'START OF ANTENNA') | |
if len(lin)>0: | |
comment,lin=readuntil(atx,'TYPE / SERIAL NO') | |
antname=lin[:20].strip() | |
antnum=lin[20:40].strip() | |
antnumlong=lin[20:60].strip() | |
if antname[:7]=='GALILEO': | |
galcount+=1 | |
comment,lin=readuntil(atx,'DAZI') | |
dazi=float(lin[:20].strip()) | |
comment,lin=readuntil(atx,'ZEN1 / ZEN2 / DZEN') | |
zen=np.fromstring(lin[:60],sep=' ') | |
comment,lin=readuntil(atx,'# OF FREQUENCIES') | |
nfreqs=int(lin[:20]) | |
print 'Line ',atx.tell(),antname,antnumlong | |
if galcount<maxplots: | |
fig,ax=plt.subplots(figsize=(8,6)) | |
for f in range(nfreqs): | |
comment,lin=readuntil(atx,'START OF FREQUENCY') | |
freqname=lin[3:20].strip() | |
comment,lin=readuntil(atx,'NORTH / EAST / UP') | |
neu=np.fromstring(lin[:60],sep=' ') | |
if True: #freqname=='E01': | |
print ' freq',freqname,'has NEU',neu | |
numstore.append(antnum) | |
neustore = np.vstack((neustore,neu)) | |
if galcount<maxplots: | |
lin=atx.readline() | |
if lin[3:8]=='NOAZI': | |
noazi=np.fromstring(lin[8:],sep=' ') | |
theta=np.linspace(zen[0],zen[1],num=int((zen[1]-zen[0])/zen[2])+1) | |
ax.plot(theta,noazi,label=freqname) | |
if galcount<maxplots: | |
ax.legend(loc=3) | |
plt.xlabel('nadir angle, degrees (12.5 deg is the limb of the earth') | |
plt.ylabel('phase centre delta, mm') | |
plt.xlim([0,12.5]); plt.ylim([-2,1]) | |
plt.title('%s - %s.\nPhase centre from CoM is N %.1f E %.1f U %.1f mm\n Deviation from phase centre, by frequency is as follows:' | |
% (antname,antnum,neu[0],neu[1],neu[2])) | |
ax.grid() | |
plt.show() | |
comment,lin=readuntil(atx,'END OF ANTENNA') | |
atx.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment