Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
import numpy as np | |
# create an example dataset | |
da = xr.DataArray(np.random.rand(10,30,40), dims=['time', 'lat', 'lon']) | |
# define a function to compute a linear trend of a timeseries | |
def linear_trend(x): | |
pf = np.polyfit(x.time, x, 1) | |
# we need to return a dataarray or else xarray's groupby won't be happy |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def open_date_file(file_path): | |
df = pd.read_csv(file_path, index_col=0, parse_dates=True) | |
df['BeginDate'] = df.BeginDate.apply(lambda t: pd.to_datetime(t, format='%Y-%m-%d')) | |
return df | |
var = sys.argv[1] | |
path = '' | |
max_lag = 30 | |
type_ls = ['split', 'displ'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# implement my own aggregation downsampling function | |
from itertools import product | |
import numpy as np | |
import xarray as xr | |
def aggregate(data, factor=2, mean=True): | |
ndim = data.ndim | |
shape = data.shape | |
# promote single value to list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def longest_com_period_possible(xa_list): | |
"""Determine the longest common period for list of xarrays | |
Parameters | |
---------- | |
xa_list: list of xarray dataarrays | |
Returns | |
------- | |
period: slice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def autocorr(x, t=1): | |
"""Calculates autocorrelation with lag = 1. | |
Parameters | |
---------- | |
x: numpy.array | |
Input | |
Returns | |
------- |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer