Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointing out errors in the Breizhcrops Tutorial Colab Notebook #34

Open
wakame1367 opened this issue Apr 12, 2022 · 0 comments
Open

Pointing out errors in the Breizhcrops Tutorial Colab Notebook #34

wakame1367 opened this issue Apr 12, 2022 · 0 comments

Comments

@wakame1367
Copy link

I'd like to point out that the latest changes to the Breizhcrops library affected the code in Breizhcrops Tutorial Colab Notebook
, so I'm going to point out the fixes.

Normalized Difference Vegetation Index

I think the error is probably caused by the addition of label, id to Bands.
I think the changes we made in this commit affected it.

It will work if you make the following changes.

def calculate_ndvi(input_timeseries):
  # https://github.com/dl4sits/BreizhCrops/pull/24/commits/cbe3009c9adee06f51d252b1a734a1ba5636a2b6
  # add ['label', 'id']
  bands = allbands["L1C"].copy()
  bands.remove('label')
  bands.remove('id')
  data = pd.DataFrame(input_timeseries,columns=bands)
  data["doa"] = pd.to_datetime(data["doa"])
  data = data.set_index("doa")
  
  l1c_bands = ['B1', 'B10', 'B11', 'B12', 'B2', 'B3', 'B4', 
               'B5', 'B6', 'B7', 'B8','B8A', 'B9']
  data[l1c_bands] *= 1e-4

  nir = data["B8"]#
  red = data["B4"]

  return (nir-red) / (nir+red+1e-8)

dataset_index = 125 #@param {type:"slider", min:0, max:1048, step:1}

fig,axs = plt.subplots(1,2, figsize=(22,3))

ax = axs[0]

regular_dataset = breizhcrops.BreizhCrops(region="belle-ile", level="L1C", transform=raw_transform)
x,y,field_id = datasets["L1C"][dataset_index]
date = pd.to_datetime(x[:,-1])
x = x[:,:-1]
ax.plot(date,x[:,:-1])
ax.set_title("all spectral bands")

fig.suptitle(regular_dataset.classname[y])
ax = axs[1]

ndvi_dataset = breizhcrops.BreizhCrops(region="belle-ile", level="L1C", transform=calculate_ndvi)
x,y,field_id = ndvi_dataset[dataset_index]
ax.plot(x)
ax.set_title("NDVI")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant