-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_stat_monthly.py
36 lines (33 loc) · 1.05 KB
/
data_stat_monthly.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
import os
import re
import subprocess as sp
import time
import process_helper as ph
processes = ph.ProcessCounter(16)
#stats = ['max','min','mean']
stats = ['vmean']
in_dir = '/scratch/project_2001635/siiriasi/smartsea_data/syke_test/'
for stat in stats:
cdo_oper = {\
'max':'timmax',
'min':'timmin',
'mean':'timmean',
'vmax':'vertmax',
'vmin':'vertmin',
'vmean':'vertmean'
}
out_dir = '/scratch/project_2001635/siiriasi/smartsea_data/syke_test/{}/'.format(stat)
in_files = ph.get_file_list(in_dir,".*nc")
for f in in_files:
f_name_no_ext = re.search("^([^\.]*)",f).groups()[0]
f_extension = re.search("([^\.]*)$",f).groups()[0]
f_out_name = "{}_monthly_{}.{}".format(\
f_name_no_ext,\
stat,\
f_extension)
the_command = "cdo {} {}/{} {}/{}".format(\
cdo_oper[stat], \
in_dir, f, \
out_dir, f_out_name)
processes.add(the_command)
print("All done!")