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

No supported files found for OLCI L2A #2966

Open
HafezAhmad opened this issue Nov 4, 2024 · 5 comments
Open

No supported files found for OLCI L2A #2966

HafezAhmad opened this issue Nov 4, 2024 · 5 comments

Comments

@HafezAhmad
Copy link

HafezAhmad commented Nov 4, 2024

I am trying to read OLCI level 2 A. but it is not working.

import glob, os
from datetime import datetime
from satpy import Scene, find_files_and_readers
path=r"C:\Users\hafez\MSU\Research\data\satellitedata\OLCI_rs"
file=os.path.join(path,"\S3A_OL_2_WFR____20241023T160700_20241023T161000_20241023T180154_0179_118_211_2520_MAR_O_NR_003.SEN3" ,"S3A_OL_2_WFR____20241023T160700_20241023T161000_20241023T180154_0179_118_211_2520_MAR_O_NR_003.SEN3")
files = find_files_and_readers(sensor='olci',
                               start_time=datetime(2024, 10, 23, 16, 7),
                               end_time=datetime(2024, 10, 23, 16, ),
                               base_dir=file,
                               reader='olci_l2')

ValueError Traceback (most recent call last)
Cell In[13], line 3
1 path=r"C:\Users\hafez\MSU\Research\data\satellitedata\OLCI_rs"
2 file=os.path.join(path,"\S3A_OL_2_WFR____20241023T160700_20241023T161000_20241023T180154_0179_118_211_2520_MAR_O_NR_003.SEN3" ,"S3A_OL_2_WFR____20241023T160700_20241023T161000_20241023T180154_0179_118_211_2520_MAR_O_NR_003.SEN3")
----> 3 files = find_files_and_readers(sensor='olci',
4 start_time=datetime(2024, 10, 23, 16, 7),
5 end_time=datetime(2024, 10, 23, 16, ),
6 base_dir=file,
7 reader='olci_l2')
9 scn = Scene(filenames=files)

File c:\Users\hafez\miniconda3\envs\sentinel\lib\site-packages\satpy\readers_init_.py:494, in find_files_and_readers(start_time, end_time, base_dir, reader, sensor, filter_parameters, reader_kwargs, missing_ok, fs)
491 raise ValueError("Sensor '{}' not supported by any readers".format(sensor))
493 if not (reader_files or missing_ok):
--> 494 raise ValueError("No supported files found")
495 return reader_files

ValueError: No supported files found

@mraspaud
Copy link
Member

mraspaud commented Nov 5, 2024

Looks like the end time is before the start time... end_time=datetime(2024, 10, 23, 16, ) means 16:00, and start time was 16:07... :D

@hafez-ahmad
Copy link

@mraspaud Thank you so much! I am trying to save as geotif. but export geotif is not georeferenced. Any way to do that with sat py?

@mraspaud
Copy link
Member

mraspaud commented Nov 5, 2024

The level 2 data is not on a known grid out of the box. You need to resample the data before saving it to have a georeferenced geotiff. Check the satpy documentation on how to resample if you are unsure.

@HafezAhmad
Copy link
Author

The output is resampled data, but the original OLCI data appears to have a 300-meter resolution. After reprojecting, the resolution doesn't seem to stay at 300 meters. Additionally, the output should be a single-band raster, but it's showing as a two-band raster. Instead of reflectance values, it’s displaying integer values, which is entirely incorrect. I must be missing something. Could you please help me troubleshoot this?

import os
from datetime import datetime
from satpy import find_files_and_readers

# Define the directory path
path = r"C:\Users\hafez\MSU\Research\data\satellitedata\OLCI_rs\exo"

# No need to join specific file names, only the directory path is required for `base_dir`
# Ensure end_time is correctly specified

files = find_files_and_readers(
    sensor='olci',
    start_time=datetime(2024, 10, 23, 16, 7),
    end_time=datetime(2024, 10, 23, 16, 10),  # end time complete
    base_dir=path,  # base_dir should be the directory, not a specific file
    reader='olci_l2'
)

# Load Scene with the located files (if any files were found)
scn = Scene(filenames=files)
# Load the dataset
data= scn.load(['Oa01'])
# Define the output directory and filename
output_dir = r"C:\Users\hafez\MSU\Research\data\satellitedata\OLCI_rs\output"
output_filename = os.path.join(output_dir, "Oa02_reflectance.tif")

# Ensure the output directory exists
os.makedirs(output_dir, exist_ok=True)

# Define the area definition for resampling
area_id = '300m_area' 
description = '300m resolution area' 
proj_id = '300m_proj' 
proj_dict = {'proj': 'latlong'} 
width = 300 # Example width in pixels 
height = 300 # Example height in 
area_extent = (-89.474, 30.064, -88.337, 30.390) # Specified extent in degrees

area_def = create_area_def(area_id, proj_dict, width, height, area_extent, description=description, proj_id=proj_id)

# Resample the dataset to 300-meter resolution
scn_resampled = scn.resample(area_def)
# save the resampled dataset
scn_resampled.save_datasets(writer='geotiff', datasets=['Oa01'], filename=output_filename)

print(f"GeoTIFF saved to {output_filename}")

@mraspaud
Copy link
Member

mraspaud commented Nov 8, 2024

  1. By default, the tiff writer outputs ints with alpha channel as we use it mainly as an image format. To keep the data as floats with only one channel, something like this might work: scn_resampled.save_datasets(writer='geotiff', datasets=['Oa01'], filename=output_filename, dtype=np.float64, fill_value=np.nan)
  2. The width and height parameters do not define the size of a single pixel, but the total size of the result. In the current case you get an image that is 300x300 pixels in size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants