Repository: ESMValGroup/ESMValCore

Issue:
No explicit logging of supplementary variable file paths
**Is your feature request related to a problem? Please describe.**

Currently, file paths of supplementary variables are logged together with their parent variable:

https://github.com/ESMValGroup/ESMValCore/blob/79455c1dfb4c29e801472cadccd723027997cc88/esmvalcore/_recipe/recipe.py#L252-L269

While this is usually not a problem for CMIP datasets where the variable name appears in the path, this might be problematic for native model output where the variable name is not in the path, which might lead to confusing output.

It would be good if the log specifically mentioned which file belongs to which variable.

**Would you be able to help out?**
Yes!


Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/ESMValGroup/ESMValCore/pull/2303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ESMValGroup) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`79455c1`)](https://app.codecov.io/gh/ESMValGroup/ESMValCore/commit/79455c1dfb4c29e801472cadccd723027997cc88?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ESMValGroup) 93.70% compared to head [(`7ba27d7`)](https://app.codecov.io/gh/ESMValGroup/ESMValCore/pull/2303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ESMValGroup) 93.71%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #2303   +/-   ##
=======================================
  Coverage   93.70%   93.71%           
=======================================
  Files         238      238           
  Lines       13115    13122    +7     
=======================================
+ Hits        12290    12297    +7     
  Misses        825      825           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/ESMValGroup/ESMValCore/pull/2303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ESMValGroup).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ESMValGroup).

schlunma: Thanks for the review @bouweandela! @ESMValGroup/technical-lead-development-team does anyone have a minute for a final check and merge? Thanks!!


Patch:
diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py
index 1613f6cf6..d245880fa 100644
--- a/esmvalcore/_recipe/recipe.py
+++ b/esmvalcore/_recipe/recipe.py
@@ -250,25 +250,42 @@ def _add_to_download_list(dataset):
 
 
 def _schedule_for_download(datasets):
-    """Schedule files for download and show the list of files in the log."""
+    """Schedule files for download."""
     for dataset in datasets:
         _add_to_download_list(dataset)
         for supplementary_ds in dataset.supplementaries:
             _add_to_download_list(supplementary_ds)
 
-        files = list(dataset.files)
-        for supplementary_ds in dataset.supplementaries:
-            files.extend(supplementary_ds.files)
+
+def _log_input_files(datasets: Iterable[Dataset]) -> None:
+    """Show list of files in log (including supplementaries)."""
+    for dataset in datasets:
+        # Only log supplementary variables if present
+        supplementary_files_str = ""
+        if dataset.supplementaries:
+            for sup_ds in dataset.supplementaries:
+                supplementary_files_str += (
+                    f"\nwith files for supplementary variable "
+                    f"{sup_ds['short_name']}:\n{_get_files_str(sup_ds)}"
+                )
 
         logger.debug(
-            "Using input files for variable %s of dataset %s:\n%s",
+            "Using input files for variable %s of dataset %s:\n%s%s",
             dataset.facets['short_name'],
-            dataset.facets['alias'].replace('_', ' '),
-            '\n'.join(f'{f} (will be downloaded)' if not f.exists() else str(f)
-                      for f in files),
+            dataset.facets['alias'].replace('_', ' '),  # type: ignore
+            _get_files_str(dataset),
+            supplementary_files_str
         )
 
 
+def _get_files_str(dataset: Dataset) -> str:
+    """Get nice string representation of all files of a dataset."""
+    return '\n'.join(
+        f'  {f}' if f.exists()  # type: ignore
+        else f'  {f} (will be downloaded)' for f in dataset.files
+    )
+
+
 def _check_input_files(input_datasets: Iterable[Dataset]) -> set[str]:
     """Check that the required input files are available."""
     missing = set()
@@ -517,6 +534,7 @@ def _get_preprocessor_products(
         _set_version(dataset, input_datasets)
         USED_DATASETS.append(dataset)
         _schedule_for_download(input_datasets)
+        _log_input_files(input_datasets)
         logger.info("Found input files for %s", dataset.summary(shorten=True))
 
         filename = _get_output_file(
diff --git a/esmvalcore/preprocessor/_area.py b/esmvalcore/preprocessor/_area.py
index ae78526a2..145b87ec3 100644
--- a/esmvalcore/preprocessor/_area.py
+++ b/esmvalcore/preprocessor/_area.py
@@ -84,7 +84,6 @@ def extract_region(
             latitude=(start_latitude, end_latitude),
             ignore_bounds=True,
         )
-        region_subset = region_subset.intersection(longitude=(0., 360.))
     else:
         region_subset = _extract_irregular_region(
             cube,


Test patch:
diff --git a/tests/unit/preprocessor/_area/test_area.py b/tests/unit/preprocessor/_area/test_area.py
index a74ac8ba0..3939437f3 100644
--- a/tests/unit/preprocessor/_area/test_area.py
+++ b/tests/unit/preprocessor/_area/test_area.py
@@ -770,7 +770,7 @@ def test_crop_cube_with_ne_file(ne_ocean_shapefile):
         result = _crop_cube(cube, *geometries.bounds, cmor_coords=False)
         result = (result.coord("latitude").points[-1],
                   result.coord("longitude").points[-1])
-        expected = (89., 359.)
+        expected = (89., 179.)
         np.testing.assert_allclose(result, expected)