def ResampleWind(): tt = np.load(coast_root + 'Left coast for each row.npy') d = rd.SentinelData() d.Get_List_NetCDF(ocn_root) for indice in range(len(d.series)): temp = rd.Data_Level2(d.series[indice], d.FList[indice]) temp.Get_WindData() temp.CalWindVector() mask = temp.windX.mask.reshape(-1) Ind = np.where(mask == 0)[0] lon = temp.lon.data.reshape(-1) lat = temp.lat.data.reshape(-1) U = temp.windX.data.reshape(-1) V = temp.windY.data.reshape(-1) lon, lat, U, V = lon[Ind], lat[Ind], U[Ind], V[Ind] r, c, u, v = md2.GridLL_Wind(lon, lat, U, V) ind = [xx for xx in range(len(r)) if tt[r[xx]] > c[xx]] r_new = [r[xx] for xx in ind] c_new = [c[xx] for xx in ind] u_new = [u[xx] for xx in ind] v_new = [v[xx] for xx in ind] r, c, u, v = r_new, c_new, u_new, v_new del r_new, c_new, u_new, v_new, ind # md2.save_fig(d.series[indice], r, c, u, v) if len(r) >= 4: u10, v10 = Lc.InterpolationWinds(r, c, u, v) np.save(level2_root + 'Interp/' + d.series[indice] + '-u10.npy', u10) np.save(level2_root + 'Interp/' + d.series[indice] + '-v10.npy', v10) u10 = np.zeros([15, 19], dtype=np.float16) v10 = np.zeros_like(u10) du = {} dv = {} for ii in range(len(r)): r1, c1 = r[ii] // 150, c[ii] // 150 if (r1, c1) in du: du[r1, c1].append(u[ii]) dv[r1, c1].append(v[ii]) else: du[r1, c1] = [u[ii]] dv[r1, c1] = [v[ii]] for rr, cc in du.keys(): u10[rr, cc] = np.mean(du[rr, cc]) v10[rr, cc] = np.mean(dv[rr, cc]) np.save(level2_root + 'NotInterp/' + d.series[indice] + '-u10.npy', u10) np.save(level2_root + 'NotInterp/' + d.series[indice] + '-v10.npy', v10) return None
def Resample(n, mode='uniform'): d = rd.SentinelData() d.Get_List(file_root) m = 1 # resize factor for indice in range(n, len(d.series)): stt = time.time() temp = rd.Data_Level1(d.series[indice], d.FList[indice]) temp.OneStep() GCP = temp.GCPs SigmaNaught = temp.denoiseNRCS name = 'Layer' + str(indice) + '-' + d.series[indice] del temp y1, x1 = SigmaNaught.shape sub_img, up_left = cod.N_sub(tempN, SigmaNaught) del SigmaNaught, up_left jo.NMatrix_save(sub_img, 'SigmaNaught', temp_root) del sub_img md2.AllLonLat(name, x1, y1, GCP, m) img, pixel_num = md2.GridLL_SigmaNaught(mode) jo.Matrix_save(img, name, layer_root) jo.Matrix_save(pixel_num, name + '-distribution', layer_root) print('1 image:', (time.time() - stt) / 60, 'mins') print('Done!\n') return None