I was trying to use the WHERE command in a NCAP2 script, and it appears that a command within a WHERE statement will not change parts of the array marked as missing. For example executing:
ncap2 -S testscript zzz1.nc zzz2.nc
where testscript contains:
test_output@_FillValue, size = 1 NC_DOUBLE, value = -99
I would have expected that the last line of the output would have been:
Does anyone know if this is the expected behavior? I would have thought that when an array on the left hand side of an equation has an entry marked as missing, that would not preclude its value from being changed. Perhaps I'm doing something wrong here, or not quite understanding something?
I'm using ncap2 version 4.1.0 linked to netCDF library version 4.2.
yes this the expected behaviour - please see
Thanks! Somehow I missed the line in the documentation for WHERE that "LHS variable elements set to missing value are not re-assigned".
In contrast to the test case I posted, for my actual work I am using a series a WHERE statements to set the values of an array. After the series of WHERE statements are complete, some elements of the array may not have been set, so I had been setting the whole array to missing before the WHERE statements, in the hope that any elements of the array untouched by any of the WHERE statements would then be marked as missing. Since WHERE will not touch any missing values this does not work since the entire array remains missing values regardless of any WHERE statements.
The alternative I'm now using is to wait to inform NCAP2 what the missing value for this variable is until after the WHERE statements. That way WHERE can affect any array elements, but the elements unaffected by any WHERE statement will still be marked as the missing value (NCAP2 just won't know it is the missing value until after the WHERE statement). I thought I'd post this in case it was helpful to someone in the future coming across a similar situation.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.