I am not sure if my question is on topic or not and if not please let me know. I have regularly spaced gridded data(output of a weather forecast simulation software) and I have latitude and longitudes as 2D arrays along with geopotential height(2D array). The data is in netCDF or GRIB format. Ultimately I am looking to make a contour plot of the heights data and I am looking to use Python's scipy and matplotlib package. I initially need to do an interpolation of the various data points. From the scipy package what would be the best interpolation function that I should choose for my use case which has structured grid data ? Is something like the linked API ideally suited for me ? Initially I went ahead and tried griddata but this seems for unstructured grid data.
1 Answer
If your data are regularly spaced, you do not need an interpolation procedure, you can directly plot a contour through a contour
or a pcolor
command. That why I don't understand why you need to initially interpolate.
Contouring algorithms often use marching cube method (and its variations) to render a contour plot. This kind of algorithm only work with a structured grid. For an unstructured grid, routines likes griddata
perform a Delaunay triangulation or similar and indeed do an interpolation to recover data on an structured grid where the contouring algorithm can be applied.