# -*- coding: UTF-8 -*- # Python """ 04-07-2023 @author: jeremy auclair Calculate NDVI images with xarray """ import os # for path exploration import csv # open csv files from typing import List, Union # to declare variables import xarray as xr # to manage dataset import dask.array as da # dask xarray from dask.distributed import Client, LocalCluster # to parallelise calculations def calculate_ndvi(download_path: Union[List[str], str]) -> str: # Start local cluster client client = Client() client # If a file name is provided instead of a list of paths, load the csv file that contains the list of paths if type(download_path) == str: with open(download_path, 'r') as file: download_path = [] csvreader = csv.reader(file, delimiter='\n') for row in csvreader: download_path.append(row[0]) products = xr.open_mfdataset(download_path, parallel = True) #, chunks = {'latitude': 100, 'longitude': 100}) ndvi_cube_path ='' return ndvi_cube_path