Gents,
I have an csv file which contends value GPS time for each record and x, y coordinates.. The purpose is to identify which vps does not match with the law parameters in the relation time and offset.
In the graphic attached you can see example of 3 vps which are showed in red color and falls in the area not allowed. All records marked as blue are ok.
Then the thing is to sort the records by GPS time .. ( I did this part in my script ). calculate the time from GPS time as HHMMSS. ( done ).. now we need to duplicate say 10 time each record and write in front the next ones ( example analysis_25.csv ).
Here is the time to calculate the offset (column 18) and time (column 19) in the file analysis_25.csv..
Using the Law parameters we need to compute the Allowed_SlipTime ( column 19 ) and with this value we can define witch records are bad ( bad_records_25.csv) ...
In the graphic analysis_25.png we can see how the law works by time and offset
Values for law are:
Slip time(s)) 18 18 6 0 0 0
Offset(m) 0 2000 6000 12000 12001 24000
Max time (s) 25
Max offset (m) 15000
Here my script till now.
awk 'NR>1{print $0}' $25.csv | awk -F, '{
line=substr($10,1,5)
point=substr($11,1,5)
ffid=$2
sw=$5
tape=$6;\
x=$49;\
y=$50;\
tb=$46
printf("%4d %5d %5d %4d %4d %10.1f %10.1f %s\n",tape,line,point,ffid,sw,x,y,tb)}' | sort -k8n |
awk '{v=substr($8,16,1); gsub(/2/,"0",v);print substr($0,1,64) v}' > toto
awk '\
function gpstojdtime(gpstime) {\
gpss = (gpstime/1000000)+10800;\
jtmp = (gpss-((2017-1980)*365+10-6)*86400-18)/86400;\
jday = int(jtmp);\
htmp = 24*(jtmp - jday);\
hour = int(htmp);\
mtmp = 60*((htmp - hour));\
minu = int(mtmp);\
stmp = 60*(mtmp - minu);\
secd = (stmp);\
return hour*10000+minu*100+secd;\
}\
{\
{\
tape=$1;\
splin=$2;\
spnum=$3;\
sprec=$4;\
sw=$5;\
x=$6;\
y=$7;\
spgps=$8;\
gpt=$8;\
printf"%4s %5d %5d %4s %4s %10.1f %10.1f %10.3f %s\n",\
tape,splin,spnum,sprec,sw,x,y,gpstojdtime(spgps),gpt\
};\
}' toto | head -20
The support data is attached :
25.csv = Input data
analysis_25.png = Graphic results
analysis_25.csv = Data results - Desired output file
bad_records_25.csv = Bad records results - Desired output file
Appreciate your help