Is there any way to do some type of stack median of Sentinel-2A time series data imagery? If yes, how?

Hi, so I’m working with Sentinel-2A data imagery and I’m trying to differentiate the water from land and work only on water. In some research paper it is mentioned that:
“all processed scenes (water index maps) were composited along the time dimension into a single scene by applying a median operator. The median was calculated after removing all non-data pixels. This ensures that the gaps produced by clouds and missing data are filled in the composite image.”

Does SNAP have this kind of function (median operator)? If so, how to use it in order to fill the gaps produced by clouds?

the research paper mentioned: Monitoring of Coastal Aquaculture Sites in the Philippines through Automated Time Series Analysis of Sentinel-1
SAR Images
Andrey A. Kurekin 1, Peter I. Miller, Arlene L. Avillanosa and Joel D. C. Sumeldan

You could try at least two options to separate water from land and other non-valid pixels:
In Raster–>Mask–>land/sea Mask;
Idepix in Optical/preprocessing/masking

For the median over a region you could use the gpt operator StastOp.