[ncl-talk] Writing data to netcdf file

Rick Brownrigg brownrig at ucar.edu
Mon Mar 25 16:02:28 MDT 2019


Hi Zilore,

1. You'll want to read the docs at the following like, especially on Method
1, for a full understanding and examples. But its fairly straigh forward,
usually something like

   out = addfile("...name_of_output_file", "c")   ; open file for "creation"
   out->newVariableName = P197903_ym

Don't worry about Method 1 begin inefficient unless you will be doing this
sort of thing many many times. However, you probably want to add some
metadata to the file and info about how your variable was created, and
that's where you want to look at the examples at this link:

    http://ncl.ucar.edu/Applications/write_netcdf.shtml

2. There area a couple of ways to specify colors in a palette.  One is by
named palette, such as "rainbow" as you point out. The other is by an array
of named individual colors; e.g., (/ "red", "green", "purple", ... /).  The
third way is by giving the indices for colors *relative to the
workstation's palette*, and that's the case you are asking about.  The
workstation always has a palette -- you can explicitly specify, otherwise
the default one is this:

    http://ncl.ucar.edu/Document/Graphics/ColorTables/ncl_default.shtml

So, assuming the default palette, the first color in your list is 2, a
purple color, the second is 22, a darkish blue, the 3rd is 42 a slightly
lighter blue, and so on.  Does that make sense?

Hope that helps...
Rick

On Mon, Mar 25, 2019 at 5:07 AM zilore mumba <zmumba at yahoo.com> wrote:

> Hello,
> I have two simple questions to which I hope I can get a quick fix
> 1. I have calculated annual means of monthly sea level pressure from the
> file SLP.1979_2003.nc found on the ncl dataset list, using the c0de:
> begin
>   f=addfile("SLP.1979_2003.nc","r")
>   p=f->slp(:,:,:)
>
>   P197903_ym = month_to_annual(p,1)
> end
>
> When I run the above code, there is no error, but then nothing happens. I
> was expecting to see a file named P197903_ymP197903_ym. When I run the
> code interactively, and print(P197903_ym) I can see the annual means.
>
> I have seen efficient and efficient ways of writing data to netcdf file.
> Is there a simple line for writing the output to file? Sorry I have not
> checked the archives
>
> 2. I am plotting a contour map with colored contours. I am using
> res at cnLineColors ="toint(fspan(2,240,20))"
>
> What do the numbers 2,240,20 mean. I have searched every where I cannot
> find. I know I can use e.g. "Rainbow"
>
> Thank you very much for any assistance.
>
>
>
> _______________________________________________
> 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/20190325/02b57408/attachment.html>


More information about the ncl-talk mailing list