ocw/utils.py
def calc_climatology_monthly(dataset):
    ''' Calculate monthly mean values for a dataset.
    Follow COARDS climo stats calculation, the year can be given as 0
    but the min year allowed in Python is 1
    http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology

    :param dataset: Monthly binned Dataset object with the number of months
        divisible by 12
    :type dataset: :class:`dataset.Dataset`

    :returns: Mean values for each month of the year of shape
              (12, num_lats, num_lons) and times array of datetime objects
              of length 12

    :raise ValueError: If the number of monthly bins is not divisible by 12
    '''

    if dataset.values.shape[0] % 12:
        error = (
            "The length of the time axis in the values array should be "
            "divisible by 12."
        )
        raise ValueError(error)
    else:
        values = reshape_monthly_to_annually(dataset).mean(axis=0)

        # A year can commence from any month
        first_month = dataset.times[0].month
        times = np.array([dt.datetime(1, first_month, 1) +
                          relativedelta(months=x)
                          for x in range(12)])
        return values, times
 Calculate monthly mean values for a dataset.
    Follow COARDS climo stats calculation, the year can be given as 0
    but the min year allowed in Python is 1
    http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology

    :param dataset: Monthly binned Dataset object with the number of months
        divisible by 12
    :type dataset: :class:`dataset.Dataset`

    :returns: Mean values for each month of the year of shape
              (12, num_lats, num_lons) and times array of datetime objects
              of length 12

    :raise ValueError: If the number of monthly bins is not divisible by 12
    
Calculate monthly mean values for a dataset.
Calculate monthly mean values for a dataset .
def calc_climatology_monthly(dataset):
    if dataset.values.shape[0] % 12:
        error = (
            "The length of the time axis in the values array should be "
            "divisible by 12."
        )
        raise ValueError(error)
    else:
        values = reshape_monthly_to_annually(dataset).mean(axis=0)
        first_month = dataset.times[0].month
        times = np.array([dt.datetime(1, first_month, 1) +
                          relativedelta(months=x)
                          for x in range(12)])
        return values, times
def calc_climatology_monthly ( dataset ) : if dataset . values . shape [ 0 ] % 12 : error = ( "The length of the time axis in the values array should be " "divisible by 12." ) raise ValueError ( error ) else : values = reshape_monthly_to_annually ( dataset ) . mean ( axis = 0 ) first_month = dataset . times [ 0 ] . month times = np . array ( [ dt . datetime ( 1 , first_month , 1 ) + relativedelta ( months = x ) for x in range ( 12 ) ] ) return values , times
Calculate monthly mean values for a dataset.
Calculate monthly mean values for a dataset .
''' Calculate monthly mean values for a dataset.
    Follow COARDS climo stats calculation, the year can be given as 0
    but the min year allowed in Python is 1
    http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology

    :param dataset: Monthly binned Dataset object with the number of months
        divisible by 12
    :type dataset: :class:`dataset.Dataset`

    :returns: Mean values for each month of the year of shape
              (12, num_lats, num_lons) and times array of datetime objects
              of length 12

    :raise ValueError: If the number of monthly bins is not divisible by 12
    ''' # A year can commence from any month
Mean values for each month of the year of shape
(12, num_lats, num_lons) and times array of datetime objects
of length 12
Mean values for each month of the year of shape ( 12 num_lats num_lons ) and times array of datetime objects of length 12
If the number of monthly bins is not divisible by 12
If the number of monthly bins is not divisible by 12
ValueError
dataset
Monthly binned Dataset object with the number of months
divisible by 12
Monthly binned Dataset object with the number of months divisible by 12