Hi,
I’m using gpt to batch process thousands of L2 LST products from sentinel 3. I wrote a very simple python script calling gpt via subprocess, here it is:
psg = "4326"
for entry in os.scandir("./data"):
if entry.is_dir():
#compute final tiff filename from product name
splitname = entry.name.split("____")
timestamp = splitname[1]
sat = splitname[0][:3] # Crops the satellite name from the file name
date = timestamp.split("_")[0] # Crops the date & time portion from the file name
date = ''.join(date) # Convert the list to string
fullname = date+"_"+sat #full final tiff filename
#product xml file
in_file = entry.path + "/" + "xfdumanifest.xml"
print(fullname)
start = perf_counter()
print("subset")
proc = subprocess.run(["gpt","subset","-Ssource="+in_file,"-PcopyMetadata='false'","-PsourceBands=LST", "-f","GeoTIFF-BigTIFF","-t","./tiffs/z_"+fullname])
t1 = perf_counter()
print("reproject")
proc = subprocess.run(["gpt","reproject","-Ssource=./tiffs/z_"+fullname+".tif","-Pcrs="+psg,"-PnoDataValue=-9999", "-f","GeoTIFF-BigTIFF","-t","./tiffs/"+fullname])
end = perf_counter()
print("subset duration ",t1-start)
print("reproject duration ",end-t1)
print("overall duration ",end-start)
print("***")
it works, but the process is extremely slow: each time gpt gets called, it starts looking for GDAL and configuring it. the actual process time is also not that performant, but acceptable. This is the output for two files:
20210105T000155_S3A
subset
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 2.3.3 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: D:\projects\MAAT\T4\sentinel3_SLSTR\data\S3A_SL_2_LST____20210105T000155_20210105T000455_20210105T020632_0179_067_059_1620_LN2_O_NR_004.SEN3 (Accesso negato)
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: Could not find ''.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
Executing operator...
20%46%73%99% done.
INFO: org.esa.snap.core.gpf.common.WriteOp: Start writing product Subset_S3A_SL_2_LST____20210105T000155_20210105T000455_20210105T020632_0179_067_059_1620_LN2_O_NR_004.SEN3 to .\tiffs\z_20210105T000155_S3A
Writing...
.10%.INFO: org.esa.snap.dataio.bigtiff.BigGeoTiffProductWriter: writing to output file .\tiffs\z_20210105T000155_S3A.tif
20%46%73%99% done.
INFO: org.esa.snap.core.gpf.common.WriteOp: End writing product z_20210105T000155_S3A to .\tiffs\z_20210105T000155_S3A
INFO: org.esa.snap.core.gpf.common.WriteOp: Time: 3.629 s total, 3.024 ms per line, 0.002016 ms per pixel
reproject
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 2.3.3 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
Executing operator...
20%.....30%.....42%....52%....62%....72%...90%88%86%84%82%..... done.
INFO: org.esa.snap.core.gpf.common.WriteOp: Start writing product projected_z_20210105T000155_S3A to .\tiffs\20210105T000155_S3A
Writing...
..10%..INFO: org.esa.snap.dataio.bigtiff.BigGeoTiffProductWriter: writing to output file .\tiffs\20210105T000155_S3A.tif
.21%....31%.....41%....51%....61%....71%....81%....91%.... done.
INFO: org.esa.snap.core.gpf.common.WriteOp: End writing product 20210105T000155_S3A to .\tiffs\20210105T000155_S3A
INFO: org.esa.snap.core.gpf.common.WriteOp: Time: 104.328 s total, 86.868 ms per line, 0.003072 ms per pixel
subset duration 87.1625576
reproject duration 129.3651081
overall duration 216.5276657
***
20210105T000155_S3A
subset
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 2.3.3 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: D:\projects\MAAT\T4\sentinel3_SLSTR\data\S3A_SL_2_LST____20210105T000155_20210105T000455_20210106T044313_0179_067_059_1620_LN2_O_NT_004.SEN3 (Accesso negato)
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: Could not find ''.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
Executing operator...
20%73%73%99%126% done.
INFO: org.esa.snap.core.gpf.common.WriteOp: Start writing product Subset_S3A_SL_2_LST____20210105T000155_20210105T000455_20210106T044313_0179_067_059_1620_LN2_O_NT_004.SEN3 to .\tiffs\z_20210105T000155_S3A
Writing...
.10%.INFO: org.esa.snap.dataio.bigtiff.BigGeoTiffProductWriter: writing to output file .\tiffs\z_20210105T000155_S3A.tif
20%46%73%99% done.
INFO: org.esa.snap.core.gpf.common.WriteOp: End writing product z_20210105T000155_S3A to .\tiffs\z_20210105T000155_S3A
INFO: org.esa.snap.core.gpf.common.WriteOp: Time: 2.120 s total, 1.767 ms per line, 0.001178 ms per pixel
reproject
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: GDAL 2.3.3 found on system. JNI driver will be used.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
INFO: org.esa.s2tbx.dataio.gdal.GDALVersion: Installed GDAL 2.3.3 set to be used by SNAP.
INFO: org.hsqldb.persist.Logger: dataFileCache open start
Executing operator...
20%....30%....40%....50%....60%.....70%...82%80%......94%.. done.
INFO: org.esa.snap.core.gpf.common.WriteOp: Start writing product projected_z_20210105T000155_S3A to .\tiffs\20210105T000155_S3A
Writing...
..10%..INFO: org.esa.snap.dataio.bigtiff.BigGeoTiffProductWriter: writing to output file .\tiffs\20210105T000155_S3A.tif
.21%....31%....41%....51%....61%....71%....81%....91%.... done.
INFO: org.esa.snap.core.gpf.common.WriteOp: End writing product 20210105T000155_S3A to .\tiffs\20210105T000155_S3A
INFO: org.esa.snap.core.gpf.common.WriteOp: Time: 99.907 s total, 83.187 ms per line, 0.002942 ms per pixel
subset duration 54.68569120000001
reproject duration 118.79726160000001
overall duration 173.48295280000002
***
Am I missing some configuration steps? Should I use some arguments when calling GPT?
Thanks!