Atmospheric Toolbox

Sentinel 5p regridding parameters with bin_spatial()

Hi all. I am interested to know if there are recommendations or examples for the cell size value for regridding to a global sized grid. I am merging all the files for a single day into one hdf5 file for writing to COG with GDAL. As of now I am using bin_spatial(1801,-90,0.1,3601,-180,0.1) as seen in several examples on this forum and elsewhere, but I am wondering if I were to change the grid size from .1 to .05, what if, if any other changes to the bin_spatial values would need to change - would the 1801 and 3601 values need increase by 2 for example? Thanks for any input you might have.

it depends what you want to do. If you check the documentation of the overloaded function bin_spatial it should be clear, I think. (Operations — HARP 1.14 documentation) :

“bin_spatial(lat_edge_length, lat_edge_offset, lat_edge_step, lon_edge_length, lon_edge_offset, lon_edge_step)”

for example if you change the grid size from .1 to .05 and keep the other parameters fixed in your example : bin_spatial(1801,-90,0.05,3601,-180,0.05) , then it is clear that your lat grid will extend from -90 to 1801 * 0.05 and the lon grid from -180 to 3601 * 0.05

Maybe a good way to look at this is by considering your min/max latitude/longitude of your grid.
The parameters then become:

bin_spatial((lat_max-lat_min)/lat_resolution + 1, lat_min, lat_resolution, (lon_max-lon_min)/lon_resolution + 1, lon_min, lon_resolution)

The +1 is important to pay attention to. This is the relation between the number of cells (N) and the number of corner positions (N+1) you have with a regular grid. You specify the grid to bin_spatial() in terms of the grid cell corner positions (not the cell center positions).

Thank you both @jonasv and @sander.niemeijer, I greatly appreciate it. So for a global grid at resolution or cell size of .05, the bin_spatial function call would look like: bin_spatial(3601,-90,0.05,7201,-180,.05), following your example of ‘bin_spatial((lat_max-lat_min)/lat_resolution + 1, lat_min, lat_resolution, (lon_max-lon_min)/lon_resolution + 1, lon_min, lon_resolution)’? Please correct me if I am misunderstanding your explanation.