Greetings,
How do I change some values of a particular variable in a bunch of my netcdf files?
Any advice would be greatly appreciated. Here's what I wish to do:
Change variable "zaxis = 1, 2, 3;" to "zaxis = 0.3, 0.6, 0.9;" for the file below:
I tried the following command but the command unexpectedly changed other things in my file. For example, some dimensions got deleted; zaxis variable got deleted.
Greetings,
How do I change some values of a particular variable in a bunch of my netcdf files?
Any advice would be greatly appreciated. Here's what I wish to do:
Change variable "zaxis = 1, 2, 3;" to "zaxis = 0.3, 0.6, 0.9;" for the file below:
netcdf filex {
dimensions:
two = 2 ;
three = 3 ;
time = UNLIMITED ; // (15 currently)
xaxis = 1320 ;
yaxis = 1482 ;
zaxis = 3 ;
zip2 = 1117087 ;
zip3 = 5587693 ;
variables:
int zaxis(zaxis) ;
zaxis:long_name = "coordinate variables of zaxis" ;
zaxis:units = "sigma_level" ;
zaxis:figure = "na" ;
zaxis:positive = "down" ;
…
zaxis = 1, 2, 3 ;
I tried the following command but the command unexpectedly changed other things in my file. For example, some dimensions got deleted; zaxis variable got deleted.
% ncap -s 'zaxis=.33;zaxis=.66;zaxis=.99' filex.nc x.nc
I got:
netcdf x {
dimensions:
time = UNLIMITED ; // (15 currently)
xaxis = 1320 ;
yaxis = 1482 ;
zaxis = 3 ;
variables:
double zaxis ;
…
zaxis = 0.33 ;
Thanks.
-chk
Use ncap2. Both of these should work:
ncap2 -s 'zaxis/=3.3333333' filex.nc x.nc
ncap2 -s 'zaxis(:)={0.33,0.66,0.99}' filex.nc x.nc
cz
So I am trying to change the value of dimension lat and lon in two files to be the same.
dimensions:
time = UNLIMITED; // (1 currently)
lat = 73;
lon = 144;
Clarify how/whether you want to regrid, extrapolate, leave empty the values of the associated coordinates and data fields.
cz
Many thanks, Charlie.
-chk
Hi, I have the same problem.
I would like to replace all the null values with a "zero" value:
from
netcdf current {
dimensions:
...
...
variables
float current (lon, lat, time)
...
...
current:
, , , , 1, , , , , , , 3, , , 25, , , , , _
in
current:
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 25, 0, 0, 0,......
thanks
Emanuele
Last edit: Emanuele 2014-08-29
ncap2 where() syntax can do this:
http://nco.sf.net/nco.html#where
cz