Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ channels:
- defaults
dependencies:
- python
- numpy<2
- scipy
- xarray
- cython
Expand All @@ -28,7 +29,7 @@ dependencies:
- bioconda::ecmwfapi

# for Landsat8:
- xlrd<2
- openpyxl

# For Sentinel-2:
- glymur
Expand All @@ -42,4 +43,4 @@ dependencies:
- pytest
- pytest-html
- pytest-xdist
- matplotlib
- matplotlib
24 changes: 11 additions & 13 deletions polymer/level1_landsat8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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'),
Expand All @@ -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<wb[bname].max_row:
i += 1
try:
wav.append(sh.cell(i, 0).value)
srf.append(sh.cell(i, 1).value)
except IndexError:
break
if sh.cell(i, 1).value is None: break
wav.append(sh.cell(i, 1).value)
srf.append(sh.cell(i, 2).value)


wav, srf = np.array(wav), np.array(srf)
wav_eq = np.trapz(wav*srf)/np.trapz(srf)
Expand Down
23 changes: 10 additions & 13 deletions polymer/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def defaults_hico(self):
self.K_NO2 = K_NO2_HICO

self.band_cloudmask = 862


def defaults_prisma(self):
self.bands_corr = [
Expand Down Expand Up @@ -753,7 +753,8 @@ def defaults_oli(self):
'''
Landsat8/OLI defaults
'''
import xlrd
# QV 2024-07-25 use openpyxl instead of xlrd
from openpyxl import load_workbook
import pandas as pd

self.bands_corr = [440, 480, 560, 655, 865 ]
Expand All @@ -775,7 +776,7 @@ def defaults_oli(self):
self.K_OZ = OrderedDict()
srf_file = join(self.dir_base, 'auxdata', 'oli',
'Ball_BA_RSR.v1.2.xlsx')
wb = xlrd.open_workbook(srf_file)
wb = load_workbook(filename = srf_file)

solar_spectrum_file = join(self.dir_common, 'SOLAR_SPECTRUM_WMO_86')
solar_data = pd.read_csv(solar_spectrum_file, sep=' ')
Expand All @@ -793,18 +794,16 @@ def defaults_oli(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<wb[bname].max_row:
i += 1
try:
wav.append(sh.cell(i, 0).value)
srf.append(sh.cell(i, 1).value)
except IndexError:
break
if sh.cell(i, 1).value is None: break
wav.append(sh.cell(i, 1).value)
srf.append(sh.cell(i, 2).value)

wav, srf = np.array(wav), np.array(srf)

Expand Down Expand Up @@ -892,5 +891,3 @@ def finalize(self):

# number of terms in the model
self.Ncoef = self.atm_model.count(',')+1