Skip to content
Snippets Groups Projects
Commit f9aceef6 authored by Nils Brüggemann's avatar Nils Brüggemann
Browse files

pyicon/pyicon_tb.py: Added find_section_indices.

parent 396b61c2
No related branches found
No related tags found
No related merge requests found
......@@ -1954,3 +1954,21 @@ def cons_remap(da, lon=None, lat=None, cell_area=None):
dai = xr.DataArray(dai_ma, coords={'lat': lat_da, 'lon': lon_da})
return dai
def find_section_indices(clon, clat, lon_sec, lat_sec):
# reduce domain to save time
ind_reg = np.where(
(clon>=lon_sec.min()) & (clon<lon_sec.max()) & (clat>=lat_sec.min()) & (clat<lat_sec.max())
)[0]
clon_r = clon[ind_reg]
clat_r = clat[ind_reg]
# get indices
dckd_sec_c, ickd_sec_c = calc_ckdtree(lon_i=clon_r.data, lat_i=clat_r.data,
lon_o=lon_sec, lat_o=lat_sec,
n_nearest_neighbours=1,
)
inds = np.arange(clon.size, dtype=int)
inds_r = inds[ind_reg]
inds_sec = inds_r[ickd_sec_c]
return inds_sec
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment