diff --git a/src/access_moppy/derivations/__init__.py b/src/access_moppy/derivations/__init__.py index 6e630b7..6f367d8 100644 --- a/src/access_moppy/derivations/__init__.py +++ b/src/access_moppy/derivations/__init__.py @@ -3,10 +3,14 @@ from access_moppy.derivations.calc_atmos import level_to_height from access_moppy.derivations.calc_land import ( - average_tile, + calc_carbon_pool_kg_m2, + calc_cland_with_wood_products, calc_landcover, + calc_mass_pool_kg_m2, + calc_nitrogen_pool_kg_m2, calc_topsoil, extract_tilefrac, + weighted_tile_sum, ) custom_functions = { @@ -19,11 +23,16 @@ "mean": lambda *args: sum(args) / len(args), "kelvin_to_celsius": lambda x: x - 273.15, "celsius_to_kelvin": lambda x: x + 273.15, + "isel": lambda x, **kwargs: x.isel(**kwargs), "level_to_height": level_to_height, "calc_topsoil": calc_topsoil, "calc_landcover": calc_landcover, "extract_tilefrac": extract_tilefrac, - "average_tile": average_tile, + "weighted_tile_sum": weighted_tile_sum, + "calc_cland_with_wood_products": calc_cland_with_wood_products, + "calc_carbon_pool_kg_m2": calc_carbon_pool_kg_m2, + "calc_mass_pool_kg_m2": calc_mass_pool_kg_m2, + "calc_nitrogen_pool_kg_m2": calc_nitrogen_pool_kg_m2, } diff --git a/src/access_moppy/derivations/calc_land.py b/src/access_moppy/derivations/calc_land.py index 6aa880d..9f5e061 100644 --- a/src/access_moppy/derivations/calc_land.py +++ b/src/access_moppy/derivations/calc_land.py @@ -21,29 +21,100 @@ import numpy as np -def extract_tilefrac(tilefrac, tilenum, landfrac=None): +def extract_tilefrac(tilefrac, tilenum, landfrac=None, lev=None): """ - Calculates the land fraction of a specific type (e.g., crops, grass). + Calculates the land fraction of a specific tile type as a percentage. + + This function extracts the fractional coverage of specific land tile types + (e.g., crops, grass, forests) and converts the result to percentage values. + The calculation accounts for the overall land fraction to provide accurate + tile coverage relative to the total grid cell area. Parameters ---------- tilefrac : xarray.DataArray - Tile fraction variable. + Tile fraction variable containing fractional coverage for each tile type. + Must have a pseudo-level dimension representing different tile types. tilenum : int or list of int - Tile number(s) to extract. + Tile number(s) to extract: + - int: Extract single tile type + - list: Extract and sum multiple tile types landfrac : xarray.DataArray, optional - Land fraction variable. If None, raises Exception. + Land fraction variable (fractional, 0-1) representing the proportion + of each grid cell that is land. Required for proper calculation. + lev : str, optional + Name of vegetation type key from mod_mapping dictionary to add as a + dimension to output array. Used for CMOR character-type variables. + Examples: "typebare", "typecrop", "typetree", etc. Returns ------- xarray.DataArray - Land fraction of specified tile(s). + Land fraction of specified tile type(s) as percentage (0-100%). + - Units: % (percentage) + - Missing values filled with 0 + - Represents tile coverage relative to total grid cell area + - If lev is specified, includes additional dimension with vegetation type label Raises ------ Exception - If tilenum is not int or list, or landfrac is None. + If tilenum is not int or list, or if landfrac is None. + + Examples + -------- + Extract crop fraction as percentage: + + >>> crop_percent = extract_tilefrac(tilefrac, 9, landfrac) + + Extract combined grass types with vegetation type dimension: + + >>> grass_percent = extract_tilefrac(tilefrac, [6, 7], landfrac, lev="typenatgr") + + Notes + ----- + - Output is converted to percentage (0-100%) for CMIP compliance + - Multiple tile types are summed before percentage calculation + - Result represents actual land coverage accounting for land/ocean fraction + - Missing values are filled with zeros for consistent output + - When lev is specified, creates dimension for CMOR character-type output """ + # Vegetation type mapping for CMOR character variables + mod_mapping = { + "typebare": "bare_ground", + "typeburnt": "burnt_vegetation", + "typec3pft": "c3_plant_functional_types", + "typec3crop": "crops_of_c3_plant_functional_types", + "typec3natg": "natural_grasses_of_c3_plant_functional_types", + "typec3pastures": "pastures_of_c3_plant_functional_types", + "typec4pft": "c4_plant_functional_types", + "typec4crop": "crops_of_c4_plant_functional_types", + "typec4natg": "natural_grasses_of_c4_plant_functional_types", + "typec4pastures": "pastures_of_c4_plant_functional_types", + "typecloud": "cloud", + "typecrop": "crops", + "typefis": "floating_ice_shelf", + "typegis": "grounded_ice_sheet", + "typeland": "land", + "typeli": "land_ice", + "typemp": "sea_ice_melt_pond", + "typenatgr": "natural_grasses", + "typenwd": "herbaceous_vegetation", + "typepasture": "pastures", + "typepdec": "primary_deciduous_trees", + "typepever": "primary_evergreen_trees", + "typeresidual": "residual", + "typesdec": "secondary_deciduous_trees", + "typesea": "sea", + "typesever": "secondary_evergreen_trees", + "typeshrub": "shrubs", + "typesi": "sea_ice", + "typesirdg": "sea_ice_ridges", + "typetree": "trees", + "typeveg": "vegetation", + "typewetla": "wetland", + } + pseudo_level = tilefrac.dims[1] tilefrac = tilefrac.rename({pseudo_level: "pseudo_level"}) if isinstance(tilenum, int): @@ -54,7 +125,46 @@ def extract_tilefrac(tilefrac, tilenum, landfrac=None): raise Exception("E: tile number must be an integer or list") if landfrac is None: raise Exception("E: landfrac not defined") - vout = vout * landfrac + + # Convert to percentage + vout = vout * landfrac * 100.0 + + # TODO: Revisit adding vegetation type dimension + # Add vegetation type dimension if requested + # if lev: + # if lev not in mod_mapping: + # raise Exception(f"E: vegetation type '{lev}' not found in mod_mapping") + # + # # Create character coordinate for the type dimension + # type_string = mod_mapping[lev] + # strlen = len(type_string) + # + # # Convert string to character array for NetCDF + # char_data = np.array([c.encode("utf-8") for c in type_string], dtype="S1") + # + # # Import xarray locally + # import xarray as xr + # + # # Create 2D character array: typebare(typebare=1, strlen=N) + # char_2d = char_data.reshape(1, -1) + # + # # Add both the type dimension and strlen dimension to the data variable + # vout = vout.expand_dims(dim={lev: 1, "strlen": strlen}) + # + # # Create character coordinate as a proper 2D character array + # type_coord = xr.DataArray( + # char_2d, + # dims=[lev, "strlen"], + # coords={ + # lev: [0], # Single index for the type dimension + # "strlen": np.arange(strlen), + # }, + # attrs={"long_name": "surface type", "standard_name": "area_type"}, + # ) + # + # # Assign the character coordinate to the type dimension + # vout = vout.assign_coords({lev: type_coord}) + return vout.fillna(0) @@ -82,19 +192,55 @@ def calc_topsoil(soilvar): def calc_landcover(var, model): """ - Returns land cover fraction variable. + Calculate land cover fraction variable as percentage with vegetation type labels. + + This function computes land cover fractions by combining tile fractions with + land fractions, converts the result to percentage values, and assigns + meaningful vegetation type names based on the specified land surface model. Parameters ---------- var : list of xarray.DataArray - List of input variables to sum. + List containing exactly 2 input variables: + - var[0]: Tile fraction variable (fractional, 0-1) + - var[1]: Land fraction variable (fractional, 0-1) + Both must have compatible dimensions for multiplication. model : str - Name of land surface model to retrieve land tiles definitions. + Name of land surface model to retrieve vegetation type definitions: + - "cable": CABLE land surface model (17 vegetation types) + - "cmip6": CMIP6 standard land categories (4 categories) Returns ------- xarray.DataArray - Land cover fraction variable. + Land cover fraction variable as percentage (0-100%). + - Units: % (percentage) + - Coordinates: Includes 'vegtype' dimension with descriptive names + - Missing values filled with 0 + - Represents land cover relative to total grid cell area + + Examples + -------- + Calculate CABLE vegetation fractions as percentage: + + >>> landcover_pct = calc_landcover([tilefrac, landfrac], "cable") + + Calculate CMIP6 land categories as percentage: + + >>> landcover_pct = calc_landcover([tilefrac, landfrac], "cmip6") + + Notes + ----- + - Output is converted to percentage (0-100%) for CMIP compliance + - Vegetation type coordinate provides human-readable category names + - CABLE model includes 17 vegetation types (forests, grasses, crops, etc.) + - CMIP6 model includes 4 broad categories (primary/secondary land, pastures, crops, urban) + - Result represents actual land coverage accounting for land/ocean fraction + - Missing values are filled with zeros for consistent output + + Vegetation Types by Model: + - CABLE: Evergreen/Deciduous Forests, Shrub, C3/C4 Grass, Crops, Tundra, etc. + - CMIP6: Primary/Secondary Land, Pastures, Crops, Urban """ land_tiles = { "cmip6": ["primary_and_secondary_land", "pastures", "crops", "urban"], @@ -121,17 +267,21 @@ def calc_landcover(var, model): vegtype = land_tiles[model] pseudo_level = var[0].dims[1] - vout = (var[0] * var[1]).fillna(0) + # convert to percentage + vout = (var[0] * var[1]).fillna(0) * 100.0 vout = vout.rename({pseudo_level: "vegtype"}) vout["vegtype"] = vegtype vout["vegtype"].attrs["units"] = "" return vout -def average_tile(var, tilefrac, landfrac=1.0): +def weighted_tile_sum(var, tilefrac, landfrac=1.0): """ - Returns variable averaged over grid-cell, counting only - specific tile(s) and land fraction when suitable. + Returns variable weighted by tile fractions and summed over tiles. + + This function performs tile-weighted integration by multiplying each tile + value by its fractional coverage, summing across all tiles, and scaling + by land fraction to get the grid-cell integrated value. Parameters ---------- @@ -145,10 +295,97 @@ def average_tile(var, tilefrac, landfrac=1.0): Returns ------- xarray.DataArray - Averaged input variable. + Tile-weighted and land-fraction scaled variable. """ - pseudo_level = var.dims[1] + # TODO: Might be good to avoid hardcoding pseudo_level name + pseudo_level = "pseudo_level_0" vout = var * tilefrac vout = vout.sum(dim=pseudo_level) vout = vout * landfrac return vout + + +def calc_cland_with_wood_products(carbon_pools_sum, wood_pools_sum, tilefrac, landfrac): + """ + Calculate total land carbon including wood products with correct weighting. + + Parameters: + - carbon_pools_sum: Sum of variables 851-860 (to be weighted by tilefrac) + - wood_pools_sum: Sum of variables 898-900 (no tilefrac weighting) + - tilefrac, landfrac: Weighting variables + """ + # TODO: Might be good to avoid hardcoding pseudo_level name + pseudo_level = "pseudo_level_0" + + # Carbon pools: multiply by tilefrac then sum over tiles + carbon_weighted = carbon_pools_sum * tilefrac + carbon_sum = carbon_weighted.sum(dim=pseudo_level) + + # Wood products: sum over tiles only (no tilefrac multiplication) + wood_sum = wood_pools_sum.sum(dim=pseudo_level) + + # Combine and apply land fraction, convert to kg m-2 (divide by 1000) + total = ((carbon_sum + wood_sum) / 1000.0) * landfrac + + return total + + +def calc_mass_pool_kg_m2(var, tilefrac, landfrac): + """ + Calculate mass pool variable (carbon, nitrogen, etc.) with unit conversion to kg m-2. + + This function provides a generalized calculation for any mass pool variable + that requires tile weighting, spatial integration, and unit conversion. + + Parameters + ---------- + var : xarray.DataArray + Mass pool variable (in g m-2) to be weighted by tilefrac and converted. + Must have a pseudo-level dimension representing tiles. + tilefrac : xarray.DataArray + Variable defining tiles' fractions (fractional, 0-1). + landfrac : xarray.DataArray + Land fraction (fractional, 0-1). + + Returns + ------- + xarray.DataArray + Mass pool variable in kg m-2, weighted by tile fractions and land fraction. + """ + pseudo_level = "pseudo_level_0" + + # Weight by tilefrac then sum over tiles + weighted = var * tilefrac + summed = weighted.sum(dim=pseudo_level) + + # Apply land fraction and convert to kg m-2 (divide by 1000) + result = (summed / 1000.0) * landfrac + return result + + +def calc_carbon_pool_kg_m2(var, tilefrac, landfrac): + """ + Calculate individual carbon pool variable with unit conversion to kg m-2. + + This function is an alias for calc_mass_pool_kg_m2 to maintain backward + compatibility with existing carbon pool calculations. + + Parameters + ---------- + var : xarray.DataArray + Carbon pool variable (to be weighted by tilefrac and converted). + tilefrac : xarray.DataArray + Variable defining tiles' fractions. + landfrac : xarray.DataArray + Land fraction variable. + + Returns + ------- + xarray.DataArray + Carbon pool variable in kg m-2. + """ + return calc_mass_pool_kg_m2(var, tilefrac, landfrac) + + +# Alias for nitrogen pools - same calculation as carbon pools +calc_nitrogen_pool_kg_m2 = calc_mass_pool_kg_m2 diff --git a/src/access_moppy/mappings/ACCESS-ESM1.6_mappings.json b/src/access_moppy/mappings/ACCESS-ESM1.6_mappings.json index 1ce394c..0e5d328 100644 --- a/src/access_moppy/mappings/ACCESS-ESM1.6_mappings.json +++ b/src/access_moppy/mappings/ACCESS-ESM1.6_mappings.json @@ -1291,6 +1291,23 @@ }, "CF standard Name": "runoff_flux" }, + "mrrob": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s08i235" + ], + "calculation": { + "type": "direct", + "formula": "fld_s08i235" + }, + "CF standard Name": "subsurface_runoff_flux" + }, "mrros": { "dimensions": { "time": "time", @@ -1308,6 +1325,50 @@ }, "CF standard Name": "surface_runoff_flux" }, + "mrsfl": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s08i223", + "fld_s08i230" + ], + "calculation": { + "type": "formula", + "formula": "multiply", + "operands": [ + "fld_s08i223", + "fld_s08i230" + ] + }, + "CF standard Name": "frozen_water_content_of_soil_layer" + }, + "mrfsli": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s08i223", + "fld_s08i229" + ], + "calculation": { + "type": "formula", + "formula": "multiply", + "operands": [ + "fld_s08i223", + "fld_s08i229" + ] + }, + "CF standard Name": "liquid_water_content_of_soil_layer" + }, "npp": { "dimensions": { "time": "time", @@ -1412,6 +1473,188 @@ } }, "land": { + "cLand": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i851", + "fld_s03i852", + "fld_s03i853", + "fld_s03i854", + "fld_s03i855", + "fld_s03i856", + "fld_s03i857", + "fld_s03i858", + "fld_s03i859", + "fld_s03i860", + "fld_s03i898", + "fld_s03i899", + "fld_s03i900", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_cland_with_wood_products", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i851", + "fld_s03i852", + "fld_s03i853", + "fld_s03i854", + "fld_s03i855", + "fld_s03i856", + "fld_s03i857", + "fld_s03i858", + "fld_s03i859", + "fld_s03i860" + ] + }, + { + "operation": "add", + "operands": [ + "fld_s03i898", + "fld_s03i899", + "fld_s03i900" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "mass_content_of_carbon_in_vegetation_and_litter_and_soil_and_forestry_and_agricultural_products" + }, + "cLeaf": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i852", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_carbon_pool_kg_m2", + "args": [ + "fld_s03i852" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "leaf_mass_content_of_carbon" + }, + "cLitter": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i855", + "fld_s03i856", + "fld_s03i857", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_carbon_pool_kg_m2", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i855", + "fld_s03i856", + "fld_s03i857" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "litter_mass_content_of_carbon" + }, + "cProduct": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i898", + "fld_s03i899", + "fld_s03i900", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_carbon_pool_kg_m2", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i898", + "fld_s03i899", + "fld_s03i900" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "carbon_mass_content_of_forestry_and_agricultural_products" + }, + "cRoot": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i852", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_carbon_pool_kg_m2", + "args": [ + "fld_s03i852" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "root_mass_content_of_carbon" + }, "cSoil": { "dimensions": { "time": "time", @@ -1429,7 +1672,7 @@ ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "calc_carbon_pool_kg_m2", "args": [ { "operation": "add", @@ -1445,7 +1688,7 @@ "landfrac": "fld_s03i395" } }, - "CF standard Name": "" + "CF standard Name": "soil_mass_content_of_carbon" }, "sftlf": { "CF standard Name": "land_area_fraction", @@ -1453,14 +1696,18 @@ "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i395" ], "calculation": { - "type": "direct", - "formula": "fld_s03i395" + "type": "formula", + "formula": "multiply", + "operands": [ + "fld_s03i395", + 100.0 + ] } }, "baresoilFrac": { @@ -1469,7 +1716,7 @@ "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1483,7 +1730,10 @@ 14 ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": { + "literal": "typebare" + } } }, "CF standard Name": "area_fraction" @@ -1494,7 +1744,7 @@ "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1514,11 +1764,14 @@ 6, 8, 9, - 11 + 11, + 12, + 13 ] ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typec3pft"} } }, "CF standard Name": "area_fraction" @@ -1529,7 +1782,7 @@ "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1540,10 +1793,11 @@ "operation": "extract_tilefrac", "args": [ "fld_s03i317", - 7 + [7, 10] ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typec4pft"} } }, "CF standard Name": "area_fraction" @@ -1563,7 +1817,7 @@ ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "weighted_tile_sum", "args": [ "fld_s03i858" ], @@ -1589,7 +1843,7 @@ ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "weighted_tile_sum", "args": [ "fld_s03i859" ], @@ -1615,7 +1869,7 @@ ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "weighted_tile_sum", "args": [ "fld_s03i860" ], @@ -1632,7 +1886,33 @@ "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + [9, 10] + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typecrop"} + } + }, + "CF standard Name": "area_fraction" + }, + "cropFracC3": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1646,7 +1926,8 @@ 9 ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typec3crop"} } }, "CF standard Name": "area_fraction" @@ -1660,6 +1941,7 @@ "units": "kg m-2", "positive": null, "model_variables": [ + "fld_s03i851", "fld_s03i852", "fld_s03i853", "fld_s03i854", @@ -1668,11 +1950,12 @@ ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "calc_carbon_pool_kg_m2", "args": [ { "operation": "add", "operands": [ + "fld_s03i851", "fld_s03i852", "fld_s03i853", "fld_s03i854" @@ -1686,58 +1969,408 @@ }, "CF standard Name": "vegetation_carbon_content" }, - "gpp": { + "fBNF": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, "units": "kg m-2 s-1", - "positive": "down", + "positive": null, "model_variables": [ - "fld_s03i261" + "fld_s03i885", + "fld_s03i317", + "fld_s03i395" ], "calculation": { - "type": "direct", - "formula": "fld_s03i261" + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i885" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] }, - "CF standard Name": "gross_primary_productivity_of_biomass_expressed_as_carbon" + "CF standard Name": "carbon_mass_flux_into_soil_due_to_biological_nitrogen_fixation" }, - "grassFrac": { + "fDeforestToProduct": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "kg m-2 s-1", "positive": null, "model_variables": [ - "fld_s03i317", + "fld_s03i895", "fld_s03i395" ], "calculation": { "type": "formula", - "operation": "extract_tilefrac", + "operation": "weighted_tile_sum", "args": [ - "fld_s03i317", - [ - 6, - 7 - ] + "fld_s03i895" ], "kwargs": { + "tilefrac": 1.0, "landfrac": "fld_s03i395" } }, - "CF standard Name": "area_fraction" + "CF standard Name": "carbon_mass_flux_into_forestry_and_agricultural_products_due_to_anthropogenic_land_use_or_land_cover_change" }, - "landCoverFrac": { + "fNdep": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i884", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i884" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "minus_tendency_of_atmosphere_mass_content_of_nitrogen_compounds_expressed_as_nitrogen_due_to_deposition" + }, + "fNgas": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i920", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i920" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "surface_upward_mass_flux_of_nitrogen_compounds_expressed_as_nitrogen" + }, + "fNleach": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i918", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i918" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "mass_flux_of_carbon_out_of_soil_due_to_leaching_and_runoff" + }, + "fNloss": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i918", + "fld_s03i920", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i918", + "fld_s03i920" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "surface_upward_mass_flux_of_nitrogen_compounds_expressed_as_nitrogen_out_of_vegetation_and_litter_and_soil" + }, + "fNnetmin": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i917", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i917" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "mass_flux_of_nitrogen_compounds_expressed_as_nitrogen_out_of_litter_and_soil_due_to_immobilisation_and_remineralization" + }, + "fNup": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i919", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i919" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "tendency_of_vegetation_mass_content_of_nitrogen_compounds_expressed_as_nitrogen_due_to_fixation" + }, + "fProductDecomp": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i907", + "fld_s03i908", + "fld_s03i909", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i907", + "fld_s03i908", + "fld_s03i909" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + 1.1574074074074073e-08 + ] + }, + "CF standard Name": "tendency_of_atmosphere_mass_content_of_carbon_dioxide_expressed_as_carbon_due_to_emission_from_forestry_and_agricultural_products" + }, + "gpp": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": "down", + "model_variables": [ + "fld_s03i261" + ], + "calculation": { + "type": "direct", + "formula": "fld_s03i261" + }, + "CF standard Name": "gross_primary_productivity_of_biomass_expressed_as_carbon" + }, + "grassFrac": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + [ + 6, + 7 + ] + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typenatgr"} + } + }, + "CF standard Name": "area_fraction" + }, + "grassFracC3": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 6 + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typec3natg"} + } + }, + "CF standard Name": "area_fraction" + }, + "grassFracC4": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 7 + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typec4natg"} + } + }, + "CF standard Name": "area_fraction" + }, + "landCoverFrac": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1747,44 +2380,403 @@ "type": "formula", "operation": "calc_landcover", "args": [ - [ - "fld_s03i317", - "fld_s03i395" - ], + [ + "fld_s03i317", + "fld_s03i395" + ], + { + "literal": "cable" + } + ] + }, + "CF standard Name": "area_fraction" + }, + "lai": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "1", + "positive": null, + "model_variables": [ + "fld_s03i893", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "weighted_tile_sum", + "args": [ + "fld_s03i893" + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "leaf_area_index" + }, + "mrso": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s08i223" + ], + "calculation": { + "type": "formula", + "operation": "sum", + "args": [ + "fld_s08i223" + ], + "kwargs": { + "dim": {"literal": "soil_model_level_number"} + } + }, + "CF standard Name": "mass_content_of_water_in_soil" + }, + "mrsol": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s08i223" + ], + "calculation": { + "type": "direct", + "formula": "fld_s08i223" + }, + "CF standard Name": "mass_content_of_water_in_soil_layer" + }, + "mrsos": { + "dimensions": { + "time": "time", + "depth": "depth", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s08i223" + ], + "calculation": { + "type": "formula", + "operation": "calc_topsoil", + "args": [ + "fld_s08i223" + ] + }, + "CF standard Name": "mass_content_of_water_in_soil_layer" + }, + "nbp": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": "down", + "model_variables": [ + "fld_s03i262", + "fld_s03i293", + "fld_s03i907", + "fld_s03i908", + "fld_s03i909", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "multiply", + "args": [ + { + "operation": "add", + "operands": [ + { + "operation": "add", + "operands": [ + "fld_s03i262", + { + "operation": "multiply", + "args": [ + "fld_s03i293", + -1 + ] + } + ] + }, + { + "operation": "multiply", + "args": [ + { + "operation": "weighted_tile_sum", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i907", + "fld_s03i908", + "fld_s03i909" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + -3.1688087814029656e-14 + ] + } + ] + }, + "fld_s03i395" + ] + }, + "CF standard Name": "surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_carbon_due_to_all_land_processes" + }, + "nep": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": "down", + "model_variables": [ + "fld_s03i262", + "fld_s03i293" + ], + "calculation": { + "type": "formula", + "operation": "subtract", + "args": [ + "fld_s03i262", + "fld_s03i293" + ] + }, + "CF standard Name": "surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_carbon_due_to_all_land_processes_excluding_anthropogenic_land_use_change" + }, + "nLand": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i861", + "fld_s03i862", + "fld_s03i863", + "fld_s03i864", + "fld_s03i865", + "fld_s03i866", + "fld_s03i867", + "fld_s03i868", + "fld_s03i869", + "fld_s03i870", + "fld_s03i901", + "fld_s03i902", + "fld_s03i903", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_nitrogen_pool_kg_m2", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i861", + "fld_s03i862", + "fld_s03i863", + "fld_s03i864", + "fld_s03i865", + "fld_s03i866", + "fld_s03i867", + "fld_s03i868", + "fld_s03i869", + "fld_s03i870", + "fld_s03i901", + "fld_s03i902", + "fld_s03i903" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "mass_content_of_nitrogen_in_vegetation_and_litter_and_soil_and_forestry_and_agricultural_products" + }, + "nLitter": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i864", + "fld_s03i865", + "fld_s03i866", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_nitrogen_pool_kg_m2", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i864", + "fld_s03i865", + "fld_s03i866" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "litter_mass_content_of_nitrogen" + }, + "nMineral": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2", + "positive": null, + "model_variables": [ + "fld_s03i870", + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_nitrogen_pool_kg_m2", + "args": [ + { + "operation": "add", + "operands": [ + "fld_s03i870" + ] + } + ], + "kwargs": { + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "soil_mass_content_of_inorganic_nitrogen_expressed_as_nitrogen" + }, + "npp": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": "down", + "model_variables": [ + "fld_s03i262" + ], + "calculation": { + "type": "direct", + "formula": "fld_s03i262" + }, + "CF standard Name": "net_primary_productivity_of_biomass_expressed_as_carbon" + }, + "nProduct": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": null, + "model_variables": [ + "fld_s03i901", + "fld_s03i902", + "fld_s03i903", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "calc_nitrogen_pool_kg_m2", + "args": [ { - "literal": "cable" + "operation": "add", + "operands": [ + "fld_s03i901", + "fld_s03i902", + "fld_s03i903" + ] } - ] + ], + "kwargs": { + "tilefrac": 1.0, + "landfrac": "fld_s03i395" + } }, - "CF standard Name": "area_fraction" + "CF standard Name": "nitrogen_mass_content_of_forestry_and_agricultural_products" }, - "lai": { + "nSoil": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "kg m-2", "positive": null, "model_variables": [ - "fld_s03i893", + "fld_s03i867", + "fld_s03i868", + "fld_s03i869", + "fld_s03i870", "fld_s03i317", "fld_s03i395" ], "calculation": { "type": "formula", - "operation": "average_tile", + "operation": "calc_nitrogen_pool_kg_m2", "args": [ - "fld_s03i893" + { + "operation": "add", + "operands": [ + "fld_s03i867", + "fld_s03i868", + "fld_s03i869", + "fld_s03i870" + ] + } ], "kwargs": { "tilefrac": "fld_s03i317", "landfrac": "fld_s03i395" } }, - "CF standard Name": "leaf_area_index" + "CF standard Name": "soil_mass_content_of_nitrogen" }, - "mrso": { + "nVeg": { "dimensions": { "time": "time", "lat": "lat", @@ -1793,40 +2785,53 @@ "units": "kg m-2", "positive": null, "model_variables": [ - "fld_s08i223" + "fld_s03i861", + "fld_s03i862", + "fld_s03i863", + "fld_s03i317", + "fld_s03i395" ], "calculation": { "type": "formula", - "operation": "sum", + "operation": "calc_nitrogen_pool_kg_m2", "args": [ - "fld_s08i223" + { + "operation": "add", + "operands": [ + "fld_s03i861", + "fld_s03i862", + "fld_s03i863" + ] + } ], "kwargs": { - "dim": "depth" + "tilefrac": "fld_s03i317", + "landfrac": "fld_s03i395" } }, - "CF standard Name": "mass_content_of_water_in_soil" + "CF standard Name": "vegetation_mass_content_of_nitrogen" }, - "mrsos": { + "orog": { "dimensions": { - "time": "time", - "depth": "depth", "lat": "lat", "lon": "lon" }, - "units": "kg m-2", + "units": "m", "positive": null, "model_variables": [ - "fld_s08i223" + "fld_s00i033" ], "calculation": { "type": "formula", - "operation": "calc_topsoil", + "operation": "isel", "args": [ - "fld_s08i223" - ] + "fld_s00i033" + ], + "kwargs": { + "time": 0 + } }, - "CF standard Name": "mass_content_of_water_in_soil_layer" + "CF standard Name": "surface_altitude" }, "ra": { "dimensions": { @@ -1845,13 +2850,54 @@ }, "CF standard Name": "surface_upward_mass_flux_of_carbon_dioxide_expressed_as_carbon" }, + "rh": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "kg m-2 s-1", + "positive": "up", + "model_variables": [ + "fld_s03i293" + ], + "calculation": { + "type": "direct", + "formula": "fld_s03i293" + }, + "CF standard Name": "surface_upward_mass_flux_of_carbon_dioxide_expressed_as_carbon_due_to_heterotrophic_respiration" + }, + "sftgif": { + "dimensions": { + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 17 + ], + "kwargs": { + "landfrac": "fld_s03i395" + } + }, + "CF standard Name": "land_area_fraction" + }, "residualFrac": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1869,35 +2915,48 @@ ] ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typeresidual"} } }, "CF standard Name": "area_fraction" }, - "rh": { + "shrubFrac": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "kg m-2 s-1", - "positive": "up", + "units": "%", + "positive": null, "model_variables": [ - "fld_s03i293" + "fld_s03i317", + "fld_s03i395" ], "calculation": { - "type": "direct", - "formula": "fld_s03i293" + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + [ + 5, + 8 + ] + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typeshrub"} + } }, - "CF standard Name": "surface_downward_mass_flux_of_carbon_dioxide_expressed_as_carbon" + "CF standard Name": "area_fraction" }, - "shrubFrac": { + "treeFrac": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1909,23 +2968,133 @@ "args": [ "fld_s03i317", [ - 5, - 8 + 1, + 2, + 3, + 4, + 12, + 13 ] ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typetree"} } }, "CF standard Name": "area_fraction" }, - "treeFrac": { + "treeFracBdlDcd": { "dimensions": { "time": "time", "lat": "lat", "lon": "lon" }, - "units": "1", + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 4 + + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typetreebd"} + } + }, + "CF standard Name": "area_fraction" + }, + "treeFracBdlEvg": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + [4, 12, 13] + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typetreebe"} + } + }, + "CF standard Name": "area_fraction" + }, + "treeFracNdlDcd": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 3 + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typetreend"} + } + }, + "CF standard Name": "area_fraction" + }, + "treeFracNdlEvg": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 1 + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typetreene"} + } + }, + "CF standard Name": "area_fraction" + }, + "vegFrac": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", "positive": null, "model_variables": [ "fld_s03i317", @@ -1940,14 +3109,24 @@ 1, 2, 3, - 4 + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 ] ], "kwargs": { - "landfrac": "fld_s03i395" + "landfrac": "fld_s03i395", + "lev": {"literal": "typeveg"} } }, - "CF standard Name": "area_fraction" + "CF standard Name": "vegetation_area_fraction" }, "tsl": { "dimensions": { @@ -1966,6 +3145,32 @@ "formula": "fld_s08i225" }, "CF standard Name": "soil_temperature" + }, + "wetlandFrac": { + "dimensions": { + "time": "time", + "lat": "lat", + "lon": "lon" + }, + "units": "%", + "positive": null, + "model_variables": [ + "fld_s03i317", + "fld_s03i395" + ], + "calculation": { + "type": "formula", + "operation": "extract_tilefrac", + "args": [ + "fld_s03i317", + 11 + ], + "kwargs": { + "landfrac": "fld_s03i395", + "lev": {"literal": "typewetla"} + } + }, + "CF standard Name": "area_fraction" } }, "ocean": { diff --git a/src/access_moppy/vocabularies/CMIP7_CVs b/src/access_moppy/vocabularies/CMIP7_CVs index d57eb4b..1105ce2 160000 --- a/src/access_moppy/vocabularies/CMIP7_CVs +++ b/src/access_moppy/vocabularies/CMIP7_CVs @@ -1 +1 @@ -Subproject commit d57eb4b6bbd7da16313b63fef314f3460a5bc107 +Subproject commit 1105ce21b7aa319ddd39584f3c8dfa98ac64cdba diff --git a/tests/conftest.py b/tests/conftest.py index bb7263f..5bfc0f2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -238,16 +238,69 @@ def _filter_variables_by_test_data(variables, table_name): # For land variables, we need different test data files # For now, return a minimal set for basic testing "mrso", # Total Soil Moisture Content (if soil data available) + "mrsos", # Surface Soil Moisture Content + "cLeaf", # Leaf Carbon Content + "cLitter", # Litter Carbon Content + "cRoot", # Root Carbon Content + "cProduct", # Wood Product Carbon Content + "baresoilFrac", # Bare Soil Fraction + "c3PftFrac", # C3 Plant Functional Type Fraction + "c4PftFrac", # C4 Plant Functional Type Fraction + "cSoilFast", # Fast Soil Carbon Content + "cSoilSlow", # Slow Soil Carbon Content + "cSoilMedium", # Medium Soil Carbon Content + "cropFrac", # Crop Fraction + "grassFrac", + "gpp", + "landCoverFrac", + "lai", # Leaf Area Index + "nbp", # Net Biome Production + "npp", # Net Primary Production + "cVeg", # Vegetation Carbon Content + "ra", + "rh", + "residualFrac", + "shrubFrac", + "treeFrac", + "tsl", ], "Emon": [ # Only variables that actually exist in the Emon CMIP6 table # AND are compatible with the test data (aiihca.pa-101909_mon.nc) # From atmosphere component: + "cLand", # Land Carbon Content + "cSoil", # Soil Carbon Content "hus", # Specific Humidity "ps", # Surface Air Pressure "ua", # Eastward Wind "va", # Northward Wind - # Note: co23D and cSoil exist in Emon but have dimension issues with test data + "cropFracC3", # C3 Crop Fraction + "cropFracC4", # C4 Crop Fraction + "fBNF", # Fraction of Biological Nitrogen Fixation + "fDeforestToProduct", # Fraction of Deforested Carbon to Products + "fNdep", + "fNgas", + "fNleach", + "fNloss", + "fNnetmin", + "fNup", + "fProductDecomp", + "grassFracC3", + "grassFracC4", + "mrsol", # Top Layer Soil Moisture Content + "nep", # Net Ecosystem Production + "nLand", # Land Nitrogen Content + "nLitter", # Litter Nitrogen Content + "nMineral", # Mineral Nitrogen Content + "nProduct", # Wood Product Nitrogen Content + "nSoil", # Soil Nitrogen Content + "nVeg", # Vegetation Nitrogen Content + "treeFracBdlDcd", + "treeFracBdlEvg", + "treeFracNdlDcd", + "treeFracNdlEvg", + "vegFrac", + "wetlandFrac", ], } diff --git a/tests/integration/test_full_cmorisation.py b/tests/integration/test_full_cmorisation.py index 3ebbc1e..fea07aa 100644 --- a/tests/integration/test_full_cmorisation.py +++ b/tests/integration/test_full_cmorisation.py @@ -67,7 +67,7 @@ def test_full_cmorisation_all_variables( except Exception: pytest.skip(f"Cannot load variables for table {table_name}") - file_pattern = DATA_DIR / "esm1-6/atmosphere/aiihca.pa-101909_mon.nc" + file_pattern = DATA_DIR / "esm1-6/atmosphere/aiihca.pa-298810_mon.nc" # Test all available variables (since we've filtered to compatible ones) test_variables = table_variables