[ 
https://issues.apache.org/jira/browse/CLIMATE-341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13899770#comment-13899770
 ] 

Alex Goodman commented on CLIMATE-341:
--------------------------------------

Hi Mazi,

Since I am the one who refactored many of the functions in metrics to behave in 
that fashion, let me try and answer your questions:

1) Modifying the shape of an array with numpy does not require making a deep 
copy of the original as long as the the overall size of the array doesn't 
change. In fact, it is very easy to make shallow copies (or "views") of arrays 
with different shapes. Additionally, reshaping the data into this format makes 
the calculations on the arrays quite a bit faster since the arithmetic 
operations become "vectorized", ie numpy's functions are used which are derived 
from compiled C code instead of relying on slow Python loops. Because of how 
the original data are ordered, the reshaping operation should have no effect on 
the underlying data, and I have in fact tested this. Keep in mind these 
functions so far implicitly assume monthly data.

2) Again, since the original size of the arrays are maintained, it is very easy 
to return the output data to the shape of the input data. I don't see this 
being an issue with the new object oriented approach for metrics. Additionally, 
the (nYear, nMonth, nLat, nLon) shape format is used simply for computational 
convenience (as discussed above), so I don't see why a metric would need to 
return the data in both shapes, although keeping the original shape is better 
in case additional metrics are performed on the output data.

By the way, I hope all is well.

Alex

> Refactoring metric "calcAnnualCycleMeans"
> -----------------------------------------
>
>                 Key: CLIMATE-341
>                 URL: https://issues.apache.org/jira/browse/CLIMATE-341
>             Project: Apache Open Climate Workbench
>          Issue Type: Sub-task
>          Components: metrics
>    Affects Versions: 0.3-incubating
>            Reporter: Maziyar Boustani
>            Assignee: Maziyar Boustani
>             Fix For: 0.4-incubating
>
>
> Refactoring metric "calcAnnualCycleMeans" from [1] to new metrics [2].
> [1]: 
> https://svn.apache.org/repos/asf/incubator/climate/trunk/rcmet/src/main/python/rcmes/toolkit/metrics.py
> [2]:https://svn.apache.org/repos/asf/incubator/climate/trunk/ocw/metrics.py



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to