summaryrefslogtreecommitdiff
path: root/lpf.awk
diff options
context:
space:
mode:
Diffstat (limited to 'lpf.awk')
-rw-r--r--lpf.awk24
1 files changed, 13 insertions, 11 deletions
diff --git a/lpf.awk b/lpf.awk
index aba92e1..638af3c 100644
--- a/lpf.awk
+++ b/lpf.awk
@@ -1,7 +1,8 @@
#!/usr/bin/awk -f
### lpf.awk
-# Low Pass Filter with Hardcoded FIR Window
+# low pass filter with hardcoded FIR window
+
BEGIN {
OFS = FS
@@ -20,19 +21,22 @@ BEGIN {
window_size = split(H, H_arr, "[ ]*")
}
+
+# column headers
NR == 1 {
for (y=1; y<=NF; y++)
($y ~ number) ? header[y] = "col" y : header[y] = $y
}
+
+# read input data
NF > 0 {
- if (NF > nf_max)
- nf_max = NF
+ (NF > nf_max) ? nf_max = NF : nf_max = nf_max
input_size = window_size
output_size = (input_size + window_size - 1)
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
if ($y == header[y])
printf(header[y] OFS header[y] "_lpf")
@@ -75,15 +79,13 @@ NF > 0 {
printf(ORS)
}
-
-
-
}
+
END {
- ### rows
+ # rows
for (x=1; x<=window_size; x++) {
- ### columns
+ # columns
for (y=1; y<=nf_max; y++) {
# rotate input buffer
for (n=1; n<=input_size; n++) {
@@ -93,7 +95,7 @@ END {
#delete X_arr[y,input_size]
#input_size = length(X_arr)
#print length(X_arr)
-
+
Y[y] = 0
for (n=1; n<=window_size; n++) {
for (m=1; m<=input_size; m++) {
@@ -120,7 +122,7 @@ END {
printf(OFS)
else
printf(ORS)
- X_arr[input_size] = 0
+ X_arr[input_size] = 0
}
}
}