Compare commits
No commits in common. "40145bc055c25ffce09b27564de6c82fa112c0cb" and "3f645143cd13886f649a849f5e824e864e9b101a" have entirely different histories.
40145bc055
...
3f645143cd
4 changed files with 0 additions and 272 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
data/
|
|
||||||
|
|
||||||
BIN
.swa.py.swp
BIN
.swa.py.swp
Binary file not shown.
134
swa.py
134
swa.py
|
|
@ -1,136 +1,2 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
from spacepy import pycdf
|
|
||||||
import numpy as np
|
|
||||||
import datetime
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import matplotlib.dates as mdates
|
|
||||||
from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
datadir = '/home/nicolassurface/ET-U2-SWA/data'
|
|
||||||
# EAS1 filename
|
|
||||||
fname_1 = 'solo_L1_swa-eas1-NM3D_20220407T000004-20220407T060504_V01.cdf'
|
|
||||||
# EAS2 filename
|
|
||||||
fname_2 = 'solo_L1_swa-eas2-NM3D_20220407T000004-20220407T060504_V01.cdf'
|
|
||||||
|
|
||||||
# EAS1
|
|
||||||
file_1 = pycdf.CDF(datadir+fname_1)
|
|
||||||
time_1 = file_1['EPOCH'][...]
|
|
||||||
counts_1 = file_1['SWA_EAS1_Data'][...]
|
|
||||||
elev_1 = file_1['SWA_EAS_ELEVATION'][...]
|
|
||||||
azim_1 = file_1['SWA_EAS_AZIMUTH'][...]
|
|
||||||
energy_1 = file_1['SWA_EAS1_ENERGY'][...]
|
|
||||||
file_1.close()
|
|
||||||
|
|
||||||
# EAS2
|
|
||||||
file_2 = pycdf.CDF(datadir+fname_2)
|
|
||||||
time_2 = file_2['EPOCH'][...]
|
|
||||||
counts_2 = file_2['SWA_EAS2_Data'][...]
|
|
||||||
elev_2 = file_2['SWA_EAS_ELEVATION'][...]
|
|
||||||
azim_2 = file_2['SWA_EAS_AZIMUTH'][...]
|
|
||||||
energy_2 = file_2['SWA_EAS2_ENERGY'][...]
|
|
||||||
file_2.close()
|
|
||||||
|
|
||||||
# Sum over energy, azimuth and elevation:
|
|
||||||
def sum3d(counts, dimA, dimB, dimC):
|
|
||||||
sum3d_counts = np.sum(np.sum(np.sum(counts, axis=dimA), axis=dimB), axis=dimC)
|
|
||||||
return sum3d_counts.T
|
|
||||||
counts_tot_1 = sum3d(counts_1, 3, 2, 1) # EAS1
|
|
||||||
counts_tot_2 = sum3d(counts_2, 3, 2, 1) # EAS2
|
|
||||||
|
|
||||||
def sum2d(counts, dimA, dimB):
|
|
||||||
sum2d_counts = np.sum(np.sum(counts, axis=dimA), axis=dimB)
|
|
||||||
return sum2d_counts.T
|
|
||||||
# Sum over azimuth and elevation:
|
|
||||||
counts_energy_spectro_1 = sum2d(counts_1, 3, 1) # EAS1
|
|
||||||
counts_energy_spectro_2 = sum2d(counts_2, 3, 1) # EAS2
|
|
||||||
# Sum over energy and elevtion
|
|
||||||
counts_azim_spectro_1 = sum2d(counts_1, 2, 1) # EAS1
|
|
||||||
counts_azim_spectro_2 = sum2d(counts_2, 2, 1) # EAS2
|
|
||||||
# Sum over energy and azimuth
|
|
||||||
counts_elev_spectro_1 = sum2d(counts_1, 3, 2) # EAS1
|
|
||||||
counts_elev_spectro_2 = sum2d(counts_2, 3, 2) # EAS2
|
|
||||||
|
|
||||||
def make_plots(fname, time, counts_tot, energy, azim, elev, counts_energy_spectro, counts_azim_spectro, counts_elev_spectro):
|
|
||||||
# Set figure size
|
|
||||||
fig = plt.figure(figsize=(15,10))
|
|
||||||
fig.subplots_adjust(hspace=0.25)
|
|
||||||
# Set time range
|
|
||||||
t1 = datetime.datetime(year=int(fname[22:26]), month=int(fname[26:28]), day=int(fname[28:30]), \
|
|
||||||
hour=int(fname[31:33]), minute=int(fname[33:35])) # set start time
|
|
||||||
t2 = datetime.datetime(year=int(fname[38:42]), month=int(fname[42:44]), day=int(fname[44:46]), \
|
|
||||||
hour=int(fname[47:49]), minute=int(fname[49:51])) # set end time
|
|
||||||
xfmt = mdates.DateFormatter('%H:%M')
|
|
||||||
# Line plot
|
|
||||||
x = time
|
|
||||||
y = counts_tot
|
|
||||||
ax1 = fig.add_subplot(411)
|
|
||||||
ax1.plot(x, y, linewidth=0.5, color='k')
|
|
||||||
ax1.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax1.set_xlim(t1, t2)
|
|
||||||
ax1.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
|
|
||||||
ax1.set_xlabel('Time (HH:MM)')
|
|
||||||
ax1.set_ylabel('Total counts')
|
|
||||||
ax1.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax1.set_title('SWA-EAS%s Nominal Mode 3D Data: %s %s-%s\n' %(str(fname)[15:16], str(t1)[0:10], str(t1)[11:16], str(t2)[11:16]))
|
|
||||||
ax1_divider = make_axes_locatable(ax1)
|
|
||||||
ax1.tick_params(width=0.5, length=1.5)
|
|
||||||
cax1 = ax1_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax1.axis('off')
|
|
||||||
cax1.tick_params(width=0.5, length=1.5)
|
|
||||||
# Energy spectrogram
|
|
||||||
x, y = np.meshgrid(time, energy[1,:])
|
|
||||||
ax2 = fig.add_subplot(412)
|
|
||||||
CS2 = ax2.pcolormesh(x[:,:], y[:,:], np.log10(counts_energy_spectro[:,:]), cmap='jet') # plot spectrogram
|
|
||||||
ax2.set_yscale('log')
|
|
||||||
ax2.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax2.set_xlim(t1, t2)
|
|
||||||
ax2.tick_params(labelbottom=True)
|
|
||||||
ax2.set_xlabel('Time (HH:MM)')
|
|
||||||
ax2.set_ylabel('Energy (eV)')
|
|
||||||
ax2.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax2_divider = make_axes_locatable(ax2)
|
|
||||||
ax2.tick_params(width=0.5, length=1.5)
|
|
||||||
cax2 = ax2_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax2.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar2 = plt.colorbar(CS2, cax=cax2, label='$\mathregular{log_{10}}$(Counts)')
|
|
||||||
cbar2.minorticks_off()
|
|
||||||
# Azimuth spectrogram
|
|
||||||
x, y = np.meshgrid(time, azim)
|
|
||||||
ax3 = fig.add_subplot(413)
|
|
||||||
CS3 = ax3.pcolormesh(x[:,:], y[:,:], counts_azim_spectro[:,:], cmap='jet')
|
|
||||||
ax3.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax3.set_xlim(t1, t2)
|
|
||||||
ax3.tick_params(labelbottom=True)
|
|
||||||
ax3.set_xlabel('Time (HH:MM)')
|
|
||||||
ax3.set_ylabel('Azimuth ($^\circ$)')
|
|
||||||
ax3.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax3_divider = make_axes_locatable(ax3)
|
|
||||||
ax3.tick_params(width=0.5, length=1.5)
|
|
||||||
cax3 = ax3_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax3.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar3 = plt.colorbar(CS3, cax=cax3, label='Counts')
|
|
||||||
cbar3.formatter.set_powerlimits((0,0))
|
|
||||||
cbar3.minorticks_off()
|
|
||||||
# Elevation spectrogram
|
|
||||||
x, y = np.meshgrid(time, elev)
|
|
||||||
ax4 = fig.add_subplot(414)
|
|
||||||
CS4 = ax4.pcolormesh(x[:,:], y[:,:], counts_elev_spectro[:,:][::-1], cmap='jet')
|
|
||||||
ax4.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax4.set_xlim(t1, t2)
|
|
||||||
ax4.set_xlabel('Time (HH:MM)')
|
|
||||||
ax4.set_ylabel('Elevation ($^\circ$)')
|
|
||||||
ax4.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax4_divider = make_axes_locatable(ax4)
|
|
||||||
ax4.tick_params(width=0.5, length=1.5)
|
|
||||||
cax4 = ax4_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax4.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar4 = plt.colorbar(CS4, cax=cax4, label='Counts')
|
|
||||||
cbar4.formatter.set_powerlimits((0,0))
|
|
||||||
cbar4.minorticks_off()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
make_plots(fname_1, time_1, counts_tot_1, energy_1, azim_1, elev_1, counts_energy_spectro_1, counts_azim_spectro_1, counts_elev_spectro_1)
|
|
||||||
|
|
|
||||||
136
swa_eas.py
136
swa_eas.py
|
|
@ -1,136 +0,0 @@
|
||||||
#! /usr/bin/python3
|
|
||||||
|
|
||||||
from spacepy import pycdf
|
|
||||||
import numpy as np
|
|
||||||
import datetime
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import matplotlib.dates as mdates
|
|
||||||
from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable
|
|
||||||
|
|
||||||
# Data directory
|
|
||||||
datadir = '/home/nicolassurface/ET-U2-SWA/data'
|
|
||||||
# EAS1 filename
|
|
||||||
fname_1 = 'solo_L1_swa-eas1-NM3D_20220407T000004-20220407T060504_V01.cdf'
|
|
||||||
# EAS2 filename
|
|
||||||
fname_2 = 'solo_L1_swa-eas2-NM3D_20220407T000004-20220407T060504_V01.cdf'
|
|
||||||
|
|
||||||
# EAS1
|
|
||||||
file_1 = pycdf.CDF(datadir+fname_1)
|
|
||||||
time_1 = file_1['EPOCH'][...]
|
|
||||||
counts_1 = file_1['SWA_EAS1_Data'][...]
|
|
||||||
elev_1 = file_1['SWA_EAS_ELEVATION'][...]
|
|
||||||
azim_1 = file_1['SWA_EAS_AZIMUTH'][...]
|
|
||||||
energy_1 = file_1['SWA_EAS1_ENERGY'][...]
|
|
||||||
file_1.close()
|
|
||||||
|
|
||||||
# EAS2
|
|
||||||
file_2 = pycdf.CDF(datadir+fname_2)
|
|
||||||
time_2 = file_2['EPOCH'][...]
|
|
||||||
counts_2 = file_2['SWA_EAS2_Data'][...]
|
|
||||||
elev_2 = file_2['SWA_EAS_ELEVATION'][...]
|
|
||||||
azim_2 = file_2['SWA_EAS_AZIMUTH'][...]
|
|
||||||
energy_2 = file_2['SWA_EAS2_ENERGY'][...]
|
|
||||||
file_2.close()
|
|
||||||
|
|
||||||
# Sum over energy, azimuth and elevation:
|
|
||||||
def sum3d(counts, dimA, dimB, dimC):
|
|
||||||
sum3d_counts = np.sum(np.sum(np.sum(counts, axis=dimA), axis=dimB), axis=dimC)
|
|
||||||
return sum3d_counts.T
|
|
||||||
counts_tot_1 = sum3d(counts_1, 3, 2, 1) # EAS1
|
|
||||||
counts_tot_2 = sum3d(counts_2, 3, 2, 1) # EAS2
|
|
||||||
|
|
||||||
def sum2d(counts, dimA, dimB):
|
|
||||||
sum2d_counts = np.sum(np.sum(counts, axis=dimA), axis=dimB)
|
|
||||||
return sum2d_counts.T
|
|
||||||
# Sum over azimuth and elevation:
|
|
||||||
counts_energy_spectro_1 = sum2d(counts_1, 3, 1) # EAS1
|
|
||||||
counts_energy_spectro_2 = sum2d(counts_2, 3, 1) # EAS2
|
|
||||||
# Sum over energy and elevtion
|
|
||||||
counts_azim_spectro_1 = sum2d(counts_1, 2, 1) # EAS1
|
|
||||||
counts_azim_spectro_2 = sum2d(counts_2, 2, 1) # EAS2
|
|
||||||
# Sum over energy and azimuth
|
|
||||||
counts_elev_spectro_1 = sum2d(counts_1, 3, 2) # EAS1
|
|
||||||
counts_elev_spectro_2 = sum2d(counts_2, 3, 2) # EAS2
|
|
||||||
|
|
||||||
def make_plots(fname, time, counts_tot, energy, azim, elev, counts_energy_spectro, counts_azim_spectro, counts_elev_spectro):
|
|
||||||
# Set figure size
|
|
||||||
fig = plt.figure(figsize=(15,10))
|
|
||||||
fig.subplots_adjust(hspace=0.25)
|
|
||||||
# Set time range
|
|
||||||
t1 = datetime.datetime(year=int(fname[22:26]), month=int(fname[26:28]), day=int(fname[28:30]), \
|
|
||||||
hour=int(fname[31:33]), minute=int(fname[33:35])) # set start time
|
|
||||||
t2 = datetime.datetime(year=int(fname[38:42]), month=int(fname[42:44]), day=int(fname[44:46]), \
|
|
||||||
hour=int(fname[47:49]), minute=int(fname[49:51])) # set end time
|
|
||||||
xfmt = mdates.DateFormatter('%H:%M')
|
|
||||||
# Line plot
|
|
||||||
x = time
|
|
||||||
y = counts_tot
|
|
||||||
ax1 = fig.add_subplot(411)
|
|
||||||
ax1.plot(x, y, linewidth=0.5, color='k')
|
|
||||||
ax1.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax1.set_xlim(t1, t2)
|
|
||||||
ax1.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
|
|
||||||
ax1.set_xlabel('Time (HH:MM)')
|
|
||||||
ax1.set_ylabel('Total counts')
|
|
||||||
ax1.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax1.set_title('SWA-EAS%s Nominal Mode 3D Data: %s %s-%s\n' %(str(fname)[15:16], str(t1)[0:10], str(t1)[11:16], str(t2)[11:16]))
|
|
||||||
ax1_divider = make_axes_locatable(ax1)
|
|
||||||
ax1.tick_params(width=0.5, length=1.5)
|
|
||||||
cax1 = ax1_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax1.axis('off')
|
|
||||||
cax1.tick_params(width=0.5, length=1.5)
|
|
||||||
# Energy spectrogram
|
|
||||||
x, y = np.meshgrid(time, energy[1,:])
|
|
||||||
ax2 = fig.add_subplot(412)
|
|
||||||
CS2 = ax2.pcolormesh(x[:,:], y[:,:], np.log10(counts_energy_spectro[:,:]), cmap='jet') # plot spectrogram
|
|
||||||
ax2.set_yscale('log')
|
|
||||||
ax2.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax2.set_xlim(t1, t2)
|
|
||||||
ax2.tick_params(labelbottom=True)
|
|
||||||
ax2.set_xlabel('Time (HH:MM)')
|
|
||||||
ax2.set_ylabel('Energy (eV)')
|
|
||||||
ax2.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax2_divider = make_axes_locatable(ax2)
|
|
||||||
ax2.tick_params(width=0.5, length=1.5)
|
|
||||||
cax2 = ax2_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax2.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar2 = plt.colorbar(CS2, cax=cax2, label='$\mathregular{log_{10}}$(Counts)')
|
|
||||||
cbar2.minorticks_off()
|
|
||||||
# Azimuth spectrogram
|
|
||||||
x, y = np.meshgrid(time, azim)
|
|
||||||
ax3 = fig.add_subplot(413)
|
|
||||||
CS3 = ax3.pcolormesh(x[:,:], y[:,:], counts_azim_spectro[:,:], cmap='jet')
|
|
||||||
ax3.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax3.set_xlim(t1, t2)
|
|
||||||
ax3.tick_params(labelbottom=True)
|
|
||||||
ax3.set_xlabel('Time (HH:MM)')
|
|
||||||
ax3.set_ylabel('Azimuth ($^\circ$)')
|
|
||||||
ax3.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax3_divider = make_axes_locatable(ax3)
|
|
||||||
ax3.tick_params(width=0.5, length=1.5)
|
|
||||||
cax3 = ax3_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax3.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar3 = plt.colorbar(CS3, cax=cax3, label='Counts')
|
|
||||||
cbar3.formatter.set_powerlimits((0,0))
|
|
||||||
cbar3.minorticks_off()
|
|
||||||
# Elevation spectrogram
|
|
||||||
x, y = np.meshgrid(time, elev)
|
|
||||||
ax4 = fig.add_subplot(414)
|
|
||||||
CS4 = ax4.pcolormesh(x[:,:], y[:,:], counts_elev_spectro[:,:][::-1], cmap='jet')
|
|
||||||
ax4.xaxis.set_major_formatter(xfmt)
|
|
||||||
ax4.set_xlim(t1, t2)
|
|
||||||
ax4.set_xlabel('Time (HH:MM)')
|
|
||||||
ax4.set_ylabel('Elevation ($^\circ$)')
|
|
||||||
ax4.grid(linestyle=':', linewidth=0.5)
|
|
||||||
ax4_divider = make_axes_locatable(ax4)
|
|
||||||
ax4.tick_params(width=0.5, length=1.5)
|
|
||||||
cax4 = ax4_divider.append_axes('right', size='2%', pad='2%')
|
|
||||||
cax4.tick_params(width=0.5, length=1.5)
|
|
||||||
cbar4 = plt.colorbar(CS4, cax=cax4, label='Counts')
|
|
||||||
cbar4.formatter.set_powerlimits((0,0))
|
|
||||||
cbar4.minorticks_off()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
make_plots(fname_1, time_1, counts_tot_1, energy_1, azim_1, elev_1, counts_energy_spectro_1, counts_azim_spectro_1, counts_elev_spectro_1)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue