-1

I have a data set with (latitude, longitude, temperature) and I'm trying to interpolate the temperature to graph it with contourf. However, the interpolated has nan values in it (I'm sure that my data does not have nan values).

df = pd.read_excel('temp_data.xlsx')
lat = df['LatDD'].values
lon = df['LongDD'].values
tem = df['Air_T'].values

# convert from ccrs.LambertConformal to ccrs.PlateCarree()
xp, yp, _ = crs.transform_points(ccrs.PlateCarree(), lon, lat ).T

xp, yp, tem = remove_nan_observations(xp, yp, tem)

alt_x, alt_y, data = interpolate_to_grid( xp, yp, tem, minimum_neighbors=1, interp_type = 'cressman', hres = 2000)
print(data.min())

Below is the interpolated temperature result (as well as some information)

Printed result

Is it normal for interpolated data to have nan even though the original data does not have any? Will it affect my contourf plot at the end? If yes, how do I fix this problem?

QHoang
  • 45
  • 5

2 Answers2

1

If the grid tries to interpolate to points outside the domain of the original data, than nan is returned rather than extrapolating.

DopplerShift
  • 5,472
  • 1
  • 21
  • 20
0

As DopplerShift mentioned above, it seems that my search_radius is too small and some point that is outside of the domain cannot find any reference point close to it to interpolate. My solution was to increase the search_radius and the problem was solved.

QHoang
  • 45
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 19:16