Example #1
0
import sys
import NuRadioReco.detector.detector as detector
from astropy.time import Time
import numpy as np
import matplotlib.pyplot as plt


list_of_files = ['dipoles_RNOG_200m_2.00km.json', 'dipoles_RNOG_20m_1.00km.json']

dets = []
print(list_of_files)
for iF, file in enumerate(list_of_files):
	det = detector.Detector(json_filename=list_of_files[iF], antenna_by_depth=False, create_new=True)
	dets.append(det)
	print(det.get_station_ids())

print(dets)
Example #2
0
from NuRadioReco.framework.parameters import stationParameters as stnp

logging.basicConfig(level=logging.INFO)

# Parse eventfile as argument
parser = argparse.ArgumentParser(description='NuRadioSim file')
parser.add_argument('inputfilename',
                    type=str,
                    help='path to NuRadioMC simulation result')
parser.add_argument('detectordescription',
                    type=str,
                    help='path to detectordescription')
args = parser.parse_args()

# read in detector positions (this is a dummy detector)
det = detector.Detector(json_filename=args.detectordescription)

# initialize modules
eventReader = NuRadioReco.modules.io.eventReader.eventReader()
eventReader.begin(args.inputfilename)

#for plotting
fig = plt.figure()

channelCtr = 0

for event in eventReader.run():
    binNum = 0
    channelNum = 0
    dt = 0.0
    event_id = event.get_id()
Example #3
0
if (station_id == 32):
    triggered_channels = [0, 1, 2, 3]
    used_channels_efield = [0, 1, 2, 3]
    used_channels_fit = [0, 1, 2, 3]
    channel_pairs = ((0, 2), (1, 3))
else:
    print("Default channels not defined for station_id != 32")

try:
    detector_file = sys.argv[3]
    print("Using {0} as detector".format(detector_file))
except:
    print("Using default file for detector")
    detector_file = '../examples/example_data/arianna_station_32.json'

det = detector.Detector(json_filename=detector_file)  # detector file
det.update(datetime.datetime(2018, 10, 1))

dir_path = os.path.dirname(
    os.path.realpath(__file__))  # get the directory of this file

# initialize all modules that are needed for processing
# provide input parameters that are to remain constant during processung
readCoREAS = NuRadioReco.modules.io.coreas.readCoREAS.readCoREAS()
readCoREAS.begin([input_file], station_id, n_cores=10, max_distance=None)
simulationSelector = NuRadioReco.modules.io.coreas.simulationSelector.simulationSelector(
)
simulationSelector.begin()
efieldToVoltageConverter = NuRadioReco.modules.efieldToVoltageConverter.efieldToVoltageConverter(
)
efieldToVoltageConverter.begin(debug=False)
Example #4
0
Tnoise = 300
Vrms = (Tnoise * 50 * constants.k * 500 * units.MHz / units.Hz)**0.5

plot = False
counter = -1
filename = sys.argv[1]
x = float(sys.argv[2]) * units.m
print("using file {} and distance {:.0f}m".format(filename, x / units.m))

fin = h5py.File(filename)
print(np.log10(fin.attrs['Emin']))

with open('det.json', 'w') as fout:
    fout.write(fin.attrs['detector'])
    fout.close()
det = detector.Detector(json_filename="det.json")
max_amps_env = np.array(fin['station_101']['maximum_amplitudes_envelope'])
weights = fin['weights']

n_channels = det.get_number_of_channels(101)
n_stations = det.get_number_of_channels(
    101) / 4  # (we had 4 antennas per station)
xs = np.zeros(n_stations)
ys = np.zeros(n_stations)

triggered_near_surface = np.any(
    max_amps_env[:, 0:3] > (3 * Vrms),
    axis=1)  # triggered any LPDA or dipole of the center station
triggered_near_deep = max_amps_env[:, 3] > (3 * Vrms)  # triggered deep dipole
triggered_surface = np.zeros(
    (max_amps_env.shape[0],
Example #5
0
import sys
import NuRadioReco.detector.detector as detector
from astropy.time import Time
import numpy as np

det = detector.Detector(json_filename=sys.argv[1], antenna_by_depth=False)
det.update(Time.now())

f = open(sys.argv[1] + '.csv', 'w')

station_ids = det.get_station_ids()
for station_id in station_ids:
    loc = det.get_absolute_position(station_id)
    f.write("{}, {}, {}\n".format(station_id, loc[0], loc[1]))
Example #6
0
                    help='number of channels to phase',
                    default=4)

args = parser.parse_args()

if (args.threshold == -1.0):
    thresholds = np.arange(0.5, 2.0, 0.05)
else:
    thresholds = np.array([float(args.thresholds)])

det_file = args.detectordescription
n_channels = args.nchannels
ntrials = args.ntries
ncpus = args.ncpus

det = detector.Detector(json_filename=det_file)
det.update(Time.now())

channelBandPassFilter = NuRadioReco.modules.channelBandPassFilter.channelBandPassFilter(
)

main_low_angle = np.deg2rad(-59.55)
main_high_angle = np.deg2rad(59.55)
channels = []

station_id = 1
n_samples = det.get_number_of_samples(
    station_id, 1)  # we assume that all channels have the same parameters
sampling_rate = det.get_sampling_frequency(station_id, 1)
print(f"sampling rate = {sampling_rate/units.MHz}MHz, {n_samples} samples")
# det_files = ['pa_200m_2.00km.json', 'surface_4LPDA_PA_15m_RNOG_300K_1.50km.json']
det_files = [
    'pa_200m_2.00km.json', 'surface_4LPDA_PA_15m_RNOG_300K_1.00km.json'
]
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111)
markers = ['o', 'x', '+']
det_file_to_label_map = {
    'pa_200m_2.00km.json': 'Deep',
    'surface_4LPDA_PA_15m_RNOG_300K_1.00km.json': 'Surface 1km',
    'surface_4LPDA_PA_15m_RNOG_300K_1.50km.json': 'Surface 1.5km',
}

for idet, det_file in enumerate(det_files):
    det = detector.Detector(json_filename=det_file,
                            antenna_by_depth=False,
                            create_new=True)
    det.update(Time.now())
    station_ids = det.get_station_ids()

    print('num stations {}'.format(len(station_ids)))

    x = []
    y = []

    station_ids = det.get_station_ids()
    for station_id in station_ids[0:10]:
        loc = det.get_absolute_position(station_id)
        print(loc)
        x.append(loc[0] / scale)
        y.append(loc[1] / scale)
Example #8
0
import NuRadioReco.detector.detector as detector
from astropy.time import Time

det_deep = detector.Detector(json_filename='pa_200m_2.00km.json',
                             antenna_by_depth=False,
                             create_new=True)
det_deep.update(Time.now())
deep_station_ids = det_deep.get_station_ids()

det_shallow = detector.Detector(
    json_filename='surface_4LPDA_PA_15m_RNOG_300K_1.00km.json',
    antenna_by_depth=False,
    create_new=False)

for d_id in deep_station_ids:
    loc_deep = det_deep.get_absolute_position(d_id)
    print("Station {}, Deep {}".format(d_id, loc_deep))

print(det_deep)
print(det_shallow)
print(det_deep)

# for s_id in shallow_station_ids:
# 	loc_shallow = det_shallow.get_absolute_position(s_id)
# 	print("Station {}, Shallow {}".format(s_id, loc_shallow))

# for deep_station in deep_station_ids:
# 	loc_deep = det_deep.get_absolute_position(deep_station)
# 	loc_shallow = det_shallow.get_absolute_position(deep_station)
# 	print("Station {}, Deep {}, Shallow {}".format(deep_station, loc_deep, loc_shallow))
Example #9
0
parser = argparse.ArgumentParser(description='NuRadioSim file')
parser.add_argument('inputfilename',
                    type=str,
                    help='path to NuRadioMC simulation result')
# parser.add_argument('detectordescription', type=str,
#                     help='path to detectordescription')
args = parser.parse_args()

pos_SP1 = np.array(
    [41153.2175 * units.feet, 50381.75 * units.feet, -1.5 * units.m])
pos_spice = np.array([42600, 48800, 0]) * units.feet

print('distance = {:.2f}'.format(np.linalg.norm(pos_SP1 - pos_spice)))

# read in detector positions (this is a dummy detector)
det = detector.Detector()

t1 = datetime(2018, 12, 30, 22, 30, 22)
t2 = datetime(2018, 12, 31, 2, 3, 11)
# initialize modules
eventReader = NuRadioReco.modules.io.eventReader.eventReader()
eventReader.begin(args.inputfilename)

results = {
    'corr_LPDA': [],
    'corr_dipole': [],
    'depth': [],
    'exp': [],
    'time_LPDA': [],
    'time_dipole': [],
    'chi2_time_dipole': [],
Example #10
0
def plot_shallow_detectors():
	scale=1000
	det_files_deep = ['surface_4LPDA_PA_15m_RNOG_1.00km.json', 'surface_4LPDA_PA_15m_RNOG_1.50km.json']
	det_file_to_label_map = {
		'surface_4LPDA_PA_15m_RNOG_1.00km.json' : '1 km spacing',
		'surface_4LPDA_PA_15m_RNOG_1.50km.json' : '1.5 km spacing',
	}

	# top down
	fig_deep = plt.figure(figsize=(6,5))
	ax_deep = fig_deep.add_subplot(111)
	markers = ['o', 'x']
	colors = ['C0', 'C3']

	fig_deep_side, axs_deep_side = plt.subplots(1,1, figsize=(5,5))
	fig_top_station, ax_top_station = plt.subplots(1,1, figsize=(5,5))

	for idet, det_file in enumerate(det_files_deep):

		det = detector.Detector(json_filename='det_files/'+det_file, antenna_by_depth=False, create_new=True)
		det.update(Time.now())

		station_ids = det.get_station_ids()

		if idet==0:
			# side view
			local_x_8chan = []
			local_x_4chan = []
			local_x_lpda = []
			z_lpda = []
			z_8chan = []
			z_4chan = []
			n_channels = det.get_number_of_channels(1)
			for channel_id in range(n_channels):
				loc = det.get_relative_position(1, channel_id)
				if channel_id < 4:
					local_x_lpda.append(loc[0])
					z_lpda.append(loc[2])
				else:
					z_8chan.append(loc[2])
					local_x_8chan.append(loc[0])
					if channel_id in range(6,10):
						z_4chan.append(loc[2])
						local_x_4chan.append(loc[0])
			axs_deep_side.plot(local_x_lpda, z_lpda, 'C0v', label='LPDAs')
			axs_deep_side.plot(local_x_8chan, z_8chan, 'kd', label='8 ch PA')
			axs_deep_side.plot(local_x_4chan, z_4chan, 'rx', markersize=12, linewidth=12, label='4 ch PA')

			# top down view of station
			local_x_lpda= []
			local_y_lpda = []
			local_x_dipoles = []
			local_y_dipoles = []
			n_channels = det.get_number_of_channels(1)
			for channel_id in range(n_channels):
				loc = det.get_relative_position(1, channel_id)
				if channel_id < 4:
					the_x = loc[0]
					the_y = loc[1]
					x_for_plotting = []
					y_for_plotting = []
					if abs(the_y) > 1:
						# top or bottom antenna
						x_for_plotting.append(the_x+0.5)
						x_for_plotting.append(the_x-0.5)
						y_for_plotting.append(the_y)
						y_for_plotting.append(the_y)
					else:
						# right or left antenna
						x_for_plotting.append(the_x)
						x_for_plotting.append(the_x)
						y_for_plotting.append(the_y+0.5)
						y_for_plotting.append(the_y-0.5)
					if channel_id==1:
						ax_top_station.plot(x_for_plotting, y_for_plotting, 'C0', 
							linewidth=4,
							label='LPDAs')
					else:
						ax_top_station.plot(x_for_plotting, y_for_plotting, 'C0',
							linewidth=4)
				else:
					local_x_dipoles.append(loc[0])
					local_y_dipoles.append(loc[1])
			ax_top_station.plot(local_x_dipoles, local_y_dipoles, 'ro', label='PA String')

		# top down view of array
		x = []
		y = []

		station_ids = det.get_station_ids()
		print("Num stations is {}".format(len(station_ids)))
		for station_id in station_ids:
			loc = det.get_absolute_position(station_id)
			x.append(loc[0]/scale)
			y.append(loc[1]/scale)

		ax_deep.plot(x, y, markers[idet],
			markersize=3,
			# color=colors[idet],
			label=det_file_to_label_map[det_file])

	# side figure of single station
	axs_deep_side.set_xlabel(r'X [m]', size=15)
	axs_deep_side.set_ylabel(r'Depth [m]', size=15)
	axs_deep_side.set_xlim([-3.5, 3.5])
	axs_deep_side.set_ylim([-25, 1])
	# axs_deep_side.set_aspect('equal')
	axs_deep_side.set_title("Side View")
	axs_deep_side.tick_params(labelsize=15)
	axs_deep_side.legend(loc='lower left')
	axs_deep_side.legend()
	plt.tight_layout()
	fig_deep_side.savefig('shallow_detectors_side.png', dpi=300, edgecolor='none', bbox_inches='tight')

	# top down figure of single station
	ax_top_station.set_xlabel(r'X [m]',size=15)
	ax_top_station.set_ylabel(r'Y [m]',size=15)
	ax_top_station.set_xlim([-3.5, 3.5])
	ax_top_station.set_aspect('equal')
	ax_top_station.tick_params(labelsize=15)
	ax_top_station.legend()
	ax_top_station.set_title("Top Down View")
	plt.tight_layout()
	fig_top_station.savefig('shallow_detectors_topdown_station.png', dpi=300, edgecolor='none', bbox_inches='tight')

	# top down figure of array	
	ax_deep.set_xlabel(r'Easting [km]',size=15)
	ax_deep.set_ylabel(r'Northing [km]',size=15)
	ax_deep.set_xlim([-15000/scale, 15000/scale])
	ax_deep.set_ylim([-15000/scale, 15000/scale])
	ax_deep.set_aspect('equal')
	ax_deep.tick_params(labelsize=15)
	ax_deep.legend()
	plt.tight_layout()
	fig_deep.savefig('shallow_detectors.png', dpi=300, edgecolor='none', bbox_inches='tight')
Example #11
0
def plot_deep_detectors():
	scale=1000
	det_files_deep = ['pa_100m_2.00km.json', 'pa_200m_3.00km.json']
	det_file_to_label_map = {
		'pa_100m_2.00km.json' : '2km spacing',
		'pa_100m_3.00km.json' : '3km spacing',
		'pa_200m_3.00km.json' : '3km spacing'
	}

	det_file_to_depth_map = {
		'pa_100m_2.00km.json' : '100m deep',
		'pa_100m_3.00km.json' : '100m deep',
		'pa_200m_3.00km.json' : '200m deep'
	}

	# top down
	fig_deep = plt.figure(figsize=(6,5))
	ax_deep = fig_deep.add_subplot(111)
	markers = ['o', 'x']

	fig_deep_side, axs_deep_side = plt.subplots(1,2, figsize=(10,5))

	for idet, det_file in enumerate(det_files_deep):

		det = detector.Detector(json_filename='det_files/'+det_file, antenna_by_depth=False, create_new=True)
		det.update(Time.now())

		station_ids = det.get_station_ids()

		# side view
		local_x = []
		z_8chan = []
		z_4chan = []
		n_channels = det.get_number_of_channels(1)
		for channel_id in range(n_channels):
			loc = det.get_relative_position(1, channel_id) + det.get_absolute_position(1)
			z_8chan.append(loc[2])
			if channel_id in range(2,6):
				z_4chan.append(loc[2])
			local_x.append(0)
		axs_deep_side[idet].plot(local_x, z_8chan, 'kd', label='8 ch PA')
		axs_deep_side[idet].plot(local_x[0:4], z_4chan, 'rx', markersize=12, linewidth=12, label='4 ch PA')
		axs_deep_side[idet].set_title(det_file_to_depth_map[det_file], size=15)

		# top down view
		x = []
		y = []

		station_ids = det.get_station_ids()
		for station_id in station_ids:
			loc = det.get_absolute_position(station_id)
			x.append(loc[0]/scale)
			y.append(loc[1]/scale)

		ax_deep.plot(x, y, markers[idet], label=det_file_to_label_map[det_file])

	# top down figure
	for ax in axs_deep_side.reshape(-1):
		ax.set_xlabel(r'X [m]', size=15)
		ax.set_ylabel(r'Depth [m]', size=15)
		ax.set_xlim([-2.5, 2.5])
		ax.set_aspect('equal')
		ax.tick_params(labelsize=15)
		ax.legend(loc='lower left')
	plt.tight_layout()
	fig_deep_side.savefig('deep_detectors_side.png', dpi=300, edgecolor='none', bbox_inches='tight')

	# side figure
	ax_deep.set_xlabel(r'Easting [km]',size=15)
	ax_deep.set_ylabel(r'Northing [km]',size=15)
	ax_deep.set_xlim([-15000/scale, 15000/scale])
	ax_deep.set_ylim([-15000/scale, 15000/scale])
	ax_deep.set_aspect('equal')
	ax_deep.tick_params(labelsize=15)
	ax_deep.legend()
	plt.tight_layout()
	fig_deep.savefig('deep_detectors.png', dpi=300, edgecolor='none', bbox_inches='tight')
Example #12
0
from NuRadioReco.utilities import units
import NuRadioReco.framework.channel
import NuRadioReco.framework.station
import NuRadioReco.framework.event
import NuRadioReco.modules.channelResampler
import NuRadioReco.modules.channelGenericNoiseAdder
import NuRadioReco.modules.channelBandPassFilter
import NuRadioReco.modules.channelSignalReconstructor
import NuRadioReco.modules.channelLengthAdjuster
import NuRadioReco.utilities.diodeSimulator
import NuRadioReco.modules.ARA.triggerSimulator
import NuRadioReco.modules.trigger.highLowThreshold
from NuRadioReco.modules.base import module
from NuRadioReco.detector import detector
from NuRadioReco.framework.parameters import channelParameters as chp
det = detector.Detector(json_filename='../example_data/dummy_detector.json')

logger = module.setup_logger(level=logging.WARNING)

channelGenericNoiseAdder = NuRadioReco.modules.channelGenericNoiseAdder.channelGenericNoiseAdder(
)
channelGenericNoiseAdder.begin(debug=False)
channelResampler = NuRadioReco.modules.channelResampler.channelResampler()
channelSignalReconstructor = NuRadioReco.modules.channelSignalReconstructor.channelSignalReconstructor(
)
channelSignalReconstructor.begin(debug=False)
channelBandPassFilter = NuRadioReco.modules.channelBandPassFilter.channelBandPassFilter(
)
channelLengthAdjuster = NuRadioReco.modules.channelLengthAdjuster.channelLengthAdjuster(
)
channelLengthAdjuster.begin(number_of_samples=400, offset=50)