Project

General

Profile

Clarification for sellonlatbox

Added by Brendan DeTracey about 2 years ago

Hi again (cdo 2.0.4),
The docs for sellonlatbox state the field must be "rectangularly understood". But the source for Selbox.cc indicates the command operates on all grid types. Could you please clarify for me?

Also, in the Selbox function in Selbox.cc there is the following conditional:

  for (index = 0; index < ngrids; index++)
    {
      auto &sb = sbox[index];
      const auto gridID1 = vlistGrid(vlistID1, index);
      const auto gridtype = gridInqType(gridID1);
      const auto projtype = gridInqProjType(gridID1);

      const auto lprojection = (gridtype == GRID_PROJECTION && projtype == CDI_PROJ_RLL);
      //                    || (gridtype == GRID_PROJECTION && projtype == CDI_PROJ_LCC)
      //                    || (gridtype == GRID_PROJECTION && projtype == CDI_PROJ_STERE);
      if (gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_CURVILINEAR || lprojection
          || (operatorID == SELINDEXBOX && (gridtype == GRID_GENERIC || gridtype == GRID_PROJECTION) && gridInqXsize(gridID1) > 0
              && gridInqYsize(gridID1) > 0)
          || (operatorID == SELLONLATBOX && gridtype == GRID_UNSTRUCTURED))
        {
          int gridID2;
          if (operatorID == SELLONLATBOX)
            {
              const auto gridsize = gridInqSize(gridID1);
              if (gridsize == 1) continue;

              gridID2 = (gridtype == GRID_UNSTRUCTURED) ? gencellgrid(gridID1, sb.nvals, sb.cellidx) : genlonlatgrid(gridID1, sb);
            }
          else
            {
              gridID2 = genindexgrid(gridID1, sb);
            }

          sb.gridtype = gridtype;
          sb.gridID1 = gridID1;
          sb.gridID2 = gridID2;

          vlistChangeGridIndex(vlistID2, index, gridID2);

          for (varID = 0; varID < nvars; varID++)
            if (gridID1 == vlistInqVarGrid(vlistID1, varID)) vars[varID] = true;
        }
      else if (gridtype == GRID_GENERIC && gridInqXsize(gridID1) <= 1 && gridInqYsize(gridID1) <= 1)
        {
        }
      else
        {
          // cdo_print("Unsupported grid type: %s", gridNamePtr(gridtype));
          // if (gridtype == GRID_GAUSSIAN_REDUCED) cdo_print("Use option -R to convert Gaussian reduced grid to a regular grid!");
          // cdo_abort("Unsupported grid type!");
        }
    }
I just wanted to point out the danger of having that last else block with only comments in it. Should it not still emit an error for an unhandled grid type?


Replies (1)

RE: Clarification for sellonlatbox - Added by Ralf Mueller about 2 years ago

hi Brendan!

sellonlatbox indeed works with unstructured grid like ICON or GME. Thx for the hint to the source: an empty else branch is certainly worth changing ;-)

    (1-1/1)