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

Ross Laidlaw commented on CLIMATE-341:
--------------------------------------

Looking at owc/utils.py, it looks like this might already be covered by the 
'calc_climatology_season' method:

{code}
def calc_climatology_season(month_start, month_end, dataset):
    ''' Calculate seasonal mean and time series for given months.

    :param month_start: An integer for beginning month (Jan=1)
    :type month_start: Integer
    :param month_end: An integer for ending month (Jan=1)
    :type month_end: Integer
    :param dataset: Dataset object with full-year format
    :type dataset: ocw.dataset.Dataset object

    :returns:  
        t_series - monthly average over the given season
        means - mean over the entire season
    :rtype: A tuple of two numpy arrays
    '''

    if month_start > month_end:
        # Offset the original array so that the the first month
        # becomes month_start
        # note that this cuts off the first year of data
        offset = slice(month_start - 1, month_start - 13)
        reshape_data = reshape_monthly_to_annually(dataset[offset])
        month_index = slice(0, 13 - month_start + month_end)
    else:
        # Since month_start <= month_end
        # just take a slice containing those months
        reshape_data = reshape_monthly_to_annually(dataset)
        month_index = slice(month_start - 1, month_end)
    
    t_series = reshape_data[:, month_index].mean(axis=1)
    means = t_series.mean(axis=0)
    return t_series, means
{code}

> 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: Ross Laidlaw
>             Fix For: 0.5
>
>
> 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.3.4#6332)

Reply via email to