def read_baseline_info(baseline_file, reference_file): """Read date, bperp and/or DOP info Parameters: baseline_file : str, path of bl_list.txt file reference_file : str, path of ifgramStack.h5 file Returns: date_list : list of str in YYMMDD format tbase_list : list of int in days pbase_list : list of float in meter dop_list : None, list of 1D array in size of (3,) """ dop_list = None if baseline_file: date_list, pbase_list, dop_list = pnet.read_baseline_file( baseline_file)[0:3] date_list = ptime.yymmdd(date_list) tbase_list = ptime.date_list2tbase(date_list)[0] elif reference_file: obj = ifgramStack(reference_file) date12_list_all = obj.get_date12_list(dropIfgram=False) date12_list_all = ptime.yymmdd_date12(date12_list_all) m_dates = [i.split('-')[0] for i in date12_list_all] s_dates = [i.split('-')[1] for i in date12_list_all] date_list = sorted(list(set(m_dates + s_dates))) tbase_list = ptime.date_list2tbase(date_list)[0] pbase_list = obj.get_perp_baseline_timeseries( dropIfgram=False).tolist() return date_list, tbase_list, pbase_list, dop_list
def read_network_info(inps): ext = os.path.splitext(inps.file)[1] # 1. Read dateList and pbaseList if ext in ['.h5', '.he5']: k = readfile.read_attribute(inps.file)['FILE_TYPE'] print('reading temporal/spatial baselines from {} file: {}'.format(k, inps.file)) if k == 'ifgramStack': inps.dateList = ifgramStack(inps.file).get_date_list(dropIfgram=False) inps.pbaseList = ifgramStack(inps.file).get_perp_baseline_timeseries(dropIfgram=False) elif k == 'timeseries': obj = timeseries(inps.file) obj.open(print_msg=False) inps.dateList = obj.dateList inps.pbaseList = obj.pbase else: raise ValueError('input file is not ifgramStack/timeseries, can not read temporal/spatial baseline info.') else: print('reading temporal/spatial baselines from list file: '+inps.bl_list_file) inps.dateList, inps.pbaseList = pnet.read_baseline_file(inps.bl_list_file)[0:2] print('number of acquisitions: {}'.format(len(inps.dateList))) # 2. Read All Date12/Ifgrams/Pairs inps.date12List = pnet.get_date12_list(inps.file) print('reading interferograms info from file: {}'.format(inps.file)) print('number of interferograms: {}'.format(len(inps.date12List))) if inps.save_list: txtFile = os.path.splitext(os.path.basename(inps.file))[0]+'_date12List.txt' np.savetxt(txtFile, inps.date12List, fmt='%s') print('save pairs/date12 info to file: '+txtFile) # Optional: Read dropped date12 / date inps.dateList_drop = [] inps.date12List_drop = [] if ext in ['.h5', '.he5'] and k == 'ifgramStack': inps.date12List_keep = ifgramStack(inps.file).get_date12_list(dropIfgram=True) inps.date12List_drop = sorted(list(set(inps.date12List) - set(inps.date12List_keep))) print('-'*50) print('number of interferograms marked as drop: {}'.format(len(inps.date12List_drop))) print('number of interferograms marked as keep: {}'.format(len(inps.date12List_keep))) mDates = [i.split('_')[0] for i in inps.date12List_keep] sDates = [i.split('_')[1] for i in inps.date12List_keep] inps.dateList_keep = sorted(list(set(mDates + sDates))) inps.dateList_drop = sorted(list(set(inps.dateList) - set(inps.dateList_keep))) print('number of acquisitions marked as drop: {}'.format(len(inps.dateList_drop))) if len(inps.dateList_drop) > 0: print(inps.dateList_drop) # Optional: Read Coherence List inps.cohList = None if ext in ['.h5', '.he5'] and k == 'ifgramStack': inps.cohList, cohDate12List = ut.spatial_average(inps.file, datasetName='coherence', maskFile=inps.maskFile, saveList=True, checkAoi=False) if all(np.isnan(inps.cohList)): inps.cohList = None print('WARNING: all coherence value are nan! Do not use this and continue.') if set(cohDate12List) > set(inps.date12List): print('extract coherence value for all pair/date12 in input file') inps.cohList = [inps.cohList[cohDate12List.index(i)] for i in inps.date12List] elif set(cohDate12List) < set(inps.date12List): inps.cohList = None print('WARNING: not every pair/date12 from input file is in coherence file') print('turn off the color plotting of interferograms based on coherence') return inps