From ff3f73a7b84e6284afc3fd48ed26678364c49eaf Mon Sep 17 00:00:00 2001
From: Carsten Hinz <c.hinz@fz-juelich.de>
Date: Wed, 15 May 2024 15:53:31 +0200
Subject: [PATCH] changed ID and filename creation to include variable names

added type_of_area for separation of stations
---
 tests/get_sample_data.ipynb           | 2 +-
 tests/produce_data_withOptional.ipynb | 8 ++++++--
 toargridding/toar_rest_client.py      | 4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tests/get_sample_data.ipynb b/tests/get_sample_data.ipynb
index 1d244c9..32962c2 100644
--- a/tests/get_sample_data.ipynb
+++ b/tests/get_sample_data.ipynb
@@ -20,7 +20,7 @@
     "time = TimeSample(start, end, sampling=sampling)\n",
     "# { \"station_type_of_area\" : \"urban\" } category is not known\n",
     "#metadata = Metadata.construct(\"mole_fraction_of_ozone_in_air\", time, statistic, { \"toar1_category\" : \"RuralLowElevation\"})#\n",
-    "metadata = Metadata.construct(\"mole_fraction_of_ozone_in_air\", time, statistic, { \"type_of_area\" : \"Urban\" })\n",
+    "metadata = Metadata.construct(\"mole_fraction_of_ozone_in_air\", time, statistic, { \"type_of_area\" : \"Urban\" })#also test Rural, Suburban,\n",
     "\n",
     "start_time = datetime.now()\n",
     "print(start_time)"
diff --git a/tests/produce_data_withOptional.ipynb b/tests/produce_data_withOptional.ipynb
index 5450e57..5dd1600 100644
--- a/tests/produce_data_withOptional.ipynb
+++ b/tests/produce_data_withOptional.ipynb
@@ -31,16 +31,20 @@
     "#see page 18 in https://toar-data.fz-juelich.de/sphinx/TOAR_UG_Vol03_Database/build/latex/toardatabase--userguide.pdf\n",
     "\n",
     "details4Query ={\n",
-    "    \"toar1_category\" : \"Urban\" #uncomment if wished:-)\n",
+    "    #\"toar1_category\" : \"Urban\" #uncomment if wished:-)\n",
     "    #\"toar1_category\" : \"RuralLowElevation\" #uncomment if wished:-)\n",
     "    #\"toar1_category\" : \"RuralHighElevation\" #uncomment if wished:-)\n",
+    "    #\"type_of_area\" : \"Urban\" #also test Rural, Suburban,\n",
+    "    \"type_of_area\" : \"Rural\" #also test Rural, Suburban,\n",
+    "    #\"type_of_area\" : \"Suburban\" #also test Rural, Suburban,\n",
     "}\n",
     "\n",
     "valid_data = Config(\n",
     "    RegularGrid( lat_resolution=1.9, lon_resolution=2.5, ),\n",
     "    TimeSample( start=dt(2000,1,1), end=dt(2019,12,31), sampling=\"daily\"),#possibly adopt range:-)\n",
     "    [\"mole_fraction_of_ozone_in_air\"],#variable name\n",
-    "    [ \"mean\", \"dma8epax\"],# will start one request after another other...\n",
+    "    #[ \"mean\", \"dma8epax\"],# will start one request after another other...\n",
+    "    [ \"dma8epa_strict\" ],\n",
     "    details4Query\n",
     ")\n",
     "\n",
diff --git a/toargridding/toar_rest_client.py b/toargridding/toar_rest_client.py
index 9c7ff53..c1faa15 100644
--- a/toargridding/toar_rest_client.py
+++ b/toargridding/toar_rest_client.py
@@ -74,7 +74,7 @@ class QueryOptions:
     def cache_key(self):
         """creation to identify the request in the cache of known request.
         """
-        return "".join(asdict(self, dict_factory=quarryToDict).values())
+        return "".join(f"{key}{val}" for key, val  in asdict(self, dict_factory=quarryToDict).items())
 
 
 def quarryToDict(data : QueryOptions):
@@ -494,5 +494,5 @@ class AnalysisServiceDownload(AnalysisService):
         metadata:
             metadata for the request.
         """
-        addition = "_".join(str(i) for i in sorted(metadata.moreOptions.values()))
+        addition = "_".join(f"{key}{val}" for key,val in sorted(metadata.moreOptions).items())
         return "_".join(str(i) for i in [metadata.statistic, metadata.time.sampling, metadata.variable.cf_standardname, metadata.time.start.date(), metadata.time.end.date(), addition]) + ".zip"
-- 
GitLab