pyuvdata icon indicating copy to clipboard operation
pyuvdata copied to clipboard

read_cst_beam turning negative gain values into positives

Open mickeyhorn opened this issue 5 years ago • 2 comments
trafficstars

I am attempting to use the read_cst_beam feature of UVBeam and am running into an odd bug. Chiropter_NS_PECBico_ff70_YupZnull.txt is a standard CST export file of the directivity/gain of the farfield beam. You'll see that both plots show points around +60dB, but the maximum value of the text file is 1.9. There appears to be some sort of inversion happening at some points.

import os
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import cm,colors,ticker
from pyuvdata import UVBeam
from pyuvdata.data import DATA_PATH
beam = UVBeam()
%matplotlib notebook

CST_txtfile = ['Chiropter_NS_PECBico_ff70_YupZnull.txt']
beam.read_cst_beam(CST_txtfile, beam_type='efield', frequency=[70e6], 
                   telescope_name='Chiropter', feed_name='BicoLOG', feed_version='1.0', 
                   model_name = 'Chiropter_NS_2019', model_version='1.0', feed_pol='y')

plt.figure()
ax1 = plt.subplot(121)
ax1.plot(beam.axis2_array*180/np.pi, beam.data_array[0, 0, 0, 0, :, 0],'.')
ax1.set_xlabel('Zenith Angle / Theta (degrees)') 
ax1.set_ylabel('Gain (dB)')
ax1.set_ylim(-80,80)
ax1.set_yticks(np.arange(-80,81,20))

ax2 = plt.subplot(122, sharey=ax1)
ax2.plot(beam.axis1_array*180/np.pi, beam.data_array[0, 0, 0, 0, 0, :],'.')
ax2.set_xlabel('Azimuth Angle / Phi (degrees)')
plt.setp(ax2.get_yticklabels(), visible=False)
plt.subplots_adjust(wspace=0)

raw_data = np.loadtxt('Chiropter_NS_PECBico_ff70_YupZnull.txt',skiprows=2,usecols=(0,1,2))
gain = raw_data[:,2]
print(np.max(gain),np.min(gain))

mickeyhorn avatar Jun 15 '20 20:06 mickeyhorn

Here's a 3D image of the exported beam. YupZnullsouthXeast

mickeyhorn avatar Jun 15 '20 20:06 mickeyhorn

Hi Mickey, thanks for making the issue and I'm sorry I've been slow. The CST beam reader for UVBeam currently does not properly support directivity files (with units in dBi), rather it supports farfield E files (with units in V or V/m).

We have had an open issue for a long time to get the proper documentation about how to export the correct file type from CST, but I haven't managed to get that documentation from the right people. I will ping them again and try to get that documentation, unfortunately I know very little about CST. @jaguirre do you have this kind of thing?

I am willing to help make the reader more flexible to support directivities, but I need someone who really understands these simulations to help me figure out what needs to be different for that file type. We actually had a PR in the past to do that, but I couldn't ever get the information I needed to figure it out (see #438).

bhazelton avatar Jun 28 '20 00:06 bhazelton