python 数値計算 絶対値|a|
pythonで絶対値を計算したい場合
abs(またはabsolute等)を使う
# -*- coding: utf-8 -*- def main(): a = -10 a = abs(a) print(a) if __name__ == "__main__": main()
python 数値計算 4捨5入
1.25を入力した場合round(x,1)で少数第一位で四捨五入する 以下コード
#coding: utf-8 def main(): x = 1.23 x = round(x,1) print(x) if __name__ == "__main__": main()
FIRフィルタの設計by python
FIRフィルタの設計by python
○firwinの使い方
例)
scipy.signal.firwin(numtaps, cutoff, width=None, window='hamming', pass_zero=True, scale=True, nyq=1.0)
numtaps:タップ数
cutoff:カットオフ周波数
window:窓関数
pass_zero:
nyq:ナイキスト周波数
参考:https://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.signal.firwin.html
○scipy.absoluteの使い方
NumPy で絶対値 (負の数は正の数として出力、正の数は正の数として出力) を求めるには、np.absolute()があります。
参考https://docs.scipy.org/doc/numpy-1.9.1/reference/generated/numpy.absolute.html
○scipy.fft使い方
https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.fftpack.fft.html
○unwrapとは
連続だったデータもラップ(wrap)されて位相のジャンプが現れる。 これをUnwrapするたのもの
参考retrofocus28.blogspot.jp
#coding:utf8 import scipy import scipy.signal as ss from matplotlib import pyplot as pp import numpy as np import scipy.signal from pylab import * N = 221 fc = 1000. fc2 = 3000. Fs = 44100. #%% LPF h = ss.firwin(numtaps=N, cutoff=fc/(Fs/2.), window='blackman', pass_zero=True) #%% HPF f = ss.firwin(numtaps=N, cutoff=fc/(Fs/2.), window='blackman', pass_zero=False) #%% BPF e = ss.firwin(numtaps=N, cutoff=scipy.array([fc/(Fs/2.), fc2/(Fs/2.)]), window='blackman', pass_zero=False) #%% BEF h = ss.firwin(numtaps=N, cutoff=scipy.array([fc/(Fs/2.), fc2/(Fs/2.)]), window='blackman', pass_zero=True) #%% 表示 f = scipy.array(range(0, N)) * Fs / scipy.double(N) tf = scipy.fft(h) mag = scipy.absolute(tf) phase = scipy.unwrap(scipy.angle(tf)) * 180. / scipy.pi figure(1) subplot(3,1,1) pp.plot(h) grid('on', 'both') subplot(3,1,2) pp.semilogx(f, mag) xlim([20, 20000]) ylim([0, 1.2]) grid('on', 'both') subplot(3,1,3) pp.plot(f, phase) xlim([0, 20000]) grid('on', 'both') figure(2) subplot(3,1,1) pp.plot(f) grid('on', 'both') subplot(3,1,2) pp.semilogx(f, mag) xlim([20, 20000]) ylim([0, 1.2]) grid('on', 'both') subplot(3,1,3) pp.plot(f, phase) xlim([0, 20000]) grid('on', 'both') figure(3) subplot(3,1,1) pp.plot(e) grid('on', 'both') subplot(3,1,2) pp.semilogx(f, mag) xlim([20, 20000]) ylim([0, 1.2]) grid('on', 'both') subplot(3,1,3) pp.plot(f, phase) xlim([0, 20000]) grid('on', 'both') plt.show() || 参考
Raspbianのインストールと初期設定
Raspbianのインストールと初期設定
1.RaspbianをDownload
- 今回はNoobsのページからダウンロードします。
「Noobsダウンロードページ」
1'.SD formaterでSDカードのフォーマット
2.SDへNoobsをcopy
3.NoobsからRaspbianを選択しインストール
参考:
3分でECCUBEを使った会員制ECサイト化
1.ここからプラグインをダウンロード&install
https://drive.google.com/file/d/0B0D4RKG_piu8clVrcC10ckF4NVU/view
2.非ログイン状態でも表示可能とするページの設定等を行う
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
function preProcess(LC_Page $objPage ) { if ( strstr (get_class( $objPage ), "Admin" ) != "" || strstr (get_class( $objPage ), "Upgrade" )) { // 管理画面のためアクセスOK return ; } if (TOP_URLPATH == $_SERVER [ "REQUEST_URI" ]) { // TOPページはリダイレクトしない return ; } $objCustomer = new SC_Customer_Ex(); if ( $objCustomer ->isLoginSuccess(true)) { // 会員はアクセス可能 return ; } $filename = $objPage ->arrPageLayout[ 'filename' ]; // 許可するページを指定 $arrAccessPage = array ( 'mypage/' , 'entry/' , 'login' , '' ); foreach ( $arrAccessPage as $pagename ) { if ( strstr ( $filename , $pagename ) != "" || $filename == $pagename ) { return ; } } header( 'Location: ' . TOP_URLPATH); exit ; } |
以上。
参考