-
Notifications
You must be signed in to change notification settings - Fork 2
/
currents.py
42 lines (34 loc) · 1.17 KB
/
currents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if __name__ == "__main__":
from supported_variables.utils.supported_variable import (
supported_variable,
preprocessing,
)
import utils.utils as utils
else:
from supported_variables.utils.supported_variable import (
supported_variable,
preprocessing,
)
import supported_variables.utils.utils as utils
from utils.import_cdo import cdo
from typing import List, Union, Tuple
import os.path as path
@supported_variable
class Currents:
realm = "o"
@preprocessing(Currents, "BRIDGE")
def preprocessing(
inputs: List[Tuple[str, str]], output_directory: str
) -> List[Tuple[str, str]]:
outputs = []
u_file, u_var = inputs[0]
v_file, v_var = inputs[1]
name = path.basename(u_file).replace(".nc", ".u.out.nc")
out = path.join(output_directory, name)
cdo.sellonlatbox("-180,180,90,-90", input = f"-selvar,{u_var} {u_file}", output=out)
outputs.append((out, u_var))
name = path.basename(v_file).replace(".nc", ".v.out.nc")
out = path.join(output_directory, name)
cdo.sellonlatbox("-180,180,90,-90", input = f"-selvar,{v_var} {v_file}", output=out)
outputs.append((out, v_var))
return outputs