Sampling a xarray dataset into positive and negative samples for self supervised feature learning

I have a xarray dataset with 2 variables depicting cloud cover value and precipitation values (coordinates: Latitude, Longitude and Time )which i need to sample into positive and negatives pairs for training the model.

This basically is a part for self supervised feature learning. The sampling has to be done based on region i.e all values lying inside a region is considered as positive pairs and one value inside and one value outside is considered as negative pair for which i would annotate the labels 0 for positive pairs and 1 for negative pairs respectively and thereby feed it to the model.

I’m not sure how to achieve the sampling data with latitude, longitude and time as they are 3D. I’m a beginner in this field, any sort of help would be much appreciated :slight_smile:

Format of data: