[ncl-talk] Problem aligning data with map

Mary Haley haley at ucar.edu
Tue Mar 27 16:58:28 MDT 2018


Hi Chris,

You were almost there.

The issue is that you are subsetting your data by selecting a lat/lon area
of interest, but then trying to plot this data using the projection defined
for the original data. When you set the "tfDoNDCOverlay" resource to True,
this signals to NCL that you are plotting data in its "native" projection,
and hence you need to set the map parameters exactly right for the data you
are plotting.

If you are plotting the original data (see narr_plot.ncl), then you can use
the map projection parameters on the file to plot the data. This script
shows how to plot the data on both a cylindrical equidistant projection
using the 2D lat/lon arrays read off the file, and in the native projection
using map projection information attached to the lat/lon arrays. I've
attached the PNGs from this script.

If you want to zoom in on the data, then unless you know the exact
projection parameters for the zoomed data, you will have to subset the 2D
lat/lon arrays in the same fashion as the data, and use these for
plotting.  See the attached narr_plot_zoom.ncl and image.

Finally, I took your original script and applied the same concepts I used
in narr_plot_zoom.ncl. Instead of using tfDoOverlay, it uses the subsetted
lat/lon arrays to get the overlay correct:

  res at sfXArray               = lon2d_small
  res at sfYArray               = lat2d_small

Note that in narr_plot_zoom.ncl, I didn't use sfXArray / sfYArray.
Instead, I used:

  var_subset at lat2d = lat_subset
  var_subset at lon2d = lon_subset

These are essentially the same thing. I was just lazy and didn't want to
have to attach the special "lat2d" and "lon2d" attributes to every variable
being plotted.

For more descriptive information on all this, you may want to visit our
"plotting data on a map" page:

http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml

Let me know if you have any questions about what I did.

--Mary







On Tue, Mar 27, 2018 at 3:02 PM, Herbster, Christopher G. <herbstec at erau.edu
> wrote:

> Hi folks,
>
>
>
> Here is a sequence of events that we are using to download some NARR data
> from NOMADS at NCDC:
>
> We use the get-httpsubset.pl script from
>
> https://nomads.ncdc.noaa.gov/guide/index.php?name=advanced#adv-httpsubset
> and the Perl scripts from
>
> http://www.cpc.ncep.noaa.gov/products/wesley/fast_downloading_grib.html
> to grab a handful of parameters from the NARR dataset.
>
>
>
> This gives us GRIB files like:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/
> narr-a_221_20101201_1200_000.sub.grb
>
>
>
> I then used: ncl_convert2nc narr-a_221_20101201_1200_000.sub.grb -nc4c -l
>
> To make
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/
> narr-a_221_20101201_1200_000.sub.nc4
>
>
>
> I did this for 30 years of data ending 12-31-2010.
>
>
>
> We then used an NCL script to do some calculations on a month of data, and
> write the results into a new file.
>
> Here is the script:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/
> read_narr_ncar-help.ncl
>
> My apologies to those of you who actually know how to code in NCL.  I am
> strictly an amateur at this.
>
>
>
> Here is the file we created:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/D-
> Value_Monthly_Stats.2010.12.averages.1200.nc
>
>
>
> Our problem seems to be aligning the data to the map background, as I can
> show with the following images:
>
>
>
> The grey area in this image is supposed to be where the terrain is higher
> than the calculated value:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/narr-paper.000001.png
>
>
>
> The data mask area is too far to the west, even extending out over the
> ocean.
>
>
>
> When we plot it in the Unidata IDV we get what we expect:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/IDV_4K_Mask_D-Val.png
>
>
>
> Then we decided to try plotting it in Matlab as another test.  We got:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/
> Matlab_Plot_NARR_Mask.jpg
>
>
>
>
>
> While I suspect that I am not doing something properly with the mapping of
> the data, I am also wondering about the results of making the NetCDF file
> from the ncl_convert command.
>
>
>
> First, is the compression lossy?  I realized that the default compression
> is zero, so this step did not do much for disk space!  (Actually made
> bigger files, but never mind.)
>
>
>
> When I load the original GRIB file into the IDV it displays the region
> properly without any problem.  When I try to load the original NetCDF file,
> the IDV does not seem to know the geographic region of the data.
>
>
>
> This can be seen in the following images:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/load-both-idv.png
> shows the Mean Sea Level Pressure data from both files.  They appear to
> match.  However, when I added the second panel (NetCDF file), the IDV did
> not display the data properly, and did so only after I selected a
> predefined CONUS projection (as shown).
>
>
>
> When I open the NetCDF file and plotted MSLP in a window by itself, I got
> this:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/load-netcdf-idv.png
>
>
>
> I had to zoom way out to display this data.  It knows where to put the
> data, but the IDV thinks the data should be in the white box area, I
> think.  (I’m not really sure about this interpretation.)
>
>
>
> The questions I have are:
>
> 1)      Why does this happen?
>
> 2)      Is this related to my data masking and mapping problem, or are
> they separate issues?
>
>
>
> Thanks in advance for any help on any of these problems/questions.
>
>
>
> Cheers,
>
>
>
> Chris
>
>
>
> PS  If you want to test our script, there is a month of data in this tar
> file:
>
> http://wx.erau.edu/faculty/herbster/demo/.hidden/NCL/sample-narr.tgz
>
> --
>
>
>
> Dr. Christopher G. Herbster
>
> Associate Professor
>
> Director of Science and Technology
>
> for the ERAU Weather Center
>
> Applied Aviation Sciences
>
> Embry-Riddle Aeronautical Univ.
>
> 600 S. Clyde Morris Blvd.
>
> Daytona Beach, FL 32114-3900
>
>  386.226.6444 <(386)%20226-6444> Office
>
> 386.226.6446 <(386)%20226-6446> Weather Center
>
> http://wx.erau.edu/
>
>
>
> Schedule at:  http://wx.erau.edu/faculty/herbster/Schedules/
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr_plot.ncl
Type: application/octet-stream
Size: 4274 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr_plot_zoom.ncl
Type: application/octet-stream
Size: 3515 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr_plot_zoom.png
Type: image/png
Size: 323044 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: read_narr_ncar-help-mod.ncl
Type: application/octet-stream
Size: 25577 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr-paper.000003.png
Type: image/png
Size: 381463 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr_plot.000001.png
Type: image/png
Size: 237376 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: narr_plot.000002.png
Type: image/png
Size: 324265 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180327/0c9c9998/attachment-0007.png>


More information about the ncl-talk mailing list