Artificial intelligent assistant

Interpolate Columnar Data I am trying to find a way to interpolate between two lines of data in a CSV file, likely using `awk`. Right now, each line represents a data point at Hour 0 and Hour 6. I am looking to fill in missing hourly data between Hour 0 and Hour 6. **Current CSV** lat,lon,fhr 33.90000,-76.50000,0 34.20000,-77.00000,6 **Expected Interpolated Output** lat,lon,fhr 33.90000,-76.50000,0 33.95000,-76.58333,1 34.00000,-76.66667,2 34.05000,-76.75000,3 34.10000,-76.83333,4 34.15000,-76.91667,5 34.20000,-77.00000,6

Given this file:


cat file



lat,lon,fhr
33.90000,-76.50000,0
34.20000,-77.00000,6
34.20000,-77.50000,12


then


awk -F, '
function interpolate(lat1, lon1, t1, lat2, lon2, t2, i) {
for (i = 1; i <= (t2 - t1); i++) {
printf "%.5f,%.5f,%d\
",
lat1 + i * (lat2 - lat1) / (t2 - t1),
lon1 + i * (lon2 - lon1) / (t2 - t1),
t1 + i
}
}
NR <= 2 {print}
NR >= 3 {interpolate(lat, lon, t, $1, $2, $3)}
{lat = $1; lon = $2; t = $3}
' file



lat,lon,fhr
33.90000,-76.50000,0
33.95000,-76.58333,1
34.00000,-76.66667,2
34.05000,-76.75000,3
34.10000,-76.83333,4
34.15000,-76.91667,5
34.20000,-77.00000,6
34.20000,-77.08333,7
34.20000,-77.16667,8
34.20000,-77.25000,9
34.20000,-77.33333,10
34.20000,-77.41667,11
34.20000,-77.50000,12

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2d162e0977cede24adb4c8405639bbe4