# Is 'weight' variable used in bin() operation?

**URL:** https://forum.atmospherictoolbox.org/t/is-weight-variable-used-in-bin-operation/686
**Category:** HARP
**Created:** [September 15, 2023, 7:45am UTC](https://forum.atmospherictoolbox.org/t/is-weight-variable-used-in-bin-operation/686 "2023-09-15T07:45:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thomasd](https://forum.atmospherictoolbox.org/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@thomasd](https://forum.atmospherictoolbox.org/u/thomasd)
#### Post date: [September 15, 2023, 7:45am UTC](https://forum.atmospherictoolbox.org/t/is-weight-variable-used-in-bin-operation/686/1 "2023-09-15T07:45:05Z")

</div>

My use case is the following: when I want to create daily grids of S5P L2 data, I can either

1. merge L2 files for all orbits of a day, and use a single `bin_spatial()` operation on the merged L2 data, or
2. use `bin_spatial()` on each orbit, and then merge the per-orbit grids into a single grid using `bin()`

I’d prefer to use method 2), because it likely requires much less memory when using harpmerge ‘reduce’ operations, but I’m not 100% sure the result will be identical. `bin_spatial()` creates a weight variable, determined by the pixel area overlap of input satellite pixels and the spatial bins. Does `bin()` take into account this ‘weight’ variable when combining per-orbit grids? If not, the result of method 2 would be slightly different from that of method 1).

I’ve read a previous conversation on this topic ([How is the average of a HARP "bin" calculated? Role of weight and count variables?](https://forum.atmospherictoolbox.org/t/how-is-the-average-of-a-harp-bin-calculated-role-of-weight-and-count-variables/112)). From the C library documentation of `harp_product_bin()`, I understand that the weight variable is used, but the algorithm documentation at [Regridding operations — HARP 1.19 documentation](http://stcorp.github.io/harp/doc/html/algorithms/regridding.html#binning) suggests a more simple arithmetic average.

---

<div class="post-metadata">

### Author: ![sander.niemeijer](https://forum.atmospherictoolbox.org/user_avatar/forum.atmospherictoolbox.org/sander.niemeijer/32/5_2.png) [@sander.niemeijer](https://forum.atmospherictoolbox.org/u/sander.niemeijer)
#### Post date: [September 15, 2023, 8:37am UTC](https://forum.atmospherictoolbox.org/t/is-weight-variable-used-in-bin-operation/686/2 "2023-09-15T08:37:46Z")

</div>

This is an omission in the documentation. Existing weight/count variables are taken into account when performing temporal binning (i.e. method 2 can be used). We will update the documentation for this.  
Thanks for bringing this to our attention.
