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 meta data 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.
- Returns:
the derived attributes
- Return type:
- 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.
- Returns:
the derived attributes
- Return type:
- 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
- property led_filename
- 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.
- Returns:
the derived attributes
- Return type:
- 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
- property header_filename
- 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.
- Returns:
the derived attributes
- Return type:
- 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:
- Returns:
the vector object if outname is None, None otherwise
- Return type:
spatialist.vector.Vector or None
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.
- Returns:
the derived attributes
- Return type:
- class pyroSAR.drivers.ID(metadict)[source]
Bases:
objectAbstract class for SAR meta data 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) – the name of the vector file to be written
driver (str) – the output file format; needs to be defined if the format cannot be auto-detected from the filename extension
overwrite (bool) – overwrite an existing vector file?
buffer (None or int or float or tuple[int or float]) – a buffer to add around coordinates. Default None: do not add a buffer. A tuple is interpreted as (x buffer, y buffer).
- Returns:
the vector object if outname is None and None otherwise
- Return type:
Vector or None
See also
- property compression
check whether a scene is compressed into an tarfile or zipfile or not at all
- Returns:
either ‘zip’, ‘tar’ or None
- Return type:
str 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:
- 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:
- Returns:
the matched file names
- Return type:
See also
- gdalinfo()[source]
read metadata directly from the GDAL SAR image drivers
- Returns:
the metadata attributes
- Return type:
- 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:
- Returns:
the vector object if outname is None, None otherwise
- Return type:
Vector or None
See also
- getCorners()[source]
Get the bounding box corner coordinates
- Returns:
the corner coordinates as a dictionary with keys xmin, ymin, xmax, ymax
- Return type:
- 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 method
findfiles()- Returns:
a file pointer object
- Return type:
- getGammaImages(directory=None)[source]
list all files processed by GAMMA
- Parameters:
directory (str or None) – the directory to be scanned; if left empty the object attribute gammadir is scanned
- Returns:
the file names of the images processed by GAMMA
- Return type:
- Raises:
- 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:
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.
- Returns:
the derived attributes
- Return type:
- 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:
- Returns:
the vector object if outname is None, None otherwise
- Return type:
Vector or None
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) – the directory of OSV files; subdirectories POEORB and RESORB are created automatically; if no directory is defined, the standard SNAP auxdata location is used
osvType (str or list[str]) – 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 otherwise
returnMatch (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 or tuple or None) – the timeout in seconds for downloading OSV files as provided to
requests.get()url_option (int) – the OSV download URL option; see
pyroSAR.S1.OSV.catch()for options
- Returns:
the best matching OSV file if returnMatch is True or None otherwise
- Return type:
str or None
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 (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
- 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.
- Returns:
the derived attributes
- Return type:
- 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)
- 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.
- Returns:
the derived attributes
- Return type:
- 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.
- Returns:
the derived attributes
- Return type:
- 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 method
findfiles()
- Returns:
a file object
- Return type:
- pyroSAR.drivers.identify(scene)[source]
identify a SAR scene and return the appropriate metadata handler object
- Parameters:
scene (str) – a file or directory name
- Returns:
a pyroSAR metadata handler
- Return type:
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:
- Returns:
a list of pyroSAR metadata handlers
- Return type:
Examples
>>> from pyroSAR import identify_many >>> files = finder('/path', ['S1*.zip']) >>> ids = identify_many(files, pbar=False, sortkey='start')