[ncl-talk] NCL cannot work with variable within NetCDF file (WRF)

Bill Ladwig ladwig at ucar.edu
Mon Oct 15 10:31:34 MDT 2018


Hi Brock,

The 'wrf_*' routines were designed around the output from the WRF-ARW
model. Once variables have been stripped out, etc., it's probably best to
just use the regular NCL routines. You can always look at
$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl to see what variables
are needed, and then run the computation yourself. The good news is that it
looks like your script made it all the way down to the plotting before it
ran in to a problem. The error is complaining about this line:

plot = wrf_map_overlays(terfile,wks,(/contour/),pltres,mpres)


The WRF plotting routines aren't needed to make a plot. They're just
wrappers around the usual gsn_csm NCL plotting routines that make a fixed
size image with some extra labels. Most of the time, you'll want to
customize the plot yourself, and we'd be steering you back to the gsn_csm
routines anyhow.

Here's the documentation for doing overlays:

https://www.ncl.ucar.edu/Applications/overlay.shtml

Here is the documentation that talks about plotting native grids/map
projections:

https://www.ncl.ucar.edu/Applications/native.shtml

Give it a good try and let us know if you have problems.

Regards,

Bill


On Fri, Oct 12, 2018 at 2:01 PM Brock Tropea <brockt.1337 at gmail.com> wrote:

> Hi there,
>
> A little context is required. Working with this dataset:
> https://rda.ucar.edu/datasets/ds612.0/#access
> The output is not standard WRF (where all variables are in a single NetCDF
> file for an hour), rather each variable gets its own NetCDF file. In this
> case, the data is every 3 hours for 1 day (8 timesteps per file/24 hours/1
> day). This has caused me nothing but headaches with NCL, however I managed
> to fiddle with some sample scripts to make them work, somewhat.
>
> I have a semi-functional program that is looking at a vertical cross
> section of temperature (as a filled contour) and U component wind as
> vectors. I found a script online that someone made for a similar purpose,
> and have modified it to make it work with my data (somewhat).
>
> The problem I'm now having is that NCL doesn't seem to see a variable
> within one of the files. The section of code in question is intended to
> plot a line across a map of the WRF terrain field, to show where the
> subsequent cross section is. If I remove the block of code from the
> program, it works, and it generates the attached image.
> Specifically, NCL fails when it tries to locate "XLAT" within the
> "terfile", which is a constants file that holds the terrain data. However
> the variable is there, I have checked with ncl_filedump.
>
> What I THINK it is having an issue with is the fact that within that file,
> the XLAT variable is only 2 dimensional. It only has spatial dims, no time
> dim. wrf_user_getvar has 3 inputs, with the last one being the time. I have
> tried putting in 0, -1, and nothing and none of them work. I have tried
> using the XLAT from another file(ie:tkfile) which is also 2D, but that
> doesn't help. Exact error is:
>
> "fatal:Number of subscripts do not match number of dimensions of variable,
> (3) subscripts used, (2) subscripts expected
> fatal:["Execute.c":6381]:variable (XLAT) is not in file (in_file)
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 4122 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 4223 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 4306 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 290 in
> file vertcrossvectortest2.ncl
>
> [umtropea at tatanka vertical_cross]$ "
>
> Is there any way to tweak this to get it working?
>
> Keep in mind this is a WIP and I haven't gotten the A to B aspect working
> just yet, among other things. I'd like to focus on the error at hand.
>
> I've attached the script file, image of the plot generated when I remove
> the broken portion, and the filedump of XLAT as text.
> I'm running on CentOS 6.8, NCL version 6.4.0.
>
> Apologies for the long message, wanted to be specific.
>
>
>
> Thanks to anyone who might have some insight on this.
>
> _______________________________________________
> 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/20181015/0e39edcd/attachment.html>


More information about the ncl-talk mailing list