
sensors = ['MODIS Collection 6.1 Terra','MODIS Collection 6.1 Aqua']
vegtypes = ['NDVI','EVI']
vegtype500s = ['LAI','fPAR','GPP']
resolutions = ['250m, 16-day','500m, 16-day','1km, 16-day']
composites = ['2003-2017','2018-2022','2013-2022','2003-2022']
composites2 = ['2018-2022','2013-2022']

geo_ws = 'https://geoserver.silvis.forest.wisc.edu/geodata/dhis_mod6/'
geo_ws2 = 'O:/GeoData/dhis_mod6/'
download_table = geo_ws2 + "download_dhis_table.html"
fout = open(download_table, 'w')



###### COMPOSITES
# Composite Terra
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>MODIS Collection 6.1 Terra (composites)</caption>\n')
fout.write('<colgroup span="3"></colgroup><colgroup span="3"></colgroup><col><col><col>\n')
fout.write('<tr><th colspan="3" scope="colgroup">NDVI</th><th colspan="3" scope="colgroup">EVI</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th></tr>\n')
for b in composites:
	fout.write('<tr>')
	for a in range(0,9):
		fout.write('<td><a href="' + str(b) + '">' + str(b) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')

# Composite Aqua
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>MODIS Collection 6.1 Aqua (composites)</caption>\n')
fout.write('<colgroup span="3"></colgroup><colgroup span="3"></colgroup><col><col><col>\n')
fout.write('<tr><th colspan="3" scope="colgroup">NDVI</th><th colspan="3" scope="colgroup">EVI</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th></tr>\n')
for b in composites:
	fout.write('<tr>')
	for a in range(0,9):
		fout.write('<td><a href="' + str(b) + '">' + str(b) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')


# Composite Terra & Aqua
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>MODIS Collection 6.1 Terra & Aqua (composites)</caption>\n')
fout.write('<col>\n')
fout.write('<tr><th scope="col">LAI</th>')
fout.write('<th scope="col">500m (4-day)</th>')
for b in composites:
	fout.write('<th><a href="' + str(b) + '">' + str(b) + '</a></th>')
fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')


# Composite VIIRS
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>VIIRS (composites)</caption>\n')
fout.write('<col><col><col><col><col><col>\n')
fout.write('<tr><th scope="col">NDVI</th><th scope="col">EVI</th><th scope="col">EVI2</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th></tr>\n')
for b in composites2:
	fout.write('<tr>')
	for a in range(0,6):
		fout.write('<td><a href="' + str(b) + '">' + str(b) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')




###### ANNUAL

# Annual Terra
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>MODIS Collection 6.1 Terra (annual)</caption>\n')
fout.write('<colgroup span="3"></colgroup><colgroup span="3"></colgroup><col><col><col>\n')
fout.write('<tr><th colspan="3" scope="colgroup">NDVI</th><th colspan="3" scope="colgroup">EVI</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th></tr>\n')
for y in range(2003,2023):
	fout.write('<tr>')
	for a in range(0,9):
		fout.write('<td><a href="' + str(y) + '">' + str(y) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')

# Annual Aqua
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>MODIS Collection 6.1 Aqua (annual)</caption>\n')
fout.write('<colgroup span="3"></colgroup><colgroup span="3"></colgroup><col><col><col>\n')
fout.write('<tr><th colspan="3" scope="colgroup">NDVI</th><th colspan="3" scope="colgroup">EVI</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">250m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">1km<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th><th scope="col">500m<br>16-day</th></tr>\n')
for y in range(2003,2023):
	fout.write('<tr>')
	for a in range(0,9):
		fout.write('<td><a href="' + str(y) + '">' + str(y) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')

# Annual VIIRS
fout.write('<div>\n')
fout.write('<table>\n')
fout.write('<caption>VIIRS (annual)</caption>\n')
fout.write('<col><col><col><col><col><col>\n')
fout.write('<tr><th scope="col">NDVI</th><th scope="col">EVI</th><th scope="col">EVI2</th><th scope="col">LAI</th><th scope="col">fPAR</th><th scope="col">GPP</th></tr>\n')
fout.write('<tr><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th><th scope="col">500m<br>8-day</th></tr>\n')
for y in range(2012,2023):
	fout.write('<tr>')
	for a in range(0,6):
		fout.write('<td><a href="' + str(y) + '">' + str(y) + '</a></td>')
	fout.write('</tr>\n')
fout.write('</table>\n')
fout.write('</div>\n')






















# # MODIS NDVI/EVI
# for sensor in sensors:
	# fout.write('<div>')
	# fout.write('<h3>' + sensor + '</h3>\n')
	# for vegtype in vegtypes:
		# fout.write('<h4>' + vegtype + '</h4>\n')
		# for res in resolutions:
			# print(sensor,vegtype,res)
			# fout.write('<h5>' + res + '</h5>\n')
			# fout.write('<h6>Single Year:</h6>\n')
			# for year in range(2003,2023):
				# print(year)
				# zipfile = geo_ws + 'zip/gtiff.zip'
				# fout.write('<a href="' + zipfile + '">' + str(year) + '</a> ')
			# fout.write('\n')
			# fout.write('<h6>Composites:</h6>\n')
			# for composite in composites:
				# print(composite)
				# compositefile = geo_ws + 'zip/composite_gtiff.zip'
				# fout.write('<a href="' + compositefile + '">' + composite + '</a> ')
			# fout.write('\n')
	# fout.write('</div>\n')
			
fout.close()
