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 datacube | |
import matplotlib.pyplot as plt | |
from matplotlib.pyplot import cm | |
from matplotlib.patches import Patch | |
import numpy as np | |
import sys | |
import xarray as xr | |
sys.path.append('../Scripts') | |
from deafrica_datahandling import load_ard |
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
from datacube.utils.geometry import assign_crs | |
import datacube | |
import numpy as np | |
import sys | |
import xarray as xr | |
sys.path.append('../Scripts') | |
from deafrica_bandindices import calculate_indices | |
from deafrica_temporal_statistics import temporal_statistics | |
from deafrica_classificationtools import HiddenPrints |
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 random_sampling(da, | |
n, | |
sampling='stratified_random', | |
manual_class_ratios=None, | |
out_fname=None | |
): | |
""" | |
Creates randomly sampled points for post-classification | |
accuracy assessment. |
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 cartopy.crs as ccrs | |
def plot_towns(ax, lats, lons, resolution='10m', transform=ccrs.PlateCarree(), zorder=3): | |
""" | |
This function will download the 'populated_places' shapefile from | |
NaturalEarth, trim the shapefile based on the limits of the provided | |
lat & long coords, and then plot the locations and names of the towns | |
on a given GeoAxes. | |
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 | |
from scipy import stats | |
def significance_tests(xarray_a, xarray_b, t_test=False, levene_test=False, | |
equal_variance = False, nan_policy= 'omit', mask_not_sig = False, | |
level_of_sig = 0.05, center='mean'): | |
""" | |
This function operates on a per-pixel basis and contains two types of significance tests: | |
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 dask.array as da | |
from datacube.utils.geometry import assign_crs | |
from dask_ml.wrappers import ParallelPostFit | |
def predict_xr(model, | |
input_xr, | |
chunk_size=None, |
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 datacube | |
import xarray as xr | |
import geopandas as gpd | |
from datacube.utils import geometry | |
sys.path.append('../Scripts') | |
from deafrica_datahandling import load_ard | |
from deafrica_spatialtools import xr_rasterize |
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 datacube | |
import numpy as np | |
import xarray as xr | |
from odc.algo import xr_reproject | |
from pyproj import Proj, transform | |
from datacube.utils.geometry import assign_crs | |
from datacube.testutils.io import rio_slurp_xarray | |
from deafrica_tools.bandindices import calculate_indices | |
def common_ops(ds, era): |
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 geopandas as gpd | |
from dea_tools.spatial import xr_rasterize | |
#read shapefile | |
mask_vector = gpd.read_file('mask.shp') | |
#import xarray ds | |
ds = xr.open_dataset('testing.nc') |
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 dask | |
import hdstats | |
from odc.algo import randomize, reshape_for_geomedian | |
from odc.algo._dask import reshape_yxbt | |
from datacube.utils.geometry import assign_crs | |
def xr_geomad(ds, axis='time', where=None, **kw): | |
""" |
OlderNewer