Skip to content

Commit

Permalink
corrections to the file description Compute_Plot_Galactic_Noise.py
Browse files Browse the repository at this point in the history
  • Loading branch information
snonis committed Oct 26, 2024
1 parent 2aa9d01 commit 5ec16fd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 55 deletions.
6 changes: 3 additions & 3 deletions grand/sim/noise/Compute_Plot_Galactic_Noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
#LST value for frequency plot
# Example of how to use:
#python3 Compute_plot_Galactic_Noise.py --site gp13 --du_type GP300 --run_mode Voc --lst_value 18
# For the Voc run_mode the output file that saved is in shape (221,72,3) wich means the Volts/Hz for 221 #frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min) for X, Y, Z ports.
# For the Voc run_mode the output file that saved is in shape (221,72,3) wich means the Volts^2/Hz (square Vrms) for 221 #frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min) for X, Y, Z ports.

# For the Vout run_mode the output file that saved is in shape (221,72,3) wich means the Volts/Hz for #221 frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min) for X, Y, Z ports.
# For the Vout run_mode the output file that saved is in shape (221,72,3) wich means the Volts^2/Hz (square Vrms) for #221 frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min) for X, Y, Z ports.

# For the PL run_mode the output file that saved is in shape (221,72,3) wich means the Watt/Hz for 221 #frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min) for X, Y, Z ports.

# For the Efield run_mode the output file that saved is in shape (221,72,3) wich means the <temp * kB> (J), the average radiance <B_nu> (W/m2/Hz) and the average Efiled_rms^2 (V2/m2/Hz) for 221 #frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min).
# For the Efield run_mode the output file that saved is in shape (221,72,3) wich means the <temp * kB> (J), the average radiance <B_nu> (W/m2/Hz) and the average Efiled_rms^2 (V^2/m^2/Hz) for 221 #frequencies bins (30-250 MHz step 1MHz), 72 LST bins (0:00-23:40, step 20 min).


import numpy as np
Expand Down
85 changes: 35 additions & 50 deletions grand/sim/noise/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,65 +55,50 @@ def galactic_noise(f_lst, size_out, freqs_mhz, nb_ant, seed=None, du_type='GP300
lst = int(f_lst)

if du_type == 'GP300':
gala_file = grand_add_path_data("noise/Vocmax_30-250MHz_uVperMHz_hfss.npy")
gala_file1 = grand_add_path_data("noise/Pocmax_30-250_Watt_per_MHz_hfss.npy")
gala_file2 = grand_add_path_data("noise/Pocmax_30-250_dBm_per_MHz_hfss.npy")
gala_file3 = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file3, "r")
gala_voltage = np.load(gala_file)
gala_voltage = np.transpose(gala_voltage, (0, 2, 1)) #micro Volts per MHz (max)
gala_power_watt = np.load(gala_file1)
gala_power_watt = np.transpose(gala_power_watt, (0, 2, 1)) #watt per MHz
gala_power_dbm = np.load(gala_file2)
gala_power_dbm = np.transpose(gala_power_dbm, (0, 2, 1)) # dBm per MHz
lst = int(f_lst)
gala_file = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file, "r")
gala_psd_dbm = np.transpose(gala_show["psd_narrow_huatu"])
gala_power_dbm = np.transpose(
gala_show["p_narrow_huatu"]
) # SL, dbm per MHz, P=mean(V*V)/imp with imp=100 ohms
gala_voltage = np.transpose(
gala_show["v_amplitude"]
) # SL, microV per MHz, seems to be Vmax=sqrt(2*mean(V*V)), not std(V)=sqrt(mean(V*V))
# gala_power_mag = np.transpose(gala_show["p_narrow"])
gala_freq = gala_show["freq_all"]

"""f_start = 30
f_end = 250
# TODO: 221 is the number of frequency ? why ? and comment to explain
nb_freq = 221
v_complex_double = np.zeros((nb_ant, size_out, 3), dtype=complex)
galactic_v_time = np.zeros((nb_ant, size_out, 3), dtype=float)
galactic_v_m_single = np.zeros((nb_ant, int(size_out / 2) + 1, 3), dtype=float)
galactic_v_p_single = np.zeros((nb_ant, int(size_out / 2) + 1, 3), dtype=float)"""
v_amplitude_infile = gala_voltage[:, :, lst - 1]

elif du_type == 'GP300_nec':
gala_file = grand_add_path_data("noise/Vocmax_30-250MHz_uVperMHz_nec.npy")
gala_file1 = grand_add_path_data("noise/Pocmax_30-250_Watt_per_MHz_nec.npy")
gala_file2 = grand_add_path_data("noise/Pocmax_30-250_dBm_per_MHz_nec.npy")
gala_file3 = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file3, "r")
gala_voltage = np.load(gala_file)
gala_voltage = np.transpose(gala_voltage, (0, 2, 1)) #micro Volts per MHz (max)
gala_power_watt = np.load(gala_file1)
gala_power_watt = np.transpose(gala_power_watt, (0, 2, 1)) #watt per MHz
gala_power_dbm = np.load(gala_file2)
gala_power_dbm = np.transpose(gala_power_dbm, (0, 2, 1)) # dBm per MHz
lst = int(f_lst)
gala_file = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file, "r")
gala_psd_dbm = np.transpose(gala_show["psd_narrow_huatu"])
gala_power_dbm = np.transpose(
gala_show["p_narrow_huatu"]
) # SL, dbm per MHz, P=mean(V*V)/imp with imp=100 ohms
gala_voltage = np.transpose(
gala_show["v_amplitude"]
) # SL, microV per MHz, seems to be Vmax=sqrt(2*mean(V*V)), not std(V)=sqrt(mean(V*V))
# gala_power_mag = np.transpose(gala_show["p_narrow"])
gala_freq = gala_show["freq_all"]
"""f_start = 30
f_end = 250
# TODO: 221 is the number of frequency ? why ? and comment to explain
nb_freq = 221
v_complex_double = np.zeros((nb_ant, size_out, 3), dtype=complex)
galactic_v_time = np.zeros((nb_ant, size_out, 3), dtype=float)
galactic_v_m_single = np.zeros((nb_ant, int(size_out / 2) + 1, 3), dtype=float)
galactic_v_p_single = np.zeros((nb_ant, int(size_out / 2) + 1, 3), dtype=float)"""
v_amplitude_infile = gala_voltage[:, :, lst - 1]

elif du_type == 'GP300_mat':
gala_file = grand_add_path_data("noise/Vocmax_30-250MHz_uVperMHz_mat.npy")
gala_file1 = grand_add_path_data("noise/Pocmax_30-250_Watt_per_MHz_mat.npy")
gala_file2 = grand_add_path_data("noise/Pocmax_30-250_dBm_per_MHz_mat.npy")
gala_file3 = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file3, "r")
gala_voltage = np.load(gala_file)
gala_voltage = np.transpose(gala_voltage, (0, 2, 1)) #micro Volts per MHz (max)
gala_power_watt = np.load(gala_file1)
gala_power_watt = np.transpose(gala_power_watt, (0, 2, 1)) #watt per MHz
gala_power_dbm = np.load(gala_file2)
gala_power_dbm = np.transpose(gala_power_dbm, (0, 2, 1)) # dBm per MHz
lst = int(f_lst)

gala_file = grand_add_path_data("noise/30_250galactic.mat")
gala_show = h5py.File(gala_file, "r")
gala_psd_dbm = np.transpose(gala_show["psd_narrow_huatu"])
gala_power_dbm = np.transpose(
gala_show["p_narrow_huatu"]
) # SL, dbm per MHz, P=mean(V*V)/imp with imp=100 ohms
gala_voltage = np.transpose(
gala_show["v_amplitude"]
) # SL, microV per MHz, seems to be Vmax=sqrt(2*mean(V*V)), not std(V)=sqrt(mean(V*V))
# gala_power_mag = np.transpose(gala_show["p_narrow"])
gala_freq = gala_show["freq_all"]

"""f_start = 30
f_end = 250
# TODO: 221 is the number of frequency ? why ? and comment to explain
Expand Down
5 changes: 3 additions & 2 deletions scripts/convert_efield2voltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def manage_args():

parser.add_argument(
"--rf_chain_gaa",
action="store_false",
action="store_true",
default=False,
help="add RF chain for G@Auger setup",
)
Expand Down Expand Up @@ -160,7 +160,8 @@ def manage_args():
signal.params["add_noise"] = args.no_noise
signal.params["add_rf_chain"] = args.no_rf_chain
signal.params["lst"] = args.lst

signal.params["add_rf_chain_nut"] = args.rf_chain_nut
signal.params["add_rf_chain_gaa"] = args.rf_chain_gaa
#signal.compute_voltage_event(0)
#signal.save_voltage(append_file=False)
signal.compute_voltage() # saves automatically
Expand Down

0 comments on commit 5ec16fd

Please sign in to comment.