413413</ li >
414414
415415 < li class ="md-nav__item ">
416- < a href ="#resampling-algorithms " class ="md-nav__link ">
416+ < a href ="#spatial- resampling-algorithms " class ="md-nav__link ">
417417 < span class ="md-ellipsis ">
418- Resampling Algorithms
418+ Spatial Resampling Algorithms
419419 </ span >
420420 </ a >
421421
422- < nav class ="md-nav " aria-label ="Resampling Algorithms ">
422+ < nav class ="md-nav " aria-label ="Spatial Resampling Algorithms ">
423423 < ul class ="md-nav__list ">
424424
425425 < li class ="md-nav__item ">
498498 </ span >
499499 </ a >
500500
501+ </ li >
502+
503+ < li class ="md-nav__item ">
504+ < a href ="#remarks " class ="md-nav__link ">
505+ < span class ="md-ellipsis ">
506+ Remarks
507+ </ span >
508+ </ a >
509+
501510</ li >
502511
503512 </ ul >
506515</ li >
507516
508517 < li class ="md-nav__item ">
509- < a href ="#remarks " class ="md-nav__link ">
518+ < a href ="#temporal-resampling " class ="md-nav__link ">
510519 < span class ="md-ellipsis ">
511- Remarks
520+ Temporal Resampling
521+ </ span >
522+ </ a >
523+
524+ < nav class ="md-nav " aria-label ="Temporal Resampling ">
525+ < ul class ="md-nav__list ">
526+
527+ < li class ="md-nav__item ">
528+ < a href ="#frequency-and-mode-selection " class ="md-nav__link ">
529+ < span class ="md-ellipsis ">
530+ Frequency and Mode Selection
512531 </ span >
513532 </ a >
514533
534+ </ li >
535+
536+ < li class ="md-nav__item ">
537+ < a href ="#interpolation " class ="md-nav__link ">
538+ < span class ="md-ellipsis ">
539+ Interpolation
540+ </ span >
541+ </ a >
542+
543+ </ li >
544+
545+ < li class ="md-nav__item ">
546+ < a href ="#aggregation " class ="md-nav__link ">
547+ < span class ="md-ellipsis ">
548+ Aggregation
549+ </ span >
550+ </ a >
551+
552+ </ li >
553+
554+ </ ul >
555+ </ nav >
556+
515557</ li >
516558
517559 </ ul >
796838</ li >
797839
798840 < li class ="md-nav__item ">
799- < a href ="#resampling-algorithms " class ="md-nav__link ">
841+ < a href ="#spatial- resampling-algorithms " class ="md-nav__link ">
800842 < span class ="md-ellipsis ">
801- Resampling Algorithms
843+ Spatial Resampling Algorithms
802844 </ span >
803845 </ a >
804846
805- < nav class ="md-nav " aria-label ="Resampling Algorithms ">
847+ < nav class ="md-nav " aria-label ="Spatial Resampling Algorithms ">
806848 < ul class ="md-nav__list ">
807849
808850 < li class ="md-nav__item ">
881923 </ span >
882924 </ a >
883925
926+ </ li >
927+
928+ < li class ="md-nav__item ">
929+ < a href ="#remarks " class ="md-nav__link ">
930+ < span class ="md-ellipsis ">
931+ Remarks
932+ </ span >
933+ </ a >
934+
884935</ li >
885936
886937 </ ul >
889940</ li >
890941
891942 < li class ="md-nav__item ">
892- < a href ="#remarks " class ="md-nav__link ">
943+ < a href ="#temporal-resampling " class ="md-nav__link ">
893944 < span class ="md-ellipsis ">
894- Remarks
945+ Temporal Resampling
946+ </ span >
947+ </ a >
948+
949+ < nav class ="md-nav " aria-label ="Temporal Resampling ">
950+ < ul class ="md-nav__list ">
951+
952+ < li class ="md-nav__item ">
953+ < a href ="#frequency-and-mode-selection " class ="md-nav__link ">
954+ < span class ="md-ellipsis ">
955+ Frequency and Mode Selection
956+ </ span >
957+ </ a >
958+
959+ </ li >
960+
961+ < li class ="md-nav__item ">
962+ < a href ="#interpolation " class ="md-nav__link ">
963+ < span class ="md-ellipsis ">
964+ Interpolation
965+ </ span >
966+ </ a >
967+
968+ </ li >
969+
970+ < li class ="md-nav__item ">
971+ < a href ="#aggregation " class ="md-nav__link ">
972+ < span class ="md-ellipsis ">
973+ Aggregation
895974 </ span >
896975 </ a >
897976
900979 </ ul >
901980 </ nav >
902981
982+ </ li >
983+
984+ </ ul >
985+ </ nav >
986+
903987</ li >
904988
905989 </ ul >
9221006
9231007
9241008< h1 id ="user-guide-for-xcube-resampling "> User Guide for xcube-resampling</ h1 >
925- < p > < strong > xcube-resampling</ strong > provides algorithms for representing a dataset in a different grid
926- mapping. It supports:</ p >
1009+ < p > < strong > xcube-resampling</ strong > provides algorithms for up- and downsampling
1010+ a gridded dataset in both spatial grids and temporal scales.
1011+ It supports:</ p >
9271012< ul >
928- < li > Simple resampling via affine transformation </ li >
929- < li > Reprojection between coordinate reference systems (CRS) </ li >
930- < li > Rectification of non-regular grids to regular grids </ li >
1013+ < li > < strong > [Spatial]</ strong > Simple resampling via affine transformation </ li >
1014+ < li > < strong > [Spatial]</ strong > Reprojection between coordinate reference systems (CRS) </ li >
1015+ < li > < strong > [Spatial]</ strong > Rectification of non-regular grids to regular grids </ li >
1016+ < li > < strong > [Temporal]</ strong > Up- and Downsampling in the time dimension to the frequency and method requested.</ li >
9311017</ ul >
932- < p > All resampling methods are built around the < a href ="../api/#xcube_resampling.gridmapping.GridMapping "> < code > GridMapping</ code > </ a >
1018+ < p > All spatial resampling methods are built around the < a href ="../api/#xcube_resampling.gridmapping.GridMapping "> < code > GridMapping</ code > </ a >
9331019class, which represents a spatial grid mapping and contains all necessary information
9341020for resampling. </ p >
935- < p > We first introduce the < code > GridMapping</ code > class before explaining the three resampling
1021+ < p > We first introduce the < code > GridMapping</ code > class before explaining the three spatial resampling
9361022algorithms.</ p >
9371023< hr />
9381024< h2 id ="gridmapping-the-grid-mapping-object "> < code > GridMapping</ code > – the grid mapping object</ h2 >
@@ -992,8 +1078,8 @@ <h4 id="derive-new-gridmapping-instances">Derive new <code>GridMapping</code> in
9921078</ ul >
9931079< p > An example is available in the < a href ="../examples/coords/ "> Example Notebooks</ a > .</ p >
9941080< hr />
995- < h3 id ="resampling-algorithms "> Resampling Algorithms</ h3 >
996- < p > The function < a href ="../api/#xcube_resampling.spatial. resample_in_space "> < code > resample_in_space</ code > </ a >
1081+ < h3 id ="spatial- resampling-algorithms "> Spatial Resampling Algorithms</ h3 >
1082+ < p > The function < a href ="../api/#xcube_resampling.resample_in_space "> < code > resample_in_space</ code > </ a >
9971083integrates all three resampling algorithms and automatically selects the most
9981084appropriate one:</ p >
9991085< table >
@@ -1007,17 +1093,17 @@ <h3 id="resampling-algorithms">Resampling Algorithms</h3>
10071093< tbody >
10081094< tr >
10091095< td > < strong > Affine Transformation</ strong > </ td >
1010- < td > < a href ="../api/#xcube_resampling.affine. affine_transform_dataset "> < code > affine_transform_dataset</ code > </ a > </ td >
1096+ < td > < a href ="../api/#xcube_resampling.affine_transform_dataset "> < code > affine_transform_dataset</ code > </ a > </ td >
10111097< td > Source and target grids are both regular and share the same CRS.</ td >
10121098</ tr >
10131099< tr >
10141100< td > < strong > Reprojection</ strong > </ td >
1015- < td > < a href ="../api/#xcube_resampling.reproject. reproject_dataset "> < code > reproject_dataset</ code > </ a > </ td >
1101+ < td > < a href ="../api/#xcube_resampling.reproject_dataset "> < code > reproject_dataset</ code > </ a > </ td >
10161102< td > Source and target grids are both regular but have different CRS.</ td >
10171103</ tr >
10181104< tr >
10191105< td > < strong > Rectification</ strong > </ td >
1020- < td > < a href ="../api/#xcube_resampling.rectify. rectify_dataset "> < code > rectify_dataset</ code > </ a > </ td >
1106+ < td > < a href ="../api/#xcube_resampling.rectify_dataset "> < code > rectify_dataset</ code > </ a > </ td >
10211107< td > Source grid is irregular with 2D coordinates.</ td >
10221108</ tr >
10231109</ tbody >
@@ -1070,7 +1156,7 @@ <h4 id="common-parameters-for-all-resampling-algorithms">Common parameters for a
10701156< h4 id ="1-affine-transformation "> 1. Affine Transformation</ h4 >
10711157< p > An < strong > affine transformation</ strong > can be applied when both the source and target grid
10721158mappings are < strong > regular</ strong > and share the same CRS. The function
1073- < a href ="../api/#xcube_resampling.affine. affine_transform_dataset "> < code > affine_transform_dataset</ code > </ a >
1159+ < a href ="../api/#xcube_resampling.affine_transform_dataset "> < code > affine_transform_dataset</ code > </ a >
10741160requires the input dataset and the target grid mapping. </ p >
10751161< p > For any data array in the dataset with < strong > two spatial dimensions as the last two axes</ strong > ,
10761162an affine transformation is performed using
@@ -1092,7 +1178,7 @@ <h4 id="1-affine-transformation">1. Affine Transformation</h4>
10921178< h4 id ="2-reprojection "> 2. Reprojection</ h4 >
10931179< p > < strong > Reprojection</ strong > can be applied when both source and target grid mappings are
10941180< strong > regular</ strong > but use < strong > different CRSs</ strong > . The function
1095- < a href ="../api/#xcube_resampling.reproject. reproject_dataset "> < code > reproject_dataset</ code > </ a >
1181+ < a href ="../api/#xcube_resampling.reproject_dataset "> < code > reproject_dataset</ code > </ a >
10961182requires the input dataset and the target grid mapping. </ p >
10971183< p > The procedure is as follows:</ p >
10981184< ol >
@@ -1110,7 +1196,7 @@ <h4 id="2-reprojection">2. Reprojection</h4>
11101196< hr />
11111197< h4 id ="3-rectification "> 3. Rectification</ h4 >
11121198< p > < strong > Rectification</ strong > is used when the source dataset has an < strong > irregular grid</ strong > . The
1113- function < a href ="../api/#xcube_resampling.rectify. rectify_dataset "> < code > rectify_dataset</ code > </ a >
1199+ function < a href ="../api/#xcube_resampling.rectify_dataset "> < code > rectify_dataset</ code > </ a >
11141200requires only the input dataset. </ p >
11151201< p > If no target grid mapping is provided, the source grid mapping is < strong > converted to a
11161202regular grid</ strong > , and interpolation is performed so that the new dataset is defined on
@@ -1171,7 +1257,7 @@ <h4 id="triangular-triangular">Triangular - <code>"triangular"</code></h4>
11711257< li > < em > V = V4 + (1 - u) (V3 − V4) + (1 - v) (V2 − V4), if u+v >= 1</ em > </ li >
11721258</ ul >
11731259< p > where < em > V1</ em > , < em > V2</ em > , < em > V3</ em > , < em > V4</ em > are the pixel values of the points in the source dataset.</ p >
1174- < h3 id ="remarks "> Remarks</ h3 >
1260+ < h4 id ="remarks "> Remarks</ h4 >
11751261< ol >
11761262< li > If the < strong > target pixel size is much smaller</ strong > than the source pixel size, and the
11771263 source has low spatial resolution, results may be inaccurate. Curved source pixel
@@ -1187,6 +1273,51 @@ <h3 id="remarks">Remarks</h3>
11871273</ ul >
11881274</ li >
11891275</ ol >
1276+ < hr />
1277+ < h3 id ="temporal-resampling "> Temporal Resampling</ h3 >
1278+ < p > The function < a href ="../api/#xcube_resampling.resample_in_time "> < code > resample_in_time</ code > </ a >
1279+ allows resampling of a dataset along its < strong > time axis</ strong > . Under the hood, it applies
1280+ < a href ="https://docs.xarray.dev/en/stable/generated/xarray.DataArray.resample.html "> < code > xarray.DataArray.resample</ code > </ a >
1281+ to each data variable that includes a time dimension. A valid time coordinate must
1282+ be present in the dataset.</ p >
1283+ < h4 id ="frequency-and-mode-selection "> Frequency and Mode Selection</ h4 >
1284+ < p > The argument < code > frequency</ code > specifies the < strong > target temporal frequency</ strong > , following the
1285+ same conventions as the < code > freq</ code > argument in < a href ="https://docs.xarray.dev/en/stable/generated/xarray.groupers.TimeResampler.html "> < code > xarray.groupers.TimeResampler</ code > </ a > .</ p >
1286+ < p > The function automatically compares the target frequency with the dataset’s native
1287+ temporal resolution and determines whether to perform:</ p >
1288+ < ul >
1289+ < li > < strong > Aggregation</ strong > (downsampling), or</ li >
1290+ < li > < strong > Interpolation</ strong > (upsampling)</ li >
1291+ </ ul >
1292+ < p > unless specific < code > interp_methods</ code > or < code > agg_methods</ code > are provided by the user.</ p >
1293+ < p > If the dataset shows < strong > high temporal irregularity</ strong > — defined as a < strong > coefficient of
1294+ variation (CV = std/mean)</ strong > greater than 5% — the user
1295+ must explicitly specify either < code > interp_methods</ code > or < code > agg_methods</ code > , since the function
1296+ cannot reliably infer the appropriate mode.</ p >
1297+ < h4 id ="interpolation "> Interpolation</ h4 >
1298+ < p > When interpolation is required,
1299+ < a href ="https://docs.xarray.dev/en/v2024.05.0/generated/xarray.core.resample.DataArray.Resample.interpolate.html "> < code > xarray.core.resample.DataArrayResample.interpolate</ code > </ a >
1300+ is used internally.</ p >
1301+ < p > Available interpolation methods defined in
1302+ < a href ="../api/#xcube_resampling.constants.TemporalInterpMethod "> < code > TemporalInterpMethod</ code > </ a > and
1303+ correspond to the < code > kind</ code > argument in
1304+ < a href ="https://docs.xarray.dev/en/v2024.05.0/generated/xarray.core.resample.DataArrayResample.interpolate.html "> < code > xarray.core.resample.DataArrayResample.interpolate</ code > </ a > .</ p >
1305+ < p > < strong > Defaults:</ strong > </ p >
1306+ < ul >
1307+ < li > < code > nearest</ code > for integer data</ li >
1308+ < li > < code > linear</ code > for all other data types</ li >
1309+ </ ul >
1310+ < h4 id ="aggregation "> Aggregation</ h4 >
1311+ < p > When aggregation is applied, the available aggregation methods are defined in
1312+ < a href ="../api/#xcube_resampling.constants.TemporalAggMethod "> < code > TemporalAggMethod</ code > </ a > .</ p >
1313+ < p > Refer to the
1314+ < a href ="https://docs.xarray.dev/en/v2024.05.0/generated/xarray.core.resample.DataArray.Resample.html "> < code > xarray.core.resample.DataArrayResample</ code > </ a >
1315+ documentation for detailed descriptions of supported aggregation operations.</ p >
1316+ < p > < strong > Defaults:</ strong > </ p >
1317+ < ul >
1318+ < li > < code > nearest</ code > for integer data</ li >
1319+ < li > < code > mean</ code > for all other data types</ li >
1320+ </ ul >
11901321
11911322
11921323
0 commit comments