From commits-return-2873-archive-asf-public=cust-asf.ponee.io@climate.apache.org Wed Aug 1 07:28:11 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 496D9180634 for ; Wed, 1 Aug 2018 07:28:11 +0200 (CEST) Received: (qmail 86414 invoked by uid 500); 1 Aug 2018 05:28:10 -0000 Mailing-List: contact commits-help@climate.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@climate.apache.org Delivered-To: mailing list commits@climate.apache.org Received: (qmail 86405 invoked by uid 99); 1 Aug 2018 05:28:09 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2018 05:28:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D014ADFA6D; Wed, 1 Aug 2018 05:28:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lewismc@apache.org To: commits@climate.apache.org Date: Wed, 01 Aug 2018 05:28:09 -0000 Message-Id: <7efea8b761ec44f891bc39572e13933b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/4] climate git commit: include absolute bias Repository: climate Updated Branches: refs/heads/master 7cdaa7c0c -> cf3ef6015 include absolute bias Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/4fd7d491 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/4fd7d491 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/4fd7d491 Branch: refs/heads/master Commit: 4fd7d4916f12757434fe4494940aac064ca24852 Parents: 3a80408 Author: Prateek Chanda Authored: Sat Jun 23 22:25:12 2018 +0530 Committer: GitHub Committed: Sat Jun 23 22:25:12 2018 +0530 ---------------------------------------------------------------------- ocw/metrics.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/4fd7d491/ocw/metrics.py ---------------------------------------------------------------------- diff --git a/ocw/metrics.py b/ocw/metrics.py index 3a6477e..b266012 100644 --- a/ocw/metrics.py +++ b/ocw/metrics.py @@ -281,6 +281,29 @@ def calc_bias(target_array, reference_array, average_over_time=False): return ma.average(bias, axis=0) else: return bias + + +def calc_absbias(target_array, reference_array, average_over_time=False): + ''' Calculate absolute difference between two arrays + + :param target_array: an array to be evaluated, as model output + :type target_array: :class:'numpy.ma.core.MaskedArray' + + :param reference_array: an array of reference dataset + :type reference_array: :class:'numpy.ma.core.MaskedArray' + + :param average_over_time: if True, calculated bias is averaged for the axis=0 + :type average_over_time: 'bool' + + :returns: Absolute Biases array of the target dataset + :rtype: :class:'numpy.ma.core.MaskedArray' + ''' + + bias = abs(target_array - reference_array) + if average_over_time: + return ma.average(bias, axis=0) + else: + return bias def calc_stddev(array, axis=None):