NCRA will happily average character variables

  • Richard P Signell

    Just wanted to point out that NCRA will happily average over character variables as well as numeric variables, which can lead to some unexpected consequences.   We had a bunch of hourly output from an ocean model where the time was represented as a CF compliant double, but also as a character string variable

     char Times(time, DateStrLen) ;
                    Times:time_zone = "UTC" ;

    with values like


    We used NCRA to compute monthly averages, and then used NCML on a THREDDS server to virtually aggregate these into a single dataset, which was worked great.

    Except that it turned out that someone had developed code that was reading that Times character variable, which after being averaged by NCRA produced goofy values like:
    "1878-01-14T03:009//-500000", "1868-02-14T03:009//-000000", "1878-03-14T03:009//-000000"

    So just a heads up that if you want times as character strings to work after being NCRA, you might have to do some correction.

  • Charlie Zender

    Charlie Zender - 2013-03-06

    Hello Rich,
    I am unable to reproduce the problem you describe.
    The NCO arithmetic operators like ncra are designed to ignore character variables, and to just copy them instead.
    Please post a full use case that shows ncra altering character variables and we will look into it.

  • Charlie Zender

    Charlie Zender - 2013-03-12

    Here is my example with the latest snapshot that shows ncra does not fiddle with character variables:

    ncra -O -v time,date_rec,fl_nm_rec ~/nco/data/ ~/

  • Alexander Semenov

    I am using ncra to split the netcdf file into 3 based on time. Typically it works on other files but when I type the command
    ncra -d time,0,1119

    it gives me the file with only 1 timestep. Do you any suggestions on how to fix it? I am guessing that this error is due to the time format which is double. 

  • Charlie Zender

    Charlie Zender - 2013-08-27

    ncra averages files into a file with only one timestep, exactly as you have described.
    to split files into multiple files use ncks not ncra.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks