[ncl-talk] About using nc file to do XY plot

Mary Haley haley at ucar.edu
Tue Jun 27 14:03:31 MDT 2017


Dear Teng Fei,

We always recommend that you look at your data with "printVarSummary" and
"printMinMax" if there's something going on that you don't understand.

It would look like this in your script:

 f     = addfile (dir + "plot_test.nc","r")
 u     = f->obs_arr
 v     = f->hdr_vld                                    ; get u data

 printVarSummary(u)
 printVarSummary(v)
 printMinMax(u,0)

The output looks like this:

Variable: u
Type: float
Total Size: 1880 bytes
            470 values
Number of Dimensions: 2
Dimensions and sizes: [nobs | 94] x [obs_arr_len | 5]
Coordinates:
Number Of Attributes: 8
  long_name : array of observation values
  _fill_value : -9999
  columns : hdr_id gc lvl hgt ob
  hdr_id_long_name : index of matching header data
  gc_long_name : grib code corresponding to the observation type
  lvl_long_name : pressure level (hPa) or accumulation interval (sec)
  hgt_long_name : height in meters above sea level or ground level (msl or
agl)
  ob_long_name : observation value

Variable: v
Type: character
Total Size: 3760 bytes
            3760 values
Number of Dimensions: 2
Dimensions and sizes: [nhdr | 94] x [mxstr | 40]
Coordinates:
Number Of Attributes: 2
  long_name : valid time
  units : YYYYMMDD_HHMMSS UTC

(0) array of observation values : min=-9999   max=289.55

There are two things to note here:


   1. The minimum of "u" is -9999 which is not correct. This is because the
   missing value attribute, "_FillValue" has not been set.

   2. Your "v" variable is a character array. You cannot plot character
   data with gsn_csm_xy.


To fix #1, you need to add this to fix the missing value:

 u at _FillValue = u at _fill_value

To fix #2, you can plot your data with "gsn_csm_y" which doesn't require an
X array. This will use index values starting at 0 on the X axis, and going
to "ny-1" where "ny" represents the number of Y values.

You can then use the "v" array to label the X axis. This array is a bit
strange, as it has the same value for 20 iterations and then increments by
one hour. I only grabbed the first 10 columns of this array, and then
plotted every 20th value on the X axis.

See the attached script and image.

--Mary



On Tue, Jun 27, 2017 at 1:20 AM, Teng Fei <fay900902 at gmail.com> wrote:

> Dear NCL helpdesk,
> I am using METv5.2 to conduct my research. Now, I encounter one problem. I
> want to use the output file (plot_test.nc) from ASCII2NC tool to plot a
> XY plot via NCL 6.3.0. The x-axis is time series, which should be hdr_vld
> in plot_test.nc. The y-axis is temperature: obs_arr (:,4) in plot_test.nc.
> When I run the ncl to plot it, some mismatches occurred. After checking, I
> found this is the problem of hdr_vld couldn't match the observation arrays.
> Could you help me solve this problem? My file plot_test.nc, and my
> script have been attached. Thank you!
>
> Yours,
> Teng Fei
>
> _______________________________________________
> 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/20170627/f5ae6243/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xy.png
Type: image/png
Size: 60623 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170627/f5ae6243/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: this_is_the_script_I_used_mod.ncl
Type: application/octet-stream
Size: 2213 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170627/f5ae6243/attachment.obj 


More information about the ncl-talk mailing list