swb2
swb2 copied to clipboard
Need more testing and code cleanup for netCDF file inputs
A recently encountered netCDF file revealed a weakness in the algorithm used to tie row and column numbers to real-world coordinates. The original code was from the days before netCDF was even an input option in SWB. When using Arc ASCII grids as input, it is safe to assume that one can calculate the coordinate value of a cell from the row/column number and the cell size, along with the coordinates of the origin.
The netCDF file encountered features continuously varied grid cell sizes from north to south; this caused the simple coordinate calculation method to fail spectacularly. The solution was to use the coordinates from the netCDF file lon and lat variables directly, rather than assuming that the coordinates can be calculated. As a bonus, this seems to ripple through the code in such a way that the grids no longer need to be 'flipped' on input, but can be read as is. This needs to be tested and verified with a sample of in-the-wild netCDF files.