-
Notifications
You must be signed in to change notification settings - Fork 2
/
tos.py
53 lines (40 loc) · 1.38 KB
/
tos.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
43
44
45
46
47
48
49
50
51
52
53
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, Tuple, Union
import os.path as path
@supported_variable
class Tos:
realm = "o"
@preprocessing(Tos, "BRIDGE")
def preprocessing_1(
inputs: List[Tuple[str, str]], output_directory: str
) -> List[Tuple[str, str]]:
file, var = inputs[0]
name = path.basename(file).replace(".nc", ".out.nc")
output = path.join(output_directory, name)
cdo.sellonlatbox("-180,180,90,-90", input=f"-selvar,{var} {file}", output=output)
return [(output, var)]
# SST data is not saved in annual mean data,
# so we need to calculate the annual mean from monthly data
@preprocessing(Tos, "BRIDGE-monthly-to-annual")
def preprocessing_2(
inputs: List[Tuple[str, str]], output_directory: str
) -> List[Tuple[str, str]]:
file, var = inputs[0]
name = path.basename(file).replace(".nc", ".out.nc")
output = path.join(output_directory, name)
cdo.sellonlatbox(
"-180,180,90,-90", input=f" -yearmean -selvar,{var} {file}", output=output
)
return [(output, var)]