Skip to content

Commit a35e881

Browse files
committed
Calibration support for Envisat and ERS1&2 SLCs.
1 parent eea23e6 commit a35e881

45 files changed

Lines changed: 227 additions & 23 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

asar_xarray/asar.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import xarray as xr
88
import numpy as np
9+
import math
910
from osgeo import gdal
1011
from xarray.backends import AbstractDataStore
1112
from xarray.core.types import ReadBuffer
@@ -58,7 +59,8 @@ def open_asar_dataset(filepath: str | os.PathLike[Any] | ReadBuffer[Any] | Abstr
5859
metadata = get_metadata(gdal_dataset)
5960

6061
# Duplicate, read directly from file, as gdal does not parse some necessary metadata
61-
metadata["direct_parse"] = envisat_direct.parse_direct(filepath)
62+
63+
metadata["direct_parse"] = envisat_direct.parse_direct(filepath, metadata)
6264

6365
# Create an xarray Dataset with pixel data and metadata attributes
6466
dataset: xr.Dataset = create_dataset(metadata, filepath)
@@ -80,14 +82,17 @@ def create_dataset(metadata: dict[str, Any], filepath: str) -> xr.Dataset:
8082
number_of_samples = metadata["line_length"]
8183
product_first_line_utc_time = metadata["first_line_time"]
8284
product_last_line_utc_time = metadata["last_line_time"]
83-
print(product_first_line_utc_time)
8485

8586
number_of_lines = metadata["records"]["main_processing_params"]["num_output_lines"]
86-
azimuth_time_interval = 1 / metadata["records"]["main_processing_params"]["image_parameters"]["prf_value"][0]
87+
azimuth_time_interval = metadata["line_time_interval"]
88+
8789
range_sampling_rate = metadata["records"]["main_processing_params"]["range_samp_rate"]
8890
image_slant_range_time = metadata["direct_parse"]["slant_time_first"] * 1e-9
8991

90-
number_of_bursts = 0
92+
if metadata["sph_descriptor"] == "Image Mode SLC Image":
93+
product_type = "SLC"
94+
else:
95+
raise RuntimeError("Only Image mode SLC files(IMS) supported for now")
9196

9297
attrs = {
9398
"family_name": "Envisat",
@@ -98,33 +103,29 @@ def create_dataset(metadata: dict[str, Any], filepath: str) -> xr.Dataset:
98103
"relative_orbit_number": metadata["rel_orbit"],
99104
"pass": metadata["pass"],
100105
"transmitter_receiver_polarisations": metadata["mds1_tx_rx_polar"],
101-
"product_type": "SLC",
106+
"product_type": product_type,
102107
"start_time": product_first_line_utc_time,
103108
"stop_time": product_last_line_utc_time,
104-
109+
"range_pixel_spacing" : metadata["range_spacing"],
110+
"azimuth_pixel_spacing" : metadata["azimuth_spacing"],
105111
"radar_frequency": metadata["records"]["main_processing_params"]["radar_freq"] / 1e9,
106112
"ascending_node_time": "",
107113
"azimuth_pixel_spacing": metadata["records"]["main_processing_params"]["azimuth_spacing"],
108-
"range_pixel_spacing": metadata["records"]["main_processing_params"]["range_samp_rate"],
109114
"product_first_line_utc_time": product_first_line_utc_time,
110115
"product_last_line_utc_time": product_last_line_utc_time,
111116
"azimuth_time_interval": azimuth_time_interval,
112117
"image_slant_range_time": image_slant_range_time,
113118
"range_sampling_rate": range_sampling_rate,
114-
"incidence_angle_mid_swath": metadata["direct_parse"]["incidence_angle_center"],
119+
"incidence_angle_mid_swath": metadata["direct_parse"]["incidence_angle_center"] * 2 * math.pi / 360 ,
115120
"metadata": metadata
116121
}
117122

118123
azimuth_time = compute_azimuth_time(
119124
product_first_line_utc_time, product_last_line_utc_time, number_of_lines
120125
)
121126

122-
if number_of_bursts == 0:
123-
swap_dims = {"line": "azimuth_time", "pixel": "slant_range_time"}
124-
else:
125-
raise NotImplementedError(
126-
"Burst processing is not implemented yet."
127-
)
127+
128+
swap_dims = {"line": "azimuth_time", "pixel": "slant_range_time"}
128129

129130
coords: dict[str, Any] = {
130131
"pixel": np.arange(0, number_of_samples, dtype=int),
@@ -179,7 +180,7 @@ def get_chirp_parameters(dataset: gdal.Dataset) -> dict[str, Any]:
179180
new_key = key.replace('CHIRP_PARAMS_ADS_CHIRP_', '').lower()
180181
params['chirp'][new_key] = float(value)
181182

182-
params['elev_corr_factor'] = float(metadata.get('CHIRP_PARAMS_ADS_ELEV_CORR_FACTOR'))
183+
#params['elev_corr_factor'] = float(metadata.get('CHIRP_PARAMS_ADS_ELEV_CORR_FACTOR'))
183184
params['cal_pulse_info'] = get_chirp_cal_pulse_info(metadata)
184185

185186
return params
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ASAR Auxiliary Files
2+
3+
ASA_CON_AXVIEC20030703_000000_20020301_000000_20020815_000000
4+
ASA_CON_AXVIEC20030909_000000_20020815_000000_20021017_130000
5+
ASA_CON_AXVIEC20120626_153045_20030601_000000_20050916_195733
6+
ASA_CON_AXVIEC20120626_153730_20021017_130000_20030601_000000
7+
ASA_CON_AXVIEC20120626_154436_20050916_195733_20070204_165113
8+
ASA_CON_AXVIEC20120626_155037_20070204_165113_20101231_000000
9+
ASA_CON_AXVIEC20120626_160512_20100317_120410_20141231_000000
10+
ASA_CON_AXVIEC20120626_163200_20100311_094400_20100317_120409
11+
ASA_CON_AXVIEC20120627_074358_20101027_215740_20141231_000000
12+
13+
ASA_INS_AXVIEC20020308_112323_20020301_000000_20021231_000000
14+
ASA_INS_AXVIEC20020425_093155_20020413_000000_20021231_000000
15+
ASA_INS_AXVIEC20021018_095608_20020613_092400_20020815_131000
16+
ASA_INS_AXVIEC20031212_122530_20020815_131000_20021017_162400
17+
ASA_INS_AXVIEC20061220_105425_20030211_000000_20071231_000000
18+
ASA_INS_AXVIEC20070223_140724_20070226_000000_20071231_000000
19+
ASA_INS_AXVIEC20070227_105626_20070228_060000_20071231_000000
20+
ASA_INS_AXVIEC20090525_115408_20070307_060000_20090428_095959
21+
ASA_INS_AXVIEC20091217_114637_20090428_100000_20101231_235959
22+
ASA_INS_AXVIEC20101222_143805_20101022_000000_20141231_235959
23+
ASA_INS_AXVIEC20110124_114858_20101228_112000_20141231_235959
24+
ASA_INS_AXVIEC20170504_152600_20021030_100500_20030211_000000
25+
ASA_INS_AXVIEC20170504_152900_20021017_162400_20021030_100500
26+
27+
ASA_XCA_AXVIEC20020308_112533_20020301_000000_20021231_000000
28+
ASA_XCA_AXVIEC20070130_105508_20020413_000000_20030211_000000
29+
ASA_XCA_AXVIEC20070130_110635_20030211_000000_20030601_000000
30+
ASA_XCA_AXVIEC20070130_111029_20030601_000000_20030804_000000
31+
ASA_XCA_AXVIEC20070130_111245_20030804_000000_20040412_000000
32+
ASA_XCA_AXVIEC20070130_111449_20040412_000000_20050101_000000
33+
ASA_XCA_AXVIEC20070215_184408_20050916_195733_20070204_165113
34+
ASA_XCA_AXVIEC20090311_104037_20070204_165113_20080731_235959
35+
ASA_XCA_AXVIEC20091217_114112_20080801_000000_20101231_235959
36+
ASA_XCA_AXVIEC20100315_123052_20090501_000000_20110101_000000
37+
ASA_XCA_AXVIEC20100608_122638_20100311_094400_20100317_120409
38+
ASA_XCA_AXVIEC20100608_123419_20100317_120410_20110101_000000
39+
ASA_XCA_AXVIEC20101111_113830_20100601_000000_20141231_000000
40+
ASA_XCA_AXVIEC20110526_075734_20101027_215740_20141231_000000
41+
ASA_XCA_AXVIEC20120126_110323_20110607_000000_20141231_000000
42+
ASA_XCA_AXVIEC20120607_091724_20120127_000000_20141231_000000
43+
ASA_XCA_AXVIEC20161028_150126_20050101_000000_20050914_080040
44+
45+
ASA_XCH_AXVIEC20101222_143057_20020301_000000_20141231_000000

0 commit comments

Comments
 (0)