Re: problems with unstructured/conserver regridding - with fewer attachments

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 04 2013 - 14:38:45 MDT

Hi Dick,

I was able to fix the "hump" issue. You have a regional source grid in this case, so you need to set:

Opt@SrcRegional = True

I've further modified your script to attach the lat/lon corners grid (for debug purposes, although you don't really need that now), and to clean up the plotting so that it zooms in on the area of interest.
This makes it easier to see the grid. I also set gsnAddCyclic to True for the regridded data, since the cyclic point needs to be added.

See attached.

To not draw the lat/lon corners grid, simply comment out or remove this code:

;--Attach the lat_corners/lon_corners grid to the regridded plot
    nlat = dimsizes(lat_corners(:,0,0))
    nlon = dimsizes(lat_corners(0,:,0))

    line_id = new((/nlat,nlon/),graphic)
    lnres = True
    do i=0,nlat-1
      do j=0,nlon-1
        line_id(i,j) = gsn_add_polyline(wks,plot_regrid,\
                                        lon_corners(i,j,:),\
                                        lat_corners(i,j,:),lnres)
      end do
    end do

--Mary

On Jun 4, 2013, at 11:24 AM, Richard G French wrote:

> That sounds like a good idea - I'm not sure how to do that, and if you think it is an easy task, I'd be grateful for the help!
>
> Dick
>
>
>
> On Tue, Jun 4, 2013 at 1:19 PM, Mary Haley <haley@ucar.edu> wrote:
> I was surprised by the differences in shapes too. Maybe it has something to do with the lat/lon_corners data on the file?
> It might be worth drawing the corners (as polylines) to see where they are with regard to the data itself.
>
> Let me know if you need help with that.
>
> --Mary
>
> On Jun 4, 2013, at 10:00 AM, Richard G French wrote:
>
> > Dear Mary,
> > Many thanks for your help on this - I'm grateful for your prompt reply. This looks promising, and I'll now try it with a denser grid to see how things look. I'm a bit surprise by the difference in shapes between the initial image and the final image, but this might be a result of the coarse gridding. The revised code will give me some ways to try some new experiments.
> > Dick
> >
> >
> >
> > On Tue, Jun 4, 2013 at 11:49 AM, Mary Haley <haley@ucar.edu> wrote:
> > Hi Richard,
> >
> > Thanks for providing your script and data.
> >
> > The problem appears to be that your curvilinear grid is being treated as a 1D unstructured grid.
> >
> > Since you have the curvilinear cell centers and corners, my recommendation is to treat this as a curvilinear grid.
> >
> > I changed your code to remove the "ndtooned" calls that were converting your lat/lon arrays to 1D, and commented out the "SrcESMF" setting (which is not really needed if you use ESMF_regrid, because this function will set this internally for you if you are using an unstructured grid).
> >
> > Here are the differences: (">" are the old lines, and "<" are the new lines):
> >
> > > Opt@SrcGridLat = ndtooned(sfile->lat_centers) ; source grid
> > > Opt@SrcGridLon = ndtooned(sfile->lon_centers)
> > 45,48c45,49
> > < if(interpMethod.eq."conserve") then
> > < Opt@GridCornerLat = sfile->lat_corners
> > < Opt@GridCornerLon = sfile->lon_corners
> > < end if
> > ---
> > > Opt@GridCornerLat = ndtooned(sfile->lat_corners)
> > > Opt@GridCornerLon = ndtooned(sfile->lon_corners)
> > >
> > > Opt@SrcGridType = "unstructured"
> > > Opt@SrcESMF = True ; unstructured format
> >
> >
> > I've included your modified script and the image.
> >
> > --Mary
> >
> >
> >
> > On Jun 3, 2013, at 8:24 PM, Richard G French wrote:
> >
> > > I'm resending this with only the critical attachments to stay under the 1500K limit. Thanks!
> > > Dick
> > >
> > >
> > > ---------- Forwarded message ----------
> > > From: Richard G French <rfrench@wellesley.edu>
> > > Date: Mon, Jun 3, 2013 at 10:20 PM
> > > Subject: problems with unstructured/conserver regridding
> > > To: ncl-talk@ucar.edu
> > >
> > >
> > > Hi, everyone -
> > >
> > > I'm having a problem getting an unstructured grid of lat/lon corners to regrid properly using the "conserve" option.
> > >
> > > I can get bilinear and patch regridding to work, but when I try "conserve", I find that my regridded data array seems to have just one element in it. The "conserve" option is essential to my application, since I need to preserve the integrated data value over the area of the regridded array.
> > >
> > > I've attached:
> > >
> > > 1) the ncl script (based on ESMF_all_conserve_12.ncl):
> > >
> > > rgf_regrid_test_v3_conserve.ncl
> > >
> > > 2) the output from running the script, with debugging turned on:
> > >
> > > ncl rgf_regrid_test_v3_conserve.ncl>ncl_script_output.txt
> > >
> > > 3) the input datafile containing the data array and the unstructured grid:
> > >
> > > rgf_regrid_test_v3small.nc
> > >
> > > 4) the ncl_filedump of this file, listing all of the variables:
> > >
> > > ncl_filedump -v flux,lon_centers,lat_centers,lon_corners,lat_corners \
> > >
> > > rgf_regrid_test_v3small.nc>ncl_filedump_output.txt
> > >
> > > 5) a postscript and PDF plot of the original data and the unsuccessful regridded version, which gives "NO CONTOUR DATA" as an error message.
> > >
> > >
> > >
> > > The script output file [2), above] shows the error messages and the problem with the regridded data array:
> > >
> > > (0) --------------------------------------------------
> > >
> > > (0) ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was successful.
> > >
> > > (0) ESMF_regrid_with_weights: regridding using interpolation weights ...
> > >
> > > (0) ESMF_regrid_with_weights: warning: destination grid is not
> > >
> > > (0) completely covered by the source grid. This is not an error.
> > >
> > > (0) It just means your destination grid covers a larger area
> > >
> > > (0) than your source grid.
> > >
> > > (0) ESMF_regrid_with_weights: Source Grid:
> > >
> > > (0) rank: 1
> > >
> > > (0) dimensions: 15791
> > >
> > > (0) original source rank: 2
> > >
> > > (0) latitude min/max: 9.81775/79.5803
> > >
> > > (0) longitude min/max:-75.1696/9.90834
> > >
> > > (0) ESMF_regrid_with_weights: Destination Grid:
> > >
> > > (0) dimensions: 719 1440
> > >
> > > (0) latitude min/max: -89.75/89.75
> > >
> > > (0) longitude min/max:0/359.75
> > >
> > > (0) ESMF_regrid_with_weights: retrieving interpolation weights ...
> > >
> > > (0) ESMF_regrid_with_weights: error: source data on the description
> > >
> > > (0) file does not have proper dimensions.
> > >
> > > and then
> > >
> > > Variable: flux
> > >
> > > Type: double
> > >
> > > Total Size: 64000 bytes
> > >
> > > 8000 values
> > >
> > > Number of Dimensions: 2
> > >
> > > Dimensions and sizes: [ysize | 100] x [xsize | 80]
> > >
> > > Coordinates:
> > >
> > > Number Of Attributes: 1
> > >
> > > comment : Sky plane flux for occultation
> > >
> > > Variable: flux_regrid
> > >
> > > Type: float
> > >
> > > Total Size: 4 bytes
> > >
> > > 1 values
> > >
> > > Number of Dimensions: 1
> > >
> > > Dimensions and sizes: [1]
> > >
> > > I don't know why flux_regrid is a float instead of a double, or why it has only one value.
> > >
> > > I suspect that the problem comes from the way I have specified the grid corners - I created the netCDF file using IDL, and tried to make sure that the array elements are in the appropriate order, as shown in the ncl_filedump output file:
> > >
> > > variables:
> > >
> > > double flux ( ysize, xsize )
> > >
> > > comment : Sky plane flux for occultation
> > >
> > > double lon_centers ( ysize, xsize )
> > >
> > > comment : Center longitude (deg)
> > >
> > > double lat_centers ( ysize, xsize )
> > >
> > > comment : Center latitude (deg)
> > >
> > > double lon_corners ( ysize, xsize, ncorners )
> > >
> > > comment : Corner longitudes (deg)
> > >
> > > double lat_corners ( ysize, xsize, ncorners )
> > >
> > > comment : Corner latitudes (deg)
> > >
> > > but clearly there is something that I'm missing. I'd be grateful for any suggestions, and my apologies for naive questions. This is my first attempt at using ncl, which appears to be very powerful and which I hope will be useful for my application, which involves tests of atmospheric tidal models for Pluto's tenuous atmosphere.
> > >
> > > Thanks for any help anyone can provide.
> > >
> > > Dick French
> > >
> > > --
> > > Richard G. French
> > > Dean of Academic Affairs
> > > McDowell and Whiting Professor of Astrophysics
> > > Cassini Radio Science Team Leader
> > > 341A Green Hall, Wellesley College
> > > Wellesley, MA 02481-8203
> > > (781) 283-3583
> > >
> > >
> > > <ncl_script_output.txt><rgf_regrid_test_v3_conserve.ncl><rgf_regrid_test_v3small.nc><rgf_regrid_test_v3_wgt_conserve.pdf>_______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> >
> >
> > --
> > Richard G. French
> > Dean of Academic Affairs
> > McDowell and Whiting Professor of Astrophysics
> > Cassini Radio Science Team Leader
> > 341A Green Hall, Wellesley College
> > Wellesley, MA 02481-8203
> > (781) 283-3583
>
>
>
>
> --
> Richard G. French
> Dean of Academic Affairs
> McDowell and Whiting Professor of Astrophysics
> Cassini Radio Science Team Leader
> 341A Green Hall, Wellesley College
> Wellesley, MA 02481-8203
> (781) 283-3583

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

rgf_regrid_test_v3_wgt_conserve.png
Received on Tue Jun 4 14:41:44 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT