Repository navigation
Bring in Land and Native Grid - #502
Draft
richling-ucar wants to merge 504 commits into
Draft
richling-ucar wants to merge 504 commits into
richling-ucar wants to merge 504 commits into
Conversation
The Framework Linting check (pylint >= 9.5 on every modified python file under lib/, in an env without uxarray, xesmf or pytest) failed on four files: adf_utils.py 9.01, test_adf_file_utils.py 9.25, test_native_climo_fallback.py 7.14, test_year_tagged_files.py 6.76. No behaviour changes: - adf_utils: standard-library imports first, unused 'os' dropped, the optional uxarray/xesmf imports marked import-error for the lint env; docstrings for make_se_regridder, the four regrid_*_se_data helpers and calc_area; repeated mid-file imports removed; the unused helpers regrid_variable and add_area (from the land-branch port, called nowhere; calc_area does add_area's job) removed; make_se_regridder's 'Method' argument is 'method' and its unused 'var' argument is gone (its one caller, grid_to_latlon, updated; cloud_regime_analysis has its own copy); snake_case names in calc_area; 'uxgrid' initialized in seasonal_mean; membership tests and an over-long line in create_clean_grid/regridder. - tests: Path.touch() instead of open().close(); docstrings for the test functions; pytest marked import-error for the lint env; protected access allowed where the tests drive AdfData's private helpers. Reproduced the CI check locally (PR file list, lib/test/pylintrc, threshold 9.5, CI's pip packages): all 21 modified lib/ files pass. Unit tests: 336 pass; CI-like (PyYAML + pytest): 97 pass, 144 skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Minor corrections
Collaborator
Author
Port the cached to_raster pixel mapping from the adf repo: mappings are keyed on grid, projection, extent and panel size, and reused across panels, seasons and variables. Lat-lon maps now use equal-size panels in a 2x2 layout with tighter spacing (so all panels share one mapping) and are drawn at dpi=300 for sharper native-grid rasters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # lib/plotting_functions.py
Set the circular boundary and polar extent before rasterizing instead of rasterizing onto a global extent and zooming in afterwards, which left only ~10% of the raster inside the plotted domain. Also create the polar figure at dpi=300 so the raster matches the saved resolution, as for lat-lon maps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prep_ux_for_plot filled NaNs with 0 before rasterizing, so ocean cells of land fields were drawn as 0 (and land cells without data, e.g. BTRANMN over glaciers, were counted as 0 in the panel means). uxarray's to_raster handles NaN fine, as the polar maps already rely on, so keep NaNs and only convert infinities to NaN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Improve lat-lon plots
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native-grid and CLM land diagnostics, merged with main
This PR brings native-grid (ne30pg3) support and the CLM land diagnostics (from
ww-clm-diags) onto currentmain, with the bug fixes found by a 64-run regression suite on Casper. The full results, plots and per-file comparisons are in the LDF Merge Test Log.What this PR does
unstructured_plotting). Native and lat/lon cases, and native cases and observations, can be compared either way: in UXarray mode the lat/lon side is remapped onto the native side's mesh (ESMF conservative weights, uxarray bilinear fallback).clm2inhist_str. Area × landfrac weighting, separate time-series and climatology years, regional climatologies and time series fromregions_lnd.yaml, the LMWG table and website.cam_ts_doneis nowcalc_cam_ts(old key still accepted). Existing time series are reused per variable.meridional_meannow averages over thelatboundsband (default 5°S–5°N), whichmainsets but ignores, averaging over all latitudes. All meridional-mean plots change.lens2_filein the variable defaults, found in the config'slens2_data_loc(asobs_fileandobs_data_loc), instead of a hard-coded directory.…_climo_0011-0013.nc), so a run over other years never reuses a file made for the old ones. Time series files recordts_yrs, climo and regridded filesclimo_yrs. Older names are still read.adf_v1.0.5: uxarray 2025.6.0 (needed for native maps), plus pylint 4.1.3, astroid 4.3.4 and pytest 9.1.1 as developer tools. Every other pin is unchanged.Testing
main. Only the meridional band and the new one-side-only time-series plots differ.mainin obs mode (S11–S13 against S00b); only the meridional band and the one-sided global-mean plots differ. Native ts and climo entries match N08 to 1.8e-6. Atmosphere only: no land observations to test against.ww-clm-diagsc6db27e)lib/test/unit_tests)f736c77. With CI's packages only (PyYAML, pytest): 97 pass, 152 skip.lib/file)lib/The latest clean rerun (all 38 runs, on
1a9fbb7) started from wiped output folders, in an env built fromenv/conda_environment.yaml. S00 ran onmainin its own env; S00 and S01 agree in every value, so the env change moves no result.Bugs fixed
grid_to_latlon, threesave_to_nc,use_time_bounds_midpointto_raster.zonal_mean.plot_press_levels.lndgridclimo._region_nativeAdfData._native_climo_fallbackget_regrid_fileraised for variables with no reference.main'screate_clean_gridfails on bounds with a time dimension.nanmean.lsmlat/lsmlon).cell_weightsdropped the uxarray grid withisel(time=0).area/landfracareakept the model's time labels and aligned to NaN against a one-step obs file.area,landfracwritten time-independentreturnskipped the remaining pairs; crashes on the mesh without pressure levels orplot_press_levels.global_latlon_map; 30 plots byte-identicalKeyError: 'lat'(lat/lon test vs native reference).prep_ux_for_plotno longer fills NaN with 0Two more were in the test setup (a config that read its own output, stale files between runs). Details for each are in the test log.
Release notes
cam_ts_doneis nowcalc_cam_ts, with the opposite meaning, matchingcalc_cam_climo:calc_cam_ts: truemakes time series from the history files, ascam_ts_done: falsedid. Replacecam_ts_done: Xwithcalc_cam_ts: not X. The old key still works and prints a deprecation note; giving both with contradicting values stops the run.calc_cam_ts: true, files already incam_ts_locare kept and only the years they do not cover are made, each stretch in a file of its own.calc_cam_ts: falseandcalc_cam_climo: falsea case needs no time series; scripts that need them leave that case out.config_cam_baseline_example.yaml. Indiag_basic_info:unstructured_plotting,regions_file,lens2_data_loc. Per case:climo_start_year/climo_end_year(withts_start_year/ts_end_yearas other names forstart_year/end_year), and for native-grid casesmesh_file,weights_file,regrid_methodand, for CLM,latlon_file. At the top level:region_listandregional_var_list.lens2_data_loc. A config that runsglobal_mean_timeseriesand wants the LENS2 range must setlens2_data_loc(on Derecho/Casper:/glade/campaign/cgd/cas/islas/CESM_DATA/LENS2/global_means/annualmeans). Newlens2_fileentries cover ACTREL, AODVIS, CDNUMC, CLDHGH, CLDLOW, CLDMED, CLDTOT, FSDS, FSDSC, FSNT, FSNTC, SWCF, TGCLDIWP, TGCLDLWP and TS. The aerosol burdens (BURDEN*dn) have LENS2 files but no variable-defaults entry, so they no longer get the range.climo_start_year/climo_end_yearnarrower than the time series, the table still covers all the time-series years; the climatology years no longer steer its file choice or its one-year check.{stem}_YYYY-YYYY.nc). Existing files with the older names are still read, but are never overwritten or reused by a run over other years: that run makes new year-tagged files. Time series files now recordts_yrs.mainusers: meridional means (5°S–5°N band), and single-case time-series, QBO, tape-recorder, zonal and meridional plots for runs where one case has no data, which used to be skipped.adf_v1.0.5: rebuild withconda env create -f env/conda_environment.yaml. uxarray 2025.6.0 is required for native-grid maps.Before this PR is ready
Commit this round's work. The fixes above, the new unit tests and the env change are in five commits,8e60e34toc1e6bd2, pushed to the branch. The two root-level CLM configs below were left out.Commit fix 15. The single-case plot fix inlib/plotting_functions.py: committed and pushed asc711eb7.Commit the year-tagged file names and fixes 16 and 17, with their unit tests: pushed asf45d03d,b2a660dande8a7c65.Rerun the full suite (now 38 runs with L00) on the year-tagged names: done one8a7c65, all 38 pass.Fix two unit strings inldf_variable_defaults.yaml: ELAIm${-2}$ m${-2}$and QBOTkg kg{-1}$come out garbled in tables: fixed in1a9fbb7.Decide on the root-level CLM configs. Kept, and updated to the new config keys (start_year/end_year,calc_cam_ts) ineb0ccfb.Document the new config keys inconfig_cam_baseline_example.yaml. Added, commented out:unstructured_plotting,regions_file, the per-caseclimo_start_year/climo_end_year,mesh_file,weights_file,regrid_methodandlatlon_file, andregion_list/regional_var_list;lens2_data_locis set.main's environment for every user.CI does not run the science tests. CI installs only PyYAML and pytest, so 141 tests skip, including every native-grid and land test, andscripts/is never linted. Add a CI job with the science stack, or state that HPC runs are the test.New plots and website entries onmain. Runs that used to skip time-series, zonal and meridional plots now make single-case versions.main(1, 5, 6), native grid, land, and the plot-whatever-there-is rule.Open the small PR tomainfor fix 14 (create_clean_gridwith time-dimensioned bounds).mainmoves.mainwas still ateba1f07on 2026-10-21.Hard-coded LENS2 path. Replaced by a per-variablelens2_filein the variable defaults, found in the config'slens2_data_loc. Land variables get none (the old search matched atmosphere files for them).lmwg_tableandmain'samwg_tabledivide by N instead of √N for the standard error, so the standard error and 95% columns are too small.Multiple test cases. The land regional, global-mean and table scripts use only the first test case.GenTS back end does not reuse existing time series per variable, as the ADF back end now does.lat_bnds/lon_bndsand store area in km² where the f09 files use steradians.Release notes forcam_ts_done→calc_cam_ts, the new env, and the new config keys: written (section above), ready for the GitHub release.LAND-DIAGS_README.mdwith the release-note changes.fdb06e7,4868272; Suite 5), but the method is fixed in the code: ESMF conservative weights (made once per grid pair, cached inregrid_weights/), uxarray bilinear only when ESMF cannot run, and inverse-distance weighting if bilinear fails (GPCP 2.5°). Gridded mode lets each case choose itsweights_fileandregrid_method; mesh mode has no setting. Conservative keeps area means (fluxes, precipitation, global and regional means) and is the right default; bilinear is smoother (winds, temperature) and matches the bilinear gridded runs. Add a setting such asmesh_regrid_method: conserve | bilinear, one per run or per case, or keep conservative only?areaandlandfrac, so both sides are weighted over the same cells) are unaffected. Weight the source by its land fraction and mask the result with the mesh's, as the gridded path does withlatlon_file? Same coastal issue as the land question on coastlines.mesh_file” is no longer printed (N09a, N19).Ocean on native land maps. Native (UXarray) lat/lon maps of land fields showed the ocean as 0 in the test and baseline panels and as “no change” in the difference, becauseprep_ux_for_plotfilled missing cells with 0. Fixed (bug 23): missing cells stay blank in all four panels; checked on L07's maps, means and RMSE unchanged (92b1105).Science questions · native grid
mainignores its ownlatboundsand averages globally. Which is wanted?scale_factor: -1is never applied becausenew_unitmakes the file look converted, so maps show CAM's sign. Which sign is wanted?lat_bnds/lon_bndsor area in steradians in gridded files?Science questions · land
ncremap -P clmweights by the sub-grid mask. Table means differ by at most 0.88% (SOILWATER_10CM). Which should the ADF match?Regions across grids. A cell counts as inside a region when its centre is in the box, so two grids take in different land at the edges. TOTECOSYSC over CONUS is 1.72% higher on the native grid than on f09 for the same case, while global means are identical. Across grids (L14) that offset is about 17 times the real case difference. Grid both cases first, weight cells by overlap, use mask regions, or note it on the plots?lmwg_tableuses std/N instead of std/√N. Fix it here or withmain'samwg_table?ENERGY_BALANCEscales by a hard-codedcpl_landfrac = 0.29251054, which only fits one grid. Should it come from the case's own land fraction instead?C13/C14_TOTSOMC_pmandC13/C14_TOTLITC_pmused to get the plain sum of their constituents; the merge computes them with the per-mil isotope formula from the NCL land diagnostics. Is that right, and do the formulas match Jain et al. 1996?Software questions
gridded/folders. The ADF readsgridded/whenever it exists, so pre-made native time series must come from a run that never gridded them. Make it an explicit setting?gridded/beside pre-made native climo, inside a folder the user supplied. Should the ADF only write under its own output folders?is_lndbranches, or split into separate land scripts on shared helpers? CAM time-series plots also get no website category, unlike land.Full test log: https://claude.ai/artifact/31HPszLwAiSNJqV5orBeYy