File:Exemple superposition de pics large et etroit.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 900 × 540 pixels, file size: 29 KB)

Captions

Captions

Example of overlapping peaks, with a large and low peak, and a high and narrow peak.

Summary

[edit]
Description
Français : Exemple de superposition de pics, avec un pics large et bas, et un pic étroit et haut.
English: Example of overlapping peaks, with a large and low peak, and a high and narrow peak.
Date
Source Own work
Author Cdang
Other versions Noisy curve and peaks detection with the Savitzky-Golay algorithm: File:Detection pics savitzky golay.svg ; use of the scipy peakgfind algorithm: File:Detection pics scipy signal find peaks.svg
W3CiThe source code of this SVG is invalid due to 10 errors.
 
This W3C-invalid plot was created with Matplotlib.
 
The source code of this SVG is invalid due to 10 errors.
 
This W3C-invalid vector image was created with Python by cdang.

Source code

InfoField



Creation of the data file.

Python code

#!/usr/bin/python3
# coding: utf-8

"""nom : superpositionPics.py
auteur : User:cdang
date de création : 2023-04-20
dates de modification : 
----------------------------------------------------------------------------
version de Python : 3
module requis : NumPy, Pandas
----------------------------------------------------------------------------
Objectif : crée un graphique montrant la superposition de pics.

Entrées
-------
    Paramètres de la fonction générant le nuage de points (codé en dur).

Sorties
-------
    fichier SVG.
"""

import numpy as np
import matplotlib.pyplot as plt

# ****************
# ****************
# ** Paramètres **
# ****************
# ****************

facteurSigma = 0.03/np.sqrt(2*np.pi) # rapport entre la hauteur et la largeur d'un pic

x1 = 0.3 ; h1 = 0.5 # position et hauteur des pics
x2 = 0.75 ; h2 = 0.1
x3 = 0.8 ; h3 = 1

n = 400 # nombre de points

# chemin d'accès et nom du fichier à créer
chemin = "~/dummypath/"
nomFichier = "exemple_superposition_de_pics_large_et_etroit.svg"

# **************
# **************
# ** Fonction **
# **************
# **************

def f(x, mu, sigma):
    """Fonction pour générer un pic.
    Entrées :
    — x : vecteur de réels (abscisses) ;
    — mu : réel, position du pic ;
    — sigma : réel, écart type de la fonction gaussienne.
    Sortie : y, vecteur de réels (ordonnées) de même dimension que x.
    y = 1/(σ × √(2π)) × exp((x - μ)²/(2σ²))."""
    
    unSurSigma = 1/sigma
    y = (unSurSigma*facteurSigma)*np.exp(-0.5*unSurSigma*unSurSigma*(x - mu)*(x - mu))
    
    return y

# *************************
# *************************
# ** Programme principal **
# *************************
# *************************

X = np.linspace(0, 1, n)
Y1 = f(X, x1, facteurSigma/h1)
Y2 = f(X, x2, facteurSigma/h2)
Y3 = f(X, x3, facteurSigma/h3)
Y = Y1 + Y2 + Y3

fig = plt.figure(figsize = [10, 6])

plt.plot(X, Y, "k", linewidth = 1, label = "somme")
plt.plot(X, Y1, "r", linewidth = 0.5, label = "pic 1")
plt.plot(X, Y2, "g", linewidth = 0.5, label = "pic 2")
plt.plot(X, Y3, "b", linewidth = 0.5, label = "pic 3")
plt.xlabel("x (u.a.)")
plt.ylabel("y (u.a.)")
plt.legend()

plt.savefig(chemin+nomFichier, format="svg")

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current07:51, 20 April 2023Thumbnail for version as of 07:51, 20 April 2023900 × 540 (29 KB)Cdang (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Metadata