Concatenating multiple time based nc files

Help
Rick Kohrs
2012-11-07
2013-10-17
  • Rick Kohrs

    Rick Kohrs - 2012-11-07

    Here is an ncdump of my netcdf file.  I have one per day for several years.  Is there a way to use ncrcat to concatenate them together?

    netcdf C:/Users/rickk/Desktop/oisst/avhrr-only-v2.20080101.nc {
    dimensions:
       time = 1;
       zlev = 1;
       lat = 720;
       lon = 1440;
    variables:
       float time(time=1);
         :long_name = "Center time of the day";
         :units = "days since 1978-01-01 00:00:00";
       float zlev(zlev=1);
         :long_name = "Sea surface height";
         :units = "meters";
         :actual_range = "0, 0";
       float lat(lat=720);
         :long_name = "Latitude";
         :units = "degrees_north";
         :grids = "Uniform grid from -89.875 to 89.875 by 0.25";
       float lon(lon=1440);
         :long_name = "Longitude";
         :units = "degrees_east";
         :grids = "Uniform grid from 0.125 to 359.875 by 0.25";
       short sst(time=1, zlev=1, lat=720, lon=1440);
         :long_name = "Daily sea surface temperature";
         :units = "degrees C";
         :_FillValue = -999S; // short
         :add_offset = 0.0f; // float
         :scale_factor = 0.01f; // float
         :valid_min = -300S; // short
         :valid_max = 4500S; // short
       short anom(time=1, zlev=1, lat=720, lon=1440);
         :long_name = "Daily sea surface temperature anomalies";
         :units = "degrees C";
         :_FillValue = -999S; // short
         :add_offset = 0.0f; // float
         :scale_factor = 0.01f; // float
         :valid_min = -1200S; // short
         :valid_max = 1200S; // short
       short err(time=1, zlev=1, lat=720, lon=1440);
         :long_name = "Estimated error standard deviation of analysed_sst";
         :units = "degrees C";
         :_FillValue = -999S; // short
         :add_offset = 0.0f; // float
         :scale_factor = 0.01f; // float
         :valid_min = 0S; // short
         :valid_max = 1000S; // short
       short ice(time=1, zlev=1, lat=720, lon=1440);
         :long_name = "Sea ice concentration";
         :units = "percentage";
         :_FillValue = -999S; // short
         :add_offset = 0.0f; // float
         :scale_factor = 0.01f; // float
         :valid_min = 0S; // short
         :valid_max = 100S; // short

    :Conventions = "CF-1.0";
    :title = "Daily-OI-V2, Final, Data (Ship, Buoy, AVHRR: NOAA17&18, NCEP-ice)";
    :History = "Version 2.0";
    :creation_date = "2011-03-11";
    :Description = "Reynolds, et al.(2007) Daily High-resolution Blended Analyses. Available at ftp://eclipse.ncdc.noaa.gov/pub/OI-daily/daily-sst.pdf  Climatology is based on 1971-2000 OI.v2 SST, Satellite data: Navy NOAA17 NOAA18 AVHRR, Ice data: NCEP ice";
    :Source = "NOAA/National Climatic Data Center";
    :Contact = "Dick Reynolds, email: Richard.W.Reynolds@noaa.gov & Chunying Liu, email: Chunying.liu@noaa.gov";
    }

     
  • Charlie Zender

    Charlie Zender - 2012-11-07

    http://nco.sf.net/nco.html#mk_rcd_dmn

    for fl in `ls *.nc` ; do
        ncks -O -mk_rec_dmn time ${fl} ${fl}
    done
    ncrcat *.nc out.nc

     
  • Rick Kohrs

    Rick Kohrs - 2012-11-07

    I'm getting closer - I got ncks to work, but ncrcat is not …

    C:\Users\rickk\Desktop\oisst\temp>c:\"Program Files"\nco\ncrcat.exe c:\users\rickk\desktop\oisst\temp\*.nc c:\users\rick
    k\desktop\oisst\final.nc
    ERROR: nco__open() unable to open file "c:\users\rickk\desktop\oisst\temp\*.nc"
    nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco__open()
    nco_err_exit(): ERROR Error code is 22. Translation into English with nc_strerror(22) is "Invalid argument"
    nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)

    C:\Users\rickk\Desktop\oisst\temp>dir c:\users\rickk\desktop\oisst\temp\*.nc
    Volume in drive C has no label.
    Volume Serial Number is F0E2-F485

    Directory of c:\users\rickk\desktop\oisst\temp

    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080101.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080102.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080103.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080104.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080105.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080106.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080107.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080108.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080109.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080110.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080111.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080112.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080113.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080114.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080115.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080116.nc
    11/07/2012  03:58 PM         8,305,708 avhrr-only-v2.20080117.nc
                  17 File(s)    141,197,036 bytes
                   0 Dir(s)  169,509,916,672 bytes free

    C:\Users\rickk\Desktop\oisst\temp>

     
  • Pedro Vicente

    Pedro Vicente - 2012-11-07

    >>"c:\users\rickk\desktop\oisst\temp\*.nc"

    This is a windows shell feature, not handled in NCO.
    You will have to somehow modify the script above for Windows

     
  • Rick Kohrs

    Rick Kohrs - 2012-11-07

    The command does not work from the command line either.

     
  • Charlie Zender

    Charlie Zender - 2012-11-08

    NCO can automatically generate filenames, given a pattern.
    This helps immensely on Windows machines that lack UNIX shell features
    like filename globbing. Try

    ncrcat -n 17,8,1 avhrr-only-v2.20080101.nc out.nc

    You can fill-in the missing information by using the keywords in this
    message to search the online NCO manual.
    cz

     

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