From 5f8d072ac2d495d4eb6414dd6e35c2c5bfefd92e Mon Sep 17 00:00:00 2001 From: ro Date: Mon, 12 Apr 2021 16:13:50 +0200 Subject: [PATCH 1/7] refactor: default filename pattern --- satpy/etc/writers/cf.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satpy/etc/writers/cf.yaml b/satpy/etc/writers/cf.yaml index 5c4a875bec..4686d6d2f5 100644 --- a/satpy/etc/writers/cf.yaml +++ b/satpy/etc/writers/cf.yaml @@ -2,6 +2,6 @@ writer: name: cf description: Generic netCDF4/CF Writer writer: !!python/name:satpy.writers.cf_writer.CFWriter - filename: '{name}_{start_time:%Y%m%d_%H%M%S}.nc' + filename: '{platform_name}-{sensor}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc' compress: DEFLATE zlevel: 6 From 6666c4b15c1ba32d9408b1a4c354246b631512ea Mon Sep 17 00:00:00 2001 From: ro Date: Mon, 12 Apr 2021 16:24:31 +0200 Subject: [PATCH 2/7] refactor: add instrument to root attrs --- satpy/writers/cf_writer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/satpy/writers/cf_writer.py b/satpy/writers/cf_writer.py index f79ae168ac..785218576e 100644 --- a/satpy/writers/cf_writer.py +++ b/satpy/writers/cf_writer.py @@ -726,6 +726,10 @@ def save_datasets(self, datasets, filename=None, groups=None, header_attrs=None, if flatten_attrs: header_attrs = flatten_dict(header_attrs) root.attrs = encode_attrs_nc(header_attrs) + + # Add header attributes needed for satpy_cf_reader + root.attrs["instrument"] = datasets[0].attrs["sensor"] + _history_create = 'Created by pytroll/satpy on {}'.format(datetime.utcnow()) if 'history' in root.attrs: if isinstance(root.attrs['history'], list): From f123e23beda74df523e1e27f351c943efa902c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Tue, 16 Aug 2022 11:33:02 +0200 Subject: [PATCH 3/7] refactor: add generic filename to reader yaml --- satpy/etc/readers/satpy_cf_nc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/satpy/etc/readers/satpy_cf_nc.yaml b/satpy/etc/readers/satpy_cf_nc.yaml index bd968eb474..bdc216b3d3 100644 --- a/satpy/etc/readers/satpy_cf_nc.yaml +++ b/satpy/etc/readers/satpy_cf_nc.yaml @@ -17,3 +17,4 @@ file_types: file_patterns: - '{platform_name}-{sensor}-{resolution_type}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc' - '{platform_name}-{sensor}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc' + - '{filename}.nc' From fd2669eacdd4a17a58fc0be787841fb7ac65db53 Mon Sep 17 00:00:00 2001 From: BENR0 Date: Mon, 22 Aug 2022 10:21:27 +0200 Subject: [PATCH 4/7] refactor: remove adding instrument to root attrs --- satpy/writers/cf_writer.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/satpy/writers/cf_writer.py b/satpy/writers/cf_writer.py index 4eb0896aab..19aed171e5 100644 --- a/satpy/writers/cf_writer.py +++ b/satpy/writers/cf_writer.py @@ -822,9 +822,6 @@ def save_datasets(self, datasets, filename=None, groups=None, header_attrs=None, header_attrs = flatten_dict(header_attrs) root.attrs = encode_attrs_nc(header_attrs) - # Add header attributes needed for satpy_cf_reader - root.attrs["instrument"] = datasets[0].attrs["sensor"] - _history_create = 'Created by pytroll/satpy on {}'.format(datetime.utcnow()) if 'history' in root.attrs: if isinstance(root.attrs['history'], list): From 612b7380cb66cdf0ec0bb30066c25f8a328828fc Mon Sep 17 00:00:00 2001 From: BENR0 Date: Mon, 22 Aug 2022 10:38:27 +0200 Subject: [PATCH 5/7] fix: remove unnecessary code introduced by merge --- satpy/writers/cf_writer.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/satpy/writers/cf_writer.py b/satpy/writers/cf_writer.py index 19aed171e5..6b3584d672 100644 --- a/satpy/writers/cf_writer.py +++ b/satpy/writers/cf_writer.py @@ -822,14 +822,6 @@ def save_datasets(self, datasets, filename=None, groups=None, header_attrs=None, header_attrs = flatten_dict(header_attrs) root.attrs = encode_attrs_nc(header_attrs) - _history_create = 'Created by pytroll/satpy on {}'.format(datetime.utcnow()) - if 'history' in root.attrs: - if isinstance(root.attrs['history'], list): - root.attrs['history'] = ''.join(root.attrs['history']) - root.attrs['history'] += '\n' + _history_create - else: - root.attrs['history'] = _history_create - _set_history(root) # Remove satpy-specific kwargs From c9476f505b092e1babb990293f33d1134ae2255d Mon Sep 17 00:00:00 2001 From: BENR0 Date: Mon, 22 Aug 2022 17:31:44 +0200 Subject: [PATCH 6/7] fix: add reader name to test --- satpy/tests/test_readers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satpy/tests/test_readers.py b/satpy/tests/test_readers.py index 6a30ba09fa..0d92af9bc3 100644 --- a/satpy/tests/test_readers.py +++ b/satpy/tests/test_readers.py @@ -719,7 +719,7 @@ def test_no_reader(self): # without files it's going to be an empty result assert group_files([]) == [] - groups = group_files(self.g16_files) + groups = group_files(self.g16_files, reader='abi_l1b') self.assertEqual(6, len(groups)) def test_unknown_files(self): From a3af13d0371c7e003e0c9ef3fff2b0db8b3e27f3 Mon Sep 17 00:00:00 2001 From: BENR0 Date: Thu, 25 May 2023 14:27:42 +0200 Subject: [PATCH 7/7] refactor: change filename to stem --- satpy/etc/readers/satpy_cf_nc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satpy/etc/readers/satpy_cf_nc.yaml b/satpy/etc/readers/satpy_cf_nc.yaml index bdc216b3d3..8814c0437b 100644 --- a/satpy/etc/readers/satpy_cf_nc.yaml +++ b/satpy/etc/readers/satpy_cf_nc.yaml @@ -17,4 +17,4 @@ file_types: file_patterns: - '{platform_name}-{sensor}-{resolution_type}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc' - '{platform_name}-{sensor}-{start_time:%Y%m%d%H%M%S}-{end_time:%Y%m%d%H%M%S}.nc' - - '{filename}.nc' + - '{stem}.nc'