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 get_github_filesystem(): | |
import fsspec | |
fs = fsspec.filesystem('github', org='IPCC-WG1', repo='colormaps') | |
return fs | |
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 numpy as np | |
import xarray as xr | |
import rioxarray as rxr | |
from loguru import logger | |
from pygeotile.tile import Tile | |
__package__ = __file__.split('/')[-1].split('.')[0] | |
logger.warning( | |
f"Note that you can only use `{__package__}` for non-commercial " |
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 numpy as np | |
import xarray as xr | |
import rioxarray as rxr | |
from loguru import logger | |
from pygeotile.tile import Tile | |
__package__ = __file__.split('/')[-1].split('.')[0] | |
logger.warning( | |
f"Note that you can only use `{__package__}` for non-commercial " |
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
""" | |
Contains a function to quickly plot xarray datasets on a map | |
Loading the script creates a method for xr.DataArrays that can be used as follows: | |
da.mean('time').map() | |
Defaults can also be changed by changing values in the rcMaps dictionary. | |
I haven't figured out how this can be changed in notebooks, but you can just | |
change these with the **kwargs argument. |
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 | |
import joblib | |
import os | |
# SEASONAL CYCLE FITTING # | |
def graven2013_seasonal_fit(da, n_jobs=24): | |
""" | |
Fits a seasonal cycle to data using cos and sin functions. |
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 load_url_as_python_module(url, pkg_name=None, save_dir=None): | |
"""Imports a python file url as a package. | |
Downloads the file to local storage and imports into the global namespace. | |
Can be useful to quickly access gists and github files as functions. | |
Warning: this function could be VERY dangerous as a script could be | |
run on your machine without knowing what it does... be very careful | |
Args: |
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 input_limits(return_bool=True, return_info=True, **kwargs): | |
""" | |
This is a function wrapper for functions that have defined input limits. | |
The user can define the valid limits of any of the inputs. | |
Parameters | |
---------- | |
return_bool: array-bool | |
returns a boolean array of the original function where valid or not | |
return_info: array-str |
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 numpy as np | |
### Implementation of our EMD() function | |
def emd(data, stop_limit=0.001, spline_order=3): | |
""" | |
EMD as explained by Scott Cole (https://srcole.github.io/2016/01/18/emd/), | |
but has been modified by Luke Gregor (https://github.com/luke-gregor) to | |
automatically stop when there are no more IMFs in the dataset. | |
Additionally, the residual from the stopping point and the original dataset | |
is counted as the final IMF. |
NewerOlder