@Test
@Ignore("takes a few seconds")
public void testStitchMet_tx() throws IOException, PDUStitchingException, InvalidRangeException, URISyntaxException {

    final String ncFileName = "met_tx.nc";
    final ImageSize targetImageSize = new ImageSize("in", 21687, 64, 6000, 130);
    final ImageSize[] imageSizes = new ImageSize[3];
    imageSizes[0] = new ImageSize("in", 21687, 64, 2000, 130);
    imageSizes[1] = new ImageSize("in", 23687, 64, 2000, 130);
    imageSizes[2] = new ImageSize("in", 25687, 64, 2000, 130);
    final Date now = Calendar.getInstance().getTime();
    final File[] ncFiles = getNcFiles(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(28, variables.size());
    assertEquals("t_single", variables.get(0).getFullName());
    assertEquals(DataType.SHORT, variables.get(0).getDataType());
    assertEquals("sea_ice_fraction_tx", variables.get(9).getFullName());
    assertEquals(DataType.FLOAT, variables.get(9).getDataType());
    assertEquals("u_wind_tx", variables.get(10).getFullName());
    assertEquals(DataType.FLOAT, variables.get(10).getDataType());
    assertEquals("snow_depth_tx", variables.get(27).getFullName());
    assertEquals(DataType.FLOAT, variables.get(27).getDataType());
    List<Attribute> snowLiquidAttributes = variables.get(27).getAttributes();
    assertEquals("_ChunkSize", snowLiquidAttributes.get(0).getFullName());
    assertEquals("1 600 130 ", snowLiquidAttributes.get(0).getValues().toString());
    assertEquals("long_name", snowLiquidAttributes.get(1).getFullName());
    assertEquals("Snow liquid water equivalent depth", snowLiquidAttributes.get(1).getStringValue());
    assertEquals("standard_name", snowLiquidAttributes.get(2).getFullName());
    assertEquals("lwe_thickness_of_surface_snow_amount", snowLiquidAttributes.get(2).getStringValue());
    assertEquals("units", snowLiquidAttributes.get(3).getFullName());
    assertEquals("metre", snowLiquidAttributes.get(3).getStringValue());
    assertEquals("model", snowLiquidAttributes.get(4).getFullName());
    assertEquals("ECMWF_F", snowLiquidAttributes.get(4).getStringValue());
    assertEquals("parameter", snowLiquidAttributes.get(5).getFullName());
    assertEquals("141", snowLiquidAttributes.get(5).getStringValue());
    final List<Variable>[] inputFileVariables = new ArrayList[3];
    for (int i = 0; i < 3; i++) {
        final NetcdfFile ncFile = NetcdfFileOpener.open(ncFiles[i]);
        assertNotNull(ncFile);
        inputFileVariables[i] = ncFile.getVariables();
    }
    for (int i = 0; i < variables.size(); i++) {
        Variable variable = variables.get(i);
        for (int j = 0; j < inputFileVariables.length; j++) {
            int rowOffset = j * 2000;
            final Variable inputFileVariable = inputFileVariables[j].get(i + 1);
            final List<Dimension> inputFileVariableDimensions = inputFileVariable.getDimensions();
            int[] origin = new int[inputFileVariableDimensions.size()];
            int[] shape = new int[inputFileVariableDimensions.size()];
            for (int k = 0; k < inputFileVariableDimensions.size(); k++) {
                if (inputFileVariableDimensions.get(k).getFullName().equals("rows")) {
                    origin[k] = rowOffset;
                    shape[k] = 2000;
                } else {
                    origin[k] = 0;
                    shape[k] = inputFileVariableDimensions.get(k).getLength();
                }
            }
            final Section section = new Section(origin, shape);
            final Array stitchedArrayPart = variable.read(section);
            final Array fileArray = inputFileVariable.read();
            if (variable.getDataType() == DataType.SHORT) {
                final short[] expectedArray = (short[]) fileArray.copyTo1DJavaArray();
                final short[] actualArray = (short[]) stitchedArrayPart.copyTo1DJavaArray();
                assertArrayEquals(expectedArray, actualArray);
            } else {
                final float[] expectedArray = (float[]) fileArray.copyTo1DJavaArray();
                final float[] actualArray = (float[]) stitchedArrayPart.copyTo1DJavaArray();
                assertArrayEquals(expectedArray, actualArray, 1e-8f);
            }
        }
    }
}