Drivers
This is the core module of package pyroSAR.
It contains the drivers for the different SAR image formats and offers
functionality for retrieving metadata, unpacking images, downloading ancillary files like DEMs and
Orbit State Vector files as well as archiving scenes in a database.
The ID class and its subclasses allow easy and standardized access to the metadata of
images from different SAR sensors.
classes
Abstract class for SAR metadata handlers |
|
Handler class for BEAM-DIMAP data |
|
Handler class for ALOS-PALSAR data in CEOS format |
|
Handler class for ERS data in CEOS format |
|
Handler class for ALOS-2/PALSAR-2 data in EORC (Earth Observation Research Center) Path format |
|
Handler class for SAR data in ESA format (Envisat ASAR, ERS-1/2) |
|
Handler class for Sentinel-1 data |
|
Handler class for TerraSAR-X and TanDEM-X data |
|
Handler class for TerraSAR-X and TanDEM-X experimental data |
functions
identify a SAR scene and return the appropriate metadata handler object |
|
wrapper function for returning metadata handlers of all valid scenes in a list, similar to function |
|
Filter a list of pyroSAR objects to those that have not yet been processed and stored in the defined directory. |
|
Load a file in a SAR scene archive into a readable file object. |
|
this function gathers known time formats provided in the different SAR products and converts them to a common standard of the form YYYYMMDDTHHMMSS |
- class pyroSAR.drivers.BEAM_DIMAP(scene)[source]
Bases:
IDHandler class for BEAM-DIMAP data
- Sensors:
SNAP supported sensors
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.CEOS_ERS(scene)[source]
Bases:
IDHandler class for ERS data in CEOS format
- Sensors:
ERS1
ERS2
- Reference:
ER-IS-EPO-GS-5902-3: Annex C. ERS SAR.SLC/SLC-I. CCT and EXABYTE (ESA 1998)
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.CEOS_PSR(scene)[source]
Bases:
IDHandler class for ALOS-PALSAR data in CEOS format
- Sensors:
PSR1
PSR2
- PALSAR-1:
- References:
- Products / processing levels:
1.0
1.1
1.5
- Acquisition modes:
AB: [SP][HWDPC]
- A: supplemental remarks of the sensor type:
S: Wide observation mode
P: all other modes
- B: observation mode
H: Fine mode
W: ScanSAR mode
D: Direct downlink mode
P: Polarimetry mode
C: Calibration mode
- PALSAR-2:
- Reference:
ALOS-2/PALSAR-2 Level 1.1/1.5/2.1/3.1 CEOS SAR Product Format Description (JAXA 2014).
- Products / processing levels:
1.0
1.1
1.5
- Acquisition modes:
SBS: Spotlight mode
UBS: Ultra-fine mode Single polarization
UBD: Ultra-fine mode Dual polarization
HBS: High-sensitive mode Single polarization
HBD: High-sensitive mode Dual polarization
HBQ: High-sensitive mode Full (Quad.) polarimetry
FBS: Fine mode Single polarization
FBD: Fine mode Dual polarization
FBQ: Fine mode Full (Quad.) polarimetry
WBS: Scan SAR nominal [14MHz] mode Single polarization
WBD: Scan SAR nominal [14MHz] mode Dual polarization
WWS: Scan SAR nominal [28MHz] mode Single polarization
WWD: Scan SAR nominal [28MHz] mode Dual polarization
VBS: Scan SAR wide mode Single polarization
VBD: Scan SAR wide mode Dual polarization
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.EORC_PSR(scene)[source]
Bases:
IDHandler class for ALOS-2/PALSAR-2 data in EORC (Earth Observation Research Center) Path format
- Sensors:
PALSAR-2
- PALSAR-2:
- Reference:
NDX-150019: ALOS-2/PALSAR-2 EORC Path Product Format Description (JAXA 2016)
- Products / processing levels:
1.5
- Acquisition modes:
FBD: Fine mode Dual polarization
WBD: Scan SAR nominal [14MHz] mode Dual polarization
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.ESA(scene)[source]
Bases:
IDHandler class for SAR data in ESA format (Envisat ASAR, ERS-1/2)
- Sensors:
ASAR
ERS1
ERS2
- geo_grid(outname=None, driver=None, overwrite=True)[source]
get the geo grid as vector geometry
- Parameters:
- Return type:
- Returns:
the vector object if outname is None, None otherwise
See also
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.ID(metadict)[source]
Bases:
objectAbstract class for SAR metadata handlers
- bbox(outname=None, driver=None, overwrite=True, buffer=None)[source]
get the bounding box of a scene. The result is either returned as vector object or written to a file.
- Parameters:
outname (
str|None) – the name of the vector file to be writtendriver (
str|None) – the output file format; needs to be defined if the format cannot be auto-detected from the filename extensionoverwrite (
bool) – overwrite an existing vector file?buffer (
int|float|tuple[int|float,int|float] |None) – a buffer to add around coordinates. Default None: do not add a buffer. A tuple is interpreted as (x buffer, y buffer).
- Return type:
- Returns:
the vector object if outname is None and None otherwise
See also
- property compression: Literal['zip', 'tar'] | None
check whether a scene is compressed into a tarfile or zipfile or not at all
- Return type:
either ‘zip’, ‘tar’ or None
- examine(include_folders=False)[source]
check whether any items in the SAR scene structure (i.e. files/folders) match the regular expression pattern defined by the class. On success the item is registered in the object as attribute file.
- Parameters:
include_folders (
bool) – also match folder (or just files)?- Raises:
- Return type:
- export2dict()[source]
Return the uuid and the metadata that is defined in self.locals as a dictionary
- findfiles(pattern, include_folders=False)[source]
find files in the scene archive, which match a pattern.
- Parameters:
- Return type:
- Returns:
the matched file name(s)
See also
- geometry(outname=None, driver=None, overwrite=True)[source]
get the footprint geometry of a scene either as a vector object or written to a file
- Parameters:
- Return type:
- Returns:
the vector object if outname is None, None otherwise
See also
- getFileObj(filename)[source]
Load a file into a readable file object.
- Parameters:
filename (
str) – the name of a file in the scene archive, easiest to get with methodfindfiles()- Return type:
- Returns:
a file pointer object
- getGammaImages(directory=None)[source]
list all files processed by GAMMA
- is_processed(outdir, recursive=False)[source]
check whether a scene has already been processed and stored in the defined output directory (and subdirectories if scanned recursively)
- outname_base(extensions=None)[source]
parse a string containing basic information about the scene in standardized format. Currently, this id contains the sensor (4 digits), acquisition mode (4 digits), orbit (1 digit) and acquisition start time (15 digits)., e.g. S1A__IW___A_20150523T122350.
- static parse_date(x)[source]
this function gathers known time formats provided in the different SAR products and converts them to a common standard of the form YYYYMMDDTHHMMSS.
- abstractmethod quicklook(outname, format='kmz')[source]
export a quick look image of the scene
- Parameters:
- Return type:
Examples
>>> from pyroSAR import identify >>> scene = identify('S1A_IW_GRDH_1SDV_20180101T170648_20180101T170713_019964_021FFD_DA78.zip') >>> scene.quicklook('S1A__IW___A_20180101T170648.kmz')
- abstractmethod scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- property start_dt: datetime
- Return type:
the acquisition start time as timezone-aware datetime object
- property stop_dt: datetime
- Return type:
the acquisition stop time as timezone-aware datetime object
- class pyroSAR.drivers.SAFE(scene)[source]
Bases:
IDHandler class for Sentinel-1 data
- Sensors:
S1A
S1B
S1C
S1D
- References:
S1-RS-MDA-52-7443 Sentinel-1 IPF Auxiliary Product Specification
MPC-0243 Masking “No-value” Pixels on GRD Products generated by the Sentinel-1 ESA IPF
- geo_grid(outname=None, driver=None, overwrite=True)[source]
get the geo grid as vector geometry
- Parameters:
- Return type:
- Returns:
the vector object if outname is None, None otherwise
See also
- getOSV(osvdir=None, osvType='POE', returnMatch=False, useLocal=True, timeout=300, url_option=1)[source]
download Orbit State Vector files for the scene
- Parameters:
osvdir (
str|None) – the directory of OSV files; subdirectories POEORB and RESORB are created automatically; if no directory is defined, the standard SNAP auxdata location is usedosvType (
Literal['POE','RES'] |list[Literal['POE','RES']]) – the type of orbit file either ‘POE’, ‘RES’ or a list of both; if both are selected, the best matching file will be retrieved. I.e., POE if available and RES otherwisereturnMatch (
bool) – return the best matching orbit file?useLocal (
bool) – use locally existing files and do not search for files online if the right file has been found?timeout (
int|float|tuple[int|float,int|float] |None) – the timeout in seconds for downloading OSV files as provided torequests.get()url_option (
int) – the OSV download URL option; seepyroSAR.S1.OSV.catch()for options
- Return type:
- Returns:
the best matching OSV file if returnMatch is True or None otherwise
See also
- quicklook(outname, format='kmz', na_transparent=True)[source]
Write a quicklook file for the scene.
- removeGRDBorderNoise(method='pyroSAR')[source]
mask out Sentinel-1 image border noise.
- Parameters:
method (
Literal['pyroSAR','ESA'] |str) –the border noise removal method to be applied; one of the following:
’ESA’: the pure implementation as described by ESA
’pyroSAR’: the ESA method plus the custom pyroSAR refinement
See also
- Return type:
- resolution()[source]
Compute the mid-swath resolution of the Sentinel-1 product. For GRD products the resolution is expressed in ground range and in slant range otherwise.
- References:
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- class pyroSAR.drivers.TDM(scene)[source]
Bases:
TSXHandler class for TerraSAR-X and TanDEM-X experimental data
- Sensors:
TDM1
- References:
TD-GS-PS-3028 TanDEM-X Experimental Product Description
- Acquisition modes:
HS: High Resolution SpotLight
SL: SpotLight
SM: StripMap
- Polarisation modes:
Single (S): all acquisition modes
Dual (D): High Resolution SpotLight (HS), SpotLight (SL) and StripMap (SM)
Twin (T): StripMap (SM) (experimental)
Quad (Q): StripMap (SM) (experimental)
- Products:
CoSSCs: (bi-static) SAR co-registered single look slant range complex products (CoSSCs)
Examples
Ingest all Tandem-X Bistatic scenes in a directory and its sub-directories into the database:
>>> from pyroSAR import Archive, identify >>> from spatialist.ancillary import finder >>> dbfile = '/.../scenelist.db' >>> archive_tdm = '/.../TDM/' >>> scenes_tdm = finder(archive_tdm, [r'^TDM1.*'], foldermode=2, regex=True, recursive=True) >>> with Archive(dbfile) as archive: >>> archive.insert(scenes_tdm)
- class pyroSAR.drivers.TSX(scene)[source]
Bases:
IDHandler class for TerraSAR-X and TanDEM-X data
- Sensors:
TSX1
TDX1
- References:
TX-GS-DD-3302 TerraSAR-X Basic Product Specification Document
TX-GS-DD-3303 TerraSAR-X Experimental Product Description
TD-GS-PS-3028 TanDEM-X Experimental Product Description
TerraSAR-X Image Product Guide (Airbus Defence and Space)
- Acquisition modes:
ST: Staring Spotlight
HS: High Resolution SpotLight
HS300: High Resolution SpotLight 300 MHz
SL: SpotLight
SM: StripMap
SC: ScanSAR
WS: Wide ScanSAR
- Polarisation modes:
Single (S): all acquisition modes
Dual (D): High Resolution SpotLight (HS), SpotLight (SL) and StripMap (SM)
Twin (T): StripMap (SM) (experimental)
Quad (Q): StripMap (SM) (experimental)
- Products:
SSC: Single Look Slant Range Complex
MGD: Multi Look Ground Range Detected
GEC: Geocoded Ellipsoid Corrected
EEC: Enhanced Ellipsoid Corrected
- scanMetadata()[source]
scan SAR scenes for metadata attributes. The returned dictionary is registered as attribute meta by the class upon object initialization. This dictionary furthermore needs to return a set of standardized attribute keys, which are directly registered as object attributes.
- pyroSAR.drivers.filter_processed(scenelist, outdir, recursive=False)[source]
Filter a list of pyroSAR objects to those that have not yet been processed and stored in the defined directory. The search for processed scenes is either done in the directory only or recursively into subdirectories. The scenes must have been processed with pyroSAR in order to follow the right naming scheme.
- pyroSAR.drivers.getFileObj(scene, filename)[source]
Load a file in a SAR scene archive into a readable file object.
- Parameters:
scene (
str) – the scene archive. Can be either a directory or a compressed archive of type zip or tar.gz.filename (
str) – the name of a file in the scene archive, easiest to get with methodfindfiles()
- Return type:
- Returns:
a file object
- pyroSAR.drivers.identify(scene)[source]
identify a SAR scene and return the appropriate metadata handler object
- Parameters:
scene (
str) – a file or directory name- Return type:
- Returns:
a pyroSAR metadata handler
Examples
>>> from pyroSAR import identify >>> filename = 'S1A_IW_GRDH_1SDV_20180829T170656_20180829T170721_023464_028DE0_F7BD.zip' >>> scene = identify(filename) >>> print(scene) pyroSAR ID object of type SAFE acquisition_mode: IW cycleNumber: 148 frameNumber: 167392 lines: 16703 orbit: A orbitNumber_abs: 23464 orbitNumber_rel: 117 polarizations: ['VV', 'VH'] product: GRD projection: +proj=longlat +datum=WGS84 +no_defs samples: 26056 sensor: S1A spacing: (10.0, 10.0) start: 20180829T170656 stop: 20180829T170721
- pyroSAR.drivers.identify_many(scenes, pbar=False, sortkey=None, cores=1)[source]
wrapper function for returning metadata handlers of all valid scenes in a list, similar to function
identify().- Parameters:
- Return type:
- Returns:
a list of pyroSAR metadata handlers
Examples
>>> from pyroSAR import identify_many >>> files = finder('/path', ['S1*.zip']) >>> ids = identify_many(files, pbar=False, sortkey='start')