我正在计算信号的PSD,并且我想要0Hz到20Hz频率范围内的功率。这就是我尝试使用linspace
df = pd.read_csv(path)
df = pd.DataFrame(df)
x = np.linspace(0, 20, 41)
dt = x[1] - x[0]
fs = 1 / dt
f,P = signal.welch(df, fs=5, nperseg=30, noverlap=5,axis=0)
在这里,我得到了从0Hz到2.5Hz的6个频率分量,但是我想计算直到20Hz的频率范围的功率
有人可以在这里帮我做同样的事情吗?
答案 0 :(得分:1)
PSD仅从0到fs / 2,您应该在fs参数中指定正确的采样频率,在您的情况下为1024。
此示例说明了如何获取正弦信号的PSD:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use postgresql as the database for Active Record
gem 'pg', '0.21.0', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master
# Use Puma as the app server
gem 'puma', '~> 3.0'
gem 'config'
gem 'whenever', :require => false
# gems for database handling
gem 'activerecord-postgis-adapter'
#gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.9'
gem 'activerecord-jdbcpostgresql-adapter', :git => "git://github.com/jruby/activerecord-jdbc-adapter.git",
:branch => "50-stable", :platform => :jruby
#gem 'ffi-geos'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'mina'
gem 'mina-puma', github: 'untitledkingdom/mina-puma'
gem 'mina-whenever'
end
group :test do
gem 'whenever-test'
gem 'mocha'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'active_model_serializers'
gem 'httparty'
gem 'polylines'