Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#Deal with fact that field names are different for GPS and CAM records: 'GPS_Week' vs 'CAM_GPSWeek'
if any('CAM' in s for s in x.dtype.names):
week = 'CAM_GPSWeek'
time = 'CAM_GPSTime'
lat = 'CAM_Lat'
lon = 'CAM_Lng'
alt = 'CAM_Alt'
else:
week = 'GPS_Week'
time = 'GPS_TimeMS'
lat = 'GPS_Lat'
lon = 'GPS_Lng'
alt = 'GPS_Alt'
#Note: Need to fix gpstime UTCFromGps function to work with np arrays
utc = [gpstime.UTCFromGps(z[0], z[1]) for z in zip(x[week], x[time]/1000.)]
#Note: gpsbabel needs the ISO format, otherwise can't handle sub-second
utc_dt = np.array([datetime(*t).isoformat() for t in utc])
y = np.array([utc_dt, x[lat], x[lon], x[alt]])
hdr = 'DateTime,Lat,Lon,Elev'
#np.savetxt(out_fn, y.T, delimiter=',', fmt='%s,%0.8f,%0.8f,%0.2f', header=hdr, comments='')
np.savetxt(out_fn, y.T, delimiter=',', fmt='%s', header=hdr, comments='')