File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 34
34
--job_name=compute-derived-variables-$USER
35
35
```
36
36
"""
37
+ import ast
37
38
from absl import app
38
39
from absl import flags
39
40
import apache_beam as beam
90
91
' "total_precipitation_6hr" for backwards compatibility.'
91
92
),
92
93
)
94
+ RENAME_VARIABLES = flags .DEFINE_string (
95
+ 'rename_variables' ,
96
+ None ,
97
+ help = (
98
+ 'Dictionary of variable to rename to standard names. E.g. {"2t":'
99
+ ' "2m_temperature"}'
100
+ ),
101
+ )
93
102
WORKING_CHUNKS = flag_utils .DEFINE_chunks (
94
103
'working_chunks' ,
95
104
'' ,
@@ -143,6 +152,17 @@ def main(argv: list[str]) -> None:
143
152
{RAW_TP_NAME .value : 'total_precipitation' }
144
153
)
145
154
155
+ rename_variables = (
156
+ ast .literal_eval (RENAME_VARIABLES .value )
157
+ if RENAME_VARIABLES .value
158
+ else None
159
+ )
160
+ if rename_variables :
161
+ source_dataset = source_dataset .rename (rename_variables )
162
+ source_chunks = {
163
+ rename_variables .get (k , k ): v for k , v in source_chunks .items ()
164
+ }
165
+
146
166
for var_name in PREEXISTING_VARIABLES_TO_REMOVE .value :
147
167
if var_name in source_dataset :
148
168
del source_dataset [var_name ]
You can’t perform that action at this time.
0 commit comments