You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@climate.apache.org by "Ross Laidlaw (JIRA)" <ji...@apache.org> on 2014/11/03 19:11:33 UTC
[jira] [Commented] (CLIMATE-543) Port 'calcNashSutcliff' method
over to ocw/metrics.py module
[ https://issues.apache.org/jira/browse/CLIMATE-543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14194813#comment-14194813 ]
Ross Laidlaw commented on CLIMATE-543:
--------------------------------------
It looks like the {{calcNashSutcliff}} method could be ported directly over to the new metrics.py module without requiring any refactoring:
{code}
def calcNashSutcliff(evaluationData, referenceData):
# Flatten the spatial dimensions
data1 = evaluationData[:]
data2 = referenceData[:]
nT = data1.shape[0]
data1.shape = nT, data1.size / nT
data2.shape = nT, data2.size / nT
meanData2 = data2.mean(axis = 1)
# meanData2 must be reshaped to 2D as to obey numpy broadcasting rules
meanData2.shape = nT, 1
nashcor = 1 - ((((data2 - data1) ** 2).sum(axis = 1)) /
(((data2 - meanData2) ** 2).sum(axis = 1)))
return nashcor
{code}
This could become:
{code}
class NashSutcliff(BinaryMetric):
def run(self, eval_dataset, ref_dataset):
# Flatten the spatial dimensions
data1 = eval_dataset.values[:]
data2 = ref_dataset.values[:]
nT = data1.shape[0]
data1.shape = nT, data1.size / nT
data2.shape = nT, data2.size / nT
meanData2 = data2.mean(axis=1)
# meanData2 must be reshaped to 2D as to obey numpy broadcasting rules
meanData2.shape = nT, 1
nashcor = 1 - ((((data2 - data1) ** 2).sum(axis=1)) /
(((data2 - meanData2) ** 2).sum(axis=1)))
return nashcor
{code}
> Port 'calcNashSutcliff' method over to ocw/metrics.py module
> ------------------------------------------------------------
>
> Key: CLIMATE-543
> URL: https://issues.apache.org/jira/browse/CLIMATE-543
> Project: Apache Open Climate Workbench
> Issue Type: Sub-task
> Components: metrics
> Affects Versions: 0.4
> Reporter: Ross Laidlaw
> Assignee: Ross Laidlaw
> Fix For: 0.5
>
>
> Port this method over from rcmet/src/main/python/rcmes/toolkit/metrics_kyo.py to ocw/metrics.py.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)