From: John [H2O] <washakie@gm...> - 2009-08-11 16:10:45
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
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:
Raw data points plotted:
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.
From: Christopher Barker <Chris.B<arker@no...> - 2009-08-12 16:42:09
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:
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.
Christopher Barker, Ph.D.
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