Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
Merge branch 'CLIMATE-953'
  • Loading branch information
huikyole committed Jun 17, 2018
2 parents aa7b8f4 + 8a6bd20 commit 434752cb5ef444d3097a2e447d1d6630175ce818
Showing 2 changed files with 19 additions and 1 deletion.
@@ -909,7 +909,7 @@ def deseasonalize_dataset(dataset):
:param dataset: The dataset to convert.
:type dataset: :class:`dataset.Dataset`
:returns: A Dataset with values converted to new units.
:returns: A Dataset with values deseasonalized.
:rtype: :class:`dataset.Dataset`

@@ -711,3 +711,21 @@ def calculate_temporal_trend_of_time_series(x,y):
slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
return slope, std_err

def calculate_daily_climatology(dataset):
'''Calculate daily climatology from the input dataset
:param dataset: The dataset to convert.
:type dataset: :class:`dataset.Dataset`
:returns: values_clim
:rtype: 3d masked numpy array.shape (number of unique days, y, x)

days = [d.month * 100. + for d in dataset.times]
days_sorted = np.unique(days)
ndays = days_sorted.size
nt, ny, nx = dataset.values.shape
values_clim = ma.zeros([ndays, ny, nx])
for iday, day in enumerate(days_sorted):
t_index = np.where(days == day)[0]
values_clim[iday, :] = ma.mean(dataset.values[t_index, :], axis=0)
return values_clim

0 comments on commit 434752c

Please sign in to comment.