roms_matlab plotting and analysis routines

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

roms_matlab plotting and analysis routines

#1 Unread post by wilkin »

I have documented the core set of Matlab functions I use for simple visualization of ROMS output. These are functions such as roms_zview.m, roms_addvect.m, roms_zslice.m, roms_get_grid.m, roms_zint.m, etc.... that I have shared with various people on an ad hoc basis over the years.

The documentation is at http://romsmatlab.tiddlyspot.com and the codes are managed using svn.

The {z,s,i,j}view.m routines make simple plots directly from a ROMS file or OPeNDAP URL by slicing along coordinate directions.

For example:

>> url='http://server/thredds/dodsC/roms/cblast ... 0/averages'
>> g=roms_get_grid(url,url); % the grid structure
>> % temperature slice for time step nearest to 20JUN2002, at 2-m
>> % depth, with every 3rd velocity vector over-plotted
>> roms_zview(url,'temp','20-Jun-2002',-2,g,3,.1,'k')
Image

The *slice.m routines extract a slice through a 3- or 4-D ROMS data chunk that is already in the workspace (such as some diagnostic quantity you might have computed that is not present in an output file directly).

roms_get_grid produces a Matlab structure to facilitate passing the coordinate information to all the functions.

roms_zint performs a vertical integral of a 3-D ROMS quantity over the full water depth, between prescribed z-levels, or between iso-surfaces.

Several of these functions were created or improved with the assistance of Gordon Zhang, John Evans and other members of the Rutgers Ocean Modeling Group. The netcdf file reading is via John Evans' snctools functions.

This announcement does not represent a commitment to a high level of online support (!), but I thought it was time I shared these files more widely. There are a number of deeply embedded hacks and 'features' that I have created for my own analysis. Rather than remove them for distribution, they have been left in the code to confuse you.

This is a work in progress. If you find these tools useful, constructive comments on improvements are always appreciated.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

ocecept
Posts: 42
Joined: Tue Jan 08, 2008 3:57 pm
Location: Universidade Federal do Ceará
Contact:

#2 Unread post by ocecept »

Hi Wilkin;

Thanks for these very good tools.

I'm able to use some of then, but with some options the program complain about specific functions or sub-functions.

For example:

Using:

roms_zview('ocean_his.nc','umag',1,1,grd)

I get:
??? Undefined function or method 'av2' for input arguments of type 'double'

It happens because I don't have the "av2" function.

I have the same problem when the program calls the function "change":

can you help me to get these functions working?

many thanks


Carlos Teixeira

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

#3 Unread post by wilkin »

Oops. I thought I'd expunged all those references to my change.m but a few crept past me. There are probably more. Thanks for letting me know. I embedded the function av2.m in roms_zview.m and roms_sview.m.

The changes are made to the svn archive so update and let me know if the functions is choking on any other calls.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#4 Unread post by rouf »

I am bit confused about the visualization of ROMS output. By following upwelling test case, I found ocean_avg.nc, ocean_dia.nc, ocean_his.nc and ocean_rst.nc. Now how can i see the output in Matlab? As a new user, sugession with step by step procedure will help me lot.

I tried to follow the wilkins documentation mentioend in http://romsmatlab.tiddlyspot.com but still the process is not clear how to visualize the roms output. In terms of visualization, is scripts avaiable in tools under matlab is somehow required?...anyway confused.
pls anyone help me

Rouf

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#5 Unread post by wilkin »

If you have added my Matlab tools for ROMS described at http://romsmatlab.tiddlyspot.com to your matlabpath then the steps to get a plot the the example in my posting on the forum would be:

>> file = 'ocean_his.nc'
>> g=roms_get_grid(file,file); % the grid structure
>> % temperature slice for first time step in the history file
>> % at depth 5 meters, with every 3rd velocity vector over-plotted
>> % Try a velocity vector scale factor of 0.1
>> s = 0.1;
>> roms_zview(file,'temp',1,-5,g,3,s,'k')


>> help roms_zview
and the documentation at http://romsmatlab.tiddlyspot.com explains how the options to these routines work.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#6 Unread post by rouf »

Dear Wilkin
Yes I added your matlab tools and set to my matlab path. Tried to follow instructions but showing following errors

Code: Select all

>> file = 'ocean_his.nc'

file =

ocean_his.nc

>> g=roms_get_grid(file,file); % the grid structure
Warning: Variable not found: lon_rho
> In roms_get_grid at 58
Warning: Variable not found: lat_rho
> In roms_get_grid at 58
Warning: Variable not found: mask_rho
> In roms_get_grid at 58
Warning: Variable not found: angle
> In roms_get_grid at 58
Warning: Variable not found: h
> In roms_get_grid at 58
Warning: Variable not found: pm
> In roms_get_grid at 58
Warning: Variable not found: pn
> In roms_get_grid at 58
Warning: Variable not found: lon_rho
> In roms_get_grid at 58
Warning: Variable not found: lat_rho
> In roms_get_grid at 58
Warning: Variable not found: mask_rho
> In roms_get_grid at 58
Warning: Variable not found: lon_psi
> In roms_get_grid at 58
Warning: Variable not found: lat_psi
> In roms_get_grid at 58
Warning: Variable not found: mask_psi
> In roms_get_grid at 58
Warning: Variable not found: lon_v
> In roms_get_grid at 58
Warning: Variable not found: lat_v
> In roms_get_grid at 58
Warning: Variable not found: mask_v
> In roms_get_grid at 58
Warning: Variable not found: lon_u
> In roms_get_grid at 58
Warning: Variable not found: lat_u
> In roms_get_grid at 58
Warning: Variable not found: mask_u
> In roms_get_grid at 58
Warning: Variable not found: f
> In roms_get_grid at 58
[color=#FF0000]??? Error using ==> snctools\private\snc_error
No such file or directory

Error in ==> nc_isvar>nc_isvar_mexnc at 57
	snc_error ( 'SNCTOOLS:NC_ISVAR:MEXNC:OPEN', ncerr );

Error in ==> nc_isvar at 40
	bool = nc_isvar_mexnc ( ncfile, varname );

Error in ==> roms_get_grid at 63
  if nc_isvar(grd_file,'x_rho')[/color]
Mexnc and snctools supposed to work properly as I download and set to my matlab path. Anyway please suggest how to solve?

Rouf

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#7 Unread post by wilkin »

It looks like you are using a configuration that is not described in geographic coordinates (lon/lat) but instead in some idealized x,y coordinates. Perhaps you are running one of the examples like UPWELLING or you have constructed your own analytical grid.

(ROMS does not actually need lon/lat to run, only the grid metric factors pm,pn which are the reciprocal of the grid spacing.)

I wrote my matlab plotting code assuming the grid lat/lon (lon_rho, lat_rho, lon_u, lat_u etc) would be the spatial coordinates. So since these aren't available in this case I have amended roms_get_grid to substitute the x/y coordinates in the grid structure. I have checked in the new version to the svn repository at https://www.myroms.org/svn/om/matlab/roms_wilkin
so please run an "svn update" and see if this fixes your problem. I tested it on UPWELLING example output and it works.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#8 Unread post by rouf »

Dear Wilkin,
Thanks. There are little improvement after update but still the following errors

Code: Select all

>> file = 'ocean_his.nc'

file =

ocean_his.nc

>> g=roms_get_grid(file,file); % the grid structure
Warning: Variable not found: mask_rho
> In roms_get_grid at 57
Warning: Variable not found: mask_psi
> In roms_get_grid at 57
Warning: Variable not found: mask_u
> In roms_get_grid at 57
Warning: Variable not found: mask_v
> In roms_get_grid at 57
Warning: Variable not found: angle
> In roms_get_grid at 57
Warning: Variable not found: h
> In roms_get_grid at 57
Warning: Variable not found: pm
> In roms_get_grid at 57
Warning: Variable not found: pn
> In roms_get_grid at 57
Warning: Variable not found: f
> In roms_get_grid at 57
??? Error using ==> snctools\private\snc_error
No such file or directory

Error in ==> nc_isvar>nc_isvar_mexnc at 57
	snc_error ( 'SNCTOOLS:NC_ISVAR:MEXNC:OPEN', ncerr );

Error in ==> nc_isvar at 40
	bool = nc_isvar_mexnc ( ncfile, varname );

Error in ==> roms_get_grid at 62
  if nc_isvar(grd_file,'x_rho')
highly looking for your suggestion

Rouf

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#9 Unread post by wilkin »

If you look at the error messages you're getting you'll see that roms_get_grid is not finding any grid information in the file you are giving it. Not even the bathymetry (h), grid metrics (pm,pn) or Coriolis parameter (f). Either these are missing from ocean_his.nc, or perhaps your path to ocean_his.nc is wrong.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#10 Unread post by rouf »

Dear Wilkin,
I understand the problem you noticed regarding my errors. I ensured ocean_his.nc is in right path and got following error.

Code: Select all

>> file = 'ocean_his.nc'

file =

ocean_his.nc

>>  g=roms_get_grid(file,file);
Warning: Variable not found: mask_rho
> In roms_get_grid at 57
Warning: Variable not found: mask_psi
> In roms_get_grid at 57
Warning: Variable not found: mask_u
> In roms_get_grid at 57
Warning: Variable not found: mask_v
> In roms_get_grid at 57
Warning: Variable not found: angle
> In roms_get_grid at 57
Warning: lon_rho not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lat_rho not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lon_psi not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lat_psi not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lon_v not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lat_v not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lon_u not found. Substituting x/y coords instead
> In roms_get_grid at 83
Warning: lat_u not found. Substituting x/y coords instead
> In roms_get_grid at 83
>> roms_zview(file,'temp',1,-5,g,3,s,'k')
??? Reference to non-existent field 'mask_u'.

Error in ==> roms_zslice_var at 44
    mask = grd.mask_u;

Error in ==> roms_zslice at 64
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in ==> roms_zview at 217
      u = roms_zslice(file,'u',time,depth,grd);
I also found by using ncload command that my ocean_his.nc has no mask_rho, mask_psi, mask_u, mask_v and angle information. Anyway, I also tried to use your example but it also shows similar error

Code: Select all

>> url='http://server/thredds/dodsC/roms/cblast/2002-050/averages'

url =

http://server/thredds/dodsC/roms/cblast/2002-050/averages

>> g=roms_get_grid(url,url);
Warning: Variable not found: mask_rho
> In roms_get_grid at 57
Warning: Variable not found: mask_psi
> In roms_get_grid at 57
Warning: Variable not found: mask_u
> In roms_get_grid at 57
Warning: Variable not found: mask_v
> In roms_get_grid at 57
Warning: Variable not found: angle
> In roms_get_grid at 57
Warning: Variable not found: h
> In roms_get_grid at 57
Warning: Variable not found: pm
> In roms_get_grid at 57
Warning: Variable not found: pn
> In roms_get_grid at 57
Warning: Variable not found: f
> In roms_get_grid at 57
What should I do to overcome the errors?

Rouf

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#11 Unread post by wilkin »

Code: Select all

>> url='http://server/thredds/dodsC/roms/cblast/2002-050/averages'
is clearly not actually a valid url. In my original posting this was intended only to illustrate how to use the matlab code with an OPeNDAP URL. If you want to test this with a valid URL you need to substitute tashtego.marine.rutgers.edu:8080 for server.

Does your application using MASKING? If not, the output won't include the masks. This is why roms_get_grid only gives warnings in the absence of masks.

Do you have an input grid file (GRDNAME in ocean.in)? If so, try loading this. If your grid is specified in ana_grid, then you need to be sure you are writing the grid to the output. At the unix prompt use e.g. 'ncdump', or in Matlab use e.g. nc_dump, to see the contents of your ocean_his.nc

i.e. in Matlab:

Code: Select all

>> nc_dump('ocean_his.nc')
If there is no lon...,lat...,h.pm,pn etc variables then I wonder did you set

Code: Select all

#define NO_WRITE_GRID
to disable them on output?


John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#12 Unread post by rouf »

Dear Wilkin,
I understand your explanation regarding url.
I am using the upwelling test case. Yes, there is no information regarding masking in the ocean_his.nc file so I hope thats why roms_get_grid only gives warnings regarding masks as u mentioned.

ocean_his.nc in matlab showing the following content

Code: Select all

:ana_file = "ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_grid.h, ROMS/Functionals/ana_initial.h, ROMS/Functionals/ana_smflux.h, ROMS/Functionals/ana_stflux.h, ROMS/Functionals/ana_vmix.h" 
:CPP_options = "UPWELLING, ANA_BSFLUX, ANA_BTFLUX, ANA_GRID, ANA_INITIAL, ANA_SMFLUX, ANA_SSFLUX, ANA_STFLUX, ANA_VMIX, AVERAGES, DIAGNOSTICS_TS, DIAGNOSTICS_UV, DJ_GRADPS, DOUBLE_PRECISION, EW_PERIODIC, MIX_S_TS, MIX_S_UV, NONLINEAR, !NONLIN_EOS, POWER_LAW, PROFILE, !RST_SINGLE, SALINITY, SOLVE3D, SPLINES, TS_U3HADVECTION, TS_C4VADVECTION, TS_DIF2, UV_ADV, UV_COR, UV_U3HADVECTION, UV_C4VADVECTION, UV_LDRAG, UV_VIS2, VAR_RHO_2D,"
So I can say input grid file is in the .in file and grid is specified in ana_grid. I am not clear about the following line
If your grid is specified in ana_grid, then you need to be sure you are writing the grid to the output.

Anyway, even with the masking error i continued to follow your prescribed commands

Code: Select all

>> file = 'ocean_his.nc'
>> g=roms_get_grid(file,file); % the grid structure
>> s = 0.1;
>> roms_zview(file,'temp',1,-5,g,3,s,'k') 
and get an matlab figure. But not sure about the acceptability. Is it possible to post some output figure considering upwelling test case in this thread or in your url http://romsmatlab.tiddlyspot.com/? So that we the new users can crosscheck.
Rouf

rouf

Re: roms_matlab plotting and analysis routines

#13 Unread post by rouf »

Sorry, I forget to inform the following error messages that i get after roms_zview command. There is a output figure, but seems not the actual output figure.

Code: Select all

>> roms_zview(file,'temp',1,-5,g,3,0.1,'k')
??? Reference to non-existent field 'mask_u'.

Error in ==> roms_zslice_var at 44
    mask = grd.mask_u;

Error in ==> roms_zslice at 64
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in ==> roms_zview at 217
      u = roms_zslice(file,'u',time,depth,grd);
Looking for kind help
Rouf

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#14 Unread post by wilkin »

Rouf,

From your last message it is hard to tell what success, if any, you are having. You say
There is a output figure, but seems not the actual output figure.
Please show me what figure you get. (Use the upload attachment panel to include it in your posting.)

Your last error message (I am pleased to see they are progressing) suggests using the option to plot velocity vectors is now seeking masks at u,v points that are unavailable. So I have further modified roms_get_grid to create null masks for all of u,v,psi in the case there is no mask information in the grid or output file.

I'd like to return to one other of your comments:
So I can say input grid file is in the .in file and grid is specified in ana_grid.
ROMS can't be doing both, so which is it? Are you giving grid information by a netcdf grid file (via input GRDNAME in ocean.in), or are you using ana_grid.h . The standard out (logfile) tells you which ROMS is using. (Just because GRDNAME is set in ocean.in does not mean ROMS is using that, so please answer accurately).
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#15 Unread post by rouf »

Dear Wilkin,
Please find the attached file.
upwelling.jpg
upwelling.jpg (19.91 KiB) Viewed 1249388 times
In terms of running upwelling test case in ROMS, I didn’t modify anything except following running ROMS under the tutorial installing ROMS in windows XP via Cygwin. I am not sure about the term standard out (logfile), but I check the upwellingout.dat file (which I get by running ROMS). At the end of that file, it mentioned that ana_grid.h is used as Analytical header files. So I suppose ROMS use ana_grid.h here.

Looking for your comments
Rouf

User avatar
arango
Site Admin
Posts: 1347
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#16 Unread post by arango »

This is correct! The problem here is that you don't know how the upwelling test case looks like. Neither you are reading the information provided correctly. There is a sample of the upwelling plot in :arrow: wikiROMS. The upwelling test case is horizontally uniform :idea: You need to plot cross-sections instead :!:

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#17 Unread post by wilkin »

In Unix, "standard output" is what gets typed to your screen as the output from any command to the shell. You have presumably captured this to a file by "redirecting" standard out with ">" something like:

oceanS.exe < ocean.in > upwellingout.dat

Some people on the ROMS Forum refer to this output, when captured to a file, as the logfile.

Your plot looks correct, Did you make it with my roms_zview or not?

As Hernan points out, with UPWELLING you will get more informative plots if you make cross sections such as with roms_iview.m.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

Re: roms_matlab plotting and analysis routines

#18 Unread post by rouf »

Thanks Wilkin. Yes I made it with your roms_zview. I also make figure with your roms_iview. It seems ok. I am actually new in this field. But all of your cooperation is helping and incisting me to go forward.

Rouf

User avatar
arango
Site Admin
Posts: 1347
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#19 Unread post by arango »

Well, congratualtions. We also added some plots to wikiROMS; check the following :arrow: link. Documentation is allows a daunting and time-consuming enterprise. We continue doing progress. We also expected the users to do their homework, read the information carefully, and have a lot of patience.

brainf
Posts: 5
Joined: Tue Nov 18, 2008 5:06 pm
Location: CHINESE ACADEMY OF SCIENCES

Re: roms_matlab plotting and analysis routines

#20 Unread post by brainf »

Dear Wilkin and rouf
I had the same error that rouf said when i used roms_get_grid Function, I am actually new in using ROMS,
When I run these two commands:

Code: Select all

file = 'ocean_his.nc';
g=roms_get_grid(file,file);
g will not return any value, and the errors are:

Code: Select all

file =

ocean_his.nc

Warning: Variable not found: mask_rho
> In roms_get_grid at 57
  In plot_upwelling at 3
Warning: Variable not found: mask_psi
> In roms_get_grid at 57
  In plot_upwelling at 3
Warning: Variable not found: mask_u
> In roms_get_grid at 57
  In plot_upwelling at 3
Warning: Variable not found: mask_v
> In roms_get_grid at 57
  In plot_upwelling at 3
Warning: Variable not found: h
> In roms_get_grid at 57
  In plot_upwelling at 3
Warning: Variable not found: angle
> In roms_get_grid at 57
  In plot_upwelling at 3
??? Reference to non-existent field 'h'.

Error in ==> roms_get_grid at 59
        grd = setfield(grd,vname,zeros(size(grd.h)));

Error in ==> plot_upwelling at 3
g=roms_get_grid(file,file); ; % the grid structure


I use the latest version of the roms_wilkin matlab tools form https://www.myroms.org/svn/om/matlab/roms_wilkin, The Revision 372,and my roms's version is 3.0. I ensured ocean_his.nc is in right path, also found by using ncdump command that my ocean_his.nc has no mask_rho, mask_psi, mask_u, mask_v and angle information,the grid maybe specified in ana_grid. I didn’t modify anything In terms of running upwelling test case in ROMS.

Code: Select all

netcdf ocean_his {
dimensions:
	xi_rho = 43 ;
	xi_u = 42 ;
	xi_v = 43 ;
	xi_psi = 42 ;
	eta_rho = 82 ;
	eta_u = 82 ;
	eta_v = 81 ;
	eta_psi = 81 ;
	N = 16 ;
	s_rho = 16 ;
	s_w = 17 ;
	tracer = 2 ;
	boundary = 4 ;
	ocean_time = UNLIMITED ; // (21 currently)
variables:
	int ntimes ;
		ntimes:long_name = "number of long time-steps" ;
	int ndtfast ;
		ndtfast:long_name = "number of short time-steps" ;
	double dt ;
		dt:long_name = "size of long time-steps" ;
		dt:units = "second" ;
	double dtfast ;
		dtfast:long_name = "size of short time-steps" ;
		dtfast:units = "second" ;
	double dstart ;
		dstart:long_name = "time stamp assigned to model initilization" ;
		dstart:units = "days since 0001-01-01 00:00:00" ;
		dstart:calendar = "julian" ;
	int nHIS ;
		nHIS:long_name = "number of time-steps between history records" ;
	int nRST ;
		nRST:long_name = "number of time-steps between restart records" ;
		nRST:cycle = "only latest two records are maintained" ;
	int ntsAVG ;
		ntsAVG:long_name = "starting time-step for accumulation of time-averaged fields" ;
	int nAVG ;
		nAVG:long_name = "number of time-steps between time-averaged records" ;
	int ntsDIA ;
		ntsDIA:long_name = "starting time-step for accumulation of diagnostic fields" ;
	int nDIA ;
		nDIA:long_name = "number of time-steps between diagnostic records" ;
	double Falpha ;
		Falpha:long_name = "Power-law shape barotropic filter parameter" ;
	double Fbeta ;
		Fbeta:long_name = "Power-law shape barotropic filter parameter" ;
	double Fgamma ;
		Fgamma:long_name = "Power-law shape barotropic filter parameter" ;
	double tnu2(tracer) ;
		tnu2:long_name = "Laplacian mixing coefficient for tracers" ;
		tnu2:units = "meter2 second-1" ;
	double visc2 ;
		visc2:long_name = "Laplacian mixing coefficient for momentum" ;
		visc2:units = "meter2 second-1" ;
	double Akt_bak(tracer) ;
		Akt_bak:long_name = "background vertical mixing coefficient for tracers" ;
		Akt_bak:units = "meter2 second-1" ;
	double Akv_bak ;
		Akv_bak:long_name = "background vertical mixing coefficient for momentum" ;
		Akv_bak:units = "meter2 second-1" ;
	double rdrg ;
		rdrg:long_name = "linear drag coefficient" ;
		rdrg:units = "meter second-1" ;
	double rdrg2 ;
		rdrg2:long_name = "quadratic drag coefficient" ;
	double Zob ;
		Zob:long_name = "bottom roughness" ;
		Zob:units = "meter" ;
	double Zos ;
		Zos:long_name = "surface roughness" ;
		Zos:units = "meter" ;
	double Znudg ;
		Znudg:long_name = "free-surface nudging/relaxation inverse time scale" ;
		Znudg:units = "day-1" ;
	double M2nudg ;
		M2nudg:long_name = "2D momentum nudging/relaxation inverse time scale" ;
		M2nudg:units = "day-1" ;
	double M3nudg ;
		M3nudg:long_name = "3D momentum nudging/relaxation inverse time scale" ;
		M3nudg:units = "day-1" ;
	double Tnudg(tracer) ;
		Tnudg:long_name = "Tracers nudging/relaxation inverse time scale" ;
		Tnudg:units = "day-1" ;
	double rho0 ;
		rho0:long_name = "mean density used in Boussinesq approximation" ;
		rho0:units = "kilogram meter-3" ;
	double R0 ;
		R0:long_name = "background density used in linear equation of state" ;
		R0:units = "kilogram meter-3" ;
	double Tcoef ;
		Tcoef:long_name = "thermal expansion coefficient" ;
		Tcoef:units = "Celsius-1" ;
	double Scoef ;
		Scoef:long_name = "Saline contraction coefficient" ;
		Scoef:units = "PSU-1" ;
	double gamma2 ;
		gamma2:long_name = "slipperiness parameter" ;
	char spherical ;
		spherical:long_name = "grid type logical switch" ;
		spherical:option_T = "spherical" ;
		spherical:option_F = "Cartesian" ;
	double xl ;
		xl:long_name = "domain length in the XI-direction" ;
		xl:units = "meter" ;
	double el ;
		el:long_name = "domain length in the ETA-direction" ;
		el:units = "meter" ;
	double theta_s ;
		theta_s:long_name = "S-coordinate surface control parameter" ;
	double theta_b ;
		theta_b:long_name = "S-coordinate bottom control parameter" ;
	double Tcline ;
		Tcline:long_name = "S-coordinate surface/bottom layer width" ;
		Tcline:units = "meter" ;
	double hc ;
		hc:long_name = "S-coordinate parameter, critical depth" ;
		hc:units = "meter" ;
	double s_rho(s_rho) ;
		s_rho:long_name = "S-coordinate at RHO-points" ;
		s_rho:valid_min = -1. ;
		s_rho:valid_max = 0. ;
		s_rho:standard_name = "ocean_s_coordinate" ;
		s_rho:formula_terms = "s: s_rho eta: zeta depth: h a: theta_s b: theta_b depth_c: hc" ;
		s_rho:field = "s_rho, scalar" ;
	double s_w(s_w) ;
		s_w:long_name = "S-coordinate at W-points" ;
		s_w:valid_min = -1. ;
		s_w:valid_max = 0. ;
		s_w:standard_name = "ocean_s_coordinate" ;
		s_w:formula_terms = "s: s_w eta: zeta depth: h a: theta_s b: theta_b depth_c: hc" ;
		s_w:field = "s_w, scalar" ;
	double Cs_r(s_rho) ;
		Cs_r:long_name = "S-coordinate stretching curves at RHO-points" ;
		Cs_r:valid_min = -1. ;
		Cs_r:valid_max = 0. ;
		Cs_r:field = "Cs_r, scalar" ;
	double Cs_w(s_w) ;
		Cs_w:long_name = "S-coordinate stretching curves at W-points" ;
		Cs_w:valid_min = -1. ;
		Cs_w:valid_max = 0. ;
		Cs_w:field = "Cs_w, scalar" ;
	double h(eta_rho, xi_rho) ;
		h:long_name = "bathymetry at RHO-points" ;
		h:units = "meter" ;
		h:coordinates = "x_rho y_rho" ;
		h:field = "bath, scalar" ;
	double f(eta_rho, xi_rho) ;
		f:long_name = "Coriolis parameter at RHO-points" ;
		f:units = "second-1" ;
		f:coordinates = "x_rho y_rho" ;
		f:field = "coriolis, scalar" ;
	double pm(eta_rho, xi_rho) ;
		pm:long_name = "curvilinear coordinate metric in XI" ;
		pm:units = "meter-1" ;
		pm:coordinates = "x_rho y_rho" ;
		pm:field = "pm, scalar" ;
	double pn(eta_rho, xi_rho) ;
		pn:long_name = "curvilinear coordinate metric in ETA" ;
		pn:units = "meter-1" ;
		pn:coordinates = "x_rho y_rho" ;
		pn:field = "pn, scalar" ;
	double x_rho(eta_rho, xi_rho) ;
		x_rho:long_name = "x-locations of RHO-points" ;
		x_rho:units = "meter" ;
		x_rho:field = "x_rho, scalar" ;
	double y_rho(eta_rho, xi_rho) ;
		y_rho:long_name = "y-locations of RHO-points" ;
		y_rho:units = "meter" ;
		y_rho:field = "y_rho, scalar" ;
	double x_u(eta_u, xi_u) ;
		x_u:long_name = "x-locations of U-points" ;
		x_u:units = "meter" ;
		x_u:field = "x_u, scalar" ;
	double y_u(eta_u, xi_u) ;
		y_u:long_name = "y-locations of U-points" ;
		y_u:units = "meter" ;
		y_u:field = "y_u, scalar" ;
	double x_v(eta_v, xi_v) ;
		x_v:long_name = "x-locations of V-points" ;
		x_v:units = "meter" ;
		x_v:field = "x_v, scalar" ;
	double y_v(eta_v, xi_v) ;
		y_v:long_name = "y-locations of V-points" ;
		y_v:units = "meter" ;
		y_v:field = "y_v, scalar" ;
	double x_psi(eta_psi, xi_psi) ;
		x_psi:long_name = "x-locations of PSI-points" ;
		x_psi:units = "meter" ;
		x_psi:field = "x_psi, scalar" ;
	double y_psi(eta_psi, xi_psi) ;
		y_psi:long_name = "y-locations of PSI-points" ;
		y_psi:units = "meter" ;
		y_psi:field = "y_psi, scalar" ;
	double ocean_time(ocean_time) ;
		ocean_time:long_name = "time since initialization" ;
		ocean_time:units = "seconds since 0001-01-01 00:00:00" ;
		ocean_time:calendar = "julian" ;
		ocean_time:field = "time, scalar, series" ;
	float zeta(ocean_time, eta_rho, xi_rho) ;
		zeta:long_name = "free-surface" ;
		zeta:units = "meter" ;
		zeta:time = "ocean_time" ;
		zeta:coordinates = "x_rho y_rho ocean_time" ;
		zeta:field = "free-surface, scalar, series" ;
	float ubar(ocean_time, eta_u, xi_u) ;
		ubar:long_name = "vertically integrated u-momentum component" ;
		ubar:units = "meter second-1" ;
		ubar:time = "ocean_time" ;
		ubar:coordinates = "x_u y_u ocean_time" ;
		ubar:field = "ubar-velocity, scalar, series" ;
	float vbar(ocean_time, eta_v, xi_v) ;
		vbar:long_name = "vertically integrated v-momentum component" ;
		vbar:units = "meter second-1" ;
		vbar:time = "ocean_time" ;
		vbar:coordinates = "x_v y_v ocean_time" ;
		vbar:field = "vbar-velocity, scalar, series" ;
	float u(ocean_time, s_rho, eta_u, xi_u) ;
		u:long_name = "u-momentum component" ;
		u:units = "meter second-1" ;
		u:time = "ocean_time" ;
		u:coordinates = "x_u y_u s_rho ocean_time" ;
		u:field = "u-velocity, scalar, series" ;
	float v(ocean_time, s_rho, eta_v, xi_v) ;
		v:long_name = "v-momentum component" ;
		v:units = "meter second-1" ;
		v:time = "ocean_time" ;
		v:coordinates = "x_v y_v s_rho ocean_time" ;
		v:field = "v-velocity, scalar, series" ;
	float w(ocean_time, s_w, eta_rho, xi_rho) ;
		w:long_name = "vertical momentum component" ;
		w:units = "meter second-1" ;
		w:time = "ocean_time" ;
		w:coordinates = "x_rho y_rho s_w ocean_time" ;
		w:field = "w-velocity, scalar, series" ;
	float omega(ocean_time, s_w, eta_rho, xi_rho) ;
		omega:long_name = "S-coordinate vertical momentum component" ;
		omega:units = "meter3 second-1" ;
		omega:time = "ocean_time" ;
		omega:coordinates = "x_rho y_rho s_w ocean_time" ;
		omega:field = "omega, scalar, series" ;
	float temp(ocean_time, s_rho, eta_rho, xi_rho) ;
		temp:long_name = "potential temperature" ;
		temp:units = "Celsius" ;
		temp:time = "ocean_time" ;
		temp:coordinates = "x_rho y_rho s_rho ocean_time" ;
		temp:field = "temperature, scalar, series" ;
	float salt(ocean_time, s_rho, eta_rho, xi_rho) ;
		salt:long_name = "salinity" ;
		salt:time = "ocean_time" ;
		salt:coordinates = "x_rho y_rho s_rho ocean_time" ;
		salt:field = "salinity, scalar, series" ;

// global attributes:
		:type = "ROMS/TOMS history file" ;
		:Conventions = "CF-1.0" ;
		:title = "Wind-Driven Upwelling/Downwelling over a Periodic Channel" ;
		:var_info = "/sdc/roms/trunk/ROMS/External/varinfo.dat" ;
		:rst_file = "ocean_rst.nc" ;
		:his_file = "ocean_his.nc" ;
		:avg_file = "ocean_avg.nc" ;
		:dia_file = "ocean_dia.nc" ;
		:svn_url = "https://www.myroms.org/svn/src/trunk" ;
		:svn_rev = "r" ;
		:code_dir = "/sdc/roms/trunk" ;
		:header_dir = "./ROMS/Include" ;
		:header_file = "upwelling.h" ;
		:os = "Linux" ;
		:cpu = "i686" ;
		:compiler_system = "pgi" ;
		:compiler_command = "pgf90" ;
		:compiler_flags = " -O3 -Mfree" ;
		:tiling = "001x001" ;
		:history = "ROMS/TOMS, Version 3.0, Wednesday - July 9, 2008 - 10:03:58 AM" ;
		:ana_file = "ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_grid.h, ROMS/Functionals/ana_initial.h, ROMS/Functionals/ana_smflux.h, 

ROMS/Functionals/ana_stflux.h, ROMS/Functionals/ana_vmix.h" ;
		:CPP_options = "UPWELLING, ANA_BSFLUX, ANA_BTFLUX, ANA_GRID, ANA_INITIAL, ANA_SMFLUX, ANA_SSFLUX, ANA_STFLUX, ANA_VMIX, ASSUMED_SHAPE, 

AVERAGES, DIAGNOSTICS_TS, DIAGNOSTICS_UV, DJ_GRADPS, DOUBLE_PRECISION, EW_PERIODIC, MIX_S_TS, MIX_S_UV, NONLINEAR, !NONLIN_EOS, POWER_LAW, PROFILE, !

RST_SINGLE, SALINITY, SOLVE3D, SPLINES, TS_U3HADVECTION, TS_C4VADVECTION, TS_DIF2, UV_ADV, UV_COR, UV_U3HADVECTION, UV_C4VADVECTION, UV_LDRAG, UV_VIS2, 

VAR_RHO_2D," ;

the logfile:

Code: Select all

 Process Information:

 Thread #  0 (pid=    4074) is active.

 Model Input Parameters:  ROMS/TOMS version 3.0  
                          Wednesday - July 9, 2008 - 10:03:58 AM
 -----------------------------------------------------------------------------

 Wind-Driven Upwelling/Downwelling over a Periodic Channel

 Operating system : Linux
 CPU/hardware     : i686
 Compiler system  : pgi
 Compiler command : pgf90
 Compiler flags   :  -O3 -Mfree

 SVN Root URL  : https://www.myroms.org/svn/src/trunk
 SVN Revision  : 

 Local Root    : /roms/trunk
 Header Dir    : ./ROMS/Include
 Header file   : upwelling.h
 Analytical Dir: /roms/trunk/ROMS/Functionals

 Resolution, Grid 01: 0041x0080x016,  Parallel Threads:  1,  Tiling: 001x001


 Physical Parameters, Grid: 01
 =============================

       1440  ntimes          Number of timesteps for 3-D equations.
    300.000  dt              Timestep size (s) for 3-D equations.
         30  ndtfast         Number of timesteps for 2-D equations between
                               each 3D timestep.
          1  ERstr           Starting ensemble/perturbation run number.
          1  ERend           Ending ensemble/perturbation run number.
          0  nrrec           Number of restart records to read from disk.
          T  LcycleRST       Switch to recycle time-records in restart file.
        288  nRST            Number of timesteps between the writing of data
                               into restart fields.
          1  ninfo           Number of timesteps between print of information
                               to standard output.
          T  ldefout         Switch to create a new output NetCDF file(s).
         72  nHIS            Number of timesteps between the writing fields
                               into history file.
          1  ntsAVG          Starting timestep for the accumulation of output
                               time-averaged data.
         72  nAVG            Number of timesteps between the writing of
                               time-averaged data into averages file.
          1  ntsDIA          Starting timestep for the accumulation of output
                               time-averaged diagnostics data.
         72  nDIA            Number of timesteps between the writing of
                               time-averaged data into diagnostics file.
 0.0000E+00  tnu2(01)        Horizontal, harmonic mixing coefficient (m2/s)
                               for tracer 01: temp
 0.0000E+00  tnu2(02)        Horizontal, harmonic mixing coefficient (m2/s)
                               for tracer 02: salt
 5.0000E+00  visc2           Horizontal, harmonic mixing coefficient (m2/s)
                               for momentum.
 1.0000E-06  Akt_bak(01)     Background vertical mixing coefficient (m2/s)
                               for tracer 01: temp
 1.0000E-06  Akt_bak(02)     Background vertical mixing coefficient (m2/s)
                               for tracer 02: salt
 1.0000E-05  Akv_bak         Background vertical mixing coefficient (m2/s)
                               for momentum.
 3.0000E-04  rdrg            Linear bottom drag coefficient (m/s).
 3.0000E-03  rdrg2           Quadratic bottom drag coefficient.
 2.0000E-02  Zob             Bottom roughness (m).
 3.0000E+00  theta_s         S-coordinate surface control parameter.
 0.0000E+00  theta_b         S-coordinate bottom  control parameter.
     50.000  Tcline          S-coordinate surface/bottom layer width (m) used
                               in vertical coordinate stretching.
   1025.000  rho0            Mean density (kg/m3) for Boussinesq approximation.
      0.000  dstart          Time-stamp assigned to model initialization (days).
       0.00  time_ref        Reference time for units attribute (yyyymmdd.dd)
 0.0000E+00  Tnudg(01)       Nudging/relaxation time scale (days)
                               for tracer 01: temp
 0.0000E+00  Tnudg(02)       Nudging/relaxation time scale (days)
                               for tracer 02: salt
 0.0000E+00  Znudg           Nudging/relaxation time scale (days)
                               for free-surface.
 0.0000E+00  M2nudg          Nudging/relaxation time scale (days)
                               for 2D momentum.
 0.0000E+00  M3nudg          Nudging/relaxation time scale (days)
                               for 3D momentum.
 0.0000E+00  obcfac          Factor between passive and active
                               open boundary conditions.
     14.000  T0              Background potential temperature (C) constant.
     35.000  S0              Background salinity (PSU) constant.
   1027.000  R0              Background density (kg/m3) used in linear Equation
                               of State.
 1.7000E-04  Tcoef           Thermal expansion coefficient (1/Celsius).
 0.0000E+00  Scoef           Saline contraction coefficient (1/PSU).
      1.000  gamma2          Slipperiness variable: free-slip (1.0) or 
                                                    no-slip (-1.0).
          T  Hout(idFsur)    Write out free-surface.
          T  Hout(idUbar)    Write out 2D U-momentum component.
          T  Hout(idVbar)    Write out 2D V-momentum component.
          T  Hout(idUvel)    Write out 3D U-momentum component.
          T  Hout(idVvel)    Write out 3D V-momentum component.
          T  Hout(idWvel)    Write out W-momentum component.
          T  Hout(idOvel)    Write out omega vertical velocity.
          T  Hout(idTvar)    Write out tracer 01: temp
          T  Hout(idTvar)    Write out tracer 02: salt

 Output/Input Files:

             Output Restart File:  ocean_rst.nc
             Output History File:  ocean_his.nc
            Output Averages File:  ocean_avg.nc
         Output Diagnostics File:  ocean_dia.nc

 Tile partition information for Grid 01:  0041x0080x0016  tiling: 001x001

     tile     Istr     Iend     Jstr     Jend     Npts

        0        1       41        1       80    52480

 Activated C-preprocessing Options:

  UPWELLING          Wind-Driven Upwelling/Downwelling over a Periodic Channel
  ANA_BSFLUX         Analytical kinematic bottom salinity flux.
  ANA_BTFLUX         Analytical kinematic bottom temperature flux.
  ANA_GRID           Analytical grid set-up.
  ANA_INITIAL        Analytical initial conditions.
  ANA_SMFLUX         Analytical kinematic surface momentum flux.
  ANA_SSFLUX         Analytical kinematic surface salinity flux.
  ANA_STFLUX         Analytical kinematic surface temperature flux.
  ANA_VMIX           Analytical vertical mixing coefficients.
  ASSUMED_SHAPE      Using assumed-shape arrays.
  AVERAGES           Writing out time-averaged fields.
  DIAGNOSTICS_TS     Computing and writing tracer diagnostic terms.
  DIAGNOSTICS_UV     Computing and writing momentum diagnostic terms.
  DJ_GRADPS          Parabolic Splines density Jacobian (Shchepetkin, 2002).
  DOUBLE_PRECISION   Double precision arithmetic.
  EW_PERIODIC        East-West periodic boundaries.
  MIX_S_TS           Mixing of tracers along constant S-surfaces.
  MIX_S_UV           Mixing of momentum along constant S-surfaces.
  NONLINEAR          Nonlinear Model.
  !NONLIN_EOS        Linear Equation of State for seawater.
  POWER_LAW          Power-law shape time-averaging barotropic filter.
  PROFILE            Time profiling activated .
  !RST_SINGLE        Double precision fields in restart NetCDF file.
  SALINITY           Using salinity.
  SOLVE3D            Solving 3D Primitive Equations.
  SPLINES            Conservative parabolic spline reconstruction.
  TS_U3HADVECTION    Third-order upstream horizontal advection of tracers.
  TS_C4VADVECTION    Fourth-order centered vertical advection of tracers.
  TS_DIF2            Harmonic mixing of tracers.
  UV_ADV             Advection of momentum.
  UV_COR             Coriolis term.
  UV_U3HADVECTION    Third-order upstream horizontal advection of 3D momentum.
  UV_C4VADVECTION    Fourth-order centered vertical advection of momentum.
  UV_LDRAG           Linear bottom stress.
  UV_VIS2            Harmonic mixing of momentum.
  VAR_RHO_2D         Variable density barotropic mode.

 INITIAL: Configuring and initializing forward nonlinear model ...


 Vertical S-coordinate System: 

 level   S-coord     Cs-curve          at_hmin  over_slope     at_hmax

    16   0.0000000   0.0000000           0.000       0.000       0.000
    15  -0.0625000  -0.0188264          -1.575      -2.750      -3.925
    14  -0.1250000  -0.0383166          -3.150      -5.541      -7.932
    13  -0.1875000  -0.0591578          -4.725      -8.417     -12.108
    12  -0.2500000  -0.0820849          -6.300     -11.422     -16.544
    11  -0.3125000  -0.1079063          -7.875     -14.608     -21.342
    10  -0.3750000  -0.1375324          -9.450     -18.032     -26.614
     9  -0.4375000  -0.1720078         -11.025     -21.758     -32.492
     8  -0.5000000  -0.2125480         -12.600     -25.863     -39.126
     7  -0.5625000  -0.2605826         -14.175     -30.436     -46.696
     6  -0.6250000  -0.3178051         -15.750     -35.581     -55.412
     5  -0.6875000  -0.3862333         -17.325     -41.426     -65.527
     4  -0.7500000  -0.4682798         -18.900     -48.121     -77.341
     3  -0.8125000  -0.5668375         -20.475     -55.846     -91.216
     2  -0.8750000  -0.6853816         -22.050     -64.818    -107.586
     1  -0.9375000  -0.8280918         -23.625     -75.298    -126.971
     0  -1.0000000  -1.0000000         -25.200     -87.600    -150.000

 Time Splitting Weights: ndtfast =  30    nfast =  42

    Primary            Secondary            Accumulated to Current Step

  1-0.0008094437383769 0.0333333333333333-0.0008094437383769 0.0333333333333333
rouf said he masked error then he continued to follow your commands, but how to mask the error?
What should I do to solve the errors?

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#21 Unread post by wilkin »

Are you able to read any data at all from the file directly inside matlab:

Code: Select all

file = 'ocean_his.nc';
h = nc_varget(file,'h');
If not, then the problem is not with roms_get_grid, but more fundamental to your set-up.

(The UPWELLING test case has no masking or grid rotation, so that's why mask_rho etc are not in the file. roms_get_grid only gives a warning when it can't find the masks, and should continue to read the variables it needs while creating masks that haves 1 in all entries so that the other plotting routines work without needing to check for the existence of the masks).

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

brainf
Posts: 5
Joined: Tue Nov 18, 2008 5:06 pm
Location: CHINESE ACADEMY OF SCIENCES

Re: roms_matlab plotting and analysis routines

#22 Unread post by brainf »

Thanks wilkin, it works. According to your proposal, I found my snctools to set the wrong path. When I setup the correct path, I can see the same figure with rouf.

feroda

Re: roms_matlab plotting and analysis routines

#23 Unread post by feroda »

As in the first post by wilkin, there is no reference scale for the magnitude of vectors.
Is it not necessary or has been solved? Thanks

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#24 Unread post by wilkin »

It is solved.

Use roms_addvect_scale

Code: Select all

>> help roms_addvect_scale

   han = roms_addvect_scale(pos,uv,uscale,label,varargin)
 
   pos = [x y] position for scale vector (can use, e.g. ginput(1)
   uv = [u v] scale vector
   uscale = same scale as used in the roms_quiver command
   label = string to label vector, default is 'm/s'
   varargin = arguments to quiver, e.g. vector color
For example,

Code: Select all

roms_addvect_scale(ginput(1),[0 1],.1,'m/s','r')
will add a 1 m/s northward scale vector (in red) at the location you click on in the plot (because of the ginput).
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

duckweed

Re: roms_matlab plotting and analysis routines

#25 Unread post by duckweed »

Hello ;

Thanks for these very good tools. i am a beginner for roms.

I'm able to use some of then, but with some options the program complain about specific functions or sub-functions.

For example:

Using:

(1)
>>file='ocean_his.nc'
>>g=roms_get_grid(file,file);
>>roms_zview(file,'temp',1,-5,g,3,s,'k')

file =

ocean_his.nc

Warning: Variable not found: mask_rho
> In roms_get_grid at 57
Warning: Variable not found: mask_psi
> In roms_get_grid at 57
Warning: Variable not found: mask_u
> In roms_get_grid at 57
Warning: Variable not found: mask_v
> In roms_get_grid at 57
Warning: Variable not found: h
> In roms_get_grid at 57
Warning: Variable not found: angle
> In roms_get_grid at 57
??? Reference to non-existent field 'h'.

Error in ==> roms_get_grid at 59
grd = setfield(grd,vname,zeros(size(grd.h)));

(2)
>> file='ocean_his.nc'
>> h = nc_varget(file,'h');

file =

ocean_his.nc

??? Undefined command/function 'nc_varget'.


How to solve it ?


Thanks!

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#26 Unread post by wilkin »

Your errors indicate that command nc_varget is unknown to your matlab session. You either have not installed snctools, or not added them correctly to the matlab path.

You can confirm this is the problem with:
>> which nc_varget

If nc_varget, is in your path, then you should also be able to nc_dump the roms file and confirm it has the data in it:

>> file = 'ocean.his'
>> nc_dump(file)

If the nc_dump command exists, but fails, then there is something wrong with the roms file or, more likely, you have given an incorrect path to where it is located.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: roms_matlab plotting and analysis routines

#27 Unread post by mariafattorini »

Dear all,
I am experiencing a similar error trying to plot the upwelling model results. I am using the grd=roms_get_grid('ocean_his.nc') but the command stops because the variables long_rho, lat_rho,.........are absent in the input file. Actually, by using ncload('ocean_his.nc') I have checked that these variables are absent. Any suggestion to run the roms_get_grid properly?
Cheers Maria

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#28 Unread post by wilkin »

Is your version of roms_get_grid recent?

Several months ago I made changes to the code to trap the case that an idealized x,y coordinates grid was used (as in the upwelling example), and in this event the code reads x_rho into lon_rho, etc. It gives a warning, but not a fatal error.

The code version to be use is the version managed with svn and described in the DownLoad section at http://romsmatlab.tiddlyspot.com

Note that roms_get_grid will change again shortly is accommodate the new vertical grid stretching options. I'll post a message to the forum when I update the svn repository.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

mariafattorini
Posts: 52
Joined: Tue Mar 03, 2009 2:39 pm
Location: C.N.R. - LaMMA

Re: roms_matlab plotting and analysis routines

#29 Unread post by mariafattorini »

Dear Wilkin,
thank you very much for your help.
Actually I used the old version of the routine.

At the present I am trying to plot the vector field related to the "Sed_test1" test case. I have setted the following script:
>> ncload 'ocean_his.nc'
>> vplot=v(11,1,:,:);
>> uplot=u(11,1,:,:);
>> grd=roms_get_grid('ocean_his.nc')
>> roms_quivergrd(uplot,vplot,grd,1,1)

but the plot I get is a empty white immage.
Have you any suggestion?

Thank you again.
Maria

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#30 Unread post by wilkin »

Make sure you actually have values that will plot, so check:
>> max(uplot(:))

You might need a larger value of uscale.

You can also use roms_sview to plot the individual components to see what sort of values there are.

Note that you are plotting vertical level 1, which is near the seafloor not the surface.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

duckweed

Re: roms_matlab plotting and analysis routines

#31 Unread post by duckweed »

Thank you ! wilikin.

When i use the roms_wilkin,i found some question:

when i run

Code: Select all


file = '/disk/ROMS/ocean_his.nc';
g=roms_get_grid(file,file);
roms_sview(file,'temp',18,0,g,3,.2,'k') ;
Warning:Variable not found :angle
>In roms_get_grid at 57
???Error using ==>plus
Matrix dimensions must agree.

Error in ==> roms_zslice_var at 97
zl_ind = zl_ind + [1:1:length(zg_ind)]';

Error in ==> roms_zslice at 64
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in ==> roms_zview at 152
[data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);
But, if the depth is not at 0m,the roms_zview can run correct. I see the program , i find it has a 'SST' and a 'SSS' varible, If the depth is 0m , the varible 'temp' will be instand of 'SST'? Then, how to output the 'SST' and 'SSS'to 'ocean_his.nc'.And the 'angle'? My grid file has the 'angle'.

Thank you very much!

wuhe
Posts: 15
Joined: Mon Dec 22, 2008 5:29 pm
Location: national ocean techniqual centre

Re: roms_matlab plotting and analysis routines

#32 Unread post by wuhe »

hi, wilkin, I am very appreciate u to make so good plot package, and I can use it easily. and i just wonder whether it can plot the contours? if not, could u update the package function for this purpose? thanks!

feroda

Re: roms_matlab plotting and analysis routines

#33 Unread post by feroda »

Hi Dr. Wilkin,
Please double check the
uvz_from_clim_stdlev.m
in the matlab plotting routines.
In which, the following two lines
162 velz = -sw_gvel(ga,y',lon(:,I));
168 vel0 = -sw_gvel(ga0,y',lon(:,I));

might be
162 velz = -sw_gvel(ga,y',lon(:,I)');
168 vel0 = -sw_gvel(ga0,y',lon(:,I)');

Thank you.

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#34 Unread post by wilkin »

Could you explain why you think this change is required?

Note that the lon and lat arrays should be dimensioned lon(lat,lon) and lat(lat,lon) following the climatology temp and salt(time z lat lon). Unless you have equal dimensions in lon and lat I would expect the code to throw an error if the change you suggest is actually a bug.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#35 Unread post by wilkin »

I've installed a long overdue update to my roms_get_grid.m function so it computes the vertical grid coordinates for the new ROMS vertical stretching transformations.

The new version (thank you Hernan) uses two (and only two) functions from Hernan Arango's Matlab utilities (stretching.m and set_depth.m). If you don't already have these, you can either install all of the Arango utilities (managed by svn) or just get the two functions you need from https://www.myroms.org/svn/src/matlab/utility/

If you already have my ROMS matlab routines installed, then all you need to do is an svn update. You will get a few other updates as well - mostly small bug fixes or some added functionality (like saving the u,v values used by quiver to the optional data output of a roms_zview call).

If you want instructions on downloading these functions, see http://romsmatlab.tiddlyspot.com/ or review the previous posts to this topic.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

eivinds
Posts: 8
Joined: Mon Sep 28, 2009 6:08 pm
Location: Geosciences, Univ. of Oslo

Re: roms_matlab plotting and analysis routines

#36 Unread post by eivinds »

Hello.
In the file roms_plot_bathy.m line 12 it says
grd = get_roms_grid(grd_file);
I believe the correct function call is
grd = roms_get_grid(grd_file); ?

Eivind

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#37 Unread post by wilkin »

OK, fixed that. svn update ... to get the changes.
Thanks, John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rgon
Posts: 12
Joined: Thu Jan 29, 2009 4:00 pm
Location: University of Plymouth

Re: roms_matlab plotting and analysis routines

#38 Unread post by rgon »

Hello,
I've downloaded the new roms_wilkin version and done all the above in order to obtain the upwelling plot but I've got the following messages:

>> roms_jview(file,'salt',1,5,g);
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.


or

>> roms_zview(file,'temp',1,-5,g,3,s,'k')
??? Reference to non-existent field 'angle'.

Error in ==> roms_quivergrd at 55
angle = grd.angle;

Error in ==> roms_zview at 244
[hanquiver,dataq] = roms_quivergrd(u,v,grd,vec_d,uscale,varargin{:});

Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.
Warning: CData must be double or uint8.



Any suggestion?

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#39 Unread post by wilkin »

Your nc_varget is loading data of type 'float' into a Matlab 'single' type variable, which Matlab pcolor does not accept. pcolor will only plot type 'double'. Look in pcolorjw.m near the start and you will see a segment that converts the input to 'double'. Edit that piece of code to activate the conversion.

The behavior of nc_varget will likely alter in the near future to avert this problem. I spoke to John Evans about it a week or so ago.

John.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rgon
Posts: 12
Joined: Thu Jan 29, 2009 4:00 pm
Location: University of Plymouth

Re: roms_matlab plotting and analysis routines

#40 Unread post by rgon »

Dear Wilkin
Thank You for the advice, it is working now :D
Regards.

stone

Re: roms_matlab plotting and analysis routines

#41 Unread post by stone »

Dear Wilkin,

Does this Matlab tool require Matlab version higher than 2008a??
Since I use Matlab 2008a ,I downloaded mexcdf.R13.r2723.zip for Matlab2008a, and snctools-2.5.8.tar.gz and test UPWELLING ,
but I get these: g=roms_get_grid(file,file); % the grid structure
Warning: Variable not found: mask_rho
> In roms_get_grid at 75
Warning: Variable not found: mask_psi
> In roms_get_grid at 75
Warning: Variable not found: mask_u
> In roms_get_grid at 75
Warning: Variable not found: mask_v
> In roms_get_grid at 75
Warning: Variable not found: angle
> In roms_get_grid at 75
Warning: Variable not found: h
> In roms_get_grid at 75
Warning: Variable not found: pm
> In roms_get_grid at 75
Warning: Variable not found: pn
> In roms_get_grid at 75
Warning: Variable not found: f
> In roms_get_grid at 75
??? Undefined function or variable 'nc_nowrite_mode'.

Error in ==> nc_isvar>nc_isvar_mexnc at 54
[ncid,status] = mexnc('open',ncfile, nc_nowrite_mode );

Error in ==> nc_isvar at 40
bool = nc_isvar_mexnc ( ncfile, varname );

Error in ==> roms_get_grid at 80
if nc_isvar(grd_file,'x_rho')


Do i have to install Matlab2008b or higher?
The tutorial I'm following at
https://www.myroms.org/wiki/index.php/R ... ith_Matlab used Matlab2008b.

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#42 Unread post by wilkin »

My ROMS Matlab tools do not require anything exotic with regard to Matlab versions to work. They just need snctools which evidently you have or you would have had a different error. The warning error you get is a clue that your file does not include vital grid information. The error says the file does not include the masks (which is possible if your application has no maksing) but also the depth (h) and grid size metrics (pm, pn). So the netcdf file indicated by variable 'file' must not have important grid information.

In matlab, try:
nc_dump(file)

to see the contents. If this is your ROMS input grid file you should at least have x_rho etc or lon_rho etc, h, pm, and pn.

If it is a ROMS output file, the metrics should have been written to the file by ROMS itself.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#43 Unread post by wilkin »

I've added a new function roms_kmz.m that will convert any of the roms_zview etc type plots to a google earth kmz file. It needs two other user-contributed toolboxes available from the Mathworks (export_fig to make transparent png bitmaps, and the googleearth toolbox).

I used it to make a kmz of the prototype plot we used when designing the ROMS Hawaii Workshop T-shirt:
http://marine.rutgers.edu/~wilkin/hi/Ro ... nShirt.kmz
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

cae
Posts: 36
Joined: Mon Jun 30, 2003 5:29 pm
Location: UC Santa Cruz

Re: roms_matlab plotting and analysis routines

#44 Unread post by cae »

Hi.

closest.m from the roms_wilkin set of routines is a useful routine for trying to find the nearest grid point to a lat/lon position. I find a tiny issue when a desired point is exactly mid-way between roms grid points. The following section of code crashes when ii and jj, returned by find(), are vectors and not scalars.

Code: Select all

36 for k=1:length(xi)
37   dist = abs( (xi(k)-X) + sqrt(-1)*(yi(k)-Y));
38   [ii,jj] = find(dist==min(dist(:)));
39   i(k) = ii;
40   j(k) = jj;
41   dist = min(dist(:));
42 end
Here's a possible solution. It picks (arbitrarily) only the first nearest point:

Code: Select all

36 for k=1:length(xi)
37   dist = abs( (xi(k)-X) + sqrt(-1)*(yi(k)-Y));
38   [ii,jj] = find(dist==min(dist(:)));
39   i(k) = ii(1);
40   j(k) = jj(1);
41   dist = min(dist(:));
42 end
Other solutions are of course possible.

Chris

asujrpv

Re: roms_matlab plotting and analysis routines

#45 Unread post by asujrpv »

I am using the fortran roms plots and now starting to use the matlab routines. I wonder if you have found any problems like the following in which the variable angle has not been found before. I am running a tidal case, and it does not affect anything, just curiousity.

thanks
Rafael
>> h = nc_varget(hfile,'h');
>> g=roms_get_grid(hfile); % the grid structure
Warning: Variable not found: angle

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

Re: roms_matlab plotting and analysis routines

#46 Unread post by kate »

So is that hfile a grid file? Have you checked it for an angle variable? If it's not there, how did you get that grid file? Should it have non-zero angles?

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#47 Unread post by wilkin »

That is just an informational warning. If your hfile is an output file (history, average) it should have everything required. Evidently you do not have a curvilinear grid defined so the angle variable does not exist and is not written to the file.


In my plotting routines that draw vectors, the angle (between the grid i,j direction and x,y) is required to rotate the vectors before they are drawn by Matlab quiver.

If the ROMS application does not use the angle rotation (like many of the analytical examples) then its easiest just to generate internally an 'angle' variable and fill it with zeros in order apply no rotation by default. But I put that warning there in case you did mean to rotate coordinates - so that you know something is wrong. Otherwise the code does not throw an error because it sets angle = 0 and keeps going.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

SophieWard
Posts: 9
Joined: Fri Oct 08, 2010 4:46 pm
Location: Bangor University

Re: roms_matlab plotting and analysis routines

#48 Unread post by SophieWard »

Hi,
This is a really useful thread and sorry to revisit a simple problem but running the upwelling test case I get the same error that rgon did back in Nov 2009 but now I’m running Matlab R2011a (7.12.0). I have checked out the latest matlab functions from tiddlyspot.com and I’ve downloaded the latest SNCTOOLS (R2010b and Beyond). I’ve tried activating/editing/removing the section of code (x=double(x) etc) that converts the variable into double-precision in pcolorjw.m (as per John’s suggestion on 10th Nov 09) yet I still get the warning:

Warning: CData must be double or uint8

I’m obviously missing something fundamental but I’m not sure what it is, considering I’ve got all the latest versions (was nc_varget altered to avert this problem?) and am assured by matlab help that if a variable is already a double then it ignores this command?? Any help/suggestions much appreciated.

Many thanks in advance

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#49 Unread post by wilkin »

When you get that error in Matlab it will tell you exactly what line of what routine is calling pcolorjw. What is it?

Make sure the pcolorjw etc you are using are the ones you intend - maybe you have more than one in your Matlab path. Use ...

Code: Select all

>> which pcolorjw -all 
... to see.

Also, Matlab has an easy interactive debugger. Put a keyboard command in the code somewhere before the error, and check that the data are indeed type double.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

SophieWard
Posts: 9
Joined: Fri Oct 08, 2010 4:46 pm
Location: Bangor University

Re: roms_matlab plotting and analysis routines

#50 Unread post by SophieWard »

Hi John, thanks for the prompt reply. I have now sorted it using the debugger, as you suggested - the data that was being plotted (around line 203 of roms_zview.m, I'm not sure exactly which line as I've edited the file) was only single. I sorted this by adding a line above the code so it now reads:

Code: Select all

data=double(data);
hanpc = pcolorjw(x,y,data.*mask);
and it works - I'm not too sure why this was or whether it is something wrong with my output file, but it certinaly looks like the plots higher up in this thread. Great - thanks again!
Sophie

antoinemarie

Re: roms_matlab plotting and analysis routines

#51 Unread post by antoinemarie »

Hi,

I try to use the John's matlab toolbox. I have installed snctools.
But when I try to use it, I have some errors.
The first one:

Code: Select all

>> roms_zview('ruisseau_his.nc','ubar','01-Jan-0001 00:00:00',0,'ruisseau_grd.nc',3,.1,'k')
??? Error using ==> netcdflib
Variable ID retrieval failed, library error message "NetCDF: Variable not found"

Error in ==> inqVarID at 21
varid = netcdflib('inq_varid', ncid, varname);

Error in ==> nc_varget_tmw>nc_varget_tmw_group at 46
varid=netcdf.inqVarID(ncid,varname);

Error in ==> nc_varget_tmw at 25
    values = nc_varget_tmw_group(ncfile,gid,local_varname,start,count,stride);

Error in ==> nc_varget at 47
		data = nc_varget_tmw(ncfile,varname,start,count,stride);

Error in ==> roms_get_grid at 177
    theta_s = nc_varget(scoord,'theta_s');

Error in ==> roms_2dslice at 62
    grd = roms_get_grid(grd,file);

Error in ==> roms_zview at 135
    [data,x,y,t,grd] = roms_2dslice(file,var,time,grd);

and when I try with an other application, I have this second error:

Code: Select all

>> roms_zview('upwelling_his.nc','umag','01-Jan-0001 00:00:10',0,'reunion_grd.nc')
??? Undefined function or method 'stretching' for input arguments of type 'int32'.

Error in ==> roms_get_grid at 199
  [s_rho,Cs_r]=stretching(Vstretching, theta_s, theta_b, hc, N, 0, 0);

Error in ==> roms_zslice at 51
    grd = roms_get_grid(grd,file);

Error in ==> roms_zview at 138
    [datau,x,t,t,grd] = roms_zslice(file,'u',time,depth,grd);

If someone know how to do, please help me.
Thanks in advance,

Antoine

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#52 Unread post by wilkin »

You may have an out of date roms_get_grid.m (with the function "stretching" embedded, or an even older version that does not use the function "stretching" at all).

I suggest you update your roms_wilkin code using svn.

I took "stretching" and "set_depth" out of roms_get_grid because it is better practice to use the vertical coordinate stretching functions from the myroms repository (Hernan Arango's utilities). This way when new stretching options are added you will get those promptly.

I updated, today, the "help" on roms_zview to emphasize I recommend computing the grd structure once and then passing it to roms_zview on subsequent calls. This avoids needlessly recomputing the coordinates.

I say this because you may be having trouble using the grid netcdf file as the grid argument to roms_get_grid. This forces the function to the load the horizontal coordinates on each call from the grid file, then go to the output file (in your case 'ruisseau_his.nc') to find the vertical stretching parameters (theta_s, etc.) and compute z_r and z_w. However, in my test today this method does work so I could not reproduce your error for your combination of inputs: var='ubar', depth=0, etc.

Also, I generally advise against using depth 0 with roms_zview because with zeta=0 (which is assumed if you don't specify otherwise), the depth of the shallowest rho points is strictly < 0. But it should work anyway. In your case, you are asking for a 2-D variable (ubar) so it doesn't really matter. I tested it and it works for me.

To plot on s-levels, use roms_sview instead. It's probably faster.

In case you still have trouble, these work with my version of the codes:

Code: Select all

f = 'http://tashtego.marine.rutgers.edu:8080/thredds/dodsC/roms/espresso/2009_da/avg';
grd = roms_get_grid(f,f);
roms_zview(f,'ubar','18-Jan-2010',0,grd)

f = 'http://tashtego.marine.rutgers.edu:8080/thredds/dodsC/roms/espresso/2009_da/avg'
roms_zview(f,'ubar','18-Jan-2010',0,f)
You effort to plot "umag" will fail because you ask for depth = 0. Try a depth < 0.

This works:

Code: Select all

f = 'http://tashtego.marine.rutgers.edu:8080/thredds/dodsC/roms/espresso/2009_da/avg'
roms_zview(f,'umag','18-Jan-2010',-10,f)
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

antoinemarie

Re: roms_matlab plotting and analysis routines

#53 Unread post by antoinemarie »

Thanhs John for replying,

I update my roms_wilkin code and I have another error, even if I try with your files. Function roms_cgridpos desn't manage to determine the C grid location. I have the following error:

Code: Select all

??? Error using ==> roms_cgridpos at 39
Could not determine C-grid location

Error in ==> roms_2dslice at 70
switch roms_cgridpos(size(data),grd)

Error in ==> roms_zview at 140
    [data,x,y,t,grd] = roms_2dslice(file,var,time,grd);

Error in ==> essai at 3
roms_zview(f,'ubar','18-Jan-2010',0,grd)
 

achimherrmann
Posts: 3
Joined: Fri Dec 01, 2006 5:10 am
Location: Arizona State University

Re: roms_matlab plotting and analysis routines

#54 Unread post by achimherrmann »

Hi, I have the same problem as one of the posters in this thread (i.e., plotting the 'upwelling' test case with the matlab routines) but unfortunately I can not resolve my problem despite reading through this thread.
I have ROMS installed. It compiles, runs, and writes the *.nc files.
I have the scntools and mexnc installed. I have also obtained the matlab plotting routines via svn (Checked out revision 402). I can read the ocean-his file from the upwelling testcase (file = 'ocean_his.nc';) and read in a variable from the file (h = nc_varget(file,'h');) as suggested above. I can then look at the varibale content:

>> h

h =

Columns 1 through 10

25.2005 25.2005
....
So I guess my netcdf and matlab setup are correct (I am using matlab 2010b).

However, I can, as one poster above, not read in and plot the test case using the roms plot routines as it gives me masking errors. Could someone tell me how I can make the upwelling case plotable with the routines?
>>
>> file = 'ocean_his.nc'

file =

ocean_his.nc

>> g=roms_get_grid(file,file); % the grid structure
Warning: Variable not found: mask_rho
> In roms_get_grid at 74
Warning: Variable not found: mask_psi
> In roms_get_grid at 74
Warning: Variable not found: mask_u
> In roms_get_grid at 74
Warning: Variable not found: mask_v
> In roms_get_grid at 74
Warning: Variable not found: angle
> In roms_get_grid at 74
Warning: lon_rho not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_rho not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_psi not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_psi not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_v not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_v not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_u not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_u not found. Substituting x/y coords instead
> In roms_get_grid at 107
??? Undefined function or method 'stretching' for input arguments of type 'int32'.

Error in ==> roms_get_grid at 199
[s_rho,Cs_r]=stretching(Vstretching, theta_s, theta_b, hc, N, 0, 0);

>>

Thank you very much in advance for your time and help.
Achim

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#55 Unread post by wilkin »

Earlier in this thread I note:
I took "stretching" and "set_depth" out of roms_get_grid because it is better practice to use the vertical coordinate stretching functions from the myroms repository (Hernan Arango's utilities). This way when new stretching options are added you will get those promptly.
The error you get indicates Matlab does not have "stretching.m"

It is amongst the matlab utility files in myroms.org.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

achimherrmann
Posts: 3
Joined: Fri Dec 01, 2006 5:10 am
Location: Arizona State University

Re: roms_matlab plotting and analysis routines

#56 Unread post by achimherrmann »

Thanks for the quick reply. I have the "stretching.m" and "set_depth.m" in a folder that is a path linked in matlab. I can open the files so they are accesible to matlab, but I sill have the same problem. Any other suggestions?
thanks in advance
>> which stretching.m
/mexcdf/plotting_routines/stretching.m
>> file = 'ocean_his.nc'

file =

ocean_his.nc

>> g=roms_get_grid(file,file); % the grid structure
Warning: Variable not found: mask_rho
> In roms_get_grid at 74
...

hencoi
Posts: 1
Joined: Fri Jul 15, 2005 9:18 pm
Location: University of Concepcion

Re: roms_matlab plotting and analysis routines

#57 Unread post by hencoi »

Hello Mr. Wilkin,

Are you planning to implement the routines under heading "RomsPlots" of this toolbox to AGRIF version of ROMS? I think it would be great if so.

Regards.
David.

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#58 Unread post by wilkin »

Thanks for the quick reply. I have the "stretching.m" and "set_depth.m" in a folder that is a path linked in matlab. I can open the files so they are accesible to matlab, but I sill have the same problem. Any other suggestions?
The message you note is only a Matlab warning. roms_get_grid always attempts to load the land/sea mask, but if the application does not generate one it proceeds anyway. I could turn off the warning, but at the risk of having other people confused if for some reason the mask should be there but is not. It's hard to anticipate every error that users might make configuring the model.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#59 Unread post by wilkin »

Hello Mr. Wilkin,

Are you planning to implement the routines under heading "RomsPlots" of this toolbox to AGRIF version of ROMS? I think it would be great if so.

Regards.
David.
I increasingly assume use of the CF-conventions in netcdf files when I write plotting and analysis routines.

This makes code more robust and less susceptible to programming errors. If the output of the ROMS-Agrif were to make more extensive of CF-conventions in the netcdf metadata (the attributes) it would be a relatively straightforward step to make my code more interoperable because I would not need to write anything special to recognize different conventions for specifying the vertical coordinates. That would be handled by netcdf-java.

But it's just not a high priority for me. Sorry.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

cfan608
Posts: 2
Joined: Tue Apr 19, 2011 4:39 pm
Location: Morgan State University

Re: roms_matlab plotting and analysis routines

#60 Unread post by cfan608 »

Dear wilkin, I having lots trouble on plotting the netcdf output.
my matlab is R2010a.

after install all the plotting packages.here is the results, thank you very much for your help.

>> roms_zview(file, 'temp', 2,-5, g,2,0.2, 'k')
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.

Error in ==> roms_zslice_var at 78
z = [-Inf*ones([1 L*M]); z; zeros([1 L*M])];

Error in ==> roms_zslice at 64
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in ==> roms_zview at 157
[data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);


and the roms_get_grid results:

>> g=roms_get_grid(file, file)
Warning: Variable not found: mask_rho
> In roms_get_grid at 74
Warning: Variable not found: mask_psi
> In roms_get_grid at 74
Warning: Variable not found: mask_u
> In roms_get_grid at 74
Warning: Variable not found: mask_v
> In roms_get_grid at 74
Warning: Variable not found: angle
> In roms_get_grid at 74
Warning: lon_rho not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_rho not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_psi not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_psi not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_v not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_v not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lon_u not found. Substituting x/y coords instead
> In roms_get_grid at 107
Warning: lat_u not found. Substituting x/y coords instead
> In roms_get_grid at 107

g =

grd_file: 'ocean_avg.nc'
h: [43x82 double]
pm: [43x82 double]
pn: [43x82 double]
f: [43x82 double]
angle: [43x82 double]
x_rho: [43x82 double]
y_rho: [43x82 double]
x_u: [42x82 double]
y_u: [42x82 double]
x_v: [43x81 double]
y_v: [43x81 double]
x_psi: [42x81 double]
y_psi: [42x81 double]
lon_rho: [43x82 double]
nolatlon: 1
lat_rho: [43x82 double]
lon_psi: [42x81 double]
lat_psi: [42x81 double]
lon_v: [43x81 double]
lat_v: [43x81 double]
lon_u: [42x82 double]
lat_u: [42x82 double]
mask_rho: [43x82 double]
mask_rho_nan: [43x82 double]
mask_u: [43x81 double]
mask_v: [42x82 double]
mask_psi: [42x81 double]
nomask: 1
zeta: [43x82 double]
z_r: [16x43x82 double]
z_w: [17x43x82 double]
Vtransform: 2
Vstretching: 4
theta_s: 3
theta_b: 0
Tcline: 25
N: 16
hc: 25
sc_w: [1x17 double]
Cs_w: [1x17 double]
sc_r: [1x16 double]
Cs_r: [1x16 double]
s_w: [1x17 double]
s_rho: [1x16 double]

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#61 Unread post by wilkin »

Hmmm. I don't see anything obvious but then I don't know the contents of your netcdf file.

Tell me the result of size(z) in roms_zslice_var.m at line 73 - either by uncommenting that line or using the debugger.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

cfan608
Posts: 2
Joined: Tue Apr 19, 2011 4:39 pm
Location: Morgan State University

Re: roms_matlab plotting and analysis routines

#62 Unread post by cfan608 »

Wilkin, thanks for the reply. Here is the debug results:

the line 71 is the reshape statement for z, before line 71, the size(z) is:
>> size(z)

ans =

17 43 82


after the reshape statement, size(z) becomes
size(z)

ans =

17 3526

[/color]
at then at line 78, all variables gone!

??? Error using ==> vertcat
CAT arguments dimensions are not consistent.

Error in ==> roms_zslice_var at 78
z = [-Inf*ones([1 L*M]); z; zeros([1 L*M])];

and if I comment out the line 78, here is the result:

>> roms_zview(file, 'temp', 2, -5, g, 0.2, 'k')
??? Index exceeds matrix dimensions.

Error in ==> roms_zslice_var at 91
data_greater_z = data(zg_ind);

Error in ==> roms_zslice at 64
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in ==> roms_zview at 157
[data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);



thanks for your help.


wilkin wrote:Hmmm. I don't see anything obvious but then I don't know the contents of your netcdf file.

Tell me the result of size(z) in roms_zslice_var.m at line 73 - either by uncommenting that line or using the debugger.

nma

Re: roms_matlab plotting and analysis routines

#63 Unread post by nma »

Dear all,
In my initial trials to utilize this efficient matlab package, I have few doubts (as follows) and need some advice to overcome them:

1. While plotting temperature using roms_zview, the plot came out fine, however the vectors were not visible. Vectors I suppose should work with:

s = 0.5;
roms_zview(hisfile,'temp',1,-10,p,10,s,'k')

2. Plotting vectors with u,v using
roms_quivergrd(ubot,vbot,p,10,1)

This gave a blank image........
To make sure the range of data I am working with:
max(max(ubot))= 4.1737
max(max(vbot))= 1.0127
min(min(ubot))= -3.9670
min(min(vbot))= -1.0410
The size my ubot and vbot are:
size(ubot)=199x226
size(vbot)=198x227

3. With bathymetry plot, I could not really plot it:
while trying these commands:-
roms_plot_bathy(p,zebra(2,64),[100 250 500 1000:1000:4000],h)
OR
roms_plot_bathy(p,zebra(2,64),[100 250 500 1000:1000:4000],'h')
gave following error:

??? Undefined function or method 'sawtooth' for input arguments of type 'double'.
Error in ==> zebra at 29
sat = m+(1-m)*(0.5*(1+sawtooth(2*pi*x/(n/a))));


In this case, probably I am not using this command correclty!
thanks, nilima

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#64 Unread post by wilkin »

The sawtooth function is part of the signal processing toolbox. If you don't have that then use some other colormap, like "jet".

Code: Select all

roms_plot_bathy(p,jet(64),[100 250 500 1000:1000:4000],'h')
There is nothing very clever about roms_plot_bathy. All it does is:

Code: Select all

pcolor(lon_rho,lat_rho,h) 
but I left in in there will all the other code for my own convenience.

To choose a suitable scale for your vectors try not decimating them so much. You are asking for every 10th vector. You should also be guided by typical magnitudes, not min/max. i.e. consider mean(abs(ubot(:)+i*vbot(:))). You might have one large vector dominating your calculation, and the decimation might have eliminated it from the plot.

The quiver scaling also depends on the grid coordinates you are plotting in, not just the velocity.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

pingding

Re: roms_matlab plotting and analysis routines

#65 Unread post by pingding »

Dear Wilkin and rouf
I had the same error that rouf said when i used roms_get_grid Function, I am actually new in using ROMS,
When I run these two commands:
code :
file='estuary_his_0001.nc';
grd=roms_get_grid(file,file);

error:
>> plot_mesh
??? Undefined function or method 'isnc3' for input arguments of type
'char'.

Error in ==> nc_isvar>determine_retrieval_method at 48
file_is_nc3 = exist(ncfile,'file') && isnc3(ncfile);

Error in ==> nc_isvar at 33
nc_method = determine_retrieval_method(ncfile);

Error in ==> roms_get_grid at 98
if nc_isvar(grd_file,'x_rho')

Error in ==> plot_mesh at 10
grd=roms_get_grid(file,file);

when i change nc_varget to ncread then have these error.

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#66 Unread post by wilkin »

error:
>> plot_mesh
??? Undefined function or method 'isnc3' for input arguments of type
'char'.
There is no plot_mesh command in my code. If you've received these routines third hand from someone else perhaps they can help you.

You can't switch between nc_varget and ncread because those functions follow a different protocol for returning the order of dimensions. Your data will be transposed and matrix operations will be unconforming.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

pingding

Re: roms_matlab plotting and analysis routines

#67 Unread post by pingding »

wilkin wrote:
error:
>> plot_mesh
??? Undefined function or method 'isnc3' for input arguments of type
'char'.
There is no plot_mesh command in my code. If you've received these routines third hand from someone else perhaps they can help you.

You can't switch between nc_varget and ncread because those functions follow a different protocol for returning the order of dimensions. Your data will be transposed and matrix operations will be unconforming.
thanks ,plot_mesh.m is my code name for plot my study area mesh.if i don't change,the error is
Warning: Variable not found: mask_rho
> In roms_get_grid at 85
In plot_mesh at 10
Warning: Variable not found: mask_psi
> In roms_get_grid at 85
In plot_mesh at 10
Warning: Variable not found: mask_u
> In roms_get_grid at 85
In plot_mesh at 10
Warning: Variable not found: mask_v
> In roms_get_grid at 85
In plot_mesh at 10
Warning: Variable not found: h
> In roms_get_grid at 85
In plot_mesh at 10
Warning: Using initial bath for h
> In roms_get_grid at 90
In plot_mesh at 10
??? Undefined function or method 'snc_read_backend' for input arguments
of type 'char'.

Error in ==> nc_varget at 66
retrieval_method = snc_read_backend(ncfile);

Error in ==> roms_get_grid at 91
grd.(vname) = squeeze(...
i see nc_varget.m in this nc_varget.m in http://romsmatlab.tiddlyspot.com/

but i don't know how to get it

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#68 Unread post by wilkin »

Error in ==> roms_get_grid at 91
grd.(vname) = squeeze(...
i see nc_varget.m in this nc_varget.m in http://romsmatlab.tiddlyspot.com/

but i don't know how to get it
There are instructions at http://romsmatlab.tiddlyspot.com under DownLoad on where to get the snctools that include nc_varget.m. Sorry if it wasn't clear these tools require snctools.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

pingding

Re: roms_matlab plotting and analysis routines

#69 Unread post by pingding »

wilkin wrote:
Error in ==> roms_get_grid at 91
grd.(vname) = squeeze(...
i see nc_varget.m in this nc_varget.m in http://romsmatlab.tiddlyspot.com/

but i don't know how to get it
There are instructions at http://romsmatlab.tiddlyspot.com under DownLoad on where to get the snctools that include nc_varget.m. Sorry if it wasn't clear these tools require snctools.
thanks very much,it can run! :lol: :D

now i want to your help,i want to plot mesh with topography,my code is
lat=ncread('estuary_his_0008.nc','lat_rho');
lon=ncread('estuary_his_0008.nc','lon_rho');
m_proj('miller','lon',[117 134],'lat',[15 43]);
m_grid('linestyle','none','box','fancy','tickdir','in','xtick',117:4:134,'ytick',15:4:43);
m_gshhs_i('patch',[.6 .6 .6])
hold on
addpath('J:\east\east preference\ROMSprocess\');
file=('G:\mysoftware\bin\delft2roms\case2\smooth_east_grd3_728.nc');
grd=roms_get_grid(file);
roms_plot_mesh(grd,1,[0 0 0],'rho');

but my figure is

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#70 Unread post by wilkin »

m_proj('miller','lon',[117 134],'lat',[15 43]);
m_grid('linestyle','none','box','fancy','tickdir','in','xtick',117:4:134,'ytick',15:4:43);
m_gshhs_i('patch',[.6 .6 .6])
hold on
addpath('J:\east\east preference\ROMSprocess\');
file=('G:\mysoftware\bin\delft2roms\case2\smooth_east_grd3_728.nc');
grd=roms_get_grid(file);
roms_plot_mesh(grd,1,[0 0 0],'rho');
Looks to me like you're mixing plotting using the Rich Pawlowicz m_map mapping toolbox (m_grid etc.) with regular Matlab plotting inside roms_plot_mesh.

If you want to plot in map coordinates borrow the code out of roms_plot_mesh.m for the options you are selecting and replace the calls to plot with calls to m_line.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

pingding

Re: roms_matlab plotting and analysis routines

#71 Unread post by pingding »

wilkin wrote:
m_proj('miller','lon',[117 134],'lat',[15 43]);
m_grid('linestyle','none','box','fancy','tickdir','in','xtick',117:4:134,'ytick',15:4:43);
m_gshhs_i('patch',[.6 .6 .6])
hold on
addpath('J:\east\east preference\ROMSprocess\');
file=('G:\mysoftware\bin\delft2roms\case2\smooth_east_grd3_728.nc');
grd=roms_get_grid(file);
roms_plot_mesh(grd,1,[0 0 0],'rho');
Looks to me like you're mixing plotting using the Rich Pawlowicz m_map mapping toolbox (m_grid etc.) with regular Matlab plotting inside roms_plot_mesh.

If you want to plot in map coordinates borrow the code out of roms_plot_mesh.m for the options you are selecting and replace the calls to plot with calls to m_line.
ok ,thanks :D

pingding

Re: roms_matlab plotting and analysis routines

#72 Unread post by pingding »

pingding wrote:
wilkin wrote:
m_proj('miller','lon',[117 134],'lat',[15 43]);
m_grid('linestyle','none','box','fancy','tickdir','in','xtick',117:4:134,'ytick',15:4:43);
m_gshhs_i('patch',[.6 .6 .6])
hold on
addpath('J:\east\east preference\ROMSprocess\');
file=('G:\mysoftware\bin\delft2roms\case2\smooth_east_grd3_728.nc');
grd=roms_get_grid(file);
roms_plot_mesh(grd,1,[0 0 0],'rho');
Looks to me like you're mixing plotting using the Rich Pawlowicz m_map mapping toolbox (m_grid etc.) with regular Matlab plotting inside roms_plot_mesh.

If you want to plot in map coordinates borrow the code out of roms_plot_mesh.m for the options you are selecting and replace the calls to plot with calls to m_line.


thanks very much, i plot it,but i plot mesh in map coordinates use m_line instead of plot of roms_plot_mesh.m

also with error:
Attempt to reference field of non-structure array.

Error in m_ll2xy (line 35)
if strcmp(MAP_COORDS.name,MAP_PROJECTION.coordsystem.name),

Error in m_line (line 46)
[X,Y]=m_ll2xy(long,lat,'clipping',clp);

Error in plot_mesh (line 10)
hline1=m_line(long,lat);

i don't know uderstand untill now,so i try to use m_plot,it work; :D

code:lat=ncread('estuary_his_0008.nc','lat_rho');
lon=ncread('estuary_his_0008.nc','lon_rho');
m_proj('miller','lon',[117 134],'lat',[15 43]);
m_grid('linestyle','none','tickdir','in','xtick',117:4:134,'ytick',15:4:43);
hold on
file=('G:\mysoftware\bin\delft2roms\case2\smooth_east_grd3_728.nc');
grd=roms_get_grid1(file);
n=5;
lat=grd.lat_rho(1:n:end,1:n:end);
long=grd.lon_rho(1:n:end,1:n:end);
hold on
m_plot(long,lat,'color','k');
hold on
m_plot(long',lat','color','k');
hold on
m_gshhs_i('color','k')

rivano10
Posts: 2
Joined: Fri Jan 15, 2016 2:29 pm
Location: Universidad Tecnica Federico Santa Maria

Re: roms_matlab plotting and analysis routines

#73 Unread post by rivano10 »

Hi all. I have a problem plotting the 'upwelling' test case with the matlab routines.
I have ROMS installed and all necessary paths (scntools and mexnc installed). I can read the ocean-his file from the upwelling testcase (file = 'ocean_his.nc';) and read in a variable from the file (h = nc_varget(file,'h');) too.

Code: Select all

file='ocean_his.nc';
g=roms_get_grid(file,file);
h=nc_varget(file,'h');
roms_zview(file,'temp',1,2,g,3,0.1,'k')

Warning: Variable not found: mask_rho 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: mask_psi 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: mask_u 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: mask_v 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: angle 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: dmde 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: dndx 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: visc_factor 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: Variable not found: diff_factor 
> In roms_get_grid at 84
  In untitled3 at 9 
Warning: lon_rho not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lat_rho not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lon_psi not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lat_psi not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lon_v not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lat_v not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lon_u not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Warning: lat_u not found. Substituting x/y coords instead 
> In roms_get_grid at 118
  In untitled3 at 9 
Attempt to reference field of non-structure array.

Error in roms_zslice (line 51)
  time_variable = Iv.Dimensions(end).Name;

Error in roms_zview (line 163)
    [data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);

Error in untitled3 (line 11)
roms_zview(file,'temp',1,2,g,3,0.1,'k')
What should I do to solve the errors?

Pd: I know "Warning" are not a problem.

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#74 Unread post by wilkin »

Code: Select all

Error in roms_zslice (line 51)
  time_variable = Iv.Dimensions(end).Name;

Error in roms_zview (line 163)
    [data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);

Error in untitled3 (line 11)
roms_zview(file,'temp',1,2,g,3,0.1,'k')
The error is being thrown when roms_zslice tries to determine the name of the time coordinate, which it gets from the output of Iv = nc_vinfo(file,var) at line 50 in roms_zslice.m

Check that your nc_vinfo (in Maltba >> which nc_vinfo) is the nc_vinfo from the ROMS Matlab repository (https://www.myroms.org/svn/src/matlab/netcdf) which you should be downloading using svn: svn checkout https://www.myroms.org/svn/src/matlab MyDir

If that's OK, then set a debug stop inside roms_zslice

Code: Select all

>> dbstop in roms_zslice
and when it stops check the result of:

Code: Select all

K>> Iv = nc_vinfo(file,var)
You should see

Code: Select all

K>> Iv.Dimensions.Name
ans = 
   xi_rho
ans = 
   eta_rho
... etc. and

ans = 
ocean_time
The last dimension tells ROMS the time dimension name. Now, if you have a different time coordinate name from the dimension that might be the cause. I'd need to modify the code to trap that possibility. But I can't think why you would have changed the default names of the dimension or coordinate.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

chauri
Posts: 3
Joined: Tue Jul 12, 2016 1:07 am
Location: UAF

Re: roms_matlab plotting and analysis routines

#75 Unread post by chauri »

Hi John,

Thank you so much for sharing the roms tools with everybody. I really appreciate it. Running roms_zview and roms_zslice, I'm also running into the problem of getting

Attempt to reference field of non-structure array.

Error in roms_zslice (line 51)
time_variable = Iv.Dimensions(1,1).Name;

Error in roms_zview (line 163)
[data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);



When I do
Iv = nc_vinfo(file,var)

I get
Iv =

ocean_time
s_rho
eta_rho
xi_rho

ncdump of my output file includes the following:
double ocean_time(ocean_time) ;
ocean_time:long_name = "averaged time since initialization" ;
ocean_time:units = "seconds since 1900-01-01 00:00:00" ;
ocean_time:calendar = "gregorian" ;
ocean_time:field = "time, scalar, series" ;
float zeta(ocean_time, eta_rho, xi_rho) ;
zeta:long_name = "time-averaged free-surface" ;
zeta:units = "meter" ;
zeta:time = "ocean_time" ;
zeta:coordinates = "lon_rho lat_rho ocean_time" ;
zeta:field = "free-surface, scalar, series" ;
zeta:_FillValue = 1.e+37f ;



How could I solve this issue?

Thanks a lot,
Claudine

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#76 Unread post by wilkin »

The result of

Code: Select all

Iv = nc_vinfo(file,var)
should look like:
K>> Iv = nc_vinfo(file,var)
Iv =
Filename: 'http://tds.marine.rutgers.edu/thredds/d ... sso/2013_d...'
Name: 'temp'
Dimensions: [1x4 struct]
Size: [130 82 36 27684]
Attributes: [1x8 struct]
Cgridtype: [1x1 struct]
Datatype: 'single'
ncType: 5
Is your nc_vinfo.m up to date?

If you meant you checked

Code: Select all

Iv.Dimensions.Name
you should get:
K>> Iv.Dimensions.Name
ans =
xi_rho
ans =
eta_rho
ans =
s_rho
ans =
time
You may have the dimensions coming back in the wrong order (for roms_zslice.m).

We have seen this before for some netCDF-4 files. The problem went away if the files were converted to netCDF-3, or if the netCDF-4 files were served by OPeNDAP.

What are you trying to read - nc3, nc4, or Opendap?

I think we found a workaround for the problem but I can't recall right now what it was. Let me check with the team.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

chauri
Posts: 3
Joined: Tue Jul 12, 2016 1:07 am
Location: UAF

Re: roms_matlab plotting and analysis routines

#77 Unread post by chauri »

Hi John,

When I do

Code: Select all

Iv = nc_vinfo(file,var)
I get
Iv =

ocean_time
s_rho
eta_rho
xi_rho
and

Code: Select all

Iv.Dimensions.Name
I get
Attempt to reference field of non-structure array.
There is something funky going on with my nc_vinfo.m. I downloaded it yesterday from https://github.com/dcherian/tools/blob/ ... nc_vinfo.m. Is there a better place to get it?

Also, I think you are right that the dimensions are coming back in the wrong order. The format is "netCDF-4/HDF5 file" Conventions = "CF-1.4". Please let me know if you remember how to get around this problem -especially if it is an easier fix than converting all files.

Thanks,
Claudine

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#78 Unread post by wilkin »

There is something funky going on with my nc_vinfo.m. I downloaded it yesterday from https://github.com/dcherian/tools/blob/ ... nc_vinfo.m. Is there a better place to get it?
That distribution by Deepak Cherian on github of Hernan Arango's netcdf utilities for ROMS is woefully out of date.

You should get Hernan's utilities from the myroms code source at the same place you got ROMS:
https://www.myroms.org/projects/src/browser

So download with svn:
svn checkout https://www.myroms.org/svn/src/matlab MyDir

(It's possible that the old version is required by some code of Deepak's own creation that he has on github, so you'll just have to deal with that as you encounter issues.)

I notice Deepak is also redistributing my ROMS plotting tools. Is that where you got them? Then they are out of date also.

The place to get them is:
svn checkout https://www.myroms.org/svn/om/matlab/roms_wilkin MyDir
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

chauri
Posts: 3
Joined: Tue Jul 12, 2016 1:07 am
Location: UAF

Re: roms_matlab plotting and analysis routines

#79 Unread post by chauri »

Thanks John, the issue is solved!

thanh44nq
Posts: 6
Joined: Tue Mar 01, 2016 1:38 am
Location: Kumamoto University

Re: roms_matlab plotting and analysis routines

#80 Unread post by thanh44nq »

Dear all,

I am also trying to use Roms_wilkin for plotting Roms results.
When I used the following instruction for upwelling test case:

file = 'ocean_his.nc'
g=roms_get_grid(file,file)
s = 0.1;
roms_zview(file,'temp',1,-5,g,3,s,'k')

the problem was

Error using ncread
Too many input arguments.

Error in roms_zslice (line 56)
t = ncread(file,time_variable,time,1);

Error in roms_zview (line 141)
[data,x,y,t,grd] = roms_zslice(file,var,time,depth,grd);

I really do not know why.
Could anyone help me

thanh44nq
Posts: 6
Joined: Tue Mar 01, 2016 1:38 am
Location: Kumamoto University

Re: roms_matlab plotting and analysis routines

#81 Unread post by thanh44nq »

I have recently solved the problem.
Thanks

hclarke
Posts: 22
Joined: Sun Dec 04, 2016 1:03 am
Location: UTAS

Re: roms_matlab plotting and analysis routines

#82 Unread post by hclarke »

Hi

I'm also testing the upwelling case in matlab. I'm trying to follow the instructions, and what I get is this:

>> filename='ocean_his.nc'

filename =

ocean_his.nc

>> grd = roms_get_grid(filename,filename)
Warning: Using initial bath for h
> In roms_get_grid (line 95)
Undefined function or variable 'nc_varget'.

Error in roms_get_grid (line 97)
nc_varget(grd_file,'bath',[0 0 0],[1 -1 -1]));


Thanks for your help.

Hans

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#83 Unread post by wilkin »

If you enter

>> help roms_wilkin

that should direct you to some old documentation on this code at http://romsmatlab.tiddlyspot.com/ that explains that I use snctools (which has nc_varget etc.) for the netcdf read.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

hclarke
Posts: 22
Joined: Sun Dec 04, 2016 1:03 am
Location: UTAS

Re: roms_matlab plotting and analysis routines

#84 Unread post by hclarke »

Thanks John

I just want to start off with a simple plot. Is it possible or feasible to plot pcolor(x_rho, y_rho, h)?

I'm getting the following:

file = 'ocean_his.nc';
x_rho=ncread(file,'x_rho');
y_rho=ncread(file,'y_rho');
h=ncread(file,'h');
mymap=pcolor(x_rho, y_rho, h)

with no figure. How do I get a figure? Sorry about the basic questions!

noah.eckman
Posts: 7
Joined: Tue Jun 28, 2016 7:00 pm

Re: roms_matlab plotting and analysis routines

#85 Unread post by noah.eckman »

hclarke wrote: with no figure. How do I get a figure? Sorry about the basic questions!

Just do pcolor(x_rho, y_rho, h). Matlab has very good documentation.

hclarke
Posts: 22
Joined: Sun Dec 04, 2016 1:03 am
Location: UTAS

Re: roms_matlab plotting and analysis routines

#86 Unread post by hclarke »

Thanks for that...Sorry, not getting a figure. I just tried it, and the first time I get a warning:

Warning: MATLAB has disabled some advanced graphics rendering features by
switching to software OpenGL. For more information, click <a
href="matlab:opengl('problems')">here</a>.

The second time I tried it, I get nothing.

P.S. Am I supposed to get lat_rho and long_rho in my upwelling output?

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#87 Unread post by wilkin »

This is a Matlab problem, not ROMS or Matlab tools for ROMS issue. Get some help from someone in your group or department to get started. Try the Matlab "peaks" command to test your plotting:

>> peaks
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

hclarke
Posts: 22
Joined: Sun Dec 04, 2016 1:03 am
Location: UTAS

Re: roms_matlab plotting and analysis routines

#88 Unread post by hclarke »

Hi again

I have successfully plotted the upwelling case, but now I want to plot it at a different times and even set up a bunch of times to be able to animate them. Can someone point me in the right direction in terms of the wilkin routines or otherwise?

Thanks

hclarke
Posts: 22
Joined: Sun Dec 04, 2016 1:03 am
Location: UTAS

Re: roms_matlab plotting and analysis routines

#89 Unread post by hclarke »

Hi again

I've used:

>> file = 'ocean_his.nc'
>> g=roms_get_grid(file,file)
>> roms_iview(file,'temp','1-Jan-0001',1,g,1)

then compared the plot with:
>> roms_iview(file,'temp','6-Jan-0001',1,g,1).

I've attached the figures. Is this what I'm supposed to be seeing? There is distortion to the left of the latter plot. Is that the upwelling?
Attachments
Upwelling figures.docx
(56.84 KiB) Downloaded 842 times

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: roms_matlab plotting and analysis routines

#90 Unread post by neelbasak08 »

Hello Mr. Wilkin !

I am using your roms_matlab plotting and analysis routines for the first time to plot observations for my model and unfortunately I encountered some errors. I was successful with plotting the upwelling results with your package. But as I try to implement them on my output files of my model, I use the following command:

Code: Select all

 >> file = 'Lombok_roms_his.nc'

file =

    'Lombok_roms_his.nc'

>> grd=roms_get_grid(file,file); % the grid structure
>> roms_zview(file,'u','1-Jan-2020',-1,grd) 
and I get the shown the following error :
Index exceeds the number of array elements (84150).

Error in roms_zslice_var (line 83)
data_greater_z = data(zg_ind);

Error in roms_zslice (line 81)
[data,x,y] = roms_zslice_var(data,1,depth,grd);

Error in roms_zview (line 177)
data = roms_zslice(file,var,time,depth,grd);
This is the only function I face error with. As per the TiddlyWiki website in which you maintain these routines, it's written " Produces a pcolor plot of the requested VarName at constant depth. If requested, velocity vectors are plotted over the image according to the inputs Vec_d, UScale and varargin." And the depth parameter in the function says that it's depth in z direction of a 3D ROMS grid. I don't know where my plot's going wrong in that case. I have a total of 15 vertical levels in my grid file and my model is also a 3D model with the following resolution Resolution, Grid 01: 98x48x7.

Is there some data missing in my his.nc file or grid file ? Or I am doing or interpreting something wrong ?
I am attaching the ncdisp output from my his.nc file for your reference.

Kind regards
-Neel
Attachments
ncdisp output.txt
(35.01 KiB) Downloaded 652 times

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#91 Unread post by wilkin »

I have no idea what you have done wrong.

I assume you have tested other options, like plotting different variables than 'u', specifying time as an index instead of a date string, plotting at constant vertical index (instead of z) using roms_sview? Does that tell us anything?

Where you are getting the error, Matlab is finding the index of the z-levels that bracket the -1 m depth you request.
Depth -1 m is shallow and might be less than the depth of the center of the surface cell if your vertical resolution is coarse, but at this point in the code the array it is slicing has already been padded with zeros to ensure that there is a point to complete the interpolation.

You will have to debug this in Matlab. Set a debug break point in roms_zslice_var.m ...

>> dbstop in roms_zslice_var

The run roms_zslice.

Check the inputs to roms_zslice_var in the Matlab command window, in particular size(data) and size(grd.z_u). They should match, and in your case I think they should be [15 50 99] though I could be off by 1. Then step your way down to row 82 where you got the error. Now data should have the vertical coordinate padded and have been be rearranged into a 2-D ribbon of size [N+2 xi_u*xi_eta] so for you [17 4950]. Check everything that's going on in the code there to figure out why you get that error.

By the way, the tiddlywiki page is a bit out of date, but the instructions you quote are still correct. I maintain this code now on github at
https://github.com/johnwilkin/roms_wilkin
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: roms_matlab plotting and analysis routines

#92 Unread post by neelbasak08 »

Thanks Mr. Wilkin,

Yes, I did test some other variables like ubar in roms_zview but I believe it's a 2D parameter therefore having depth was no sense there and MATLAB plotted the results anyways. Yes, the roms_sview worked fine with date input as a string.

I followed your debugging suggestion. It seems that my data attribute has a dimension 17x4950 and my error causing parameter zg_ind has a dimension of 6202x1. May be that's why the indexing error might occur. But I am sure what might be causing these varied dimensions ?

Rest all parameters look pretty fine as per what you had suggested like z attribute was of the size 17x4950 and z_r attribute was 15x50x100.

Attaching the workspace values for reference.

Kind regards
-Neel
Attachments
workspace details during debug
workspace details during debug
Screenshot 2021-04-01 190344.jpg (49.89 KiB) Viewed 1189173 times

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#93 Unread post by wilkin »

Have you inadvertently edited any of the roms_wilkin code?

Is it up to date?

Maybe send a small version of your output file for me to look at. Not all 172 records. Just a couple.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: roms_matlab plotting and analysis routines

#94 Unread post by neelbasak08 »

Thanks Mr. Wilkin for your reply !

Earlier I'd been using the version I had downloaded via svn though I hadn't changes anything in that and ran it command line just. And I am sorry I didn't read the part in one of your previous posts mentioning that now you maintain it in your git repository. I was more focused on the debugging checks that you had suggested. So I downloaded the git version and tried if i were any successful but alas! no. The same problem seems to persist and the debug produced pretty similar results like the earlier one.

I failed to understand the part where you said " Maybe send a small version of your output file for me to look at. Not all 172 records. Just a couple." By output file you meant the history .nc file I believe. I am attaching it for your reference. It has only output for an hour of simulation.

Kind regards
-Neel
Attachments
Lombok_roms_his.nc
output his.nc file
(14.3 MiB) Downloaded 625 times

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#95 Unread post by wilkin »

The issue is that your grid has bathymetry values h < 0 and roms_get_grid is calculating z_r etc. values that are not monotonic.

roms_zslice_var uses the tests:

Code: Select all

zg_ind = find(diff(z<depth)~=0);
and

Code: Select all

zl_ind = find(diff(z>depth)~=0);
as the basis of the logic to find the k indices immediately above and below the slice depth.

With a non-monotonic z coordinate these are multivalued and the resulting index vectors exceed the dimension of the grid.

I can't believe no one has ever struck this problem before. I thought my code was robust to h < 0 in the land mask. In fact, I'm sure I've worked successfully with such girds before.

I don't have the time to check, but it may be that you have very large negative h values, and a very strongly stretched coordinate (theta_s = 8, theta_b = 4), and this combination is perhaps producing the non-monotonic z coordinate.

I suggest you modify your grid file to make h in the land mask some benign small positive value. It will make no difference to the ROMS solution.

Meanwhile, I'll think of what logic I need to add to trap this case.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#96 Unread post by wilkin »

I have modified roms_zslice_var.m to reset all z to equal 0 on land.

If you update from github https://github.com/johnwilkin/roms_wilkin you should be able to plot from the output files you already have.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

User avatar
neelbasak08
Posts: 99
Joined: Wed Dec 09, 2020 3:58 pm
Location: Thapar Institute of Engineering and Technology, Patiala, PN, India

Re: roms_matlab plotting and analysis routines

#97 Unread post by neelbasak08 »

Thanks a lot, Mr. Wilkin!

I updated the code from GitHub and it works just fine. Again another thing I wanted to confirm is that the documentation of these routines is the same as the one in TiddlyWiki right?

Again thanks for providing the plot package. It's super easy to use and user friendly

Kind regards
-Neel

javadi
Posts: 115
Joined: Mon Jan 27, 2020 5:55 pm
Location: UoT

Re: roms_matlab plotting and analysis routines

#98 Unread post by javadi »

Dear wikin

I use some packages for plotting and can see the history file. But, honestly, I have problems with your package !

For a few days, I am working on it but I can't use it, and all of the time the error is

g=roms_get_grid(file,file);
You need to add stretching.m to your matlab path
Error using roms_get_grid (line 65)
from e.g. https://www.myroms.org/svn/src/matlab/utility


Your explanation is here http://romsmatlab.tiddlyspot.com/ but I cannot solve the problems. Here I try to explain more about that!

initially, I have put svn checkout https://www.myroms.org/svn/om/matlab/roms_wilkin in my terminal.

I have downloaded and seen your folder in my system. Then, in your folder, I have put this command to my terminal to download John Evans' snctool;

svn co svn://svn.code.sf.net/p/mexcdf/svn/mexnc/trunk ./mexcdf/mexnc
svn co svn://svn.code.sf.net/p/mexcdf/svn/snctools/trunk ./mexcdf/snctools


Hence,
After that, I add your name folder(also two mexnc and snctools) in my path like this figure.

For plotting; I put my history file roms_his.nc in your folder and follow this command:
file='roms_his.nc'

g=roms_get_grid(file,file);

I have tested many methods but I cannot use your codes. I download your https://github.com/johnwilkin/roms_wilkin

But, my problem is not solved. I use Matlab 2014a and 2020 a. I have both versions too!

Do you have any suggestions?

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#99 Unread post by wilkin »

That nothing has changed at http://romsmatlab.tiddlyspot.com/ since 2010 is your clue that maybe that's not up to date. I'm struggling to remember how to update that web site with new info, but here it is...

My codes, much updated since 2010, are now on GitHub at https://github.com/johnwilkin/roms_wilkin. Please clone that repo to use roms_wilkin tools.

I have changed the code to use the native Matlab interface to netcdf, so Evans' snctools are not required.

The specific error you are getting at the start ...
g=roms_get_grid(file,file);
You need to add stretching.m to your matlab path
Error using roms_get_grid (line 65)
from e.g. https://www.myroms.org/svn/src/matlab/utility
... indicates that I use the s-coordinate stretching function (stretching.m) that is part of the Matlab toolset distributed at myroms.org (same place you get your ROMS code). I do this, rather than keep a copy of stretching.m in roms_wilkin, so that when new coordinate definitions are added my code doesn't fall out of date. There are other functions in myroms.org Matlab that I make use of.

So, just as the error says, You need to add stretching.m to your matlab path

I recommend you download all the Matlab tools from https://www.myroms.org/svn/src/matlab using svn, browse what's there (lots of useful things) and add to your matlabpath the things you are likely to make use of (definitely the utility folder, and probably more).
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

javadi
Posts: 115
Joined: Mon Jan 27, 2020 5:55 pm
Location: UoT

Re: roms_matlab plotting and analysis routines

#100 Unread post by javadi »

Hi

Thanks!

I guess that I have solved the problems of installation with your suggestions!

However, I cannot use it! For example,

file =

'E:\roms_his.nc'

>> grd=roms_get_grid(file,file);

I will face:

Error using ncread
Too many input arguments.

Error in roms_zslice (line 56)
t = ncread(file,time_variable,time,1);

Error in roms_zview (line 174)
data = roms_zslice(file,var,time,depth,grd);


Here is all information when using this command.

I have read this post and you mention angle and h(sign). I put some information about that!
Attachments
log.matlab.txt
(3.78 KiB) Downloaded 567 times
GRID INFO.txt
(704 Bytes) Downloaded 573 times

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#101 Unread post by wilkin »

Looks to me like you have the wrong ncread.

You are not getting the ncread that is the native Matlab netcdf interface.

In Matlab try ...

>> which ncread -all

You should see something like ...

Code: Select all

>> which ncread -all
/Applications/MATLAB_R2020b.app/toolbox/matlab/imagesci/ncread.m
>> 
If you see some other function called ncread is shadowing the system function, modify your Matlabpath to correct that.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

jbettencourt

Re: roms_matlab plotting and analysis routines

#102 Unread post by jbettencourt »

Hi,

I'm using the roms_wilkin tools, that I've cloned with git from https://github.com/johnwilkin/roms_wilkin.git, but I'm getting several errors related to unrecognised functions/variables. The latest was:

Code: Select all

Unrecognized function or variable 'nc_global'.

Error in roms_cpplist (line 11)
cpp = nc_attget(file,nc_global,'CPP_options');

Error in post_process_ROMS_1D (line 70)
  romsCPP = roms_cpplist([lower(MyAppCPP) '.h']);
I believe I'm missing some additional Matlab package, where nc_global is defined/exists as a function, although I have on my path the Matlab codes from https://www.myroms.org/svn/src/matlab/.
I had the same error with 'nc_isvar' (unrecognised).
I'm using Matlab version '9.8.0.1417392 (R2020a) Update 4'.

Any help would be greatly appreciated.
Cheers,
Joao

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#103 Unread post by wilkin »

I thought I had expunged all the old calls to SNC tools functions, but missed this one.

The first line just needs to be:

Code: Select all

cpp = ncreadatt(file,'/','CPP_options');
I've updated the repo on GitHub.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

jbettencourt

Re: roms_matlab plotting and analysis routines

#104 Unread post by jbettencourt »

Ok. It's working now. Thanks.
(there was also an error in my code that was calling the CPP header file and not the history file)

manhnt181
Posts: 33
Joined: Wed Feb 03, 2021 5:07 pm
Location: Institute of Geophysics

Re: roms_matlab plotting and analysis routines

#105 Unread post by manhnt181 »

Hi Wilkin,

I'm a new user of Matlab and ROMS model. Can you kindly help me how to print the image of roms_zview command?
Which command I can do to plot with specific area?
Thank you very much!

User avatar
wilkin
Posts: 872
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: roms_matlab plotting and analysis routines

#106 Unread post by wilkin »

The Mathworks have several online tutorials for getting started with using Matlab
https://www.mathworks.com/learn/tutoria ... nramp.html
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Post Reply