re grid non regular data, then mask for continents / artifacts

Hello,

I have a dataset that is provided with 0.5degree latitude information, but
1,2, or 10 degree longitude. I have used the matplotlib.mlab.griddata
function with natgrid installed to resample the dataset to a uniform 0.5x0.5
degree grid.

The dataset locations can be seen below, note the regular lat spacing but
shifting lon spacing.

Now, the second plot below shows the raw data plotted. And the next the
regridded data. Note the artifacts. I have two requirements now for a data
mask. First, I need to mask any data over (under?) land, and secondly I need
to create a mask to get rid of the artifact data. Does anyone have a good
solution for this? Do I have to use something like the mlab.inside_poly
function? If so, how would I create the 'vertices' of the polygon?

I'm not looking for the landsea mask just for plotting, but I actually have
to mask the raw data array for writing out.

Could I use my original data to create the mask somehow? The problem is that
all the points between data locations would not be included....
Suggestions? Direct examples? It seems it must be a fairly common problem.

Raw data locations:
http://www.nabble.com/file/p24920704/datalocations_flat.png

Raw data points plotted:
http://www.nabble.com/file/p24920704/rawdata.png

Regridded data:
http://www.nabble.com/file/p24920704/regriddata.png

···


View this message in context: http://www.nabble.com/regrid-non-regular-data%2C-then-mask-for-continents---artifacts-tp24920704p24920704.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Impatiently I somewhat double posted (though, actually, I thought this was a
better list than scipy for the question). Regardless... the conversation is
mostly here:
http://www.nabble.com/2d-interpolation%2C-non-regular-lat-lon-grid-td24909685.html

···


View this message in context: http://www.nabble.com/regrid-non-regular-data%2C-then-mask-for-continents---artifacts-tp24920704p24926044.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

John [H2O] wrote:

Impatiently I somewhat double posted (though, actually, I thought this was a
better list than scipy for the question). Regardless... the conversation is
mostly here:
http://www.nabble.com/2d-interpolation%2C-non-regular-lat-lon-grid-td24909685.html

One comment:

mgrid() is designed to interpolate form unstructured data to a regular grid.

Given that your data is, in fact, quite structured, I suspect you may get better results from a a custom-written interpolator -- simple bi-linear (or bspline) interpolation would be pretty easy to write, and may give you a cleaner result. You may even be able to grab code straight from scipy.interpolate, an apply it on the different portions of your grid separately.

HTH,

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...