|
From: Jeff W. <js...@fa...> - 2005-11-03 02:25:48
|
Brian Donovan wrote: > basemap folks, > > I'm trying to understand how the transform_scalar function works. > What are the units of the native projection grid and how are they > determined? I'm trying to scale a scalar data field and overlay it on > the map. Does the location of the origin matter when I do this? To be > clear here's what I'm trying to do. > > 1) I have a Numeric array with a scalar field > 2) I want to overlay this onto a map projection > 3) The data is slightly larger than the map area (in terms of latitude > and longitude) > 4) From the examples it seams like transform_scalar and then imshow > can be used to show the data > 5) I can't seem to use transform_scalar properly > > Thanks is advance, > > Brian Brian: I'm going to assume your data (latlondata) is on a latitude/longitude grid with latitudes lats and longitude lons, and you have created a Basemap instance for your projection regrion (m). Then, to create a nx by ny grid to overlay on the map, all you need is xydata = m.transform_scalar(latlondata,lons,lats,nx,ny) you can then overlay xydata on the map with im = x.imshow(xydata, cm.jet) You only need to do this to plot the data with imshow - with pcolor or contourf you can plot the data on the original lat/lon grid using x,y = m(lons,lons) cs = m.contourf(x,y,latlondata,20,cmap=cm.jet) or im = m.pcolor(x,y,latlondata,shading='flat',cmap=cm.jet) HTH, -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Jeff W. <js...@fa...> - 2005-11-03 02:33:34
|
Jeff Whitaker wrote: > Brian Donovan wrote: >> basemap folks, >> >> I'm trying to understand how the transform_scalar function works. >> What are the units of the native projection grid and how are they >> determined? I'm trying to scale a scalar data field and overlay it on >> the map. Does the location of the origin matter when I do this? To be >> clear here's what I'm trying to do. >> >> 1) I have a Numeric array with a scalar field >> 2) I want to overlay this onto a map projection >> 3) The data is slightly larger than the map area (in terms of >> latitude and longitude) >> 4) From the examples it seams like transform_scalar and then imshow >> can be used to show the data >> 5) I can't seem to use transform_scalar properly >> >> Thanks is advance, >> >> Brian > Brian: I'm going to assume your data (latlondata) is on a > latitude/longitude grid with latitudes lats and longitude lons, and > you have created a Basemap instance for your projection regrion (m). > Then, to create a nx by ny grid to overlay on the map, all you need is > > xydata = m.transform_scalar(latlondata,lons,lats,nx,ny) > > you can then overlay xydata on the map with > > im = x.imshow(xydata, cm.jet) > > You only need to do this to plot the data with imshow - with pcolor or > contourf you can plot the data on the original lat/lon grid using > > x,y = m(lons,lons) > > cs = m.contourf(x,y,latlondata,20,cmap=cm.jet) > > or > > im = m.pcolor(x,y,latlondata,shading='flat',cmap=cm.jet) > > HTH, > > -Jeff > > Brian: One correction - lons and lats are 1-d arrays describing the lat/lon grid, so instead of x,y = m(lons,lats) you'll need lons, lats = pylab.meshgrid(lons, lats) x, y = m(lons, lats) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Brian D. <do...@mi...> - 2005-11-03 17:06:54
|
Dr. Whitaker, Thank you for helping me with this. My point of confusion is what should nx and ny contain when they are sent into the transform_scalar function: >> xydata = m.transform_scalar(latlondata,lons,lats,nx,ny) Thanks, Brian On Nov 2, 2005, at 9:32 PM, Jeff Whitaker wrote: > Jeff Whitaker wrote: >> Brian Donovan wrote: >>> basemap folks, >>> >>> I'm trying to understand how the transform_scalar function >>> works. What are the units of the native projection grid and how >>> are they determined? I'm trying to scale a scalar data field and >>> overlay it on the map. Does the location of the origin matter >>> when I do this? To be clear here's what I'm trying to do. >>> >>> 1) I have a Numeric array with a scalar field >>> 2) I want to overlay this onto a map projection >>> 3) The data is slightly larger than the map area (in terms of >>> latitude and longitude) >>> 4) From the examples it seams like transform_scalar and then >>> imshow can be used to show the data >>> 5) I can't seem to use transform_scalar properly >>> >>> Thanks is advance, >>> >>> Brian >> Brian: I'm going to assume your data (latlondata) is on a >> latitude/longitude grid with latitudes lats and longitude lons, >> and you have created a Basemap instance for your projection >> regrion (m). Then, to create a nx by ny grid to overlay on the >> map, all you need is >> >> xydata = m.transform_scalar(latlondata,lons,lats,nx,ny) >> >> you can then overlay xydata on the map with >> >> im = x.imshow(xydata, cm.jet) >> >> You only need to do this to plot the data with imshow - with >> pcolor or contourf you can plot the data on the original lat/lon >> grid using >> >> x,y = m(lons,lons) >> >> cs = m.contourf(x,y,latlondata,20,cmap=cm.jet) >> >> or >> >> im = m.pcolor(x,y,latlondata,shading='flat',cmap=cm.jet) >> >> HTH, >> >> -Jeff >> >> > Brian: > > One correction - > > lons and lats are 1-d arrays describing the lat/lon grid, so > instead of > > x,y = m(lons,lats) > > you'll need > > lons, lats = pylab.meshgrid(lons, lats) > x, y = m(lons, lats) > > -Jeff > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > Meteorologist FAX : (303)497-6449 > NOAA/OAR/CDC R/CDC1 Email : Jef...@no... > 325 Broadway Office : Skaggs Research Cntr 1D-124 > Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Jeff W. <js...@fa...> - 2005-11-03 17:50:18
|
Brian Donovan wrote: > Dr. Whitaker, > > Thank you for helping me with this. My point of confusion is what > should nx and ny contain when they are sent into the transform_scalar > function: > > Brian: nx and ny define the resolution of the transformed grid - you should choose them so that the grid spacing on the transformed grid is at least as fine as the original lat/lon grid. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |