sarkit-convert 0.1.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sarkit_convert/_utils.py CHANGED
@@ -124,6 +124,38 @@ def polyfit2d_tol(x, y, z, max_order_x, max_order_y, tol, strict_tol=False):
124
124
  return best[0]
125
125
 
126
126
 
127
+ def polyshift(poly, new_origin):
128
+ """Returns new polynomial with shifted origin
129
+
130
+ Args
131
+ ----
132
+ poly: array-like
133
+ 1d polynomial coefficients, with constant term first
134
+ new_origin: float
135
+ location in `poly`'s domain to place new polynomial's origin
136
+
137
+ Returns
138
+ -------
139
+ new_poly
140
+ polynomial of same order as `poly` for which new_poly(0) == poly(new_origin)
141
+ """
142
+
143
+ working_coeffs = np.array(list(reversed(poly)))
144
+ output_coeffs = []
145
+
146
+ for _ in np.arange(len(poly)):
147
+ quot = np.zeros(shape=working_coeffs.shape)
148
+ rem = 0.0
149
+ for ndx, val in enumerate(working_coeffs):
150
+ carry = rem * new_origin
151
+ rem = val + carry
152
+ quot[ndx] = rem
153
+ output_coeffs.append(rem)
154
+ working_coeffs = quot[:-1]
155
+
156
+ return np.array(output_coeffs)
157
+
158
+
127
159
  def broadening_from_amp(amp_vals, threshold_db=None):
128
160
  """Compute the broadening factor from amplitudes
129
161
 
@@ -154,38 +186,35 @@ def broadening_from_amp(amp_vals, threshold_db=None):
154
186
  return width / fft_size * amp_vals.size
155
187
 
156
188
 
157
- def _get_sigma0_noise(xml_helper):
189
+ def _get_sigma0_noise(sicd_ew):
158
190
  """Calculate the absolute noise estimate, in sigma0 power units."""
159
191
 
160
- if xml_helper.element_tree.find("./{*}Radiometric/{*}SigmaZeroSFPoly") is None:
192
+ if "SigmaZeroSFPoly" not in sicd_ew["Radiometric"]:
161
193
  raise ValueError(
162
194
  "Radiometric.SigmaZeroSFPoly is not populated, so no sigma0 noise estimate can be derived."
163
195
  )
164
- if (
165
- xml_helper.load("./{*}Radiometric/{*}NoiseLevel/{*}NoiseLevelType")
166
- != "ABSOLUTE"
167
- ):
196
+ if sicd_ew["Radiometric"]["NoiseLevel"]["NoiseLevelType"] != "ABSOLUTE":
168
197
  raise ValueError(
169
198
  "Radiometric.NoiseLevel.NoiseLevelType is not `ABSOLUTE` so no noise estimate can be derived."
170
199
  )
171
200
 
172
- noisepoly = xml_helper.load("./{*}Radiometric/{*}NoiseLevel/{*}NoisePoly")
201
+ noisepoly = sicd_ew["Radiometric"]["NoiseLevel"]["NoisePoly"]
173
202
  scp_noise_db = noisepoly[0, 0]
174
203
  scp_noise = 10 ** (scp_noise_db / 10)
175
204
 
176
205
  # convert to SigmaZero value
177
- sigma_zero_sf = xml_helper.load("./{*}Radiometric/{*}SigmaZeroSFPoly")
206
+ sigma_zero_sf = sicd_ew["Radiometric"]["SigmaZeroSFPoly"]
178
207
  scp_noise *= sigma_zero_sf[0, 0]
179
208
 
180
209
  return scp_noise
181
210
 
182
211
 
183
- def _get_default_signal_estimate(xml_helper):
212
+ def _get_default_signal_estimate(sicd_ew):
184
213
  """Gets default signal for use in the RNIIRS calculation.
185
214
 
186
215
  This will be 1.0 for copolar (or unknown) collections, and 0.25 for cross-pole collections."""
187
216
 
188
- pol = xml_helper.load("./{*}ImageFormation/{*}TxRcvPolarizationProc")
217
+ pol = sicd_ew["ImageFormation"].get("TxRcvPolarizationProc", None)
189
218
  if pol is None or ":" not in pol:
190
219
  return 1.0
191
220
 
@@ -227,23 +256,23 @@ def _estimate_rniirs(information_density):
227
256
  return out
228
257
 
229
258
 
230
- def get_rniirs_estimate(xml_helper):
259
+ def get_rniirs_estimate(sicd_ew):
231
260
  """This calculates the value(s) for RNIIRS and information density for SICD, according to the RGIQE."""
232
- scp_noise = _get_sigma0_noise(xml_helper)
233
- signal = _get_default_signal_estimate(xml_helper)
261
+ scp_noise = _get_sigma0_noise(sicd_ew)
262
+ signal = _get_default_signal_estimate(sicd_ew)
234
263
 
235
- u_row = xml_helper.load("./{*}Grid/{*}Row/{*}UVectECF")
236
- u_col = xml_helper.load("./{*}Grid/{*}Col/{*}UVectECF")
264
+ u_row = sicd_ew["Grid"]["Row"]["UVectECF"]
265
+ u_col = sicd_ew["Grid"]["Col"]["UVectECF"]
237
266
  ipn = np.cross(u_row, u_col)
238
267
  u_ipn = ipn / np.linalg.norm(ipn)
239
268
 
240
- scp_llh = xml_helper.load("./{*}GeoData/{*}SCP/{*}LLH")
269
+ scp_llh = sicd_ew["GeoData"]["SCP"]["LLH"]
241
270
  u_gpn = sarkit.wgs84.up(scp_llh)
242
271
 
243
272
  bw_sf = np.dot(u_gpn, u_ipn)
244
273
  bw_area = abs(
245
- xml_helper.load("./{*}Grid/{*}Row/{*}ImpRespBW")
246
- * xml_helper.load("./{*}Grid/{*}Col/{*}ImpRespBW")
274
+ sicd_ew["Grid"]["Row"]["ImpRespBW"]
275
+ * sicd_ew["Grid"]["Col"]["ImpRespBW"]
247
276
  * bw_sf
248
277
  )
249
278
 
@@ -1 +1 @@
1
- __version__ = '0.1.0'
1
+ __version__ = '0.3.0'