dane = gdal.Open(plik, gdalconst.GA_ReadOnly)
kanal_5 = dane.GetRasterBand(1)

# stale do obliczen
RADIANCE_MULT_BAND_5 = 9.8986e-03
RADIANCE_ADD_BAND_5 = -49.49291

# Parametry optymalizacji (wielkosc kafelka)
TILE_SIZE_START = 32
TILE_SIZE_END = 512
TILE_INTERVAL = 8

# liczy czasy przetwarzania dla roznych wielkosci kafelka
proc_times = []
for tile_size in range(TILE_SIZE_START, TILE_SIZE_END + 1, TILE_INTERVAL):
    tiles = tile_processing.tile_img_processing(kanal_5, tile_size)
    start = timer()
    for tile, column, row in tiles:
        TOA_ref = (tile * RADIANCE_MULT_BAND_5) + RADIANCE_ADD_BAND_5
    proc_times.append(str(timer() - start))

totals = numpy.asarray(proc_times).astype(numpy.float) / len(proc_times)

# Rysowanie wykresu i zapisanie go na dysku
plt.plot(proc_times)
# os X
plt.xticks(range(0, len(totals) + 1, 4), range(TILE_SIZE_START, TILE_SIZE_END + 1, TILE_INTERVAL * 4))
plt.tick_params(axis="x", which="major", labelsize=5)
# os y
plt.yticks([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5], [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])
# Dekoracje
Exemplo n.º 2
0
proj = dane.GetProjection()
geotransform = dane.GetGeoTransform()

#Wyjscie
plik_zapis = "wynik/rad_ref_5.bsq"
sterownik_bsq = gdal.GetDriverByName("ENVI")
sterownik_bsq.Register()
zapis = sterownik_bsq.Create(plik_zapis, dane.RasterXSize, dane.RasterYSize, 1,
                             gdal.GDT_UInt16)
zapis.SetProjection(proj)
zapis.SetGeoTransform(geotransform)
zapis.SetMetadata(dane.GetMetadata())

#stale do obliczen
RADIANCE_MULT_BAND_5 = 9.8986E-03
RADIANCE_ADD_BAND_5 = -49.49291
TILE_SIZE = 128

#tiles jest generatorem ktory nam wzroci kafelki jezeli po nim iterujemy
tiles = tile_processing.tile_img_processing(kanal_5, TILE_SIZE)

for tile, column, row in tiles:
    #przetwarzanie kafelka
    rad_ref = ((tile * RADIANCE_MULT_BAND_5) + RADIANCE_ADD_BAND_5) * 100
    #zapis kafelka do nowego pliku
    zapis.GetRasterBand(1).WriteArray(rad_ref, column, row)

rad_ref = None
zapis = None
plik = None
dane = gdal.Open(plik, gdalconst.GA_ReadOnly)
kanal_5 = dane.GetRasterBand(1)

#stale do obliczen
RADIANCE_MULT_BAND_5 = 9.8986E-03
RADIANCE_ADD_BAND_5 = -49.49291

#Parametry optymalizacji (wielkosc kafelka)
TILE_SIZE_START = 32
TILE_SIZE_END = 512
TILE_INTERVAL = 8

#liczy czasy przetwarzania dla roznych wielkosci kafelka
proc_times = []
for tile_size in range(TILE_SIZE_START, TILE_SIZE_END + 1, TILE_INTERVAL):
    tiles = tile_processing.tile_img_processing(kanal_5, tile_size)
    start = timer()
    for tile, column, row in tiles:
        TOA_ref = ((tile * RADIANCE_MULT_BAND_5) + RADIANCE_ADD_BAND_5)
    proc_times.append(str(timer() - start))

totals = numpy.asarray(proc_times).astype(numpy.float) / len(proc_times)

#Rysowanie wykresu i zapisanie go na dysku
plt.plot(proc_times)
#os X
plt.xticks(range(0,
                 len(totals) + 1, 4),
           range(TILE_SIZE_START, TILE_SIZE_END + 1, TILE_INTERVAL * 4))
plt.tick_params(axis='x', which='major', labelsize=5)
#os y
y_size = dane.RasterYSize
proj = dane.GetProjection()
geotransform = dane.GetGeoTransform()

#Wyjscie
plik_zapis = "wynik/rad_ref_5.bsq"
sterownik_bsq = gdal.GetDriverByName("ENVI")
sterownik_bsq.Register()
zapis = sterownik_bsq.Create(plik_zapis,dane.RasterXSize,dane.RasterYSize,1,gdal.GDT_UInt16)
zapis.SetProjection(proj)
zapis.SetGeoTransform(geotransform)
zapis.SetMetadata(dane.GetMetadata())

#stale do obliczen
RADIANCE_MULT_BAND_5 = 9.8986E-03
RADIANCE_ADD_BAND_5 = -49.49291
TILE_SIZE =128

#tiles jest generatorem ktory nam wzroci kafelki jezeli po nim iterujemy
tiles = tile_processing.tile_img_processing(kanal_5 ,TILE_SIZE)

for tile, column, row in tiles:
    #przetwarzanie kafelka
    rad_ref = ((tile* RADIANCE_MULT_BAND_5) + RADIANCE_ADD_BAND_5)*100
    #zapis kafelka do nowego pliku 
    zapis.GetRasterBand(1).WriteArray(rad_ref, column, row)
        
rad_ref=None
zapis = None
plik = None