@Test
public void testStitchF1_BT_io() throws Exception {

    final String ncFileName = "F1_BT_io.nc";
    final ImageSize targetImageSize = new ImageSize("io", 21687, 450, 6000, 900);
    final ImageSize[] imageSizes = new ImageSize[1];
    imageSizes[0] = new ImageSize("io", 23687, 450, 2000, 900);
    final Date now = Calendar.getInstance().getTime();
    final File[] ncFiles = new File[]{getSecondNcFile(ncFileName)};
    final File stitchedFile = NcFileStitcher.stitchNcFiles(ncFileName, targetDirectory, now, ncFiles,
                                                           targetImageSize, imageSizes);
    assert (stitchedFile != null);
    assert (stitchedFile.exists());
    assertEquals(ncFileName, stitchedFile.getName());
    netcdfFile = NetcdfFileOpener.open(stitchedFile);
    assertNotNull(netcdfFile);
    final List<Variable> variables = netcdfFile.getVariables();
    assertEquals(4, variables.size());
    assertEquals("F1_BT_io", variables.get(0).getFullName());
    assertEquals(DataType.SHORT, variables.get(0).getDataType());
    assertEquals("rows columns", variables.get(0).getDimensionsString());
    final List<Attribute> F1_BT_io_attributes = variables.get(0).getAttributes();
    assertEquals("_ChunkSize", F1_BT_io_attributes.get(0).getFullName());
    Array chunkLengths = F1_BT_io_attributes.get(0).getValues();
    assertEquals(1, chunkLengths.getShape().length);
    assertEquals(2, chunkLengths.getShape()[0]);
    assertEquals(600, chunkLengths.getInt(0));
    assertEquals(450, chunkLengths.getInt(1));
    assertEquals("standard_name", F1_BT_io_attributes.get(1).getFullName());
    assertEquals("toa_brightness_temperature", F1_BT_io_attributes.get(1).getStringValue());
    assertEquals("long_name", F1_BT_io_attributes.get(2).getFullName());
    assertEquals("Gridded pixel brightness temperature for channel F1 (1km TIR grid, oblique view)",
                 F1_BT_io_attributes.get(2).getStringValue());
    assertEquals("units", F1_BT_io_attributes.get(3).getFullName());
    assertEquals("K", F1_BT_io_attributes.get(3).getStringValue());
    assertEquals("_FillValue", F1_BT_io_attributes.get(4).getFullName());
    assertEquals((short) -32768, F1_BT_io_attributes.get(4).getNumericValue());
    assertEquals("scale_factor", F1_BT_io_attributes.get(5).getFullName());
    assertEquals(0.01, F1_BT_io_attributes.get(5).getNumericValue());
    assertEquals("add_offset", F1_BT_io_attributes.get(6).getFullName());
    assertEquals(283.73, F1_BT_io_attributes.get(6).getNumericValue());
    assertEquals("F1_exception_io", variables.get(1).getFullName());
    assertEquals("F1_BT_orphan_io", variables.get(2).getFullName());
    assertEquals("F1_exception_orphan_io", variables.get(3).getFullName());
    assertEquals(DataType.UBYTE, variables.get(3).getDataType());
    assertEquals(true, variables.get(3).getDataType().isUnsigned());
    assertEquals("rows orphan_pixels", variables.get(3).getDimensionsString());
    final List<Attribute> F1_exception_orphan_io_attributes = variables.get(3).getAttributes();
    assertEquals("_ChunkSize", F1_exception_orphan_io_attributes.get(0).getFullName());
    chunkLengths = F1_exception_orphan_io_attributes.get(0).getValues();
    assertEquals(1, chunkLengths.getShape().length);
    assertEquals(2, chunkLengths.getShape()[0]);
    assertEquals(600, chunkLengths.getInt(0));
    assertEquals(112, chunkLengths.getInt(1));
    assertEquals("standard_name", F1_exception_orphan_io_attributes.get(1).getFullName());
    assertEquals("toa_brightness_temperature_status_flag", F1_exception_orphan_io_attributes.get(1).getStringValue());
    assertEquals("flag_masks", F1_exception_orphan_io_attributes.get(2).getFullName());
    assertEquals(true, F1_exception_orphan_io_attributes.get(2).isArray());
    final Array F1_exception_orphan_io_values = F1_exception_orphan_io_attributes.get(2).getValues();
    assertEquals(8, F1_exception_orphan_io_values.getSize());
    assertEquals(DataType.UBYTE, F1_exception_orphan_io_values.getDataType());
    assertEquals(true, F1_exception_orphan_io_values.isUnsigned());
    assertEquals((byte) 1, F1_exception_orphan_io_values.getByte(0));
    assertEquals((byte) 2, F1_exception_orphan_io_values.getByte(1));
    assertEquals((byte) 4, F1_exception_orphan_io_values.getByte(2));
    assertEquals((byte) 8, F1_exception_orphan_io_values.getByte(3));
    assertEquals((byte) 16, F1_exception_orphan_io_values.getByte(4));
    assertEquals((byte) 32, F1_exception_orphan_io_values.getByte(5));
    assertEquals((byte) 64, F1_exception_orphan_io_values.getByte(6));
    assertEquals((byte) 128, F1_exception_orphan_io_values.getByte(7));
    assertEquals("flag_meanings", F1_exception_orphan_io_attributes.get(3).getFullName());
    assertEquals("ISP_absent pixel_absent not_decompressed no_signal saturation invalid_radiance no_parameters unfilled_pixel",
                 F1_exception_orphan_io_attributes.get(3).getStringValue());
    assertEquals("_FillValue", F1_exception_orphan_io_attributes.get(4).getFullName());
    assertEquals((byte) -128, F1_exception_orphan_io_attributes.get(4).getNumericValue());
    List<Variable> inputFileVariables = new ArrayList<>();
    for (int i = 0; i < 1; i++) {
        final NetcdfFile ncfile = NetcdfFileOpener.open(ncFiles[i]);
        assertNotNull(ncfile);
        inputFileVariables = ncfile.getVariables();
    }
    for (int i = 0; i < variables.size(); i++) {
        Variable variable = variables.get(i);
        int offset = 2000;
        final Section section = new Section(new int[]{offset, 0}, new int[]{offset, variable.getDimension(1).getLength()});
        final Array stitchedArrayPart = variable.read(section);
        final Array fileArray = inputFileVariables.get(i).read();
        if (variable.getDataType() == DataType.SHORT) {
            final short[] expectedArray = (short[]) fileArray.copyTo1DJavaArray();
            final short[] actualArray = (short[]) stitchedArrayPart.copyTo1DJavaArray();
            assertArrayEquals(expectedArray, actualArray);
        } else {
            final byte[] expectedArray = (byte[]) fileArray.copyTo1DJavaArray();
            final byte[] actualArray = (byte[]) stitchedArrayPart.copyTo1DJavaArray();
            assertArrayEquals(expectedArray, actualArray);
        }
    }
}