src/coecms/um/um2oasis.py
def create_um_lfrac_from_mom(gridspec, targetgrid):
    """
    Sets up UM land fraction consistent with the MOM mask by interpolating the
    MOM 'wet' field conservatively

    Args:
        gridspec (xarray.DataArray): MOM grid_spec.nc data
        targetgrid (xarray.DataArray): Sample field on the UM target grid

    Returns:
        xarray.DataArray containing the UM land fraction on the target grid
    """
    src_scrip = mom_t_scrip_grid(gridspec)
    tgt_scrip = latlon_scrip_grid(targetgrid)

    src_scrip['grid_imask'] = src_scrip.grid_imask * 0 + 1
    tgt_scrip['grid_imask'] = tgt_scrip.grid_imask * 0 + 1

    weights = esmf_generate_weights(
            src_scrip,
            tgt_scrip,
            method='conserve',
            norm_type='fracarea',
            extrap_method='none',
            ignore_unmapped=True,
            )

    mom_wet_on_um = regrid(xarray.DataArray(gridspec.wet.values, dims=['lat', 'lon']), weights=weights)

    um_land_frac = 1 - mom_wet_on_um

    # Clean the field limits
    um_land_frac = um_land_frac.where(um_land_frac < 0.99, 1.0)
    um_land_frac = um_land_frac.where(um_land_frac > 0.01, 0.0)

    return um_land_frac

    Sets up UM land fraction consistent with the MOM mask by interpolating the
    MOM 'wet' field conservatively

    Args:
        gridspec (xarray.DataArray): MOM grid_spec.nc data
        targetgrid (xarray.DataArray): Sample field on the UM target grid

    Returns:
        xarray.DataArray containing the UM land fraction on the target grid
    
Sets up UM land fraction consistent with the MOM mask by interpolating the
MOM 'wet' field conservatively
Sets up UM land fraction consistent with the MOM mask by interpolating the MOM ' wet ' field conservatively
def create_um_lfrac_from_mom(gridspec, targetgrid):
    src_scrip = mom_t_scrip_grid(gridspec)
    tgt_scrip = latlon_scrip_grid(targetgrid)
    src_scrip['grid_imask'] = src_scrip.grid_imask * 0 + 1
    tgt_scrip['grid_imask'] = tgt_scrip.grid_imask * 0 + 1
    weights = esmf_generate_weights(
            src_scrip,
            tgt_scrip,
            method='conserve',
            norm_type='fracarea',
            extrap_method='none',
            ignore_unmapped=True,
            )
    mom_wet_on_um = regrid(xarray.DataArray(gridspec.wet.values, dims=['lat', 'lon']), weights=weights)
    um_land_frac = 1 - mom_wet_on_um
    um_land_frac = um_land_frac.where(um_land_frac < 0.99, 1.0)
    um_land_frac = um_land_frac.where(um_land_frac > 0.01, 0.0)
    return um_land_frac
def create_um_lfrac_from_mom ( gridspec , targetgrid ) : src_scrip = mom_t_scrip_grid ( gridspec ) tgt_scrip = latlon_scrip_grid ( targetgrid ) src_scrip [ 'grid_imask' ] = src_scrip . grid_imask * 0 + 1 tgt_scrip [ 'grid_imask' ] = tgt_scrip . grid_imask * 0 + 1 weights = esmf_generate_weights ( src_scrip , tgt_scrip , method = 'conserve' , norm_type = 'fracarea' , extrap_method = 'none' , ignore_unmapped = True , ) mom_wet_on_um = regrid ( xarray . DataArray ( gridspec . wet . values , dims = [ 'lat' , 'lon' ] ) , weights = weights ) um_land_frac = 1 - mom_wet_on_um um_land_frac = um_land_frac . where ( um_land_frac < 0.99 , 1.0 ) um_land_frac = um_land_frac . where ( um_land_frac > 0.01 , 0.0 ) return um_land_frac
Sets up UM land fraction consistent with the MOM mask by interpolating the
MOM 'wet' field conservatively
Sets up UM land fraction consistent with the MOM mask by interpolating the MOM ' wet ' field conservatively
"""
    Sets up UM land fraction consistent with the MOM mask by interpolating the
    MOM 'wet' field conservatively

    Args:
        gridspec (xarray.DataArray): MOM grid_spec.nc data
        targetgrid (xarray.DataArray): Sample field on the UM target grid

    Returns:
        xarray.DataArray containing the UM land fraction on the target grid
    """ # Clean the field limits
xarray.DataArray containing the UM land fraction on the target grid
xarray . DataArray containing the UM land fraction on the target grid
gridspec
MOM grid_spec.nc data
MOM grid_spec . nc data
targetgrid
Sample field on the UM target grid
Sample field on the UM target grid