Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def CODE_rapid_files(dt, prefixdir=""):
"""
retrieve rapid CODE products for the datetime dt
Examples of Rapid files: (FIXME: old paths!)
ftp://ftp.unibe.ch/aiub/CODE/COD17840.EPH_R ephemeris aka orbits
ftp://ftp.unibe.ch/aiub/CODE/COD17840.ERP_R erp, earth rotation parameters
ftp://ftp.unibe.ch/aiub/CODE/COD17840.CLK_R clk, clocks
"""
server = "ftp.aiub.unibe.ch"
remotedir = "CODE/"
week = gpstime.gpsWeek( dt.year, dt.month, dt.day )
dow = gpstime.dayOfWeek( dt.year, dt.month, dt.day )
clk = "COD%s%s.CLK_R" % ( week, dow )
sp3 = "COD%s%s.EPH_R" % ( week, dow )
erp = "COD%s%s.ERP_R" % ( week, dow )
print "CODE rapid products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
print "CLK = ", clk
print "SP3 = ", sp3
print "ERP = ", erp
ftp_tools.check_dir(prefixdir + "/products/")
localdir = prefixdir + "/products/CODE_rapid/"
print "local dir = ", localdir
#return CODE_download(server, directory, [clk, sp3, erp], localdir)
return (server, "", "", remotedir, [clk, sp3, erp], localdir)
def CODE_final_files(dt, prefixdir=""):
server = "ftp.aiub.unibe.ch"
remotedir = "CODE/%s/" % (dt.year)
week = gpstime.gpsWeek( dt.year, dt.month, dt.day )
dow = gpstime.dayOfWeek( dt.year, dt.month, dt.day )
clk = "COD%s%s.CLK.Z" % ( week, dow ) # clock
sp3 = "COD%s%s.EPH.Z" % ( week, dow ) # orbit
erp = "COD%s%s.ERP.Z" % ( week, dow ) # earth
print "CODE final products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
print "CLK = ", clk
print "SP3 = ", sp3
print "ERP = ", erp
ftp_tools.check_dir(prefixdir + "/products/")
localdir = prefixdir + "/products/CODE_final/"
print "local dir = ", localdir
return (server, "", "", remotedir, [clk, sp3, erp], localdir)
def CODE_rapid_files(dt, prefixdir=""):
"""
retrieve rapid CODE products for the datetime dt
Examples of Rapid files: (FIXME: old paths!)
ftp://ftp.unibe.ch/aiub/CODE/COD17840.EPH_R ephemeris aka orbits
ftp://ftp.unibe.ch/aiub/CODE/COD17840.ERP_R erp, earth rotation parameters
ftp://ftp.unibe.ch/aiub/CODE/COD17840.CLK_R clk, clocks
"""
server = "ftp.aiub.unibe.ch"
remotedir = "CODE/"
week = gpstime.gpsWeek( dt.year, dt.month, dt.day )
dow = gpstime.dayOfWeek( dt.year, dt.month, dt.day )
clk = "COD%s%s.CLK_R" % ( week, dow )
sp3 = "COD%s%s.EPH_R" % ( week, dow )
erp = "COD%s%s.ERP_R" % ( week, dow )
print "CODE rapid products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
print "CLK = ", clk
print "SP3 = ", sp3
print "ERP = ", erp
ftp_tools.check_dir(prefixdir + "/products/")
localdir = prefixdir + "/products/CODE_rapid/"
print "local dir = ", localdir
#return CODE_download(server, directory, [clk, sp3, erp], localdir)
return (server, "", "", remotedir, [clk, sp3, erp], localdir)
def CODE_final_files(dt, prefixdir=""):
server = "ftp.aiub.unibe.ch"
remotedir = "CODE/%s/" % (dt.year)
week = gpstime.gpsWeek( dt.year, dt.month, dt.day )
dow = gpstime.dayOfWeek( dt.year, dt.month, dt.day )
clk = "COD%s%s.CLK.Z" % ( week, dow ) # clock
sp3 = "COD%s%s.EPH.Z" % ( week, dow ) # orbit
erp = "COD%s%s.ERP.Z" % ( week, dow ) # earth
print "CODE final products for %d-%02d-%0d" %( dt.year , dt.month, dt.day )
print "CLK = ", clk
print "SP3 = ", sp3
print "ERP = ", erp
ftp_tools.check_dir(prefixdir + "/products/")
localdir = prefixdir + "/products/CODE_final/"
print "local dir = ", localdir
return (server, "", "", remotedir, [clk, sp3, erp], localdir)
#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='')