Some questions about using ncview

Cool Findings and Plots

Moderators: arango, robertson

Post Reply
Message
Author
dnavidad

Some questions about using ncview

#1 Unread post by dnavidad »

Hello romsusers,

Just i would like to ask a couple of questions about ncview software. I just started to use and i think it is a cool program. i can save the images (save rectangle) as a picture files, so seems (also for the view a took in the forum) that ncview is only for a quick view, but i just wondered if

1. is it possible to save the plot with colorbar, axis,..., with this program.

2. in my case ncview yields the plot with the horizontal axis inverted, the real W is in the east side of the plot and vice versa, i tried to change that from the screen, but maybe it is related with something in the netcdf file. (this is for ocean_hist.nc). However with the ocean_rst.nc this happens with N and south.


many thanks in advance.

User avatar
shchepet
Posts: 188
Joined: Fri Nov 14, 2003 4:57 pm

Re: Some questions about using ncview

#2 Unread post by shchepet »

As far as I can tell, the answer is "no", you cannot save colorbar from ncview.

There are few controls about axes, title, etc... including option for none in each
category, that is to save plain plot of the field without any extra decorations,
axes, etc. This turns out to be the most useful, since stuff can be added later,
and multiple plots combined.

...and if you need more colors for ncview, read this thread:
http://www.myroms.org/forum/viewtopic.p ... view#p6925

dnavidad

Re: Some questions about using ncview

#3 Unread post by dnavidad »

ok thanks, i just wanted to be sure.

yes, the options are limited but, anyway, i think is a cool program to have a first view of the outputs, we are also installing the extra colormaps referred in the post.

thanks.

DN.

dnavidad

Re: Some questions about using ncview

#4 Unread post by dnavidad »

I would like to make some other question about ncview.

You can plot, among others variables, ubar, vbar, u, v and w. So, i guess that the "bar" variables are referring to the z-integrated ones, of course.

what about u, v and w momentum components? what level are they plotted at? maybe in the free surface?


thanks

User avatar
shchepet
Posts: 188
Joined: Fri Nov 14, 2003 4:57 pm

Re: Some questions about using ncview

#5 Unread post by shchepet »

what level are they plotted at? maybe in the free surface?
No, not necessarily at surface or bottom.

Ncview plots exactly what you see on your screen at the time you hit its "Print" button.

Using main window of ncview you can navigate through variables present in your
file and select axes. Ncview (as well as netCDF in general) views every object as
a rectangular array of N-dimensions, but plots only a 2D-cross-section of it.
Thus, if you have only two dimensions there is nothing to select -- both of them
became axes; If there are three dimensions, you can select any two of them as axes,
and select an single index position in the remaining dimension. You can click left or
right button of your mouse pointing to that dimension to increase or decrease the index
value. So if, say there are tree dimensions X,Y,Z you can plot X-Y cross-section with
Z=const (of your selection), or X-Z crossection with Y=const, or Y-Z cross-section
with X=const. You can also select which axis is vertical or which horizontal on
your screen (not every version combination of ncview/netcdf allows you to select
first netCDF dimension for constant index; but the most recent do); If there are
four dimensions you can select two axes and two fixed indices. And so on...

By default, ncview selects the first two dimensions of the array as axis, and
selects index 0 (in C-language sense; this would be 1 in Fortran) for the remaining
dimensions, so if you look at ROMS output file and select a variable, say "temp" the
first what you see is 2D plot of near-bottom temperature at the initial time record.
Starting from this you can navigate and select different vertical layers and different
time record. Clicking "axes" allows you to change from k=const, time=const plane
to something else. E.g., selecting X(axis), Y=const, Z=const, time(axis) makes
a Hovmöller diagram.

Ncview does not do any remapping, so horizontal planes are always "along sigma"
and there is no way to change it.

dnavidad

Re: Some questions about using ncview

#6 Unread post by dnavidad »

Many thanks for your quick and vast answer. Also excuses for my, maybe a priori, simple questions about ncview. i think it is a very cool program and i would like to take advantage of it.

That is what i wanted to know: if different sections could be plotted, but i don't have the options you mentioned to do that in the controls screen. When i tried to change the axes, the pictured attached is what i see on ncview. So since, due to you say, that probably my files are 2D, but my computation it is assumed 3D

#define SOLVE3D /* use if solving 3D primitive equations */

Any suggestion?

thanks in advance and excuses for my questions.
Attachments
Picture2.png
Picture2.png (820 Bytes) Viewed 23404 times

User avatar
shchepet
Posts: 188
Joined: Fri Nov 14, 2003 4:57 pm

Re: Some questions about using ncview

#7 Unread post by shchepet »

For the purpose of Ncview and my post above 2D-, 3D-, and 4D-variables means
2-, 3-, 4-dimensional arrays.

The picture you attaching is exactly what is expected: your netCDF file have shown
all four netCDF dimensions, namely xi_rho, eta_rho, s_w, and ocean_time for the
variable you are trying to see. Highlighted dimensions -- xi_rho, eta_rho -- are
currently selected axes. You can change this by point and click.

dnavidad

Re: Some questions about using ncview

#8 Unread post by dnavidad »

thanks shchepet.

I didn't realize that when you select 3D variables, for instance, u,v,w, and plot X-Y map, also you can change (just clicking), in the enabled button or edit, the different depths.In my case from -.95 to -0.05. Now i can get 2D-map in diferent z-level.

Let me say that the quality of the plot and the .ps file by ncview it is much better than the matlab one. i think ncview is a very cool program and remind me gnuplot (simple but very cool)

thanks.
Attachments
Picture3.png
Picture3.png (1.49 KiB) Viewed 23360 times

dnavidad

Re: Some questions about using ncview

#9 Unread post by dnavidad »

Hi,

i did get this problem trying to plot my ocean_his.nc. The dimensions (Lm,Mm) in ocean.in file match with the grd.nc, (i don't get any error about that.)

i think the problem is writing the output file, isn't? what are doing wrong?


thanks.

Code: Select all

Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "wetdry_mask_rho" which has shape (1,671,466)
and has coordinates attribute "x_rho y_rho ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable
-------------
Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "wetdry_mask_u" which has shape (1,671,465)
and has coordinates attribute "x_u y_u ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable
-------------
Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "wetdry_mask_v" which has shape (1,670,466)
and has coordinates attribute "x_v y_v ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable
-------------
Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "zeta" which has shape (1,671,466)
and has coordinates attribute "x_rho y_rho ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable
-------------
Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "ubar" which has shape (1,671,465)
and has coordinates attribute "x_u y_u ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable
-------------
Warning: did not correctly match mapped dims specified in the coordinates attribute to dims in the variable
Problem encountered on variable "vbar" which has shape (1,670,466)
and has coordinates attribute "x_v y_v ocean_time"
The problem is that coordinate var "ocean_time" has shape (1), which does not match dimensions in the variable being mapped!
Abandoning coordinate mapping for this variable

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: Some questions about using ncview

#10 Unread post by kate »

What software are you using to plot with? It says the history file has one time value - I don't see why that's a problem.

dnavidad

Re: Some questions about using ncview

#11 Unread post by dnavidad »

i see problems everywhere :D.

that's from ncview. before the model finish to run i use to plot the results making a copy of the output.nc file and plotting this copy with ncview.

doing that i used to get this warnings at the first time but when more time steps are saved i don't get the message anymore.

maybe just related with try to plot a file that it is being written.

many thanks.

User avatar
shchepet
Posts: 188
Joined: Fri Nov 14, 2003 4:57 pm

Re: Some questions about using ncview

#12 Unread post by shchepet »

This would be a very natural behavior of netCDF writing (and, as a matter of fact,
any buffered writing to the disk): as long as file is not closed or forcefully
synchronized, the data does not land onto the disk, but in the memory of the machine,
and consequently, is not accessible by any process other than the writing process
itself. This is done to improve performance, so many small pieces of data aggregated
before being written onto the disk. So if you run the model and see how it progresses,
and, simultaneously try to read its netCDF output you may see less data than expected.

However, ROMS is designed to synchronize netCDF files after every time record, so at
the end of "wrt_his.F", "wrt_rst.F", "wrt_avg.F", etc files you see calls like this:

Code: Select all

!-----------------------------------------------------------------------
!  Synchronize history NetCDF file to disk to allow other processes
!  to access data immediately after it is written.
!-----------------------------------------------------------------------
!
      CALL netcdf_sync (ng, iNLM, HIS(ng)%name, HIS(ng)%ncid)
      IF (exit_flag.ne.NoError) RETURN
This forces pending data to the disk (and also makes the running model wait until
it happens) so once the model passes this point ncview should see the correct number
of records.

Subroutine "netcdf_sync" is defined at the end of Modules/mod_netcdf.F and is just
a wrapper around the standard netCDF function.

So what you are observing -- you have to wait until the run is complete -- indicates
that this mechanism does not work.

To debug, edit file Modules/mod_netcdf.F and place a print statement just if front of
the line

Code: Select all

status=nf90_sync(ncid)
(there is only one occasion) and see whether it is actually called.

Post Reply