@@ -25,29 +25,31 @@ def finalise(self, *args, **kwargs):
25
25
pass
26
26
27
27
28
- class FileOutput (Output ):
28
+ class FileOutputBase (Output ):
29
29
def __init__ (self , owner , path , metadata , ** kwargs ):
30
30
self ._first = True
31
31
metadata .setdefault ("stream" , "oper" )
32
32
metadata .setdefault ("expver" , owner .expver )
33
33
metadata .setdefault ("class" , "ml" )
34
34
35
- LOG .info ("Writing results to %s." , path )
36
35
self .path = path
37
36
self .owner = owner
38
37
self .metadata = metadata
39
38
40
39
@cached_property
41
- def output (self ):
42
-
40
+ def grib_keys (self ):
43
41
edition = self .metadata .pop ("edition" , 2 )
44
42
45
- self . grib_keys = dict (
43
+ _grib_keys = dict (
46
44
edition = edition ,
47
45
generatingProcessIdentifier = self .owner .version ,
48
46
)
49
- self .grib_keys .update (self .metadata )
47
+ _grib_keys .update (self .metadata )
48
+
49
+ return _grib_keys
50
50
51
+ @cached_property
52
+ def output (self ):
51
53
return cml .new_grib_output (
52
54
self .path ,
53
55
split_output = True ,
@@ -91,6 +93,20 @@ def write(self, data, *args, check=False, **kwargs):
91
93
return handle , path
92
94
93
95
96
+ class FileOutput (FileOutputBase ):
97
+ def __init__ (self , * args , ** kwargs ):
98
+ super ().__init__ (* args , ** kwargs )
99
+ LOG .info ("Writing results to %s" , self .path )
100
+
101
+
102
+ class NoneOutput (Output ):
103
+ def __init__ (self , * args , ** kwargs ):
104
+ LOG .info ("Results will not be written." )
105
+
106
+ def write (self , * args , ** kwargs ):
107
+ pass
108
+
109
+
94
110
class HindcastReLabel :
95
111
def __init__ (self , owner , output , hindcast_reference_year = None , hindcast_reference_date = None , ** kwargs ):
96
112
self .owner = owner
@@ -151,14 +167,6 @@ def write(self, *args, **kwargs):
151
167
return self .output .write (* args , ** kwargs )
152
168
153
169
154
- class NoneOutput (Output ):
155
- def __init__ (self , * args , ** kwargs ):
156
- LOG .info ("Results will not be written." )
157
-
158
- def write (self , * args , ** kwargs ):
159
- pass
160
-
161
-
162
170
def get_output (name , owner , * args , ** kwargs ):
163
171
result = available_outputs ()[name ].load ()(owner , * args , ** kwargs )
164
172
if kwargs .get ("hindcast_reference_year" ) is not None or kwargs .get ("hindcast_reference_date" ) is not None :
0 commit comments