Re: [netcdfgroup] stupid question: how do I dump just the contents of a variable from a netCDF file?

I just want either a single-column ascii output of the data values or a binary dump that I can run od on to get same.

$ ncdump -v data example_000.nc
$ ncks -v data example_000.nc
$ h5dump -d data example_000.nc


below outputs for each, it seems ncks is what you want


$ ncdump -v data example_000.nc

netcdf example_000 {
dimensions:
       x = 4 ;
       y = 6 ;
variables:
       float data(x, y) ;
       float x(x) ;
       float y(y) ;
data:

data =
 0, 1, 2, 3, 4, 5,
 6, 7, 8, 9, 10, 11,
 12, 13, 14, 15, 16, 17,
 18, 19, 20, 21, 22, 23 ;
}


$ ncks -v data example_000.nc

data: type NC_FLOAT, 2 dimensions, 0 attributes, chunked? no, compressed? no, packed? no, ID = 0
data size (in RAM) is 4*6*sizeof(NC_FLOAT) = 24*4 = 96 bytes
data dimension 0: x, size = 4 NC_FLOAT, dim. ID = 0 (Coordinate dimension)
data dimension 1: y, size = 6 NC_FLOAT, dim. ID = 1 (Coordinate dimension)

x: type NC_FLOAT, 1 dimension, 0 attributes, chunked? no, compressed? no, packed? no, ID = 1
x size (in RAM) is 4*sizeof(NC_FLOAT) = 4*4 = 16 bytes
x dimension 0: x, size = 4 NC_FLOAT, dim. ID = 0 (Coordinate dimension)

y: type NC_FLOAT, 1 dimension, 0 attributes, chunked? no, compressed? no, packed? no, ID = 2
y size (in RAM) is 6*sizeof(NC_FLOAT) = 6*4 = 24 bytes
y dimension 0: y, size = 6 NC_FLOAT, dim. ID = 1 (Coordinate dimension)

x[0]=0 y[0]=0 data[0]=0
x[0]=0 y[1]=10 data[1]=1
x[0]=0 y[2]=20 data[2]=2
x[0]=0 y[3]=30 data[3]=3
x[0]=0 y[4]=40 data[4]=4
x[0]=0 y[5]=50 data[5]=5
x[1]=10 y[0]=0 data[6]=6
x[1]=10 y[1]=10 data[7]=7
x[1]=10 y[2]=20 data[8]=8
x[1]=10 y[3]=30 data[9]=9
x[1]=10 y[4]=40 data[10]=10
x[1]=10 y[5]=50 data[11]=11
x[2]=20 y[0]=0 data[12]=12
x[2]=20 y[1]=10 data[13]=13
x[2]=20 y[2]=20 data[14]=14
x[2]=20 y[3]=30 data[15]=15
x[2]=20 y[4]=40 data[16]=16
x[2]=20 y[5]=50 data[17]=17
x[3]=30 y[0]=0 data[18]=18
x[3]=30 y[1]=10 data[19]=19
x[3]=30 y[2]=20 data[20]=20
x[3]=30 y[3]=30 data[21]=21
x[3]=30 y[4]=40 data[22]=22
x[3]=30 y[5]=50 data[23]=23

x[0]=0
x[1]=10
x[2]=20
x[3]=30

y[0]=0
y[1]=10
y[2]=20
y[3]=30
y[4]=40
y[5]=50



$ h5dump -d data example_000.nc

HDF5 "example_000.nc" {
DATASET "data" {
  DATATYPE  H5T_IEEE_F32LE
  DATASPACE  SIMPLE { ( 4, 6 ) / ( 4, 6 ) }
  DATA {
  (0,0): 0, 1, 2, 3, 4, 5,
  (1,0): 6, 7, 8, 9, 10, 11,
  (2,0): 12, 13, 14, 15, 16, 17,
  (3,0): 18, 19, 20, 21, 22, 23
  }
  ATTRIBUTE "DIMENSION_LIST" {
     DATATYPE  H5T_VLEN { H5T_REFERENCE { H5T_STD_REF_OBJECT }}
     DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
     DATA {
     (0): (DATASET 539 /x ), (DATASET 823 /y )
     }
  }
}
}



----------------------
Pedro Vicente
pedro.vicente@xxxxxxxxxxxxxxxxxx
http://www.space-research.org/


----- Original Message ----- From: "Lynnes, Christopher S. (GSFC-6102)" <christopher.s.lynnes@xxxxxxxx>
To: "NetCDF Group List" <netcdfgroup@xxxxxxxxxxxxxxxx>
Sent: Wednesday, September 19, 2012 3:35 PM
Subject: [netcdfgroup] stupid question: how do I dump just the contents of a variable from a netCDF file?


I mean, no header info, no data attributes, no coordinate indices. I just want either a single-column ascii output of the data values or a binary dump that I can run od on to get same.

Can't seem to find the right combo of args in either ncdump or h5dump...
--
Dr. Christopher Lynnes     NASA/GSFC, Code 610.2    phone: 301-614-5185


_______________________________________________
netcdfgroup mailing list
netcdfgroup@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/





  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: