@@ -90,23 +90,27 @@ def applyOperation( self, input_variable, operation ):
90
90
self .setTimeBounds ( input_variable )
91
91
operator = None
92
92
# pydevd.settrace('localhost', port=8030, stdoutToServer=False, stderrToServer=True)
93
+ wpsLog .debug ( " $$$ ApplyOperation: %s " % str ( operation ) )
93
94
if operation is not None :
94
95
type = operation .get ('type' ,'' ).lower ()
95
96
bounds = operation .get ('bounds' ,'' ).lower ()
96
97
op_start_time = time .clock () # time.time()
97
- wpsLog .debug ( "applyOperation: %s " % str ( [operation , type , bounds ] ) )
98
98
if not bounds :
99
99
if type == 'departures' :
100
100
ave = cdutil .averager ( input_variable , axis = 't' , weights = 'equal' )
101
101
result = input_variable - ave
102
102
elif type == 'climatology' :
103
103
result = cdutil .averager ( input_variable , axis = 't' , weights = 'equal' )
104
+ else :
105
+ result = input_variable
104
106
time_axis = input_variable .getTime ()
105
107
elif bounds == 'np' :
106
108
if type == 'departures' :
107
109
result = ma .anomalies ( input_variable ).squeeze ()
108
110
elif type == 'climatology' :
109
111
result = ma .average ( input_variable ).squeeze ()
112
+ else :
113
+ result = input_variable
110
114
time_axis = input_variable .getTime ()
111
115
else :
112
116
if bounds == 'djf' : operator = cdutil .DJF
@@ -119,14 +123,21 @@ def applyOperation( self, input_variable, operation ):
119
123
if operator <> None :
120
124
if type == 'departures' : result = operator .departures ( input_variable ).squeeze ()
121
125
elif type == 'climatology' : result = operator .climatology ( input_variable ).squeeze ()
126
+ else : result = operator ( input_variable ).squeeze ()
122
127
time_axis = result .getTime ()
123
128
op_end_time = time .clock () # time.time()
124
129
wpsLog .debug ( " ---> Base Operation Time: %.5f" % (op_end_time - op_start_time ) )
130
+ else :
131
+ result = input_variable
132
+ time_axis = input_variable .getTime ()
125
133
126
134
if isinstance ( result , float ):
127
135
result_data = [ result ]
128
- else :
129
- result_data = result .tolist ( numpy .nan ) if result is not None else None
136
+ elif result is not None :
137
+ if result .__class__ .__name__ == 'TransientVariable' :
138
+ result = ma .masked_equal ( result .squeeze ().getValue (), input_variable .getMissing () )
139
+ result_data = result .tolist ( numpy .nan )
140
+ else : result_data = None
130
141
except Exception , err :
131
142
wpsLog .debug ( "Exception applying Operation '%s':\n %s" % ( str (operation ), traceback .format_exc () ) )
132
143
return ( None , None )
@@ -159,16 +170,18 @@ def setTimeBounds( self, var ):
159
170
variables = [ { 'url' : 'file://usr/local/web/data/MERRA/u750/merra_u750.xml' , 'id' : 'u' },
160
171
{ 'url' : 'file://usr/local/web/data/MERRA/MERRA100.xml' , 'id' : 't' },
161
172
{ 'url' : 'file://usr/local/web/data/MERRA/u750/merra_u750.nc' , 'id' : 'u' },
162
- { 'url' : 'file://usr/local/web/data/MERRA/u750/merra_u750_1979_1982.nc' , 'id' : 'u' } ]
163
- var_index = 2
173
+ { 'url' : 'file://usr/local/web/data/MERRA/u750/merra_u750_1979_1982.nc' , 'id' : 'u' },
174
+ { 'url' : 'file://usr/local/web/WPCDAS/data/TestData.nc' , 'id' : 't' } ]
175
+ var_index = 4
164
176
domain = { 'latitude' : - 18.2 , 'longitude' : - 134.6 }
165
177
operations = [ { 'type' : 'departures' , 'bounds' : 'annualcycle' },
166
178
{ 'type' : 'departures' , 'bounds' : '' },
167
179
{ 'type' : 'climatology' , 'bounds' : 'annualcycle' },
168
180
{ 'type' : 'climatology' , 'bounds' : '' },
169
181
{ 'type' : 'departures' , 'bounds' : 'np' },
170
- { 'type' : 'climatology' , 'bounds' : 'np' } ]
171
- operation_index = 3
182
+ { 'type' : 'climatology' , 'bounds' : 'np' },
183
+ { 'type' : '' , 'bounds' : '' } ]
184
+ operation_index = 6
172
185
173
186
processor = TimeseriesAnalytics ( variables [var_index ] )
174
187
result = processor .execute ( operations [operation_index ], domain )
0 commit comments