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
cd xscen/ | |
pygettext.py -o xscen/data/messages.pot xscen/*.py | |
cp xscen/data/messages.pot xscen/data/fr | |
# edit xscen/data/fr/LC_MESSAGES/xscen.po | |
msgfmt.py xscen/data/*/LC_MESSAGES/xscen.po | |
git commit |
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 sys | |
import dask | |
from dask.diagnostics import ProgressBar | |
import time | |
import xarray as xr | |
import glob | |
import fsspec | |
# This was last run on commit f42b0c23aa0229cee6e5a394a860f0ad1149ace6 |
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
# Creep fill : fill missing points with the mean of the neighbors. | |
# | |
# The process here implemented first create weights and then computes the fill by a dot product, in a fashion similar to xESMF. | |
# It uses a sparse matrix to stores those weights. This enables the reuse of a creep filling mask and faster parallelization over non-creeped dims. | |
# | |
import itertools | |
import numpy as np | |
import sparse as sp | |
import xarray as xr |
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 pygeos # I'm not sure why, but it seems this must be imported before one of the other packages below | |
import xarray as xr | |
import cf_xarray as cfxr | |
from shapely.geometry import Polygon | |
import shapely | |
import ESMF | |
import xesmf as xe | |
import numpy as np | |
ds = xr.open_dataset('caw/series/200109/rhsmax_caw_200109_se.nc') # some 2D grid data |
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
# This function creates a xclim0.30-compliant yaml file from a pre-0.30 version. | |
import os | |
from yaml import safe_load, safe_dump | |
def update_yaml(raw: os.PathLike, adapted: os.PathLike): | |
"""Reads in a virtual module yaml that was created for xclim <= 0.29 and refactors it to fit xclim's current yaml specifications.""" | |
freq_names = {"annual": "A", "seasonal": "Q", "monthly": "M", "weekly": "W"} | |
freq_defs = {"annual": "YS", "seasonal": "QS-DEC", "monthly": "MS", "weekly": "W"} | |
with open(raw) as f: |
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
""" | |
Convert a geopandas dataframe to a CF compliant dataset. | |
Follows conventions as noted here : http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#geometries | |
Author: Pascal Bourgault | |
Date: 2021-02-05 | |
""" | |
import geopandas as gpd | |
from numpy import arange |
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
# Spatial intersection and average | |
# Compute weights corresponding to the intersection between grid cells and a polygon. | |
# Pascal bourgault, Sept 2020 | |
from cartopy import crs | |
from shapely.geometry import Polygon | |
from shapely.ops import transform | |
import xarray as xr | |
import numpy as np | |
from functools import partial | |
import pyproj |