ex-1: add the possibility to plot the gala and gamo plots
- gala plot: plot Gaussian + Landau PDFs - gamo plot: plot Gaussian + Moyal PDFs Also add the images to the folder.
This commit is contained in:
parent
9a3e85a11b
commit
b9e1ad651d
@ -6,23 +6,31 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# -i → agrs.show → open plot in interactive mode
|
# -i → agrs.show → open plot in interactive mode
|
||||||
# -s → args.save → save plot
|
# -s → args.save → save plot
|
||||||
#
|
#
|
||||||
# -n → agrs.note → do the Landau plot with the notes
|
# -n → agrs.note → do the Landau plot with the notes
|
||||||
# -b → args.both → do the Landau-Moyal plot
|
# -b → args.both → do the Landau-Moyal plot
|
||||||
# -m → args.area → do the Landau median plot
|
# -m → args.area → do the Landau median plot
|
||||||
# -c → args.cauchy → do the Cauchy PDF plot
|
# -gm → args.gamo → do the Gaussian-Moyal compare plot
|
||||||
|
# -gl → args.gala → do the Gaussian-Landau compare plot
|
||||||
|
# -c → args.cauchy → do the Cauchy PDF plot
|
||||||
|
|
||||||
|
|
||||||
|
# Moyal PDF
|
||||||
def moyal(x, μ, σ):
|
def moyal(x, μ, σ):
|
||||||
N = (1)/(np.sqrt(2 * np.pi) * σ)
|
N = (1)/(np.sqrt(2 * np.pi) * σ)
|
||||||
return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp(- (x - μ)/σ)))
|
return N * np.exp(- 0.5 * ((x - μ)/σ + np.exp(- (x - μ)/σ)))
|
||||||
|
|
||||||
|
# Cauchy PDF
|
||||||
def cauchy(x):
|
def cauchy(x):
|
||||||
return 1/(np.pi*(1 + x**2))
|
return 1/(np.pi*(1 + x**2))
|
||||||
|
|
||||||
|
# Gauss PDF
|
||||||
|
def gauss(x, μ, σ):
|
||||||
|
N = (1)/(np.sqrt(2 * np.pi) * σ)
|
||||||
|
return N * np.exp(- 0.5 * ((x - μ)/σ)**2)
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
# prepare figure
|
# prepare figure
|
||||||
@ -30,12 +38,12 @@ def main(args):
|
|||||||
plt.figure()
|
plt.figure()
|
||||||
elif args.save:
|
elif args.save:
|
||||||
plt.rcParams['font.size'] = 8
|
plt.rcParams['font.size'] = 8
|
||||||
if (args.both or args.area):
|
if (args.both or args.area or args.cauchy):
|
||||||
plt.figure(figsize=(3, 2))
|
plt.figure(figsize=(3, 2))
|
||||||
|
elif (args.gamo or args.gala):
|
||||||
|
plt.figure(figsize=(2.5, 2))
|
||||||
elif args.note:
|
elif args.note:
|
||||||
plt.figure(figsize=(5, 3))
|
plt.figure(figsize=(5, 3))
|
||||||
elif args.cauchy:
|
|
||||||
plt.figure(figsize=(3, 2))
|
|
||||||
|
|
||||||
if args.note:
|
if args.note:
|
||||||
# useful coordinates
|
# useful coordinates
|
||||||
@ -68,12 +76,13 @@ def main(args):
|
|||||||
plt.xlim(-10, 10)
|
plt.xlim(-10, 10)
|
||||||
plt.ylim(y_min, y_max)
|
plt.ylim(y_min, y_max)
|
||||||
|
|
||||||
if args.both:
|
if (args.both):
|
||||||
plt.ylim(-0.015, 0.265)
|
plt.ylim(-0.015, 0.265)
|
||||||
|
|
||||||
# draw Landau plot
|
# draw Landau plot
|
||||||
x, y = np.loadtxt(sys.stdin, unpack=True)
|
if not args.gamo:
|
||||||
plt.plot(x, y, color='#92182b', label='Landau')
|
x, y = np.loadtxt(sys.stdin, unpack=True)
|
||||||
|
plt.plot(x, y, color='#92182b', label='Landau')
|
||||||
|
|
||||||
# Color the area under the function
|
# Color the area under the function
|
||||||
if args.area:
|
if args.area:
|
||||||
@ -82,20 +91,31 @@ def main(args):
|
|||||||
plt.fill_between(x[:x0], y[:x0], color='#ff99a8')
|
plt.fill_between(x[:x0], y[:x0], color='#ff99a8')
|
||||||
plt.fill_between(x[x0:], y[x0:], color='#b28e94')
|
plt.fill_between(x[x0:], y[x0:], color='#b28e94')
|
||||||
|
|
||||||
# do Moyal plot
|
|
||||||
if args.both:
|
|
||||||
μ = -0.22278298
|
|
||||||
σ = 1.1191486
|
|
||||||
x = np.arange(-10, 30, 0.01)
|
|
||||||
plt.plot(x, moyal(x, μ, σ), color='gray', label='Moyal')
|
|
||||||
plt.legend()
|
|
||||||
|
|
||||||
# do Cauchy plot
|
# do Cauchy plot
|
||||||
if args.cauchy:
|
if args.cauchy:
|
||||||
x = np.arange(-10, 10, 0.01)
|
x = np.arange(-10, 10, 0.01)
|
||||||
plt.plot(x, cauchy(x), color='gray', label='Cauchy')
|
plt.plot(x, cauchy(x), color='gray', label='Cauchy')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
|
|
||||||
|
μ = -0.22278298
|
||||||
|
σ = 1.1191486
|
||||||
|
|
||||||
|
# do Moyal plot
|
||||||
|
if (args.both or args.gamo):
|
||||||
|
x = np.arange(-10, 10, 0.01)
|
||||||
|
plt.plot(x, moyal(x, μ, σ), color='gray', label='Moyal')
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
# do Gaussian plot
|
||||||
|
if (args.gamo or args.gala):
|
||||||
|
x = np.arange(-10, 10, 0.01)
|
||||||
|
if args.gala:
|
||||||
|
a = 1.97
|
||||||
|
if args.gamo:
|
||||||
|
a = 1.65
|
||||||
|
plt.plot(x, gauss(x, μ, a*σ), color='#cfb017', label='Gauss')
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
# save figure
|
# save figure
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
if args.show:
|
if args.show:
|
||||||
@ -109,6 +129,10 @@ def main(args):
|
|||||||
plt.savefig('slides/images/median.pdf', transparent=True)
|
plt.savefig('slides/images/median.pdf', transparent=True)
|
||||||
if args.cauchy:
|
if args.cauchy:
|
||||||
plt.savefig('slides/images/cauchy-pdf.pdf', transparent=True)
|
plt.savefig('slides/images/cauchy-pdf.pdf', transparent=True)
|
||||||
|
if args.gamo:
|
||||||
|
plt.savefig('slides/images/gamo-pdf.pdf')
|
||||||
|
if args.gala:
|
||||||
|
plt.savefig('slides/images/gala-pdf.pdf')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -132,5 +156,11 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument('-c', '--cauchy',
|
parser.add_argument('-c', '--cauchy',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
help='do the cauchy plot')
|
help='do the cauchy plot')
|
||||||
|
parser.add_argument('-gl', '--gala',
|
||||||
|
action='store_true', default=False,
|
||||||
|
help='do the gaussian-landau plot')
|
||||||
|
parser.add_argument('-gm', '--gamo',
|
||||||
|
action='store_true', default=False,
|
||||||
|
help='do the gaussian-moyal plot')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
main(args)
|
main(args)
|
||||||
|
BIN
slides/images/gala-pdf.pdf
Normal file
BIN
slides/images/gala-pdf.pdf
Normal file
Binary file not shown.
BIN
slides/images/gamo-pdf.pdf
Normal file
BIN
slides/images/gamo-pdf.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user