Error reading .SEN3 files

Hello, in my code, I would like to do a bands subset on multiple .SEN3 files. When I manually set the file to be for example

file = '/home/lubomir/Desktop/Sentinel3_OLCI/raw_data/S3A_OL_1_EFR____20180722T081656_20180722T081956_20180722T102419_0179_033_349_2160_MAR_O_NR_002.SEN3'

everything works just fine. However, if I try to parse through all .SEN3 files in directory: /home/lubomir/Desktop/Sentinel3_OLCI/raw_data

I get the following error:

Reading 1st file
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: /home/lubomir/Desktop/Sentinel3_OLCI/scripts_snappy/S3A_OL_1_EFR____20180820T090533_20180820T090833_20180820T111458_0179_034_378_2160_MAR_O_NR_002.SEN3/./ (No such file or directory)
WARNING: org.esa.s3tbx.dataio.s3.AbstractProductFactory: Could not find './'.
and so on .........

Seems like problems with defined path. This is my code:

for file in glob.glob("*.SEN3"):
    print ("Reading " + str(poradie) + "st file")
    product = ProductIO.readProduct(file)
    name = product.getName()
    band_names = product.getBandNames()
    cas = product.getStartTime()
    casParsnuty = datetime.strptime(str(cas),'%d-%b-%Y %H:%M:%S.%f')
    subset = '/home/lubomir/Desktop/Sentinel3_OLCI/band_subset/subset_' + 

Any suggestions ? Thanks for your help and time.

For me it seems that the files returned from the glob do not contain the full path.
The files are searched at /home/lubomir/Desktop/Sentinel3_OLCI/scripts_snappy/
which is probably the working dir, where the script has been started. And this still the working dir for the Java part of snappy. Using os.chdir in python doesn’t change it.
If you combine your path with the result from the glob it should work.

Hello, I have fixed it by changing my code to:

def albedo():
    for file in glob.glob("/home/lubomir/Desktop/Sentinel3_OLCI/band_subset/*.dim"):

Instead of defining path in os.chdir I defined whole path in glob. Now it works as I wanted.
Thank you for your reply !

1 Like