[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #PCM-734975]: NetCDF CF Conventions Issue



Hi Adriana,

The error indicates that the data type of the ‘flag_value’ attribute does not 
match the data type of the data variable, ‘var9’, which is a requirement for CF 
flag values [1]. What is the data type of the ‘var9’ variable?

Are you using ‘flag_meaning’ with ‘flag_value’ to represent enumerated status 
codes? Or both ‘flag_meaning’ and ‘flag_mask’ to indicate independent Boolean 
conditions as well?

Could you run `ncdump -h <filename>` on one of your files and send me the 
output CDL? That might help me better understand what you are trying to do. 
And, I’m not that familiar with R netCDF so the CDL would be a bit easier for 
me.

Sorry! Just realized none of the links came through in my earlier response. 
Besides the CF “Flag” section [1] I mention above, I also tried to include a 
link to the CF “Units” section [2] and the CF Discussion page [3] and forum [4].

Cheers,

Ethan

[1] 
http://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#flags
[2] 
http://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#units
[3] http://cfconventions.org/discussion.html
[4] https://github.com/cf-convention/discuss/issues



> Thanks, Ethan,
> The 1e-3 for units did solve that problem; however, I'm still struggling
> with the flag_values. I continue to get one of the following messages:
> 
> ERROR: Attribute flag_values of incorrect type (expecting 'Data
> Variable' type, got 'String' type)
> 
> ERROR: Attribute flag_values of incorrect type (expecting 'Data
> Variable' type, got 'Numeric' type)
> 
> 
> when I try either
> 
> ncatt_put(nc, var9, 'flag_values', '0, 1')
> 
> or
> 
> ncatt_put(nc, var9, 'flag_values', c(0,1))
> in the R programming language.
> 
> The actual flag values are data type "double," so I'm struggling to
> understand why one of these isn't working. (It also doesn't matter if I try
> ncatt_put(nc, var9, 'flag_values', as.double(c(0,1)))).
> 
> Any additional tips would be greatly appreciated!
> Many thanks,
> Adriana
> 
> address@hidden> wrote:
> 
> > Hi Adriana,
> >
> > > Hello Support,
> > > I'm wondering if you can help me with two questions related to creating
> > > NetCDFs. The first has to do with unit names. I'm creating a file of
> > water
> > > isotopic data, the standard unit for which is "permil" or parts per
> > > thousand. Neither "permil" or "parts per thousand" are acceptable
> > according
> > > to the CF Conventions checker, which uses the Unidata udunits library.
> > > However, from a scientific perspective, reporting the isotope ratios in
> > > "percent" or another such unit does not make sense. Do you have any
> > > recommendations?
> >
> > In the “Units” section of the CF Conventions document, the 3rd paragraph
> > discusses percent, ppm, etc. I believe it indicates you should use “1e-3”
> > for units and further details can be included in the “long_name” attribute
> > (or “standard_name” attribute, if appropriate).
> >
> > > The other question is about flag_values. Would you be able to help me
> > > understand how to write flag_values so that I do not encounter the
> > > following error: "ERROR: Attribute flag_values of incorrect type
> > (expecting
> > > 'Data Variable' type...)" I receive this error message whether I write
> > the
> > > flag_values as a string, an integer, or a double. My flag values are 0
> > and
> > > 1.
> >
> > The CF “Flags” Section  says that the flag_value has to match the data
> > type of the data variable. The flag_meaning is a blank separated string
> > that provides the meaning of the flag/data values. Flag variables are most
> > commonly stored as bytes. The first example in the “Flags” section provides
> > a CDL snippet of a flag variable provides a nice example:
> >
> >   byte current_speed_qc(time, depth, lat, lon) ;
> >     current_speed_qc:long_name = "Current Speed Quality" ;
> >     current_speed_qc:standard_name = "status_flag" ;
> >     current_speed_qc:_FillValue = -128b ;
> >     current_speed_qc:valid_range = 0b, 2b ;
> >     current_speed_qc:flag_values = 0b, 1b, 2b ;
> >     current_speed_qc:flag_meanings = "quality_good sensor_nonfunctional
> >                                       outside_valid_range" ;
> >
> > > Thank you in advance for your help,
> > > Adriana
> >
> > Hope that helps.
> >
> > Also, for CF focused questions like these, the best place to ask for help
> > is the CF Discussion forum (also see the CF Discussion page). There are
> > more CF experts there than we have here in the netCDF group.
> >
> > Cheers,
> >
> > Ethan


Ticket Details
===================
Ticket ID: PCM-734975
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.