Skip to content

Commit

Permalink
Continue video spectrum kykx
Browse files Browse the repository at this point in the history
  • Loading branch information
calpe committed Dec 13, 2018
1 parent 7b2684c commit 9599210
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions scripts/ns2d.strat/make_video_spectrum_kykx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
# forcing rot_fft, two quadrants
path = "/fsnet/project/meige/2015/15DELDUCA/DataSim/isotropy_forcing_multidim/NS2D.strat_960x240_S2pix1.571_F07_gamma1_2018-12-03_15-54-35"

# rot_fft, one quadrant
path = "/fsnet/project/meige/2015/15DELDUCA/DataSim/isotropy_forcing_multidim/NS2D.strat_960x240_S2pix1.571_F07_gamma1_2018-12-03_15-54-38"

### Parameters
skip = 20
skip = 1
tmin = 2
tmax = 1000
key = "ap_fft"
tmax = 50
scale = "log" # can be "linear"
SAVE = True

# Load object simulation
sim = load_state_phys_file(path)
Expand Down Expand Up @@ -123,29 +127,41 @@
ax2.set_ylim([kz[ikz_negative], kz[ikz] - sim.oper.deltaky])

# Sec limits colormap
vmin = 0
vmax = 0.001 * data_ap_plot_modified.max()

if scale == "linear":
vmin = 0
vmax = 0.001 * data_ap_plot_modified.max()

elif scale == "log":
vmin = -5
vmax = np.log10(data_ap_plot_modified.max()) - 3

ikx_text = np.argmin(abs(kx - kx[ikx] * 0.7))
ikz_text = np.argmin(abs(kz - kz[ikz] * 0.7))

# Plot first figure
_im = ax.pcolormesh(KX, KZ, data_ap_plot_modified, vmin=vmin, vmax=vmax)

ax.plot(kx, 1e-0 * sim.params.N * (kx / eps[-1])**(1/3), color="white")
ax.text(kx[ikx_text], kz[ikz_text], "\hat{a}_+", color="white", fontsize=15)

_im2 = ax2.pcolormesh(KX, KZ, data_am_plot_modified, vmin=vmin, vmax=vmax)
ax2.plot(kx, 1e-0 * sim.params.N * (kx / eps[-1])**(1/3), color="white")
ax2.text(kx[ikx_text], kz[ikz_text], "\hat{a}_-", color="white", fontsize=15)

if scale == "linear":
_im = ax.pcolormesh(KX, KZ, data_ap_plot_modified, vmin=vmin, vmax=vmax)
_im2 = ax2.pcolormesh(KX, KZ, data_am_plot_modified, vmin=vmin, vmax=vmax)
elif scale == "log":
_im = ax.pcolormesh(KX, KZ, np.log10(data_ap_plot_modified), vmin=vmin, vmax=vmax)
_im2 = ax2.pcolormesh(KX, KZ, np.log10(data_am_plot_modified), vmin=vmin, vmax=vmax)

ax1.plot(times, energies_ap, color="grey", alpha=0.4)
ax1.plot(times, energies_am, color="grey", alpha=0.4)

_im_inset = ax1.plot(times[0], energies_ap[0], color="red", label=r"$\hat{a}_+$")
_im_inset3 = ax1.plot(times[0], energies_am[0], color="blue", label=r"$\hat{a}_-$")
ax1.legend(fontsize=14)
cbar_ax = fig.add_axes([0.38, 0.15, 0.01, 0.7])
colorbar = fig.colorbar(_im, cax=cbar_ax, format="%.0e")
colorbar = fig.colorbar(_im, cax=cbar_ax, format="%.2e")
# colorbar.ax.ticklabel_format(style="sci")

# ax1.plot(times[0:2], energies_ap[0:2], color="red")
Expand All @@ -167,11 +183,20 @@ def _update(frame):
0:kz_modified.shape[0]//2 + 1, :]

# Trick: https://stackoverflow.com/questions/29009743/using-set-array-with-pyplot-pcolormesh-ruins-figure
_im.set_clim(vmin=0, vmax= 0.001 * data_ap_plot_modified.max())
_im.set_array(data_ap_plot_modified[:-1, :-1].flatten())
if scale == "linear":
_im.set_clim(vmin=0, vmax= 0.001 * data_ap_plot_modified.max())
_im.set_array(data_ap_plot_modified[:-1, :-1].flatten())

_im2.set_clim(vmin=0, vmax= 0.001 * data_ap_plot_modified.max())
_im2.set_array(data_am_plot_modified[:-1, :-1].flatten())
_im2.set_clim(vmin=0, vmax= 0.001 * data_ap_plot_modified.max())
_im2.set_array(data_am_plot_modified[:-1, :-1].flatten())

elif scale == "log":
_im.set_clim(vmin=-5, vmax= np.log10(data_ap_plot_modified.max()) - 3)
_im.set_array(np.log10(data_ap_plot_modified[:-1, :-1].flatten()))


_im2.set_clim(vmin=-5, vmax= np.log10(data_ap_plot_modified.max()) - 3)
_im2.set_array(np.log10(data_am_plot_modified[:-1, :-1].flatten()))

_im_inset[0].set_data(times[0:frame], energies_ap[0:frame])
_im_inset3[0].set_data(times[0:frame], energies_am[0:frame])
Expand All @@ -180,3 +205,10 @@ def _update(frame):

ani = animation.FuncAnimation(
fig, _update, len(times), interval=1000, repeat=True)

if SAVE:
ani.save("/home/users/calpelin7m/spectrumkykx_{}_kznegative_{}.mp4".format(
sim.params.forcing.key_forced,
bool(sim.params.forcing.tcrandom_anisotropic.kz_negative_enable)),
writer="ffmpeg"
)

0 comments on commit 9599210

Please sign in to comment.