SourceForge has been redesigned. Learn more.
Close

error during change FillValue to missing value

Yerguner
2014-06-12
2014-06-12
  • Yerguner

    Yerguner - 2014-06-12

    Hi All,

    I have been trying to change the "_FillValue" attribute to "missing_value" from a netCDF4_classic file, but get following errors:
    ncap2 --version
    NCO netCDF Operators version "4.3.6" last modified 2013/10/08 built Oct 19 2013 on nowhere by mockbuild
    ncap2 version 4.3.7

    ncdump -h cold00s3_4CZ.nc | grep tmin
    float tmin(time, y, x) ;
    tmin:_FillValue = -9999.f ;
    tmin:cell_methods = "area: mean time: minimum" ;
    tmin:coordinates = "lat lon" ;
    tmin:grid_mapping = "lambert_conformal_conic" ;
    tmin:long_name = "daily minimum temperature" ;
    tmin:missing_value = -9999.f ;
    tmin:units = "degrees C" ;
    "Mon May 5 14:40:21 2014: ncks -d y,0,449 -d x,1901,2890 tmin_2000s_conus.nc subsets/tmin2000_sub3.nc\n",
    "Wed Feb 19 17:51:54 2014: ncks -d x,64,4442 -d y,840,3570 tmin_2000s.nc tmin_2000s_conus.nc\n",
    "Tue Feb 18 13:52:07 2014: ncap2 -s tmin=tmin-5; where(tmin>0) tmin=0; tmin.nc4 tmin_2000s.nc" ;

    ncrename -a _FillValue,missing_value cold00s3_4CZ.nc out1.nc
    ncrename: ERROR User specified that presence of attribute '_FillValue' is required. However, the root group does not contain it. HINT: If attribute presence is intended to be optional, then prefix attribute name with the period character '.', e.g., .att_nm. With this syntax ncrename would succeed even if no variables or groups contained the attribute. If attribute is intended to be renamed only in a specific variable, then prepend the variable name plus an at-sign '@' to the attribute name, e.g., var_nm@att_nm. If attribute presence is required only for global or group attributes, then prefix attribute name with "global" and an at-sign, e.g., global@att_nm.
    nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): main
    nco_err_exit(): ERROR Error code is -43. Translation into English with nc_strerror(-43) is "NetCDF: Attribute not found"
    nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)

    ncrename -a ._FillValue,missing_value cold00s3_4CZ.nc out2.nc
    ncrename -a tmin@_FillValue,missing_value cold00s3_4CZ.nc out3.nc
    ncrename -a tmin@._FillValue,missing_value cold00s3_4CZ.nc out4.nc

    and each of these 3 give the error:
    nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_rename_att()
    nco_err_exit(): ERROR Error code is -42. Translation into English with nc_strerror(-42) is "NetCDF: String match to name in use"
    nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)

    Thanks in advance for any suggestions,
    Yasemin

     
  • Charlie Zender

    Charlie Zender - 2014-06-12

    Your command syntax is correct and ncrename is behaving properly. The reason you get this error is because the variable tmin already has an attribute named "mising_value", so renaming "_FillValue" to "missing_value" cannot succeed. Since tmin already has both attributes, and they have the same numeric value, the motivation behind your command is unclear.
    cz

     
  • Yerguner

    Yerguner - 2014-06-12

    Hi Charlie,

    While trying to perform some analysis in R with this file, I get following error:
    Error in ncvar_get_inner(idobj$group_id, idobj$id, nc$var[[li]]$missval, :
    NAs in foreign function call (arg 3)
    My motivation behind this conversion is that whether this error is related with the perception of FillValue, missing_value and NA by using netcdf4 library in R so it might be fixed by setting both to a missing_value. When I crop the part of a same file that has no missing_values, everyting works fine in R.

    BYT, I did this conversion before using ncrename with different files in the past.

    Thanks,Yasemin

     
  • Charlie Zender

    Charlie Zender - 2014-06-12

    Hi Yasemin,
    There is a difference between a variable having two attributes named "missing_value" (this has always been illegal/impossible) and a variable having one "missing_value" attribute and one "_FillValue" attribute, each of which may have its own numeric value (this has always been legal and users are encouraged to set those values to the same number for compatibility reasons).
    cz

     

Log in to post a comment.