Open nblettner opened 3 months ago
Thanks @nblettner for the prototype. I think this would be a nice addition.
It could also be added as an xarray
Accessor, as is done in #29 for the CML plotting functions. Maybe, to simplify the usage, the sensorstype
could be inferred (e.g. via default kwarg sensortype=infer
, but maybe it could be omitted completely) because there should either be lon
and lat
or site_0_lon
and site_0_lat
.
One small additional comment: I would prefer sensor_type
over sensortype
, and maybe also lat_max
over latmax
. That helps readability.
Selecting spatial subsets is a common task but a little cumbersome to implement particularly for links which include two sites. The idea is a function that takes a dataset or dataarray of sensor / gridded data and the coordinates of a bounding box, and returns a dataset or dataarray with only sensors / pixels in that box. Alternatively, a boolean dataarray could be returned that stores the information whether or not a sensor / pixel is within the bounding box.
Below is a prototype. This function addresses all kinds of data (point, link, grid), which needs to be specified via an argument. An alternative would be three (or two) separate functions. The prototype also distinguishes several modes of what it means for a link to be considered within the bounding box; this might not be necessary though. Any comment if and how such a function should be implemented is appreciated.