ncks cannot find dimension variable

  • mira

    mira - 2012-12-17

    Hi everyone,

    I'm having trouble with trying to cut down a large file to a small subsection (say the north atlantic, from a global grid). 

    I'm using ncks version 2.7.1 and type the following command:

    ncks -D 5 -d lat,50.,90. -d lon,270.,360.

    3 elements in list delimited by ","
    lst = lat
    lst = 50.
    lst = 90.

    3 elements in list delimited by ","
    lst = lon
    lst = 270.
    lst = 360.

    ncks: ERROR dimension lat is not in input file

    However, I know these variables exist, since i can ncdump -v lat and lon and receive reasonable values.  I show a snippet of that here:

    ncdump -h | less
    netcdf sic_OImon_CCSM4_past1000_r1i1p1_085001-109912 {
            time = UNLIMITED ; // (3000 currently)
            j = 384 ;
            i = 320 ;
            bnds = 2 ;
            vertices = 4 ;
            double time(time) ;
                    time:bounds = "time_bnds" ;
                    time:units = "days since 0000-01-01 00:00:00" ;
                    time:calendar = "noleap" ;
                    time:axis = "T" ;
                    time:long_name = "time" ;
                    time:standard_name = "time" ;
            double time_bnds(time, bnds) ;
            int j(j) ;
                    j:units = "1" ;
                    j:long_name = "cell index along second dimension" ;
            int i(i) ;
                    i:units = "1" ;
                    i:long_name = "cell index along first dimension" ;
            float lat(j, i) ;
                    lat:standard_name = "latitude" ;
                    lat:long_name = "latitude coordinate" ;
                    lat:units = "degrees_north" ;
                    lat:bounds = "lat_vertices" ;
            float lon(j, i) ;
                    lon:standard_name = "longitude" ;
                    lon:long_name = "longitude coordinate" ;
                    lon:units = "degrees_east" ;
                    lon:bounds = "lon_vertices" ;
            float lat_vertices(j, i, vertices) ;
                    lat_vertices:units = "degrees_north" ;
            float lon_vertices(j, i, vertices) ;
                    lon_vertices:units = "degrees_east" ;
            float sic(time, j, i) ;

    Is there something I am missing here? I've done this for other files (different model outputs), but this has me stuck.

    I've tried the same with ncea but receive the same error.
    Any thoughts?

    Thanks in advance,

  • Charlie Zender

    Charlie Zender - 2012-12-18

    First, I will express my surprise and admiration that you are using version 2.7.1, released on January 20, 2003, almost ten years ago!

    The problem is that lat and lon are not dimensions in your file, they are 2-D coordinates.
    You appear to be using a sea ice model on a non-rectangular grid.

    What you really need to do to extract rectangular lat/lon regions from 2-D coordinates is … hire a graduate student … or try the ncap2 where() clause. However, this is only available with  modern NCO. And this will not hyperslab irregular regions, but it can be use to mask the values outside the region to be zero, which is often just as useful.


  • mira

    mira - 2012-12-18

    Thanks for the response!
    Unfortunately, I AM the grad student working on this, so hiring another may not be in the budget. =P
    I'll look into the ncap2 where() clause…
    In the meantime I'll bug our admin to install a version of this millennium……
    thanks again


Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks