Closed bward-mcgill closed 2 years ago
@bward-mcgill Did you manage to solve the problem yourself? If not, I would like to keep the issue open to remember that it still needs a fix. I try to do my best but I cannot find always enough time to manage all the issues. Sorry!
Hello @molinav, I figured that the problem didn't come from the makegrid() function, but from an other part of the function that I implemented. I assumed that the makegrid was returning a rectilinear grid, but I was wrong since an equally spaced grid in a stereographic projection is in fact curvilinear. Therefore, I add to change a little bit the way I was interpolating my field and now I fixed it.
That being said, I still think that I could be nice to add the possibility to use the transform_vector with 2-D longitudes and latitudes so it could work for people that are working with non-rectilinear grid.
Thanks !!
Hello, I'm trying to reproduce the
transform_vector()
function. Basically, I want to plot my wind vector rotated and interpolated in a north polar stereographic projection. Here's the source code :So my understanding is that the function is quite simple. There is some verifications at the beginning in order to make sure that the longitude goes to -180 to 180 and that both longitude and latitude are well ordered (I guess that this is important for
interp()
). After that it callsmakegrid()
to create a nice equally spaced grid in the projection. After that it interpolates withinterp()
. Finally it rotate the vectors in the projection withrotate_vector
. I was able to use the function with a regular rectilinear grid. In such case, the a grid can be fully represented only by two 1d vectors (the latitude is constant when we are moving on a longitude line) so I can specify 1d vector as input fortransform_vector()
and it works. Here's what it looks like :However, I am working with a rotated pole curvilinear grid : my grid need to be represented by two 2d matrix since the latitude is changing when we are moving on a constant longitude line. Therefore, I cannot use
transform_vector()
anymore. From what I saw, the only problem comes ininterp()
function (it can only take a 1d array for lons and lats). The rest should still work with 2d matix (rotate_vector()
still work with 2d matrix and it should not make any difference formakegrid()
). Therefore, I implemented a function that is really similar totransform_vector()
but it uses a different method for the interpolation.The function is working except when I'm using the a stereographic projection for basem. For example, when I use :
basem = Basemap(projection='npstere', boundinglat=35,lon_0=270, resolution='l')
Here's what I get :Here's what it gives me for latsout and lonsout :
In don't understand why because I'm calling
makegrid()
in the same way that it is called intransform_vector()
but for some reason it doesn't work for me. What confuse me even more is that when I use the mercator projection themakegrid()
works perfectly. For example when I usebasem = Basemap(projection='merc',llcrnrlat=-80,urcrnrlat=80, llcrnrlon=-180,urcrnrlon=180,lat_ts=20,resolution='c')
I now get :
I hope that my problem is clear. If anyone has any idea on why the
makegrid()
function doesn't work when I'm calling it in mycreate_wind_projection()
function for a npstere projection, please let me know !!