def Load_PKL_or_Compute_Kernels_With_GC_From_Other_Map(HDFfilename, Context, Band, MapPath): Band = Band.upper() path = Context['wdir'] pklz_fn = path + 'GC/' + HDFfilename + '_' + Band + 'Ker' + '.pklz' pklz2_fn = MapPath + 'GC/' + HDFfilename + '_' + Band + 'Ker' + '.pklz' if L_Files.exists(pklz_fn): print('## Using precomputed kernels for band', Band) Observation, tita = Load_PKL_Obs(HDFfilename, Context, Band) else: #read geocorrection from other map print('## Reading GeoCorr from %s for Band %s' % (MapPath, Band)) Context2 = L_Context.Load_Context(MapPath, L_Context.NO_NEIGHBORS) Dict_Bands2 = Load_PKL_or_HDF_Ells(HDFfilename, Context2) #read data and copy geocorrection print('## Reading Ells') Dict_Bands = Load_PKL_or_HDF_Ells(HDFfilename, Context, GC=False) Dict_Bands[Band]['GeoCorrection'] = Dict_Bands2[Band]['GeoCorrection'] #compute and save kernels Observation, tita = L_Kernels.Compute_Kernels(Dict_Bands, Band, Context, Mode='Cell') if SAVE_OBS: Save_PKL_Obs([Observation, tita], HDFfilename, Context, Band) return Observation, tita
def Load_Shifted_Band_Kernels(HDFfilename, Context, Band, Shift_X, Shift_Y): path = Context['wdir'] Band = Band.upper() pklz_fn = path + 'GC/' + HDFfilename + '_' + Band + 'Ker' + '.pklz' MSG = "*******************************************************************************\n" Dict_Bands = Load_SingleBand_Ells(HDFfilename, Context, Band) Dict_Bands[Band]['GeoCorrection']['X'] += Shift_X Dict_Bands[Band]['GeoCorrection']['Y'] += Shift_Y print('######################################') print('## PRECOMPUTING K for BAND', Band, '#####') print('######################################') MSG += 'Computing Kernels for Band' + Band Observation, tita = L_Kernels.Compute_Kernels(Dict_Bands, Band, Context) #LOG localtime = time.asctime(time.localtime(time.time())) + '\n' MSG += '\n' if Observation == {}: MSG += "Error loading " + HDFfilename + '\n' else: MSG += "Loaded " + HDFfilename + '\n' MSG += (not Observation['GeoCorrection']['OK'] ) * 'FAILED GeoCorrecting: ' + Observation['GeoCorrection'][ 'OK'] * 'GeoCorrection: ' MSG += '[' + str(Observation['GeoCorrection']['X']) + ', ' + str( Observation['GeoCorrection']['Y']) + ']\n' MSG += 'LSQRSols: H ' + str( Observation['LSQRSols']['H']['Sol']) + ' Error:' + str( Observation['LSQRSols']['H']['norm']) + '\n' MSG += ' V ' + str( Observation['LSQRSols']['V']['Sol']) + ' Error:' + str( Observation['LSQRSols']['V']['norm']) + '\n' logging.info(localtime + MSG) return Observation, tita
def Load_PKL_or_Compute_Kernels(HDFfilename, Context, Band, GC=True): path = Context['wdir'] Band = Band.upper() pklz_fn = path + 'GC/' + HDFfilename + '_' + Band + 'Ker' + '.pklz' MSG = "*******************************************************************************\n" print("Presto a cargar para banda", Band) if L_Files.exists(pklz_fn): print('## Using precomputed kernels for band', Band) Observation, tita = Load_PKL_Obs(HDFfilename, Context, Band) MSG += 'From PKL' else: print("Preparando a cargar las cosas....") Dict_Bands = Load_PKL_or_HDF_Ells(HDFfilename, Context, GC=GC) print('######################################') print('## PRECOMPUTING K for BAND', Band, '#####') print('######################################') MSG += 'Computing Kernels for Band' + Band Observation, tita = L_Kernels.Compute_Kernels(Dict_Bands, Band, Context) if SAVE_OBS: MSG += '\nSaving PKL' Save_PKL_Obs([Observation, tita], HDFfilename, Context, Band) localtime = time.asctime(time.localtime(time.time())) + '\n' MSG += '\n' if Observation == {}: MSG += "Error loading " + HDFfilename + '\n' else: MSG += "Loaded " + HDFfilename + '\n' + "Band: " + Band + '\n' MSG += (not Observation['GeoCorrection']['OK'] ) * 'FAILED GeoCorrecting: ' + Observation['GeoCorrection'][ 'OK'] * 'GeoCorrection: ' MSG += '[' + str(Observation['GeoCorrection']['X']) + ', ' + str( Observation['GeoCorrection']['Y']) + ']\n' MSG += 'LSQRSols: H ' + str( Observation['LSQRSols']['H']['Sol']) + ' Error:' + str( Observation['LSQRSols']['H']['norm']) + '\n' MSG += ' V ' + str( Observation['LSQRSols']['V']['Sol']) + ' Error:' + str( Observation['LSQRSols']['V']['norm']) + '\n' logging.info(localtime + MSG) return Observation, tita