8
8
import time
9
9
import matplotlib
10
10
import matplotlib .pyplot as plt
11
- import matplotlib .colors as colors # for wigner log scale
11
+ import matplotlib .colors as colors # for wigner log scale
12
12
import numpy as np
13
13
import logging
14
14
21
21
from ocelot .optics .utils import calc_ph_sp_dens
22
22
from ocelot .optics .wave import *
23
23
24
-
25
-
26
24
from ocelot .gui .colormaps2d .colormap2d import *
27
25
28
26
# in order to run decorators properly
@@ -250,7 +248,7 @@ def plot_dfl(dfl, domains=None, z_lim=[], xy_lim=[], figsize=4, cmap=def_cmap, l
250
248
suffix += '_log'
251
249
252
250
if fig_name is None :
253
- if dfl_copy .fileName () is '' :
251
+ if dfl_copy .fileName () == '' :
254
252
fig = plt .figure ('Radiation distribution' + suffix )
255
253
else :
256
254
fig = plt .figure ('Radiation distribution' + suffix + ' ' + dfl_copy .fileName ())
@@ -558,7 +556,7 @@ def plot_wigner(wig_or_out, z=np.inf, x_units='um', y_units='ev', x_lim=(None, N
558
556
raise ValueError ('Unknown object for Wigner plot' )
559
557
560
558
if fig_name is None :
561
- if W .fileName () is '' :
559
+ if W .fileName () == '' :
562
560
fig_text = 'Wigner distribution'
563
561
else :
564
562
fig_text = 'Wigner distribution ' + W .fileName ()
@@ -623,24 +621,24 @@ def plot_wigner(wig_or_out, z=np.inf, x_units='um', y_units='ev', x_lim=(None, N
623
621
624
622
# cmap='RdBu_r'
625
623
# axScatter.imshow(wigner, cmap=cmap, vmax=wigner_lim, vmin=-wigner_lim)
626
-
624
+
627
625
if log_scale != 0 :
628
- if log_scale == 1 :
629
- log_scale = 0.01
626
+ if log_scale == 1 :
627
+ log_scale = 0.01
630
628
wigplot = axScatter .pcolormesh (power_scale [::downsample ], spec_scale [::downsample ],
631
- wigner [::downsample , ::downsample ], cmap = cmap ,
632
- norm = colors .SymLogNorm (linthresh = wigner_lim * log_scale , linscale = 2 ,
633
- vmin = - wigner_lim , vmax = wigner_lim ),
634
- vmax = wigner_lim , vmin = - wigner_lim )
629
+ wigner [::downsample , ::downsample ], cmap = cmap ,
630
+ norm = colors .SymLogNorm (linthresh = wigner_lim * log_scale , linscale = 2 ,
631
+ vmin = - wigner_lim , vmax = wigner_lim ),
632
+ vmax = wigner_lim , vmin = - wigner_lim )
635
633
else :
636
634
wigplot = axScatter .pcolormesh (power_scale [::downsample ], spec_scale [::downsample ],
637
- wigner [::downsample , ::downsample ], cmap = cmap , vmax = wigner_lim , vmin = - wigner_lim )
638
-
635
+ wigner [::downsample , ::downsample ], cmap = cmap , vmax = wigner_lim , vmin = - wigner_lim )
636
+
639
637
if plot_cbar :
640
638
from mpl_toolkits .axes_grid1 .inset_locator import inset_axes
641
- cbaxes = inset_axes (axScatter , width = "50%" , height = "3%" , loc = 1 )
642
- fig .colorbar (wigplot , cax = cbaxes , orientation = 'horizontal' )
643
-
639
+ cbaxes = inset_axes (axScatter , width = "50%" , height = "3%" , loc = 1 )
640
+ fig .colorbar (wigplot , cax = cbaxes , orientation = 'horizontal' )
641
+
644
642
if plot_text :
645
643
if hasattr (wig_or_out , 'is_spectrogram' ):
646
644
if wig_or_out .is_spectrogram :
@@ -736,23 +734,20 @@ def plot_wigner(wig_or_out, z=np.inf, x_units='um', y_units='ev', x_lim=(None, N
736
734
737
735
axHistx .set_xlim (x_lim_appl [0 ], x_lim_appl [1 ])
738
736
axHisty .set_ylim (y_lim_appl [0 ], y_lim_appl [1 ])
739
-
737
+
740
738
if log_scale != 0 :
741
739
axHistx .set_ylim (np .nanmin (power ), np .nanmax (power ))
742
740
axHisty .set_xlim (np .nanmin (spec ), np .nanmax (spec ))
743
741
axHisty .set_xscale ('log' )
744
742
axHistx .set_yscale ('log' )
745
-
743
+
746
744
else :
747
745
axScatter .axis ('tight' )
748
746
axScatter .set_xlabel (p_label_txt )
749
747
axScatter .set_ylabel (f_label_txt )
750
748
751
749
# axScatter.set_xlim(x_lim[0], x_lim[1])
752
750
# axScatter.set_ylim(y_lim[0], y_lim[1])
753
-
754
-
755
-
756
751
757
752
if savefig != False :
758
753
if savefig == True :
@@ -782,15 +777,15 @@ def plot_dfl_waistscan(sc_res, fig_name=None, figsize=4, showfig=True, savefig=F
782
777
_logger .info ('plot dfl waist scan' )
783
778
if showfig == False and savefig == False :
784
779
return
785
-
780
+
786
781
if fig_name is None :
787
- if sc_res .fileName () is '' :
782
+ if sc_res .fileName () == '' :
788
783
fig = plt .figure ('Waist scan' )
789
784
else :
790
785
fig = plt .figure (sc_res .fileName () + ' waist scan' )
791
786
else :
792
787
fig = plt .figure (fig_name )
793
-
788
+
794
789
plt .clf ()
795
790
fig .set_size_inches ((3 * figsize , 2 * figsize ), forward = True )
796
791
ax_int = fig .add_subplot (1 , 1 , 1 )
@@ -952,11 +947,11 @@ def plot_stokes_values(S, fig=None, d_pol=0, norm=0, showfig=True, gw=1, directi
952
947
if np .size (sc ) <= 1 :
953
948
_logger .warning ('plot_stokes_values needs more than a single point to plot (np.size(sc) <= 1)' )
954
949
return
955
-
950
+
956
951
if d_pol != 0 :
957
- gw = 0
958
- norm = 1
959
-
952
+ gw = 0
953
+ norm = 1
954
+
960
955
if fig == None :
961
956
plt .figure ('Stokes S' )
962
957
plt .clf ()
@@ -970,7 +965,7 @@ def plot_stokes_values(S, fig=None, d_pol=0, norm=0, showfig=True, gw=1, directi
970
965
mult = 1e-9
971
966
plt .ylabel ('$S_0$ [GW]' )
972
967
elif norm :
973
- mult = 1 / np .amax (Scp .s0 )
968
+ mult = 1 / np .amax (Scp .s0 )
974
969
else :
975
970
mult = 1
976
971
plt .ylabel ('$S_0$ [W]' )
@@ -986,10 +981,10 @@ def plot_stokes_values(S, fig=None, d_pol=0, norm=0, showfig=True, gw=1, directi
986
981
else :
987
982
raise ValueError
988
983
989
- if d_pol == 'lin' :
984
+ if d_pol == 'lin' :
990
985
# plt.step(sc, np.sqrt(S.s1**2+S.s2**2), linewidth=2, where='mid',color=[0.5,0.5,0.5], linestyle='--')
991
986
plot_function (sc , Scp .deg_pol_l (), linestyle = '-' , color = '#1f77b4' , ** kwargs )
992
- elif d_pol == 1 :
987
+ elif d_pol == 1 :
993
988
plot_function (sc , Scp .deg_pol (), linestyle = '-' , color = '#1f77b4' , ** kwargs )
994
989
else :
995
990
pass
@@ -1041,8 +1036,7 @@ def plot_stokes_angles(S, fig=None, showfig=True, direction='z', plot_func='scat
1041
1036
if np .size (sc ) <= 1 :
1042
1037
_logger .warning ('plot_stokes_angles needs more than a single point to plot (np.size(sc) <= 1)' )
1043
1038
return
1044
-
1045
-
1039
+
1046
1040
if fig == None :
1047
1041
plt .figure ('Stokes angles' )
1048
1042
plt .clf ()
@@ -1067,7 +1061,7 @@ def plot_stokes_angles(S, fig=None, showfig=True, direction='z', plot_func='scat
1067
1061
1068
1062
plot_function (sc , Scp .psi (), color = 'b' , ** kwargs )
1069
1063
# if plot_func == 'scatter':
1070
- # kwargs['s'] = psize
1064
+ # kwargs['s'] = psize
1071
1065
plot_function (sc , Scp .chi (), color = 'g' , ** kwargs )
1072
1066
1073
1067
# if scatter:
0 commit comments