コード例 #1
0
ファイル: tosga.py プロジェクト: E3SM-Project/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_activeTracers_temperature into CMIP.tosga

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    if kwargs.get('simple'):
        msg = f"{VAR_NAME} is not supported for simple conversion"
        print_message(msg)
        return

    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    timeSeriesFiles = infiles['MPASO']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    cellMask2D, _ = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_activeTracers_temperature', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        thetao = dsIn.timeMonthly_avg_activeTracers_temperature
        tos = thetao.isel(nVertLevels=0).squeeze(drop=True).where(cellMask2D)
        areaCell = dsMesh.areaCell.where(cellMask2D)
        ds[VAR_NAME] = ((tos * areaCell).sum(dim='nCells') /
                        areaCell.sum(dim='nCells'))
        ds = mpas.add_time(ds, dsIn)
        ds.compute()
    ds.compute()

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{'table_entry': 'time', 'units': ds.time.units}]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #2
0
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_layerThickness and
    timeMonthly_avg_activeTracers_temperature into CMIP.thetaoga

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    timeSeriesFiles = infiles['MPASO']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    _, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_layerThickness',
        'timeMonthly_avg_activeTracers_temperature', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        layerThickness = dsIn.timeMonthly_avg_layerThickness.where(cellMask3D)
        thetao = dsIn.timeMonthly_avg_activeTracers_temperature.where(
            cellMask3D)
        vol = layerThickness * dsMesh.areaCell
        volo = (vol).sum(dim=['nVertLevels', 'nCells'])
        ds[VAR_NAME] = (vol * thetao).sum(dim=['nVertLevels', 'nCells']) / volo

        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{'table_entry': 'time', 'units': ds.time.units}]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #3
0
ファイル: mlotst.py プロジェクト: lukaszlacinski/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_dThreshMLD into CMIP.mlotst

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASO']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    cellMask2D, _ = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_dThreshMLD', 'xtime_startMonthly', 'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        ds[VAR_NAME] = dsIn.timeMonthly_avg_dThreshMLD.where(cellMask2D)

        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.add_mask(ds, cellMask2D)
    ds = mpas.remap(ds, mappingFileName)

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #4
0
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_layerThickness into CMIP.masscello

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    if kwargs.get('simple'):
        msg = f"{VAR_NAME} is not supported for simple conversion"
        print_message(msg)
        return

    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    namelistFileName = infiles['MPASO_namelist']
    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASO']

    namelist = mpas.convert_namelist_to_dict(namelistFileName)
    config_density0 = float(namelist['config_density0'])

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    _, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_layerThickness', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        ds[VAR_NAME] = config_density0 * \
            dsIn.timeMonthly_avg_layerThickness.where(cellMask3D, 0.)
        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.add_depth(ds, dsMesh)
    ds.compute()

    ds = mpas.remap(ds, mappingFileName)

    # set masked values (where there are no MPAS grid cells) to zero
    ds[VAR_NAME] = ds[VAR_NAME].where(
        ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.)

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'depth_coord',
        'units': 'm',
        'coord_vals': ds.depth.values,
        'cell_bounds': ds.depth_bnds.values
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #5
0
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_frazilLayerThicknessTendency into
    CMIP.hfsifrazil

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    timeSeriesFiles = infiles['MPASO']
    mappingFileName = infiles['MPAS_map']
    meshFileName = infiles['MPAS_mesh']
    namelistFileName = infiles['MPASO_namelist']

    namelist = mpas.convert_namelist_to_dict(namelistFileName)
    config_density0 = float(namelist['config_density0'])
    config_frazil_heat_of_fusion = \
        float(namelist['config_frazil_heat_of_fusion'])

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    _, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_frazilLayerThicknessTendency', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        ds[VAR_NAME] = -config_density0 * config_frazil_heat_of_fusion * \
            dsIn.timeMonthly_avg_frazilLayerThicknessTendency

        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.add_mask(ds, cellMask3D)
    ds = mpas.add_depth(ds, dsMesh)
    ds.compute()

    ds = mpas.remap(ds, mappingFileName)

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'depth_coord',
        'units': 'm',
        'coord_vals': ds.depth.values,
        'cell_bounds': ds.depth_bnds.values
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS, positive='down')
    except Exception:
        return ""
    return VAR_NAME
コード例 #6
0
ファイル: volcello.py プロジェクト: JGCRI/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_layerThickness into CMIP.thkcello

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    if kwargs.get('simple'):
        msg = f"{VAR_NAME} is not supported for simple conversion"
        print_message(msg)
        return

    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASO']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    earth_radius = dsMesh.attrs['sphere_radius']
    _, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_layerThickness', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        ds[VAR_NAME] = \
            dsIn.timeMonthly_avg_layerThickness.where(cellMask3D, 0.)
        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.add_depth(ds, dsMesh)
    ds.compute()

    ds = mpas.remap(ds, mappingFileName)

    # set masked values (where there are no MPAS grid cells) to zero
    ds[VAR_NAME] = ds[VAR_NAME].where(
        ds[VAR_NAME] != netCDF4.default_fillvals['f4'], 0.)

    # the result above is just a mask of area fraction.  We need to multiply
    # by the area on the output grid
    dsMap = xarray.open_dataset(mappingFileName)
    area_b = dsMap.area_b.values
    dst_grid_dims = dsMap.dst_grid_dims.values
    area_b = area_b.reshape((dst_grid_dims[1], dst_grid_dims[0]))
    area_b = xarray.DataArray(data=area_b,
                              dims=('lat', 'lon'),
                              coords=(ds.coords['lat'], ds.coords['lon']))

    # area_b is in square radians, so need to multiply by the earth_radius**2
    # multiply variables in this order so they don't get transposed
    ds[VAR_NAME] = ds[VAR_NAME] * earth_radius**2 * area_b

    setup_cmor(var_name=VAR_NAME,
               table_path=tables,
               table_name=TABLE,
               user_input_path=user_input_path)

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'depth_coord',
        'units': 'm',
        'coord_vals': ds.depth.values,
        'cell_bounds': ds.depth_bnds.values
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #7
0
ファイル: sithick.py プロジェクト: JGCRI/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASSI timeMonthly_avg_iceAreaCell and
    timeMonthly_avg_iceVolumeCell into CMIP.sithick

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    if kwargs.get('simple'):
        msg = f"{VAR_NAME} is not supported for simple conversion"
        print_message(msg)
        return

    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASSI']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    cellMask2D, _ = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_iceAreaCell', 'timeMonthly_avg_iceVolumeCell',
        'xtime_startMonthly', 'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        ds[VAR_NAME] = dsIn.timeMonthly_avg_iceVolumeCell
        ds['siconc'] = dsIn.timeMonthly_avg_iceAreaCell
        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.add_si_mask(ds, cellMask2D, ds.siconc)
    ds['cellMask'] = ds.siconc * ds.cellMask
    ds.compute()

    ds = mpas.remap(ds, mappingFileName)

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='seaice')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]

    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #8
0
ファイル: pbo.py プロジェクト: lukaszlacinski/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_pressureAdjustedSSH, timeMonthly_avg_ssh,
    timeMonthly_avg_density, timeMonthly_avg_layerThickness, and EAM PSL into
    CMIP.pbo

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    namelistFileName = infiles['MPASO_namelist']
    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASO']
    pslFileNames = infiles['PSL']

    namelist = mpas.convert_namelist_to_dict(namelistFileName)
    config_density0 = float(namelist['config_density0'])
    gravity = 9.80616

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    cellMask2D, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_pressureAdjustedSSH', 'timeMonthly_avg_ssh',
        'timeMonthly_avg_layerThickness', 'timeMonthly_avg_density',
        'xtime_startMonthly', 'xtime_endMonthly'
    ]

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        seaIcePressure = config_density0 * gravity * \
            (dsIn.timeMonthly_avg_pressureAdjustedSSH -
             dsIn.timeMonthly_avg_ssh)
        ds[VAR_NAME] = seaIcePressure.where(cellMask2D) + gravity * \
            (dsIn.timeMonthly_avg_density *
             dsIn.timeMonthly_avg_layerThickness).where(cellMask3D).sum(
                dim='nVertLevels')

        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.remap(ds, mappingFileName)

    with xarray.open_mfdataset(pslFileNames, concat_dim='time') as dsIn:
        ds[VAR_NAME] = ds[VAR_NAME] + dsIn.PSL.values

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #9
0
ファイル: zhalfo.py プロジェクト: lukaszlacinski/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO timeMonthly_avg_layerThickness into CMIP.zhalfo

    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']
    timeSeriesFiles = infiles['MPASO']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    _, cellMask3D = mpas.get_cell_masks(dsMesh)

    variableList = [
        'timeMonthly_avg_layerThickness', 'xtime_startMonthly',
        'xtime_endMonthly'
    ]

    nVertLevels = dsMesh.sizes['nVertLevels']

    ds = xarray.Dataset()
    with mpas.open_mfdataset(timeSeriesFiles, variableList) as dsIn:
        layerThickness = dsIn.timeMonthly_avg_layerThickness
        layerThickness = layerThickness.where(cellMask3D)
        thicknessSum = layerThickness.sum(dim='nVertLevels')
        mask = cellMask3D.isel(nVertLevels=0)
        zSurface = (-dsMesh.bottomDepth + thicknessSum).where(mask)
        zSurface.compute()
        # print('done zSurface')
        slices = [zSurface]
        maskSlices = [mask]
        zLayerBot = zSurface
        for zIndex in range(nVertLevels):
            mask = cellMask3D.isel(nVertLevels=zIndex)
            zLayerBot = (zLayerBot -
                         layerThickness.isel(nVertLevels=zIndex)).where(mask)
            zLayerBot.compute()
            # print('done zLayerBot {}/{}'.format(zIndex+1, nVertLevels))
            slices.append(zLayerBot)
            maskSlices.append(mask)
        ds[VAR_NAME] = xarray.concat(slices, dim='olevhalf')
        mask = xarray.concat(maskSlices, dim='olevhalf')
        ds = mpas.add_mask(ds, mask)
        ds = ds.transpose('Time', 'olevhalf', 'nCells')
        ds = mpas.add_time(ds, dsIn)
        ds.compute()

    ds = mpas.remap(ds, mappingFileName)
    depth_coord_half = numpy.zeros(nVertLevels + 1)
    depth_coord_half[1:] = dsMesh.refBottomDepth.values

    mpas.setup_cmor(VAR_NAME, tables, user_input_path, component='ocean')

    # create axes
    axes = [{
        'table_entry': 'time',
        'units': ds.time.units
    }, {
        'table_entry': 'depth_coord_half',
        'units': 'm',
        'coord_vals': depth_coord_half
    }, {
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME
コード例 #10
0
ファイル: areacello.py プロジェクト: JGCRI/e3sm_to_cmip
def handle(infiles, tables, user_input_path, **kwargs):
    """
    Transform MPASO cellArea into CMIP.areacello
    Parameters
    ----------
    infiles : dict
        a dictionary with namelist, mesh and time series file names

    tables : str
        path to CMOR tables

    user_input_path : str
        path to user input json file

    Returns
    -------
    varname : str
        the name of the processed variable after processing is complete
    """
    if kwargs.get('simple'):
        msg = f"{VAR_NAME} is not supported for simple conversion"
        print_message(msg)
        return

    msg = 'Starting {name}'.format(name=__name__)
    logging.info(msg)

    meshFileName = infiles['MPAS_mesh']
    mappingFileName = infiles['MPAS_map']

    dsMesh = xarray.open_dataset(meshFileName, mask_and_scale=False)
    earth_radius = dsMesh.attrs['sphere_radius']
    cellMask2D, _ = mpas.get_cell_masks(dsMesh)

    ds = xarray.Dataset()
    ds[VAR_NAME] = ('nCells', cellMask2D.astype(float))
    ds = mpas.remap(ds, mappingFileName)

    # the result above is just a mask of area fraction.  We need to multiply
    # by the area on the output grid
    dsMap = xarray.open_dataset(mappingFileName)
    area_b = dsMap.area_b.values
    dst_grid_dims = dsMap.dst_grid_dims.values
    area_b = area_b.reshape((dst_grid_dims[1], dst_grid_dims[0]))
    area_b = xarray.DataArray(data=area_b, dims=ds[VAR_NAME].dims)

    # area_b is in square radians, so need to multiply by the earth_radius**2
    ds[VAR_NAME] = earth_radius**2 * area_b * ds[VAR_NAME]

    setup_cmor(var_name=VAR_NAME,
               table_path=tables,
               table_name=TABLE,
               user_input_path=user_input_path)

    # create axes
    axes = [{
        'table_entry': 'latitude',
        'units': 'degrees_north',
        'coord_vals': ds.lat.values,
        'cell_bounds': ds.lat_bnds.values
    }, {
        'table_entry': 'longitude',
        'units': 'degrees_east',
        'coord_vals': ds.lon.values,
        'cell_bounds': ds.lon_bnds.values
    }]
    try:
        mpas.write_cmor(axes, ds, VAR_NAME, VAR_UNITS)
    except Exception:
        return ""
    return VAR_NAME