Exemplo n.º 1
0
 def test_landmaskcorrection(self):
     """Test landmask correction. Note that the name land_binary_mask is
     enforced to reflect the change that has been made."""
     result = CorrectLand().process(self.landmask)
     self.assertEqual(result.name(), "land_binary_mask")
     self.assertArrayEqual(result.data, self.expected_mask)
     self.assertTrue(result.dtype == np.int8)
def main(argv=None):
    """Load in arguments and get going."""
    parser = ArgParser(description=('Read the input landmask, and correct '
                                    'to boolean values.'))
    parser.add_argument('--force',
                        dest='force',
                        default=False,
                        action='store_true',
                        help=('If True, ancillaries will be generated '
                              'even if doing so will overwrite existing '
                              'files.'))
    parser.add_argument('input_filepath_standard',
                        metavar='INPUT_FILE_STANDARD',
                        help='A path to an input NetCDF file to be processed')
    parser.add_argument('output_filepath',
                        metavar='OUTPUT_FILE',
                        help='The output path for the processed NetCDF')
    args = parser.parse_args(args=argv)

    # Check if improver ancillary already exists.
    if not os.path.exists(args.output_filepath) or args.force:
        landmask = load_cube(args.input_filepath_standard)
        land_binary_mask = CorrectLandSeaMask().process(landmask)
        save_netcdf(land_binary_mask, args.output_filepath)
    else:
        print('File already exists here: ', args.output_filepath)
def process(landmask):
    """Runs landmask ancillary generation.

    Read in the interpolated landmask and round
    values < 0.5 to False
    values >= 0.5 to True.

    Args:
        landmask (iris.cube.Cube):
            Cube to process

    Returns:
        iris.cube.Cube:
            A cube landmask of boolean values.
    """
    return CorrectLandSeaMask().process(landmask)
Exemplo n.º 4
0
def process(land_sea_mask: cli.inputcube):
    """Generate a land_sea_mask ancillary.

    Reads in the interpolated land_sea_mask and rounds
    values < 0.5 to False
    values >= 0.5 to True.

    Args:
        land_sea_mask (iris.cube.Cube):
            Cube to process.

    Returns:
        iris.cube.Cube:
            A land_sea_mask of boolean values.
    """
    from improver.generate_ancillaries.generate_ancillary import CorrectLandSeaMask

    return CorrectLandSeaMask()(land_sea_mask)
 def test_landmaskcorrection(self):
     """Test landmask correction"""
     result = CorrectLand().process(self.landmask)
     self.assertEqual(result.name(), 'test land')
     self.assertArrayEqual(result.data, self.expected_mask)