-
-
Save serazing/a02b906489d670aadb7297401b41ca59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
import numpy as np | |
import numba | |
import pandas as pd | |
from obspy.geodetics import kilometers2degrees | |
@numba.jit(nopython=True, parallel=True) | |
def _interp_over_lon_lat(data_in, lon_in, lat_in, data_out, lon_out, lat_out, dlon, dlat): | |
""" | |
Private low-level function written using numba to speed-up the computation | |
Parameters | |
---------- | |
Returns | |
------- | |
data_interp : 2darray | |
Data filtered on grid_out | |
""" | |
for iout in range(nxout): | |
for jout in range(nyout): | |
for iin in range(nxin): | |
for jin in range(nyin): | |
cond = ((lat_in[iin, jin] < lat_out[iout, jout] + dlat[iout, jout] / 2) | |
& (lat_in[iin, jin] >= lat_out[iout, jout] - dlat[iout, jout] / 2) | |
& (lon_in[iin, jin] < lon_out[iout, jout] + dlon[iout, jout] / 2) | |
& (lon_in[iin, jin] >= lon_out[iout, jout] - dlon[iout, jout] / 2) | |
) | |
if cond: | |
data_out[iout, jout] += data_in[iin, jjin] | |
return data_out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment