Project

General

Profile

ROMS outputs

Added by Carlos Teixeira 4 months ago

I am trying to merge two ROMS model output, however the output is missing few variables. From what I understand CDO will not merge variables that do not have a dimension and I believe this is the case for the ROMS output.

Lets take for example the variable dstart that does not appear, it appears in the input file as:

double dstart ;
dstart:long_name = "time stamp assigned to model initilization" ;
dstart:units = "days since 1970-01-01 00:00:00" ;
dstart:calendar = "proleptic_gregorian" ;

But it is not copied to the merged output.

Even if I try cdo showvar myinput.nc it will not show this no-dimensional variables.

I have two questions:

1) Any tip on how to copy this no-dimensional variables to the output?

2) how to show the missing variable when comparing two files: like a.nc has variables x,y,z and b.nc has x,y I need something to show z.

I am attaching the ncdump -h for the input and output.

Thanks in advance
Carlos


Replies (4)

RE: ROMS outputs - Added by Ralf Mueller 4 months ago

hi Carlos!

CDO is not a general netcdf-tool like NCO. CDO can work with input data, that follows the CF-convention ( like http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html). I doubt that scalar variables with any location information is a valid CF-compliant data variable. That's why CDO does not take in into account.

Maybe this compliance checker can help u to find out more about the status of your input regard CF.

hth
ralf

RE: ROMS outputs - Added by Carlos Teixeira 4 months ago

Hi Ralf;

Thanks for your reply. I have checked and my ROMS output are CF-compliant, it only give me warnings not errors.

I have looked into http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html section 5.7. Scalar Coordinate Variables and from what I understand we can have scalar variables.

I will keep looking and try nco here.

Regarding my second question, any tip?

2) how to show the missing variables when comparing two files: like file aa.nc has the variables x,y,z and file bb.nc has x,y. I need something to show the missing variable z or the variables differences.

Thanks for your help

Carlos

RE: ROMS outputs - Added by Ralf Mueller 4 months ago

Carlos Teixeira wrote in RE: ROMS outputs:

Hi Ralf;

Thanks for your reply. I have checked and my ROMS output are CF-compliant, it only give me warnings not errors.

I have looked into http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html section 5.7. Scalar Coordinate Variables and from what I understand we can have scalar variables.

    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" ;

is not a scalar coordinate variable in any way.

from the cf-convention:

When a variable has an associated coordinate which is single-valued, that coordinate may be represented as a scalar variable
(i.e. a data variable which has no netCDF dimensions).
Since there is no associated dimension these scalar coordinate variables should be attached to a data variable via the coordinates attribute.

This is not done in your input as far as I can say

CF-conform data variables should describe potentially horizontally or vertically distributed data. maybe just a single value, but even in that case associated with proper coordinates. some of your input variables don't follow that and that's why CDO will ignore them.

I will keep looking and try nco here.

Regarding my second question, any tip?

2) how to show the missing variables when comparing two files: like file aa.nc has the variables x,y,z and file bb.nc has x,y. I need something to show the missing variable z or the variables differences.

I personally would wrote a short python or ruby script, that opens a file and reads (+prints) the list of netcdf variables and dimensions. something like this

Thanks for your help

Carlos

cheers

RE: ROMS outputs - Added by Carlos Teixeira 4 months ago

Hi Ralf;

Thanks a lot for your explanation.

Now, it is clear for me the problem my outputs and the with cf-convention.

Also thanks for the tip regarding how to list the variables using pyhton. When looking for the answer for my question 1, I end up finding a way to list the variables using ncks:

# Uncluttered listing of the variables in file_1.nc
ncks --trd -M -m file_1.nc | grep -E -i "^z attribute [0-9]+: purpose" | cut -f 11- -d ' ' | sort >1.txt
# Uncluttered listing of the variables in file_2.nc
ncks --trd -M -m file_2.nc | grep -E -i "^z attribute [0-9]+: purpose" | cut -f 11- -d ' ' | sort >2.txt

# variables content differences
diff 1.txt 2.txt | grep '>'

Cheers

Carlos

    (1-4/4)