def down_ion_dcb(ftp, time): doy = common.ymd2doy(time.year, time.month, time.day) yy = time.year - 2000 if time.year >= 2000 else time.year - 1900 gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) condition_list = list() condition_list.append('CODG{:03d}0.{:02d}I.Z'.format(doy, yy)) condition_list.append('P1C1{:2d}{:02d}.DCB.Z'.format(yy, time_idx.month)) condition_list.append('P1P2{:2d}{:02d}.DCB.Z'.format(yy, time_idx.month)) condition_list.append('P2C2{:2d}{:02d}_RINEX.DCB.Z'.format( yy, time_idx.month)) local_dir = LOCAL_DIR + str(time.year) + '/' + str( gps_week) + '/' + '{:03d}'.format(doy) + '/' + 'prods' remote_dir = 'CODE/' + str(time.year) if not os.path.exists(local_dir): os.makedirs(local_dir) ion_dcb_files = ftp.file_classification(remote_dir, condition_list, 'ion_dcb') for file_name in ion_dcb_files: if 'DCB' in file_name: local_dir = LOCAL_DIR + str(time.year) + '/' + 'dcb' else: local_dir = LOCAL_DIR + str(time.year) + '/' + str( gps_week) + '/' + '{:03d}'.format(doy) + '/' + 'prods' if not os.path.exists(local_dir): os.makedirs(local_dir) local_path = os.path.join(local_dir, file_name.split('/')[-1]) if os.path.exists(local_path[:-2]): print("%s is exit!" % local_path[:-2]) continue remote_path = remote_dir + '/' + file_name.split('/')[-1] ftp.down_file_single(local_path, remote_path) ftp.decompress_file(local_path)
def down_igs_erpsnx(ftp, time): """ 下载igs周解的erp和snx文件: ftp://igs.gnsswhu.cn/pub/gps/products/<week>/igs<yy>P<week>.<snx, erp>.Z """ doy = common.ymd2doy(time.year, time.month, time.day) yy = time.year - 2000 if time.year >= 2000 else time.year - 1900 gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) local_dir = LOCAL_DIR + str(time.year) + '/' + '{:d}/'.format(gps_week) remote_dir = 'pub/gps/products/' + str(gps_week) if not os.path.exists(local_dir): os.makedirs(local_dir) condition_list = list() condition_list.append('igs%dP%d.erp.Z' % (yy, gps_week)) condition_list.append('igs%dP%d.snx.Z' % (yy, gps_week)) down_erpsnx_files = ftp.file_classification(remote_dir, condition_list, 'igs') for file_name in down_erpsnx_files: local_path = os.path.join(local_dir, file_name) if os.path.exists(local_path[:-2]): print('%s is exits!' % local_path[:-2]) continue remote_path = os.path.join(remote_dir, file_name) ftp.down_file_single(local_path, remote_path) ftp.decompress_file(local_path)
def down_obs(ftp, down_sta_select, time): """ down_sta_select: 若为[], 则默认下载多有mgex测站数据; 不为空且为四位的测站名则下载指定的测站数据;也可指定测站所属国,如CHN 下载mgex的rinex3数据:ftp://igs.gnsswhu.cn/pub/gps/data/daily/ 长文件名改成短文件名 <SITE><DOY>.<YY>o 数据存储在 /mgex/<YEAR>/<WEEK>/<DOY>/obs/ """ doy = common.ymd2doy(time.year, time.month, time.day) yy = time.year - 2000 if time.year >= 2000 else time.year - 1900 gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) local_dir = LOCAL_DIR + str(time.year) + '/' + '{:d}/'.format(gps_week) \ + '{:03d}/'.format(doy) + 'obs' remote_dir = 'pub/gps/data/daily/' + str( time.year) + '/' + '{:03d}'.format(doy) + '/' + '{:02d}d'.format(yy) if not os.path.exists(local_dir): os.makedirs(local_dir) down_obs_files = ftp.file_classification(remote_dir, down_sta_select, 'obs') for file_name in down_obs_files: re_name = str.lower( file_name[:4]) + '{:03d}0.'.format(doy) + '{:2d}o'.format(yy) re_path = os.path.join(local_dir, re_name) if os.path.exists(re_path): print('%s is exits!' % re_path) continue local_path = os.path.join(local_dir, file_name) remote_path = os.path.join(remote_dir, file_name) ftp.down_file_single(local_path, remote_path) src_path = ftp.decompress_file(local_path) ftp.crx2rnx(local_dir, src_path, doy, yy)
def down_cod_osb(ftp, time): doy = common.ymd2doy(time.year, time.month, time.day) gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) remote_dir = 'pub/gnss/products/mgex/' + str(gps_week) local_dir = LOCAL_DIR + str(time.year) + '/' + '{:d}/'.format( gps_week) + '{:03d}/'.format(doy) + 'prods' if not os.path.exists(local_dir): os.makedirs(local_dir) file_name = 'COD0MGXFIN_%04d%03d0000_01D_01D_OSB.BIA.gz' % (time.year, doy) local_path = os.path.join(local_dir, file_name) if os.path.exists(local_path[:-2]): print("%s is exit!" % local_path[:-2]) return remote_path = os.path.join(remote_dir, file_name) ftp.down_file_single(local_path, remote_path) ftp.decompress_file(local_path)
def down_cas_dcb(ftp, time): doy = common.ymd2doy(time.year, time.month, time.day) yy = time.year - 2000 if time.year >= 2000 else time.year - 1900 gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) local_dir = LOCAL_DIR + str(time.year) + '/' + '{:d}/'.format( gps_week) + '{:03d}/'.format(doy) + 'prods' remote_dir = 'product/dcb/mgex/' + str(time.year) + '/' if not os.path.exists(local_dir): os.makedirs(local_dir) file_name = 'CAS0MGXRAP_%04d%03d0000_01D_01D_DCB.BSX.gz' % (time.year, doy) # file_name = 'CAS0MGXRAP_%04d%03d0000_01D_01D_OSB.BIA.gz' % (time.year, doy) local_path = os.path.join(local_dir, file_name) if os.path.exists(local_path[:-3]): print("%s is exit!" % local_path[:-3]) return remote_path = os.path.join(remote_dir, file_name) ftp.down_file_single(local_path, remote_path) ftp.decompress_file(local_path)
def down_pre(ftp, ac_list, time): """ 下载精密产品:ftp://igs.gnsswhu.cn/pub/gnss/products/mgex/<week> 只下载MGEX的长文件名数据,即GPS 2038周 2019 1 28 后 ac_list:发布机构 ['COD', 'GFZ', 'WUM']; 若为空则全部下载; GRG没提供erp暂不下载 数据存储在 /mgex/<YEAR>/<DOY>/products/<ac> """ doy = common.ymd2doy(time.year, time.month, time.day) gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) remote_dir = 'pub/gnss/products/mgex/' + str(gps_week) if ac_list[0] is 'GBM': remote_dir = 'GNSS/products/mgex/' + str(gps_week) if not ac_list: ac_list = ['COM', 'WUM', 'GRM'] for i in range(0, len(ac_list)): local_dir = LOCAL_DIR + str(time_idx.year) + '/' + '{:d}/'.format(gps_week) \ + str.lower(ac_list[i]) if not os.path.exists(local_dir): os.makedirs(local_dir) pre_files = ftp.file_classification(remote_dir, ac_list[i], 'pre') for file_name in pre_files: year = int(file_name[11:15]) doy = int(file_name[15:18]) gps_week, gps_dow = common.yrdoy2gpst(year, doy) re_path = rename_pre(file_name[:-3], ac_list[i], local_dir, gps_week, gps_dow) if os.path.exists(re_path): print('%s is exits!' % re_path) continue local_path = os.path.join(local_dir, file_name) remote_path = os.path.join(remote_dir, file_name) if ftp.down_file_single(local_path, remote_path) is False: continue dst_path = ftp.decompress_file(local_path) os.rename(dst_path, re_path)
def down_nav(ftp, time): """ 下载星历数据:ftp://igs.gnsswhu.cn/pub/gnss/mgex/daily/rinex3/<YEAR>/<DOY>/<YY>p/brdm<DOY>0.<YY>p.Z 数据存储在 /mgex/<YEAR>/<WEEK>/<DOY>/prods/ """ doy = common.ymd2doy(time.year, time.month, time.day) yy = time.year - 2000 if time.year >= 2000 else time.year - 1900 gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) local_dir = LOCAL_DIR + str(time.year) + '/' + '{:d}/'.format( gps_week) + '{:03d}/'.format(doy) + 'prods' remote_dir = 'pub/gnss/mgex/daily/rinex3/' + str( time.year) + '/' + '{:03d}'.format(doy) + '/' + '{:02d}p'.format(yy) if not os.path.exists(local_dir): os.makedirs(local_dir) file_name = 'brdm%03d0.%02dp.Z' % (doy, yy) local_path = os.path.join(local_dir, file_name) if os.path.exists(local_path[:-2]): print("%s is exit!" % local_path[:-2]) return remote_path = os.path.join(remote_dir, file_name) ftp.down_file_single(local_path, remote_path) ftp.decompress_file(local_path)
def down_gbm_pre(ftp, time): doy = common.ymd2doy(time.year, time.month, time.day) gps_week, gps_dow = common.yrdoy2gpst(time_idx.year, doy) remote_dir = 'pub/gnss/products/mgex/' + str(gps_week)