sarkit-convert 0.1.0__py3-none-any.whl → 0.2.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/iceye.py CHANGED
@@ -11,6 +11,7 @@ Note: In the development of this converter "Iceye Product Metadata" description
11
11
 
12
12
  import argparse
13
13
  import copy
14
+ import datetime
14
15
  import pathlib
15
16
 
16
17
  import dateutil.parser
@@ -24,6 +25,7 @@ import sarkit.wgs84
24
25
  from sarkit import _constants
25
26
  from sarkit.verification import SicdConsistency
26
27
 
28
+ from sarkit_convert import __version__
27
29
  from sarkit_convert import _utils as utils
28
30
 
29
31
  NSMAP = {
@@ -226,7 +228,7 @@ def _calc_deltaks(x_coords, y_coords, deltak_coa_poly, imp_resp_bw, spacing):
226
228
  return min_deltak, max_deltak
227
229
 
228
230
 
229
- def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
231
+ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid):
230
232
  """Converts Iceye native SLC h5 files to NGA standard SICD files.
231
233
 
232
234
  Parameters
@@ -237,7 +239,7 @@ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
237
239
  path of the output SICD file.
238
240
  classification: str
239
241
  content of the /SICD/CollectionInfo/Classification node in the SICD XML.
240
- ostaid: str, optional
242
+ ostaid: str
241
243
  content of the originating station ID (OSTAID) field of the NITF header.
242
244
 
243
245
  """
@@ -411,25 +413,27 @@ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
411
413
  / 2,
412
414
  )
413
415
 
414
- x_order = min(3, range_scp_m.shape[0] - 1)
415
- y_order = min(3, range_scp_m.shape[1] - 1)
416
+ x_order = min(4, range_scp_m.shape[0] - 1)
417
+ y_order = min(4, range_scp_m.shape[1] - 1)
416
418
 
417
419
  # fit the doppler centroid sample array
418
- dop_centroid_poly_coefs = utils.polyfit2d(
420
+ dop_centroid_poly_coefs = utils.polyfit2d_tol(
419
421
  range_scp_m.flatten(),
420
422
  azimuth_scp_m.flatten(),
421
423
  dc_sample_array.flatten(),
422
424
  x_order,
423
425
  y_order,
426
+ 1e-2,
424
427
  )
425
428
  doppler_rate_sampled = npp.polyval(azimuth_scp_m, drca_poly_coefs)
426
429
  time_coa = dc_zd_times + dc_sample_array / doppler_rate_sampled
427
- time_coa_poly_coefs = utils.polyfit2d(
430
+ time_coa_poly_coefs = utils.polyfit2d_tol(
428
431
  range_scp_m.flatten(),
429
432
  azimuth_scp_m.flatten(),
430
433
  time_coa.flatten(),
431
434
  x_order,
432
435
  y_order,
436
+ 1e-3,
433
437
  )
434
438
 
435
439
  return dop_centroid_poly_coefs, time_coa_poly_coefs
@@ -566,7 +570,6 @@ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
566
570
  image_creation = sicd.ImageCreation(
567
571
  sicd.Application(creation_application),
568
572
  sicd.DateTime(creation_date_time.isoformat() + "Z"),
569
- sicd.Site(ostaid),
570
573
  )
571
574
  image_data = sicd.ImageData(
572
575
  sicd.PixelType(pixel_type),
@@ -689,6 +692,11 @@ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
689
692
  ),
690
693
  )
691
694
 
695
+ now = (
696
+ datetime.datetime.now(datetime.timezone.utc)
697
+ .isoformat(timespec="microseconds")
698
+ .replace("+00:00", "Z")
699
+ )
692
700
  image_formation = sicd.ImageFormation(
693
701
  sicd.RcvChanProc(sicd.NumChanProc("1"), sicd.ChanIndex("1")),
694
702
  sicd.TxRcvPolarizationProc(tx_rcv_polarization_proc),
@@ -702,6 +710,10 @@ def hdf5_to_sicd(h5_filename, sicd_filename, classification, ostaid="Unknown"):
702
710
  sicd.ImageBeamComp(image_beam_comp),
703
711
  sicd.AzAutofocus(az_autofocus),
704
712
  sicd.RgAutofocus(rg_autofocus),
713
+ sicd.Processing(
714
+ sicd.Type(f"sarkit-convert {__version__} @ {now}"),
715
+ sicd.Applied("true"),
716
+ ),
705
717
  )
706
718
 
707
719
  radiometric = sicd.Radiometric(
@@ -855,21 +867,20 @@ def main(args=None):
855
867
  type=pathlib.Path,
856
868
  help="path of the input HDF5 file",
857
869
  )
858
- parser.add_argument(
859
- "classification",
860
- type=str,
861
- help="content of the /SICD/CollectionInfo/Classification node in the SICD XML",
862
- )
863
870
  parser.add_argument(
864
871
  "output_sicd_file",
865
872
  type=pathlib.Path,
866
873
  help="path of the output SICD file",
867
874
  )
868
875
  parser.add_argument(
869
- "--ostaid",
876
+ "classification",
877
+ type=str,
878
+ help="content of the /SICD/CollectionInfo/Classification node in the SICD XML",
879
+ )
880
+ parser.add_argument(
881
+ "ostaid",
870
882
  type=str,
871
883
  help="content of the originating station ID (OSTAID) field of the NITF header",
872
- default="Unknown",
873
884
  )
874
885
  config = parser.parse_args(args)
875
886