Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Project: Divers
Views: 40
License: GPL3
Image: ubuntu2004
Kernel: Python 3 (system-wide)
import pandas as pd import numpy as np import matplotlib.pyplot as plt import scipy as sp # pour le traitement du signal (tout n'est pas dans numpy) from scipy import signal from scipy import fftpack
Data=pd.read_csv('rec00001.asc',skiprows=2,names=['S']) Data
dt=0.25*10**(-3) Data['time']=np.arange(0,len(Data)*dt,dt)
figi,ax=plt.subplots(1,1) ax.scatter(Data.time,Data.S) ax.grid()
Image in a Jupyter notebook
fe=1/dt YY = fftpack.fft(Data['S'].values) frequency = fftpack.fftfreq(len(Data.S)) * fe timi=1/frequency timi[0]=0 figure, axis = plt.subplots(1,1,figsize=(10,10)) markerline, stemlines, baseline = axis.stem(timi/60, np.abs(YY),label='S') markerline.set_markerfacecolor('r') axis.legend() axis.grid() axis.set_xlabel('s') axis.set_ylabel('Spectre d''amplitude') axis.set_xscale("log", base=10) # échelle log pour l'axe des fréquences #axis.set_xlim(1/(60*fe),100000)
/tmp/ipykernel_657/706508731.py:5: RuntimeWarning: divide by zero encountered in true_divide timi=1/frequency
Image in a Jupyter notebook
figure, ax = plt.subplots(1,1,figsize=(10,10)) fre, tim, Sxx = signal.spectrogram(Data.S.values, fe) periodeTP=1/fre periodeTP[0]=periodeTP[1]*10 #pour remplacer la valeur inf correspondant à la frequence nulle ax.pcolormesh(tim, fre, np.log(Sxx), shading='gouraud') ax.set_ylabel('freq [Hz]') ax.set_xlabel('Time [s]') ax.set_ylim(0, 1000) # ax[jj,kk].set_ylim(0, 60) # affichage sur 0-60 jours (>2mois) => on voit des raies sur l'intervalle 15-30 jours
/tmp/ipykernel_657/4005303256.py:3: RuntimeWarning: divide by zero encountered in true_divide periodeTP=1/fre
(0.0, 1000.0)
Image in a Jupyter notebook