From 9f4274fd7312b01bc90790f91a6818103e1afe15 Mon Sep 17 00:00:00 2001
From: Carsten Hinz <c.hinz@fz-juelich.de>
Date: Mon, 27 May 2024 16:59:08 +0200
Subject: [PATCH] made toargridding version an dynamic global_cf_attributes
 version is now taken from pyproject.toml

added *swp files to ignore
---
 .gitignore                                             | 1 +
 toargridding/metadata.py                               | 3 +++
 toargridding/static_metadata/global_cf_attributes.json | 1 -
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 0803825..22a85bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ data/
 tests/results
 tests/temp_data_cache/
 notTracked/
+*.swp
diff --git a/toargridding/metadata.py b/toargridding/metadata.py
index 627f116..6085adf 100644
--- a/toargridding/metadata.py
+++ b/toargridding/metadata.py
@@ -10,6 +10,8 @@ from toargridding.static_metadata import global_cf_attributes, TOARVariable
 
 from typing import Dict
 
+import importlib.metadata
+
 date_created = datetime.utcnow().strftime("%Y-%m-dT%H:%M:%SZ")
 #date_created = datetime.now(datetime.UTC).strftime("%Y-%m-dT%H:%M:%SZ") # fix as utcnow will be removed in the future
 
@@ -204,6 +206,7 @@ def get_global_attributes(metadata: Metadata) -> Dict:
         "time_coverage_end": metadata.time.end.isoformat(),
         # "time_coverage_duration": 0, # TODO insert durations
         # "time_coverage_resolution": 0,
+        "product_version": f"version of toargridding {importlib.metadata.version( __package__ or __name__ )}",
     }
     for key, value in metadata.moreOptions.items():
         if not key in dynamic_cf_attributes:
diff --git a/toargridding/static_metadata/global_cf_attributes.json b/toargridding/static_metadata/global_cf_attributes.json
index c6a177c..bab7e03 100644
--- a/toargridding/static_metadata/global_cf_attributes.json
+++ b/toargridding/static_metadata/global_cf_attributes.json
@@ -18,7 +18,6 @@
     "creator_type": "institution",
     "creator_institution": "The Tropospheric Ozone Assessment Report (TOAR) Data Centre, Research Centre Jülich, Jülich, Germany",
     "publisher_type": "institution",
-    "product_version": "version of toargridding ?",
     "references": "https://toar-data.fz-juelich.de/",
     "license": "CC-BY 4",
     "acknowledgment": "This project was funded by the EU’s ERC programme, Grant Agreement 78576. This work is part of the Tropospheric Ozone Assessment Report (TOAR) which was supported by the International Global Atmospheric Chemistry (IGAC) project, the National Oceanic and Atmospheric Administration (NOAA), Forschungszentrum Jülich, and the World Meteorological Organisation (WMO). Many institutions and agencies supported the implementation of the measurements, and the processing, quality assurance, and submission of the data contained in the TOAR database"
-- 
GitLab