-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_bind_correlatefield.py
74 lines (51 loc) · 1.85 KB
/
simple_bind_correlatefield.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import subprocess
import xarray
import datetime
import json
from pprint import pprint
###
# input
inputfile = 'inputs.json' #opendap
inputfile = 'inputs_local.json'
with open(inputfile, 'r') as fp:
inputs = json.load(fp)
pprint(inputs)
###
# binding
#
sourceA = inputs["netcdf_source1"]["default"] # field
sourceB = inputs["netcdf_source2"]["default"] # time series
freq = inputs["frequency"]["default"] # mon
ratio = inputs["ratio"]["default"]
ave = inputs["average"]["default"]
var = inputs["var"]["default"]
target = inputs["netcdf_target"]["default"]
script = '../Fortran/build/correlatefield '+sourceA+' '+sourceB+' '+freq+' '+ratio+' '+ave+' '+var+' '+str(target)
print script
try:
process = subprocess.Popen( script , shell=True).communicate()
print str(process)
except Exception, e:
print "Popen process failed: "+script
raise e
#,stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE
#outs, errs = process.communicate()
#callback(24,info="errs: "+errs)
#process.wait()
# /usr/people/mihajlov/climexp/
# VIEW with ncview out.nc
####
# metadata
# #
#ncout = xarray.open_dataset('out.nc')
#print(ncout)
#ncout = xarray.Dataset(target,'a')
# ''' metadata appended, inspire worthy '''
# ncout.setncattr( "title" , "KNMI Climate Explorer correlate field service output" )
# ncout.setncattr( "summary" , "KNMI Climate Explorer correlate field service output "+sourceA+" for "+sourceB )
# ncout.setncattr( "keywords" , "climate,correlation,wps_knmi" )
# ncout.setncattr( "institute_id" , "KNMI" )
# ncout.setncattr( "contact" , "[email protected]" )
# ncout.setncattr( "date_created" , datetime.now().isoformat() )
# ncout.setncattr( "knmi_wps" , self.structure["identifier"] )
# ncout.setncattr( "software" , 'https://github.com/andrejsim/ClimExp-pyapi' )