Skip to content

Feature/wjiang/refactor ldas setup - #264

Merged
weiyuan-jiang merged 130 commits into
feature/wjiang/2d_decomposefrom
feature/wjiang/refactor_ldas_setup
Nov 30, 2026
Merged

weiyuan-jiang merged 130 commits into
feature/wjiang/2d_decomposefrom
feature/wjiang/refactor_ldas_setup

Conversation

@weiyuan-jiang

Copy link
Copy Markdown
Contributor

No description provided.

Lauren C. Andrews and others added 30 commits October 26, 2026 15:47
- read_JPSS_SCF_hdf(): read VIIRS CMG v2 hdf5 files (Snow_Cover,
  Clear_Index, Basic_QA) via io_hdf5; same QC as MODIS reader, keep
  Basic_QA=0 ("good") only
- io_hdf5.F90: added readDataset2DInt() to read 2d block (hyperslab)
- read_obs_JPSS_SCF(): fixed undeclared MODIS_product_ID; file names
  without production time stamp (renamed files, as for MODIS SCF);
  corrected launch years and MODIS wording in comments
- read_obs(): added case for VNP10C1, VJ110C1, VJ210C1
- LDASsa_DEFAULT_inputs_ensupd.nml: VIIRS obs paths and file names

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(read_JPSS_SCF_hdf)

- keep Basic_QA = 0, 1, 3 (best, good, other); exclude 2 (poor).
  "other" = low illumination (70<=SZA<85 deg), which applies to most
  high-latitude winter obs (QA=0 only kept ~1% of obs north of 60N)
- explicit Clear_Index <= 100 check (Antarctica has Snow_Cover=100 and
  Clear_Index=243)
- corrected QC comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VIIRS Snow_Cover can exceed Clear_Index by 1 (rounding), giving SCF up
to ~1.05 in ~17% of snow-covered cells; MODIS Snow_Cover never exceeds
Clear_Index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…S_SCF_hdf)

VIIRS SCF obs files are renamed without the production time stamp, so the
log did not show which production of each file was used. read_JPSS_SCF_hdf
now logs the LocalGranuleID global attribute (original file name).

- io_hdf5.F90: new readAttribute (fixed-length string attribute of root
  group; blank if attribute does not exist)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixed-length string

readAttributeChar (io_hdf5.F90) reads into one string of length
len(attrValue). An attribute of another type, or a variable-length
string, failed the type conversion and stopped the run; an array of
strings was written past the end of attrValue. Now these return blank,
like a missing attribute, so the LocalGranuleID log line in
read_JPSS_SCF_hdf can never stop or corrupt a run.

No change for normal VIIRS files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d_obs_JPSS_SCF)

The final tile mask kept tiles with lon_end <= com_lon <= lon_beg, so a
tile whose com_lon is exactly on the boundary between two assimilation
windows got the same daily obs in both windows. With 3-hourly windows
centered at 0z, 3z, ... the boundaries are at multiples of 45 deg; in
EASEv2 M36 this affects 470 tiles (full columns at +-45 and +-135 deg),
in CF0360 6 tiles, in M09 none.

Keep lon_end < com_lon <= lon_beg, as documented above (one longitude
band) and correspondingly for the band that wraps around the dateline.
Each tile now falls into exactly one window per day (checked for M36,
M09 and CF0360 tile coords, 13:30 and 10:30 overpass, windows centered
at 0z,3z,... and 1:30z,4:30z,...).

Same defect in read_obs_MODIS_SCF (develop); fixed separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CMG files and the VNP10C1 v2 user guide define Basic_QA as
0=good, 1=poor, 2=bad, 3=other; the comments used the L2 swath key
(0=best, 1=good, 2=poor). Rename qc_basic_qa_poor to qc_basic_qa_bad.
No change in the obs that are kept (QA 0, 1 and 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readAttributeChar (io_hdf5.F90) is used only for log output, but any
HDF5 error called checkErrCode_ and stopped the run (with exit status 0).
A fixed-length UTF-8 attribute stopped in h5aread_f (HDF5 does not
convert between ASCII and UTF-8), and an attribute with a null
dataspace stopped in h5sget_simple_extent_npoints_f.

Now:
- the memory datatype uses the character set of the attribute;
- the dataspace type is checked (scalar or simple) before the number
  of points;
- any HDF5 error closes the open handles and returns blank.

No change for normal VIIRS files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The striping at +-45 and +-135 deg in M36 runs came from tiles on a
window boundary getting the obs twice (fixed in 8c778e4), not from the
width of the read band or the 0.1 deg margin of the band-width check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- read_JPSS_SCF_hdf() returns the original file name (LocalGranuleID,
  blank if missing) instead of writing it to the general log.
- read_obs_JPSS_SCF() writes one obslog row per daily file read: the
  number of good obs and the file name with the original name in place
  of the renamed one (requested name if LocalGranuleID is blank).
  Same pattern as read_obs_MODIS_SCF() in PR #239.

Obs are unchanged (standalone reader check vs. Python mirror, VJ110C1,
VJ210C1, VNP10C1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Compile hdf4_c_api.c as a separate object library so that hdf.h's
  <assert.h> does not resolve to GMAO_mpeu/assert.H on case-insensitive
  file systems
- clsm_ensupd_read_obs: real(8) -> real(REAL64)
…num_from_latlon(); add check_c3_tile_grid() (LDAS_TileCoordRoutines.F90)

- get_ij_ind_from_latlon(): 'c3' branch with the geometry of MAPL_GetGlobalHorzIJIndex()
  (gnomonic equal-edge cube, pi/18 shift, real*8); global N from dlon = 360/(4*N)
- get_tile_num_from_latlon(): 'c3' branch; among tiles in the cube-sphere cell of the obs
  (then in the cells of 8 points +/- half a cell) whose bounding box holds the obs, pick
  the min box-normalized distance; else nearest center + existing max_dist check
- check_c3_tile_grid(): count tiles whose center maps to a cell other than [i_indg,j_indg];
  abort if > 0.1%

EASEv and LatLon branches unchanged; new code is not yet called (0-diff).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(clsm_ensupd_enkf_update.F90)

For cube-sphere tile space, pass tile_grid_f (= tile_grid_g) and tables built from
tile_coord_f%i_indg/j_indg to collect_obs() instead of the lat/lon pert_grid_f and its
tables, in whose cells the tiles do not nest (for CF0360, 38% of land obs were dropped
and 16% assigned to the wrong tile).  Keep the lat/lon extent of pert_grid_f so that obs
outside pert_grid_f are still dropped (needed by get_obs_pert()).  Call check_c3_tile_grid()
once on root.  Unchanged for EASE and lat/lon tile space.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce (clsm_ensupd_upd_routines.F90, clsm_ensupd_enkf_update.F90)

The QC of Tb obs for too much non-land (water, land ice) in the FOV was done for EASE grids
only.  In cube-sphere tile space a grid cell contains several tiles, whose frac_cell add up
to the land fraction of the grid cell; average the land fraction of the grid cells in the
FOV and count each grid cell once by weighting each tile with its share of the land in its
grid cell (identical to EASE if there is one tile per grid cell).  New optional input
c3_tile_space in get_obs_pred(), because tile_grid_g there is the (lat/lon) pert grid.
Needs correct frac_cell from nc4 tile files.  0-diff for EASE and lat/lon tile spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LDAS_TileCoordRoutines.F90, clsm_ensupd_enkf_update.F90)
…d the ESMF grid instead of copied cube-sphere geometry; removed check_c3_tile_grid() (LDAS_TileCoordRoutines.F90, clsm_ensupd_enkf_update.F90, clsm_ensupd_read_obs.F90, GEOS_LandAssimGridComp.F90)

- pass the grid attached to the land locstream (cube-sphere grid for c3 tile space)
  as optional c3_grid from LandAssim RUN through get_enkf_increments(), collect_obs(),
  read_obs(), the obs readers and get_tile_num_for_obs() to get_tile_num_from_latlon()
- new get_ij_ind_from_latlon_c3() (vector of lat/lon, one MAPL call) and
  get_tile_num_from_latlon_c3() (c3 search moved out of get_tile_num_from_latlon(),
  processed in chunks; neighbouring grid cells that were already searched are skipped);
  EASE and LatLon code of get_tile_num_from_latlon() is again identical to develop
- new init_c3_grid(), called once by all processes in get_enkf_increments():
  the first MAPL_GridGetCorners() call for a grid is collective (halo exchange), and
  obs are mapped to tiles on root_proc only
- removed copied MAPL constants and check_c3_tile_grid(); MAPL checks the grid and
  supports stretched grids

Standalone test (Mac, C360 ESMF grid, 6 PETs, 2,688,020 points): grid cells and tile
numbers identical to #245 for FOV 0 and 20 km; EASEv2 M36 identical to develop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…max_dist (LDAS_TileCoordRoutines.F90)

In Step 3 of get_tile_num_from_latlon_c3() (no tile bounding box contains the obs),
the closest tile (Minkowski norm) was chosen among all candidate tiles and then dropped
if it failed the per-axis max_dist check, even if another candidate passed it.  Now
only candidates within max_dist_x and max_dist_y are considered (cube-sphere tile space
only; review finding 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… obs (LDAS_TileCoordRoutines.F90)

In Step 2 of get_tile_num_from_latlon_c3() (no tile bounding box in the obs's grid cell
contains the obs), the 8 points at +/- half a grid cell could miss grid cells that hold
tiles within max_dist, so the obs was dropped although develop kept it.  Step 2 now also
searches the grid cells of a lattice of points over lat/lon +/- max_dist (spacing at most
a quarter grid cell; at most N_lattice_max intervals on either side), mapped to grid cells
with one MAPL call per batch of at most N_pts_max points.  For FOV=0 (max_dist=0), the
lattice is just the obs and the result is unchanged (cube-sphere tile space only; review
finding 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…removed unused N_tile_in_cell_ij, tile_num_in_cell_ij in cat_enkf_increments() (clsm_ensupd_enkf_update.F90, clsm_ensupd_upd_routines.F90, clsm_ensupd_read_obs.F90)

The tables N_tile_in_cell_ij_f, tile_num_in_cell_ij_f are used only in read_obs(),
which collect_obs() calls on root_proc only.  For FOV>~0, get_obs_pred() computes its
own tables for get_tile_num_in_ellipse() (the "tile_num_in_circle" mentioned in the
comment no longer exists).  The "FOV>FOV_threshold" condition for building the tables
on all processes is therefore obsolete.  0-diff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gmao-rreichle and others added 26 commits November 19, 2026 14:19
Adapt read_obs_JPSS_SCF to renamed obs-to-tile arguments (N_catf, tile_coord_f,
obs2tile_grid_f, tile_grid_g_ESMF) from #252.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… logic change)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… on any HDF5 error

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ff view on GitHub; minimal white-space changes (clsm_ensupd_read_obs.F90, io_hdf5.F90)
…eaner diff view on GitHub; minimal white-space changes (clsm_ensupd_read_obs.F90, io_hdf5.F90)"

This reverts commit 982e1c8.
…utine read_obs_MODIS_VIIRS_SCF(); renamed read_JPSS_SCF_hdf() to read_VIIRS_SCF_hdf() (clsm_ensupd_read_obs.F90)
…IIRS_SCF_hdf)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tile_to_latlongrid() and the spatial averages in the titles of
Plot_stats_maps.py used unweighted means over tiles.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A zero-area first tile in a grid cell gave 0/0 and left the cell NaN.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@weiyuan-jiang
weiyuan-jiang requested review from a team as code owners November 30, 2026 19:29
@github-actions

Copy link
Copy Markdown

This PR is being prevented from merging because you have not added one of our required labels: 0 diff, 0 diff trivial, Non 0-diff, 0 diff structural, 0-diff trivial, Not 0-diff, 0-diff, automatic, 0-diff uncoupled, github_actions. Please add one so that the PR can be merged.

@weiyuan-jiang
weiyuan-jiang merged commit 52ff736 into feature/wjiang/2d_decompose Nov 30, 2026
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants