scriptengine-tasks-ecearth 0.10.0__tar.gz → 0.10.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/PKG-INFO +1 -1
  2. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/cubes.py +27 -1
  3. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/map.py +5 -0
  4. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/temporalmap.py +6 -0
  5. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/timeseries.py +10 -0
  6. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/pyproject.toml +1 -1
  7. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/PKG-INFO +1 -1
  8. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_map.py +3 -2
  9. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_timeseries.py +41 -0
  10. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/LICENSE +0 -0
  11. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/README.md +0 -0
  12. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/__init__.py +0 -0
  13. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/dates.py +0 -0
  14. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/exceptions.py +0 -0
  15. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/files.py +0 -0
  16. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/map_type_handling.py +0 -0
  17. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/nemo.py +0 -0
  18. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/helpers/presentation_objects.py +0 -0
  19. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/diskusage_rte_scalar.py +0 -0
  20. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/gitlab.py +0 -0
  21. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/linear_combination.py +0 -0
  22. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/markdown.py +0 -0
  23. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/nemo_all_mean_map.py +0 -0
  24. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/nemo_time_mean_temporalmap.py +0 -0
  25. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/nemo_timeseries.py +0 -0
  26. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/oifs_all_mean_map.py +0 -0
  27. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/oifs_timeseries.py +0 -0
  28. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/oifs_year_mean_temporalmap.py +0 -0
  29. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/redmine.py +0 -0
  30. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/scalar.py +0 -0
  31. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/si3_hemis_point_month_mean_all_mean_map.py +0 -0
  32. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/si3_hemis_point_month_mean_temporalmap.py +0 -0
  33. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/si3_hemis_sum_month_mean_timeseries.py +0 -0
  34. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/monitoring/simulatedyears_rte_scalar.py +0 -0
  35. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/SOURCES.txt +0 -0
  36. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/dependency_links.txt +0 -0
  37. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/entry_points.txt +0 -0
  38. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/requires.txt +0 -0
  39. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/scriptengine_tasks_ecearth.egg-info/top_level.txt +0 -0
  40. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/setup.cfg +0 -0
  41. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/setup.py +0 -0
  42. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_cubes.py +0 -0
  43. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_dates.py +0 -0
  44. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_diskusage_rte_scalar.py +0 -0
  45. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_file_handling.py +0 -0
  46. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_gitlab.py +0 -0
  47. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_linear_combination.py +0 -0
  48. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_map_type_handling.py +0 -0
  49. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_markdown.py +0 -0
  50. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_nemo_all_mean_map.py +0 -0
  51. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_nemo_time_mean_temporalmap.py +0 -0
  52. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_nemo_timeseries.py +0 -0
  53. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_oifs_all_mean_map.py +0 -0
  54. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_oifs_timeseries.py +0 -0
  55. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_oifs_year_mean_temporalmap.py +0 -0
  56. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_presentation_objects.py +0 -0
  57. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_redmine.py +0 -0
  58. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_scalar.py +0 -0
  59. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_si3_hemis_point_month_mean_all_mean_map.py +0 -0
  60. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_si3_hemis_point_month_mean_temporalmap.py +0 -0
  61. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_si3_hemis_sum_month_mean_timeseries.py +0 -0
  62. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_simulatedyears_rte_scalar.py +0 -0
  63. {scriptengine_tasks_ecearth-0.10.0 → scriptengine_tasks_ecearth-0.10.1}/tests/test_temporalmap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptengine-tasks-ecearth
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: ScriptEngine tasks for use with the EC-Earth climate model
5
5
  Author-email: Valentina Schueller <valentina.schueller@gmail.com>, Uwe Fladrich <uwe.fladrich@protonmail.com>
6
6
  Project-URL: Homepage, https://github.com/uwefladrich/scriptengine-tasks-ecearth
@@ -7,7 +7,10 @@ import iris.analysis.cartography
7
7
  import iris.cube
8
8
  import numpy as np
9
9
  from iris.util import equalise_attributes
10
- from scriptengine.exceptions import ScriptEngineTaskArgumentInvalidError
10
+ from scriptengine.exceptions import (
11
+ ScriptEngineTaskArgumentInvalidError,
12
+ ScriptEngineTaskRunError,
13
+ )
11
14
 
12
15
  from helpers.dates import month_number
13
16
  from helpers.nemo import remove_unique_attributes
@@ -201,3 +204,26 @@ def compute_regular_grid_weights(cube):
201
204
  cube.coord("latitude").guess_bounds()
202
205
  cube.coord("longitude").guess_bounds()
203
206
  return iris.analysis.cartography.area_weights(cube)
207
+
208
+
209
+ def align_time_coords(new_cube, old_cube):
210
+ """
211
+ Align the time coordinates in two cubes.
212
+ Useful if one cube has time in units seconds since 1990-01-01 00:00:00
213
+ while the other has seconds since 1995-01-01 00:00:00.
214
+ Iris can not concatenate two such cubes.
215
+ """
216
+
217
+ old_time_coord = old_cube.coord("time")
218
+
219
+ new_cube.coord("time").convert_units(old_time_coord.units)
220
+
221
+ # We also need to match the attribute time_origin between
222
+ # new_cube and current_cube to make Iris happy.
223
+ # Note: This does not always exist
224
+ if "time_origin" in old_cube.coord("time").attributes.keys():
225
+ new_cube.coord("time").attributes["time_origin"] = old_cube.coord(
226
+ "time"
227
+ ).attributes["time_origin"]
228
+
229
+ return new_cube
@@ -1,4 +1,5 @@
1
1
  """Base class for map processing tasks."""
2
+
2
3
  from pathlib import Path
3
4
  from tempfile import NamedTemporaryFile
4
5
 
@@ -26,6 +27,10 @@ class Map(Task):
26
27
  iris.save(new_cube, str(dst))
27
28
  return
28
29
 
30
+ # align the time coordinates of current and new cube.
31
+ # Sets units and coordinate attributes to be the same
32
+ new_cube = helpers.cubes.align_time_coords(new_cube, current_cube)
33
+
29
34
  current_bounds = current_cube.coord("time").bounds
30
35
  new_bounds = new_cube.coord("time").bounds
31
36
  if current_bounds[-1][-1] > new_bounds[0][0]:
@@ -11,6 +11,8 @@ from scriptengine.exceptions import (
11
11
  )
12
12
  from scriptengine.tasks.core import Task
13
13
 
14
+ import helpers.cubes
15
+
14
16
 
15
17
  class Temporalmap(Task):
16
18
  """Temporalmap Processing Task"""
@@ -25,6 +27,10 @@ class Temporalmap(Task):
25
27
  iris.save(new_cube, dst)
26
28
  return
27
29
 
30
+ # set units and attribute for time coord to be the same
31
+ # in current_cube and new_cube
32
+ new_cube = helpers.cubes.align_time_coords(new_cube, current_cube)
33
+
28
34
  current_bounds = current_cube.coord("time").bounds
29
35
  new_bounds = new_cube.coord("time").bounds
30
36
  if current_bounds[-1][-1] > new_bounds[0][0]:
@@ -93,6 +93,16 @@ class Timeseries(Task):
93
93
  iris.save(new_cube, str(dst))
94
94
  return
95
95
 
96
+ # set units and attribute for time coord to be the same
97
+ # in current_cube and new_cube
98
+ # Only necessary when coordinate in time, not Leg etc.
99
+ try:
100
+ # Will work if time coordinate exists
101
+ new_cube = helpers.cubes.align_time_coords(new_cube, current_cube)
102
+ except iris.exceptions.CoordinateNotFoundError:
103
+ # Cube does not use "time" as its DimCoord
104
+ pass
105
+
96
106
  self.test_monotonic_increase(current_cube.coords()[0], new_cube.coords()[0])
97
107
 
98
108
  # Iris changes metadata when saving/loading cube
@@ -7,7 +7,7 @@
7
7
 
8
8
  [project]
9
9
  name = "scriptengine-tasks-ecearth"
10
- version = "0.10.0"
10
+ version = "0.10.1"
11
11
  authors = [
12
12
  { name = "Valentina Schueller", email = "valentina.schueller@gmail.com" },
13
13
  { name = "Uwe Fladrich", email = "uwe.fladrich@protonmail.com" },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptengine-tasks-ecearth
3
- Version: 0.10.0
3
+ Version: 0.10.1
4
4
  Summary: ScriptEngine tasks for use with the EC-Earth climate model
5
5
  Author-email: Valentina Schueller <valentina.schueller@gmail.com>, Uwe Fladrich <uwe.fladrich@protonmail.com>
6
6
  Project-URL: Homepage, https://github.com/uwefladrich/scriptengine-tasks-ecearth
@@ -1,4 +1,5 @@
1
1
  """Tests for monitoring/map.py"""
2
+
2
3
  from pathlib import Path
3
4
 
4
5
  import iris
@@ -21,10 +22,10 @@ def test_map_nonmonotonic_increase(tmp_path):
21
22
  test_map = Map({})
22
23
 
23
24
  old_coord_with_bounds = iris.coords.DimCoord(
24
- [1], bounds=[0.5, 1.5], var_name="time"
25
+ [1], bounds=[0.5, 1.5], var_name="time", units="seconds"
25
26
  )
26
27
  new_coord_with_bounds = iris.coords.DimCoord(
27
- [2], bounds=[1.5, 2.5], var_name="time"
28
+ [2], bounds=[1.5, 2.5], var_name="time", units="seconds"
28
29
  )
29
30
  old_cube = iris.cube.Cube([0], dim_coords_and_dims=[(old_coord_with_bounds, 0)])
30
31
  new_cube = iris.cube.Cube([0], dim_coords_and_dims=[(new_coord_with_bounds, 0)])
@@ -7,6 +7,7 @@ import iris
7
7
  import pytest
8
8
  import scriptengine.exceptions
9
9
 
10
+ import helpers.cubes
10
11
  from monitoring.timeseries import Timeseries
11
12
 
12
13
 
@@ -168,3 +169,43 @@ def test_time_series_date_time(tmp_path):
168
169
  assert cube.units.name == "1"
169
170
  assert cube.coord().name() == "time"
170
171
  assert cube.coord().units.name == "second since 1900-01-01 00:00:00.0000000 UTC"
172
+
173
+
174
+ def test_time_series_align(tmp_path):
175
+ seconds_value = (
176
+ datetime.datetime(1992, 1, 1) - datetime.datetime(1990, 1, 1)
177
+ ).total_seconds()
178
+ init_datetime1 = {
179
+ "title": "A date diagnostic",
180
+ "dst": str(tmp_path / "date_file1.nc"),
181
+ "data_value": 0,
182
+ "coord_value": 31536000,
183
+ "coord_unit": "seconds since 1990-01-01 00:00:00",
184
+ }
185
+ init_datetime2 = {
186
+ "title": "A date diagnostic",
187
+ "dst": str(tmp_path / "date_file2.nc"),
188
+ "data_value": 0,
189
+ "coord_value": 31536000,
190
+ "coord_unit": "seconds since 1991-01-01 00:00:00",
191
+ }
192
+ time_series1 = Timeseries(init_datetime1)
193
+ time_series2 = Timeseries(init_datetime2)
194
+ time_series1.run(init_datetime1)
195
+ time_series2.run(init_datetime2)
196
+
197
+ cube1 = iris.load_cube(init_datetime1["dst"])
198
+ cube2 = iris.load_cube(init_datetime2["dst"])
199
+ cube1.coord("time").attributes["time_origin"] = "1990-01-01 00:00:00"
200
+ cube2.coord("time").attributes["time_origin"] = "1991-01-01 00:00:00"
201
+
202
+ cube2 = helpers.cubes.align_time_coords(cube2, cube1)
203
+
204
+ print(cube1.coord("time").units.name)
205
+ print(cube2.coord("time").units.name)
206
+ assert (
207
+ cube2.coord("time").units.name
208
+ == "second since 1990-01-01 00:00:00.00000000 UTC"
209
+ )
210
+ assert cube2.coord("time").attributes["time_origin"] == "1990-01-01 00:00:00"
211
+ assert cube2.coord("time").points == [seconds_value]