satpy.readers.core.remote module
Helper functions for remote reading.
- class satpy.readers.core.remote.FSFile(file, fs=None)[source]
Bases:
PathLikeImplementation of a PathLike file object, that can be opened.
Giving the filenames to
Scenewith valid transfer protocols will automatically use this class so manual usage of this class is needed mainly for fine-grained control.This class is made to be used in conjuction with fsspec or s3fs. For example:
from satpy import Scene import fsspec filename = 'noaa-goes16/ABI-L1b-RadC/2019/001/17/*_G16_s20190011702186*' the_files = fsspec.open_files("simplecache::s3://" + filename, s3={'anon': True}) from satpy.readers.core.remote import FSFile fs_files = [FSFile(open_file) for open_file in the_files] scn = Scene(filenames=fs_files, reader='abi_l1b') scn.load(['true_color_raw'])
Initialise the FSFile instance.
- Parameters:
file (
PathLike|OpenFile|str) – String, object implementing theos.PathLikeprotocol, or anOpenFileinstance. If passed an instance ofOpenFile, the following argumentfshas no effect.fs (
AbstractFileSystem|None) – Object implementing the fsspec filesystem protocol.
- __init__(file, fs=None)[source]
Initialise the FSFile instance.
- Parameters:
file (
PathLike|OpenFile|str) – String, object implementing theos.PathLikeprotocol, or anOpenFileinstance. If passed an instance ofOpenFile, the following argumentfshas no effect.fs (
AbstractFileSystem|None) – Object implementing the fsspec filesystem protocol.
- _abc_impl = <_abc._abc_data object>
- _update_with_fs_open_kwargs(user_kwargs)[source]
Complement keyword arguments for opening a file via file system.
- property fs
Return the underlying private filesystem attribute.
- satpy.readers.core.remote._get_fs_open_kwargs(file)[source]
Get keyword arguments for opening a file via file system.
For example compression.
- satpy.readers.core.remote.open_file_or_filename(unknown_file_thing, mode=None)[source]
Try to open the provided file “thing” if needed, otherwise return the filename or Path.
This wraps the logic of getting something like an fsspec OpenFile object that is not directly supported by most reading libraries and making it usable. If a
pathlib.Pathobject or something that is not open-able is provided then that object is passed along. In the case of fsspec OpenFiles their.open()method is called and the result returned.