Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

NCRA will happily average character variables

2013-03-05
2013-10-17
  • 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

    '2010-11-01T00:00:00.000000'
    '2010-11-01T01:00:00.000000'
    '2010-11-01T02:00:00.000000'
    

    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.
    thanks,
    c

     
  • 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/in.nc ~/foo.nc

     
  • 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 nyf.ncep.T62.050923_1980.nc jjjj.nc

    it gives me the jjjj.nc 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.
    cz