stcorp / harp

Data harmonization toolset for scientific earth observation data
http://stcorp.github.io/harp/doc/html/index.html
BSD 3-Clause "New" or "Revised" License
55 stars 19 forks source link

"invalid variable ‘latitude_bounds_weight’" error when performing harpmerge #214

Closed svniemeijer closed 4 years ago

svniemeijer commented 4 years ago

This error appears if, for instance, you try to merge daily gridded averages (i.e. the result of a bin_spatial + temporal bin of daily orbits) into a monthly gridded average. The problem is in the dual usage of 'weight' variables for both spatial binning and angle variables.

svniemeijer commented 4 years ago

For now this can be worked around by removing the angle weight variables (e.g. performing a exclude(latitude_bounds_weight,longitude_bounds_weight,latitude_weight,longitude_weight)) directly after performing a bin() operation.

svniemeijer commented 4 years ago

Fixed in 78fa55b4bfd9df9692c708d17849b50f81a1634f

svniemeijer commented 4 years ago

A better approach is to actually squash the time dimension for the lat/lon variables before performing the bin() operation:

squash(time, (latitude,longitude,latitude_bounds,longitude_bounds));bin()

This approach is the preferred approach since the squash operation will raise errors if you try to merge grids with different lat/lon axis (whereas performing a bin() first would just average the axis values.