You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ph_turb=np.zeros((n_atms, ny_generate, nx_generate)) # initiate output as a rank 3 (ie n_images x ny x nx)
577
+
ph_turbs=np.zeros((n_atms, ny_generate, nx_generate)) # initiate output as a rank 3 (ie n_images x ny x nx)
578
578
xyz_m, pixel_spacing=lon_lat_to_ijk(lons_mg_ds, lats_mg_ds) # get pixel positions in metres from origin in lower left corner (and also their size in x and y direction)
579
579
xy=xyz_m[0:2].T# just get the x and y positions (ie discard z), and make lots x 2 (ie two columns)
sp=0.001*np.mean((pixel_spacing['x'], pixel_spacing['y'])) ) # generate noise using fft method. pixel spacing is average in x and y direction (and m converted to km)
590
590
ifverbose:
591
591
print(f'Generated {i+1} of {n_atms} single acquisition atmospheres. ')
592
592
593
593
else:
594
594
pixel_distances=sp_distance.cdist(xy,xy, 'euclidean') # calcaulte all pixelwise pairs - slow as (pixels x pixels)
# print(f'Generated {success} of {n_atms} single acquisition atmospheres (with {fail} failures). ')
629
+
# except:
630
+
# fail += 0
631
+
# if verbose:
632
+
# print(f"'generate_correlated_noise_cov' failed, which is usually due to errors in the cholesky decomposition that Numpy is performing. The odd failure is normal. ")
print('Interpolating to the larger size...', end='')
605
-
ph_turb_output=np.zeros((n_atms, ny, nx)) # initiate output at the upscaled size (ie the same as the original lons_mg shape)
606
-
foratm_n, atminenumerate(ph_turb): # loop through the 1st dimension of the rank 3 atmospheres.
643
+
ph_turbs_output=np.zeros((n_atms, ny, nx)) # initiate output at the upscaled size (ie the same as the original lons_mg shape)
644
+
foratm_n, atminenumerate(ph_turbs): # loop through the 1st dimension of the rank 3 atmospheres.
607
645
f=scipy_interpolate.interp2d(np.arange(0,nx_generate), np.arange(0,ny_generate), atm, kind='linear') # and interpolate them to a larger size. First we give it meshgrids and values for each point
608
-
ph_turb_output[atm_n,:,:] =f(np.linspace(0, nx_generate, nx), np.linspace(0, ny_generate, ny)) # then new meshgrids at the original (full) resolution.
646
+
ph_turbs_output[atm_n,:,:] =f(np.linspace(0, nx_generate, nx), np.linspace(0, ny_generate, ny)) # then new meshgrids at the original (full) resolution.
609
647
ifverbose:
610
648
print('Done!')
611
649
else:
612
-
ph_turb_output=ph_turb# if we're not interpolating, no change needed
650
+
ph_turbs_output=ph_turbs# if we're not interpolating, no change needed
613
651
614
652
# 4: rescale to correct range (i.e. a couple of cm)
0 commit comments