analysis of ascii outputs with awk programme on mac

Everything that didn't fit in any other topic
Post Reply
Browne Dan
WUFI User
WUFI User
Posts: 20
Joined: Mon May 25, 2009 1:12 am -1100
Location: London, England

analysis of ascii outputs with awk programme on mac

Post by Browne Dan »

Hi,

I am having some trouble with an awk programme that i have co-written that scans my WUFI ascii output file.

This is partly a problem with me not writing the perfect awk programm, partly because i'm doing it in terminal/darwin on my mac and also because the WUFI ascii outputs are so 'dirty' (sorry) :wink:

my ascii columns are as follows:

1: ref, 2: ext air temp, 3: temp at monitor position 2, :4 water content

I am using the awk to pick up a freezing event at monitor position 2, so from + to - figures and to tell me when this coincides with a water content over 208kg/m3

the awk prints all the zero crossing events with their water content, not just the ones over 208. (there is one that i put in to test)

I have pasted the awk file below, not sure how to paste a sample of an ascii output? This apparently runs perfectly on a PC so it may be a mac problem.

Any help would be appreciated

Dan

frost.awk:

{
gsub(/E\+000/,"e"); gsub(/E\-000/,"e-") # gets rid of excess zeros, note \ is to define "+" as a charcater not an action

#print $0

if (TOld>=0 && $3<0 && $4>208) print int($1/1),$3/1,$4/1 # checks if temperature drops below zero and prints ref, temp and water

TOld=$3 # resets temperature

}
veitner
WUFI SupportTeam IBP
WUFI SupportTeam IBP
Posts: 135
Joined: Tue Mar 08, 2005 11:14 pm -1100

Post by veitner »

Dear Dan,

your program works perfectly using gnu awk version 3.1.5

veitner@pc9:~/wufi/scripts$ awk --version
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.

veitner@pc9:~/wufi/scripts$ awk -f frost.awk test1.txt
652 -1.14238 670.299

Your problem might either be due to a different awk version or line endings.
To convert the line endings use e.g.

dos2unix file > converted



Regards
Veit


test1.txt (line endings converted with dos2unix):

6.490000E+0002 6.190000E-0001 1.926863E+0000 6.703314E+0001
6.500000E+0002 -3.300000E-0001 1.455098E+0000 6.703261E+0001
6.510000E+0002 -1.750000E+0000 4.624603E-0001 6.703166E+0001
6.520000E+0002 -4.050000E+0000 -1.142381E+0000 6.702995E+0002
6.530000E+0002 -3.730000E+0000 -1.436695E+0000 6.702895E+0001
6.540000E+0002 -2.720000E+0000 -1.034440E+0000 6.702851E+0001
6.550000E+0002 -2.050000E+0000 -5.451719E-0001 6.702831E+0001
6.560000E+0002 -1.600000E+0000 2.665454E-0002 6.702831E+0001
6.570000E+0002 -2.560000E-0001 1.134605E+0000 6.702903E+0001
6.580000E+0002 5.410000E-0001 2.411440E+0000 6.703006E+0001
6.590000E+0002 1.040000E+0000 3.201177E+0000 6.703087E+0001
6.600000E+0002 1.280000E+0000 3.525075E+0000 6.703126E+0001
6.740000E+0002 -3.300000E-0001 1.306051E+0000 6.702924E+0001
6.750000E+0002 -1.750000E+0000 3.456868E-0001 6.702837E+0001
6.760000E+0002 -4.050000E+0000 -1.227798E+0000 6.702675E+0001
7.560000E+0002 1.070000E+0000 3.738235E+0000 6.713934E+0001
7.570000E+0002 7.240000E-0001 3.531371E+0000 6.714119E+0001
7.660000E+0002 -3.440000E+0000 -1.080342E+0000 6.715800E+0001
7.670000E+0002 -3.720000E+0000 -1.418275E+0000 6.715846E+0001
7.910000E+0002 8.280000E-0001 2.135724E+0000 6.721413E+0001
8.690000E+0002 -3.730000E+0000 -1.376979E+0000 6.733363E+0001
8.700000E+0002 -2.720000E+0000 -9.946563E-0001 6.733358E+0001
8.710000E+0002 -2.050000E+0000 -5.170469E-0001 6.733380E+0001
8.720000E+0002 -1.600000E+0000 4.771512E-0002 6.733428E+0001
8.730000E+0002 -2.560000E-0001 1.147251E+0000 6.733551E+0001
8.740000E+0002 5.410000E-0001 2.416402E+0000 6.733712E+0001
8.750000E+0002 1.040000E+0000 3.204180E+0000 6.733853E+0001
8.760000E+0002 1.280000E+0000 3.529154E+0000 6.733952E+0001
8.770000E+0002 6.410000E-0001 2.786176E+0000 6.734039E+0001
8.780000E+0002 2.740000E+0000 4.014317E+0000 6.734168E+0001
8.790000E+0002 1.950000E+0000 3.955258E+0000 6.734217E+0001
8.800000E+0002 6.840000E-0001 2.647410E+0000 6.734235E+0001
8.810000E+0002 4.580000E-0001 1.993784E+0000 6.734180E+0001
8.820000E+0002 1.920000E-0001 1.497794E+0000 6.734135E+0001
8.830000E+0002 -3.060000E-0002 1.195003E+0000 6.734104E+0001
8.840000E+0002 3.510000E-0001 1.315398E+0000 6.734108E+0001
8.850000E+0002 5.210000E-0001 1.523725E+0000 6.734129E+0001
8.860000E+0002 6.090000E-0001 1.624197E+0000 6.734150E+0001
8.870000E+0002 6.190000E-0001 1.683499E+0000 6.734170E+0001
8.880000E+0002 4.170000E-0001 1.649352E+0000 6.734183E+0001
8.890000E+0002 6.190000E-0001 1.789445E+0000 6.734206E+0001
8.900000E+0002 -3.300000E-0001 1.308856E+0000 6.734190E+0001
8.910000E+0002 -1.750000E+0000 3.511233E-0001 6.734132E+0001
8.920000E+0002 -4.050000E+0000 -1.217724E+0000 6.733994E+0001
8.930000E+0002 -3.730000E+0000 -1.500098E+0000 6.733926E+0001
8.940000E+0002 -2.720000E+0000 -1.095447E+0000 6.733918E+0001
8.950000E+0002 -2.050000E+0000 -6.017159E-0001 6.733937E+0001
8.960000E+0002 -1.600000E+0000 -2.794007E-0002 6.733976E+0001
8.970000E+0002 -2.560000E-0001 1.077866E+0000 6.734094E+0001
8.980000E+0002 5.410000E-0001 2.341640E+0000 6.734250E+0001
8.990000E+0002 1.040000E+0000 3.143390E+0000 6.734388E+0001
9.000000E+0002 1.280000E+0000 3.477986E+0000 6.734486E+0001
9.010000E+0002 6.410000E-0001 2.754052E+0000 6.734566E+0001
9.020000E+0002 6.330000E-0001 2.543717E+0000 6.734658E+0001
9.030000E+0002 1.080000E+0000 2.714350E+0000 6.734781E+0001
9.040000E+0002 1.680000E+0000 3.107927E+0000 6.734933E+0001
9.050000E+0002 2.590000E+0000 3.400210E+0000 6.735091E+0001
9.060000E+0002 3.070000E+0000 3.752586E+0000 6.735261E+0001
9.070000E+0002 3.020000E+0000 3.830545E+0000 6.735415E+0001
9.080000E+0002 3.100000E+0000 3.913976E+0000 6.735567E+0001
9.090000E+0002 3.320000E+0000 4.082217E+0000 6.735729E+0001
9.100000E+0002 4.180000E+0000 4.671859E+0000 6.735936E+0001
9.110000E+0002 4.330000E+0000 4.936585E+0000 6.736131E+0001
9.120000E+0002 5.150000E+0000 5.159523E+0000 6.736224E+0001
9.130000E+0002 5.830000E+0000 5.519285E+0000 6.736328E+0001
9.140000E+0002 5.720000E+0000 5.628369E+0000 6.736411E+0001
9.150000E+0002 5.750000E+0000 5.707050E+0000 6.736486E+0001
9.160000E+0002 6.010000E+0000 5.925410E+0000 6.736571E+0001
9.170000E+0002 6.260000E+0000 6.217320E+0000 6.736668E+0001
9.180000E+0002 5.980000E+0000 6.313503E+0000 6.736749E+0001
9.190000E+0002 5.740000E+0000 6.340631E+0000 6.736819E+0001
9.200000E+0002 5.800000E+0000 6.582336E+0000 6.736910E+0001
9.210000E+0002 6.730000E+0000 8.016759E+0000 6.737161E+0001
Post Reply