I have a netcdf file with a variable that has no fill values and a mask variable that is also free from fill values, but the output averaged file ends up with all fill values. What am I missing? Why is the output of the average a fill value?
Please read the docs on the difference between a mask and a weight. A mask requires a mask_condition, e.g., --msk_cnd "ORO < 1" whereas a weight is just a multiplier. The default mask condition may lead to all missing values in your case.
cz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a netcdf file with a variable that has no fill values and a mask variable that is also free from fill values, but the output averaged file ends up with all fill values. What am I missing? Why is the output of the average a fill value?
The command I ran was:
ncwa -O -o areaavg.nc -a "lat,lon" -m "shape_mask" -v AIRX3STM_006_TotCO_A concat_with_mask.nc
my input file, concat_with_mask.nc, is:
netcdf concat_with_mask {
dimensions:
time = UNLIMITED ; // (3 currently)
lat = 4 ;
lon = 6 ;
latv = 2 ;
lonv = 2 ;
nv = 2 ;
variables:
float AIRX3STM_006_TotCO_A(time, lat, lon) ;
AIRX3STM_006_TotCO_A:_FillValue = -9999.f ;
AIRX3STM_006_TotCO_A:standard_name = "atmosphere_mass_content_of_carbon_monoxide" ;
AIRX3STM_006_TotCO_A:quantity_type = "CO" ;
AIRX3STM_006_TotCO_A:product_short_name = "AIRX3STM" ;
AIRX3STM_006_TotCO_A:product_version = "006" ;
AIRX3STM_006_TotCO_A:long_name = "Carbon Monoxide Total Column (Daytime/Ascending)" ;
AIRX3STM_006_TotCO_A:coordinates = "time lat lon" ;
AIRX3STM_006_TotCO_A:units = "mol/cm2" ;
int datamonth(time) ;
datamonth:long_name = "Standardized Date Label" ;
double lat(lat) ;
lat:units = "degrees_north" ;
lat:format = "F5.1" ;
lat:missing_value = -9999.f ;
lat:standard_name = "latitude" ;
lat:bounds = "lat_bnds" ;
double lat_bnds(lat, latv) ;
lat_bnds:units = "degrees_north" ;
double lon(lon) ;
lon:units = "degrees_east" ;
lon:format = "F6.1" ;
lon:missing_value = -9999.f ;
lon:standard_name = "longitude" ;
lon:bounds = "lon_bnds" ;
double lon_bnds(lon, lonv) ;
lon_bnds:units = "degrees_east" ;
int time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "seconds since 1970-01-01 00:00:00" ;
time:bounds = "time_bnds" ;
int time_bnds(time, nv) ;
time_bnds:units = "seconds since 1970-01-01 00:00:00" ;
double shape_mask(lat, lon) ;
shape_mask:cell_methods = "contrib: mean" ;
shape_mask:units = "degrees_north" ;
// global attributes:
:Conventions = "CF-1.4" ;
:start_time = "2003-12-01T00:00:00Z" ;
:end_time = "2003-12-31T23:59:59Z" ;
:temporal_resolution = "monthly" ;
:NCO = "\"4.5.3\"" ;
:nco_openmp_thread_number = 1 ;
:history = "Thu Jan 19 17:54:50 2017: ncks -O -o concat.nc -d lat,37.4,40.6 -d lon,-79.6,-74.4 concat.nc\n",
"Thu Jan 19 17:31:49 2017: ncrcat -o concat.nc scrubbed.AIRX3STM_006_TotCO_A.20031201.nc scrubbed.AIRX3STM_006_TotCO_A.20040101.nc scrubbed.AIRX3STM_006_TotCO_A.20040201.nc" ;
data:
AIRX3STM_006_TotCO_A =
2.016065e+18, 2.112892e+18, 2.184668e+18, 2.182557e+18, 2.172987e+18,
2.197053e+18,
1.895452e+18, 2.038864e+18, 2.173691e+18, 2.212675e+18, 2.212112e+18,
2.212956e+18,
1.98088e+18, 2.058849e+18, 2.155676e+18, 2.202823e+18, 2.21366e+18,
2.229986e+18,
2.039568e+18, 2.02085e+18, 2.131329e+18, 2.162854e+18, 2.176365e+18,
2.213238e+18,
2.273896e+18, 2.359042e+18, 2.381278e+18, 2.390004e+18, 2.384656e+18,
2.383812e+18,
2.084604e+18, 2.267422e+18, 2.384656e+18, 2.397885e+18, 2.386626e+18,
2.394226e+18,
2.119647e+18, 2.237445e+18, 2.325828e+18, 2.362982e+18, 2.371145e+18,
2.391411e+18,
2.200149e+18, 2.181431e+18, 2.231252e+18, 2.299369e+18, 2.317383e+18,
2.367205e+18,
2.350035e+18, 2.466284e+18, 2.533556e+18, 2.514134e+18, 2.475291e+18,
2.468817e+18,
2.220838e+18, 2.396759e+18, 2.527645e+18, 2.519764e+18, 2.52849e+18,
2.470224e+18,
2.282903e+18, 2.359042e+18, 2.47895e+18, 2.513572e+18, 2.537497e+18,
2.501468e+18,
2.393945e+18, 2.323294e+18, 2.421811e+18, 2.469098e+18, 2.491616e+18,
2.528208e+18 ;
datamonth = 200312, 200401, 200402 ;
lat = 37.5, 38.5, 39.5, 40.5 ;
lat_bnds =
37, 38,
38, 39,
39, 40,
40, 41 ;
lon = -79.5, -78.5, -77.5, -76.5, -75.5, -74.5 ;
lon_bnds =
-80, -79,
-79, -78,
-78, -77,
-77, -76,
-76, -75,
-75, -74 ;
time = 1070236800, 1072915200, 1075593600 ;
time_bnds =
1070236800, 1072915199,
1072915200, 1075593599,
1075593600, 1078099199 ;
shape_mask =
0, 0, 0, 0.0991691675364044, 0.0991691675364044, 0,
0, 0, 0.293478058819655, 0.782608156852414, 0.58695611763931,
0.0489130098032759,
0.241132682308662, 0.241132682308662, 0.530491901079058, 0.57871843754079,
0.19290614584693, 0,
0, 0, 0, 0, 0, 0 ;
}
The output file I get has all fill values for the AIRX3STM_006_TotCO_A variable:
netcdf areaavg {
dimensions:
time = UNLIMITED ; // (3 currently)
latv = 2 ;
lonv = 2 ;
nv = 2 ;
variables:
float AIRX3STM_006_TotCO_A(time) ;
AIRX3STM_006_TotCO_A:_FillValue = -9999.f ;
AIRX3STM_006_TotCO_A:standard_name = "atmosphere_mass_content_of_carbon_monoxide" ;
AIRX3STM_006_TotCO_A:quantity_type = "CO" ;
AIRX3STM_006_TotCO_A:product_short_name = "AIRX3STM" ;
AIRX3STM_006_TotCO_A:product_version = "006" ;
AIRX3STM_006_TotCO_A:long_name = "Carbon Monoxide Total Column (Daytime/Ascending)" ;
AIRX3STM_006_TotCO_A:coordinates = "time " ;
AIRX3STM_006_TotCO_A:units = "mol/cm2" ;
AIRX3STM_006_TotCO_A:cell_methods = "lat, lon: mean" ;
double lat ;
lat:units = "degrees_north" ;
lat:format = "F5.1" ;
lat:missing_value = -9999.f ;
lat:standard_name = "latitude" ;
lat:bounds = "lat_bnds" ;
lat:_FillValue = 9.96920996838687e+36 ;
lat:cell_methods = "lat: mean" ;
double lat_bnds(latv) ;
lat_bnds:units = "degrees_north" ;
lat_bnds:_FillValue = 9.96920996838687e+36 ;
lat_bnds:cell_methods = "lat: mean" ;
double lon ;
lon:units = "degrees_east" ;
lon:format = "F6.1" ;
lon:missing_value = -9999.f ;
lon:standard_name = "longitude" ;
lon:bounds = "lon_bnds" ;
lon:_FillValue = 9.96920996838687e+36 ;
lon:cell_methods = "lon: mean" ;
double lon_bnds(lonv) ;
lon_bnds:units = "degrees_east" ;
lon_bnds:_FillValue = 9.96920996838687e+36 ;
lon_bnds:cell_methods = "lon: mean" ;
int time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "seconds since 1970-01-01 00:00:00" ;
time:bounds = "time_bnds" ;
int time_bnds(time, nv) ;
time_bnds:units = "seconds since 1970-01-01 00:00:00" ;
// global attributes:
:Conventions = "CF-1.4" ;
:start_time = "2003-12-01T00:00:00Z" ;
:end_time = "2003-12-31T23:59:59Z" ;
:temporal_resolution = "monthly" ;
:NCO = "\"4.5.3\"" ;
:nco_openmp_thread_number = 1 ;
:history = "Fri Jan 20 19:22:22 2017: ncwa -O -o areaavg.nc -a lat,lon -m shape_mask -v AIRX3STM_006_TotCO_A concat_with_mask.nc\n",
"Thu Jan 19 17:54:50 2017: ncks -O -o concat.nc -d lat,37.4,40.6 -d lon,-79.6,-74.4 concat.nc\n",
"Thu Jan 19 17:31:49 2017: ncrcat -o concat.nc scrubbed.AIRX3STM_006_TotCO_A.20031201.nc scrubbed.AIRX3STM_006_TotCO_A.20040101.nc scrubbed.AIRX3STM_006_TotCO_A.20040201.nc" ;
data:
AIRX3STM_006_TotCO_A = , , _ ;
lat = 39 ;
lat_bnds = 38.5, 39.5 ;
lon = -77 ;
lon_bnds = -77.5, -76.5 ;
time = 1070236800, 1072915200, 1075593600 ;
time_bnds =
1070236800, 1072915199,
1072915200, 1075593599,
1075593600, 1078099199 ;
}
Please read the docs on the difference between a mask and a weight. A mask requires a mask_condition, e.g., --msk_cnd "ORO < 1" whereas a weight is just a multiplier. The default mask condition may lead to all missing values in your case.
cz
Whoops. Yeah. I wanted -w for weights, not -m.