You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As already briefly discussed at issue #366, parsing the reader yaml files causes the pattern to change the path separator depending on the platform. This results in the satpy.find_files_and_readers function to never return any results.
The path separator in the yaml files are, by convention, specified as "/", for example the SLSTR yaml:
The AbstractYAMLReader splits this pattern on that same separator, but then uses os.path.join to join in back to a path. In doing this, the os.path.join will use the platform depending separator. So on Windows, the pattern shown above transforms to:
When searching for files, the get_filebase function splits on "/", but this separator won't occur because of the os.path.join mentioned above. Hence the length of the split will always return 1, causing the function to only return the filename, whereas it should return the parent folder as well.
The resulting fnmatch attempt will always fail because its comparing:
Personally I think that using os.path.sep in get_filebase should work, since the pattern is created/parsed by using os.path.join. On Windows it does work, I tested it for the OLCI L1 and SLSTR L1 readers. But @djhoese expressed some concerns about this: #366 (comment)
I'm not familiar enough with SatPy's internals to understand the implications of such a change.
The text was updated successfully, but these errors were encountered:
RutgerK
changed the title
find_files_and_readers doesn't work on Windows
"find_files_and_readers" doesn't work on Windows
Jul 17, 2018
@RutgerK Awesome! Thanks so much for tracking this down. I couldn't find that file_patterns line when you first brought this up in your other issue. This all makes sense now. A pull request would be very appreciated.
As already briefly discussed at issue #366, parsing the reader yaml files causes the pattern to change the path separator depending on the platform. This results in the
satpy.find_files_and_readers
function to never return any results.The path separator in the yaml files are, by convention, specified as
"/"
, for example the SLSTR yaml:'{mission_id:3s}_SL_{processing_level:1s}_{datatype_id:_<6s}_{start_time:%Y%m%dT%H%M%S}_{end_time:%Y%m%dT%H%M%S}_{creation_time:%Y%m%dT%H%M%S}_{duration:4d}_{cycle:3d}_{relative_orbit:3d}_{frame:4d}_{centre:3s}_{mode:1s}_{timeliness:2s}_{collection:3s}.SEN3/{dataset_name}_radiance_an.nc'
The
AbstractYAMLReader
splits this pattern on that same separator, but then usesos.path.join
to join in back to a path. In doing this, theos.path.join
will use the platform depending separator. So on Windows, the pattern shown above transforms to:'{mission_id:3s}_SL_{processing_level:1s}_{datatype_id:_<6s}_{start_time:%Y%m%dT%H%M%S}_{end_time:%Y%m%dT%H%M%S}_{creation_time:%Y%m%dT%H%M%S}_{duration:4d}_{cycle:3d}_{relative_orbit:3d}_{frame:4d}_{centre:3s}_{mode:1s}_{timeliness:2s}_{collection:3s}.SEN3\\{dataset_name}_radiance_an.nc'
The code doing this is:
https://github.com/pytroll/satpy/blob/master/satpy/readers/yaml_reader.py#L99
When searching for files, the
get_filebase
function splits on"/"
, but this separator won't occur because of theos.path.join
mentioned above. Hence the length of the split will always return 1, causing the function to only return the filename, whereas it should return the parent folder as well.The resulting
fnmatch
attempt will always fail because its comparing:fnmatch('S1_radiance_an.nc', '???_SL_?_??????_????????T??????_????????T??????_????????T??????_????_???_???_????_???_?_??_???.SEN3\\*_radiance_an.nc')
Personally I think that using
os.path.sep
inget_filebase
should work, since the pattern is created/parsed by usingos.path.join
. On Windows it does work, I tested it for the OLCI L1 and SLSTR L1 readers. But @djhoese expressed some concerns about this:#366 (comment)
I'm not familiar enough with SatPy's internals to understand the implications of such a change.
The text was updated successfully, but these errors were encountered: