From 19a108f7d65580e1ba5b039afb9f126c5f850c0f Mon Sep 17 00:00:00 2001 From: acolite Date: Thu, 25 Jul 2024 15:57:03 +0200 Subject: [PATCH 1/2] Switch to openpyxl --- environment.yml | 4 ++-- polymer/level1_landsat8.py | 24 +++++++++++------------- polymer/params.py | 23 ++++++++++------------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/environment.yml b/environment.yml index c678214..74b0020 100644 --- a/environment.yml +++ b/environment.yml @@ -28,7 +28,7 @@ dependencies: - bioconda::ecmwfapi # for Landsat8: - - xlrd<2 + - openpyxl # For Sentinel-2: - glymur @@ -42,4 +42,4 @@ dependencies: - pytest - pytest-html - pytest-xdist - - matplotlib \ No newline at end of file + - matplotlib diff --git a/polymer/level1_landsat8.py b/polymer/level1_landsat8.py index bd9559c..674f384 100755 --- a/polymer/level1_landsat8.py +++ b/polymer/level1_landsat8.py @@ -16,7 +16,9 @@ import numpy as np import os from os.path import dirname, join -import xlrd + +# QV 2024-07-25 use openpyxl instead of xlrd +from openpyxl import load_workbook gdal_major_version = int(osgeo.__version__.split('.')[0]) @@ -206,9 +208,7 @@ def init_meta(self): def init_spectral(self): dir_aux_oli = join(dirname(dirname(__file__)), 'auxdata', 'oli') srf_file = join(dir_aux_oli, 'Ball_BA_RSR.v1.2.xlsx') - - wb = xlrd.open_workbook(srf_file) - + wb = load_workbook(filename = srf_file) self.wav = OrderedDict() for b, bname in [(440, 'CoastalAerosol'), @@ -218,18 +218,16 @@ def init_spectral(self): (865, 'NIR'), (1610, 'SWIR1'), (2200, 'SWIR2')]: - sh = wb.sheet_by_name(bname) + sh = wb[bname] wav, srf = [], [] - - i=0 - while True: + i=1 + while i Date: Thu, 25 Jul 2024 16:23:31 +0200 Subject: [PATCH 2/2] Add numpy<2 --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 74b0020..b8b0f60 100644 --- a/environment.yml +++ b/environment.yml @@ -7,6 +7,7 @@ channels: - defaults dependencies: - python + - numpy<2 - scipy - xarray - cython