Skip to content

Soil level clm surface input data for clm5.2.0 have missing values in large domains #2744

@maritsandstad

Description

@maritsandstad

Brief summary of bug

Input surface data for clm on spectral element grid ne30 (inputdata/lnd/clm2/surfdata_esmf/ctsm5.2.0/surfdata_ne30np4.pg3_hist_1850_78pfts_c240216.nc) at least for clm5.2.0 have weird/missing values for parts of the grid.

Here is an example showing organic carbon summed over the soil levels and similar patterns of missing data seem to be present in all the soil level data I've tried plotting including PCT_CLAY, PCT_SAND:

ORGC_output_se_toplevel_map

This pattern shows up similarly in output datasets

General bug information

Plotting and regridding input data from surface input data for spectral element grid ne30 for clm5.2.0 (inputdata/lnd/clm2/surfdata_esmf/ctsm5.2.0/surfdata_ne30np4.pg3_hist_1850_78pfts_c240216.nc) data for variables on soil levels seem to be looking weird and missing data for what looks like some of the spectral element domains.

Above is an example plot of what organic carbon summed over soil levels looks like, but the pattern of missing data seems to be the same for all the soil level data that I have plotted so far. Looking at the LMR picture framing from https://journals.ametsoc.org/view/journals/mwre/134/12/mwr3360.1.xml I can almost see at least some of the domains that are missing, here is an attempt at colouring in the missing parts:

Screenshot 2024-09-06 151006

CTSM version you are using: [output of git describe]
clm5.2.0 ne30

Does this bug cause significantly incorrect results in the model's science? [Yes ]

Configurations affected: [Fill this in if known.]

Details of bug

See above

Important details of your setup / configuration so we can reproduce the bug

I regridded using the xesmf package following this excellent guide: https://ncar.github.io/esds/posts/2022/cam-se-regridding/

For reference here is my regridding code snippet

import numpy as np
import xarray as xr
import xesmf

def make_se_regridder(weight_file):
    weights = xr.open_dataset(weight_file)
    in_shape = weights.src_grid_dims.load().data

    # Since xESMF expects 2D vars, we'll insert a dummy dimension of size-1
    if len(in_shape) == 1:
        in_shape = [1, in_shape.item()]

    # output variable shape
    out_shape = weights.dst_grid_dims.load().data.tolist()[::-1]

    dummy_in = xr.Dataset(
        {
            "lat": ("lat", np.empty((in_shape[0],))),
            "lon": ("lon", np.empty((in_shape[1],))),
        }
    )
    dummy_out = xr.Dataset(
        {
            "lat": ("lat", weights.yc_b.data.reshape(out_shape)[:, 0]),
            "lon": ("lon", weights.xc_b.data.reshape(out_shape)[0, :]),
        }
    )

    regridder = xesmf.Regridder(
        dummy_in,
        dummy_out,
        weights=weight_file,
        method="bilinear",
        reuse_weights=True,
        periodic=True,
    )
    return regridder

def regrid_se_data(regridder, data_to_regrid):
    print(data_to_regrid.dims)
    if isinstance(data_to_regrid, xr.DataArray):
        print(type(data_to_regrid))
        updated = data_to_regrid.copy().transpose(..., "lndgrid").expand_dims("dummy", axis=-2)
    else:
        vars_with_ncol = [name for name in data_to_regrid.variables if "ncol" in data_to_regrid[name].dims]
        updated = data_to_regrid.copy().update(
            data_to_regrid[vars_with_ncol].transpose(..., "lndgrid").expand_dims("dummy", axis=-2)
        )
    regridded = regridder(updated.rename({"dummy": "lat", "lndgrid": "lon"}))
    return regridded

I used this file for mapping inputdata/lnd/clm2/mappingdata/maps/ne30pg3/map_ne30pg3_to_0.5x0.5_nomask_aave_da_c180515.nc

The regridding looked ok and completely sane for other variables that didn't have soil level, and the pattern persisted regardless of whether I regridded a variable with the soil level dimension, or if I summed over and thereby eliminated the soil level dimension before regridding. It also looked the same if I regridded the same output variables from the first history files from a run.

Important output or errors that show the problem

See above

Metadata

Metadata

Assignees

Labels

bugsomething is working incorrectlyscienceEnhancement to or bug impacting science

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions