Esempio n. 1
0
    logger = logging.getLogger('sarpy')
    logger.setLevel(level)

    reader = open_complex(args.input_file)
    degree = _parse_method(args.method)
    for i, sicd in enumerate(reader.get_sicds_as_tuple()):
        if isinstance(degree, int):
            ortho_helper = BivariateSplineMethod(reader,
                                                 index=i,
                                                 row_order=degree,
                                                 col_order=degree)
        else:
            ortho_helper = NearestNeighborMethod(reader, index=i)
        if args.type == 'detected':
            create_detected_image_sidd(ortho_helper,
                                       args.output_directory,
                                       version=args.version,
                                       include_sicd=args.sicd)
        elif args.type == 'csi':
            create_csi_sidd(ortho_helper,
                            args.output_directory,
                            version=args.version,
                            include_sicd=args.sicd)
        elif args.type == 'dynamic':
            create_dynamic_image_sidd(ortho_helper,
                                      args.output_directory,
                                      version=args.version,
                                      include_sicd=args.sicd)
        else:
            raise ValueError('Got unhandled type {}'.format(args.type))
Esempio n. 2
0
    def test_sidd_creation(self):
        for fil in sicd_files:
            reader = SICDReader(fil)
            ortho_helper = NearestNeighborMethod(reader)

            # create a temp directory
            temp_directory = tempfile.mkdtemp()
            sidd_files = []

            # create a basic sidd detected image
            with self.subTest(
                    msg='Create version 1 detected image for file {}'.format(
                        fil)):
                create_detected_image_sidd(ortho_helper,
                                           temp_directory,
                                           output_file='di_1.nitf',
                                           version=1)
                sidd_files.append('di_1.nitf')
            with self.subTest(
                    msg='Create version 2 detected image for file {}'.format(
                        fil)):
                create_detected_image_sidd(ortho_helper,
                                           temp_directory,
                                           output_file='di_2.nitf',
                                           version=2)
                sidd_files.append('di_2.nitf')

            # create a csi image
            with self.subTest(
                    msg='Create version 1 csi for file {}'.format(fil)):
                create_csi_sidd(ortho_helper,
                                temp_directory,
                                output_file='csi_1.nitf',
                                version=1)
                sidd_files.append('csi_1.nitf')
            with self.subTest(
                    msg='Create version 2 csi for file {}'.format(fil)):
                create_csi_sidd(ortho_helper,
                                temp_directory,
                                output_file='csi_2.nitf',
                                version=2)
                sidd_files.append('csi_2.nitf')

            # create a dynamic image
            with self.subTest(
                    msg='Create version 1 subaperture stack for file {}'.
                    format(fil)):
                create_dynamic_image_sidd(ortho_helper,
                                          temp_directory,
                                          output_file='sast_1.nitf',
                                          version=1,
                                          frame_count=3)
                sidd_files.append('sast_1.nitf')
            with self.subTest(
                    msg='Create version 2 subaperture stack for file {}'.
                    format(fil)):
                create_dynamic_image_sidd(ortho_helper,
                                          temp_directory,
                                          output_file='sast_2.nitf',
                                          version=2,
                                          frame_count=3)
                sidd_files.append('sast_2.nitf')

            # check that each sidd structure serialized according to the schema
            if etree is not None:
                for vers in [1, 2]:
                    schema = get_schema_path('urn:SIDD:{}.0.0'.format(vers))
                    the_fil = 'di_{}.nitf'.format(vers)
                    if the_fil in sidd_files:
                        self.assertTrue(
                            check_versus_schema(
                                os.path.join(temp_directory, the_fil), schema),
                            'Detected image version {} structure not valid versus schema {}'
                            .format(vers, schema))

                    the_fil = 'csi_{}.nitf'.format(vers)
                    if the_fil in sidd_files:
                        self.assertTrue(
                            check_versus_schema(
                                os.path.join(temp_directory, the_fil), schema),
                            'csi version {} structure not valid versus schema {}'
                            .format(vers, schema))

                    the_fil = 'sast_{}.nitf'.format(vers)
                    if the_fil in sidd_files:
                        self.assertTrue(
                            check_versus_schema(
                                os.path.join(temp_directory, the_fil), schema),
                            'Dynamic image version {} structure not valid versus schema {}'
                            .format(vers, schema))

            # clean up the temporary directory
            shutil.rmtree(temp_directory)