Skip to content

Check the replanting options

What this does

It answers one question: when each planning unit is clearfelled, where can its area go? It reads Plunits and Replanting once and reports, as Tigermoth reads the rows: (A) the rows that stop the description from being run, the rows that offer nothing and the rows that hold their area at zero; (B) the planning units with nowhere to be replanted in some or all periods; (C) the planning units whose area leaves the estate at clearfell in some or all periods; (D) a count of the rest. It changes nothing.

Before you start

  1. Hold sheet_replanting: ask the tool for it if you have not in this conversation. Every rule applied below is stated on sheet_replanting or on sheet_plunits; this procedure adds none.
  2. If the workbook has no worksheet named Replanting, every planning unit is replanted into itself. Say so in one line and stop.

Read

One call of your Excel tool, reading only: the values of the used range of Plunits and of Replanting. If your Excel tool runs code, do the work of the next section in that same call and return only the result. Do not read cell by cell, and do not read again.

On both worksheets the headings are in row 4 and the data starts in row 5; rows 1 to 3 and column A are not read.

  • Plunits: B the planning unit's name (a row with a blank name is skipped, and the data ends at the last row that has a name); D Year, E Species, F Origin; L to P Tending, Regime, Croptype, Cost, Carbon; Q BYOS, R tCO2eL; from S to the last heading of row 4, one group per column: the heading is the group, the cell is the attribute, and a blank cell is no attribute.
  • Replanting: B Start, C End, D Type, E Origin Group, F Origin Attribute, G Dest Group, H Dest Attribute, I Equality, J Quantity.

Work it out

Match groups without regard to letter case, and attributes without regard to letter case or accents. Remove the spaces at the ends of every value of Plunits. A cell of Replanting that matches only once the spaces at its ends are removed is taken as matching, and is listed in the report.

  1. THE ROWS THAT ARE READ: the rows of Replanting whose Start is not blank and does not begin with #. Every other row is ignored; a row that is blank in every cell is not counted among them.
  2. THE GROUPS: each heading of Plunits row 4 from S onward that has a value somewhere below it, and the built-in groups: Plunit (the name of each planning unit, and Bareland), Species (E), Origin (F), Year (D), Tending, Regime, Croptype, Cost and Carbon (L to P, where a blank cell is the attribute Undefined), BYOS and tCO2eL (Q and R, where filled in).
  3. RESOLVE each read row. Its origin pair (E, F) and its destination pair (G, H) each select the planning units that carry that attribute of that group; Plunit with Bareland is the land outside the estate.
    • A1, THE DESCRIPTION CANNOT BE RUN (WBC-018): a group that is not one of the groups of step 2; an attribute that is not one of its group's attributes (while its group is unknown, an attribute is not checked); Bareland with a group other than Plunit; a Type that is not exactly Period or Total. Note the row, the cell and its text, and leave the row out of what follows.
    • A2, THE ROW OFFERS NOTHING: its Start is after its End. A Start below 1, or text in Start, is read as 1; text in End is read as 0.
    • A3, THE ROW HOLDS ITS AREA AT ZERO: its Equality begins with = and its Quantity is 0, blank or text.
  4. SELECTED AS AN ORIGIN: every planning unit in the origin selection of a read row that is not an A1 row, A2 and A3 rows included. A planning unit that is selected has only the options its rows give it.
  5. THE OPTIONS of a selected planning unit: the rows that select it, less the A rows. Each option has its periods, Start to End, and its destination: planning units, or Bareland.
  6. CLASSIFY each selected planning unit over the periods 1 to H, where H is the largest End among the read rows; the model's own last period is not on these two worksheets, so say what H is. The first of these that applies:
    • B1: no option at all;
    • B2: one or more of the periods 1 to H without an option (keep the first such period);
    • C: in one or more of the periods 1 to H, every option it has in that period leads to Bareland (keep the first such period);
    • otherwise it has somewhere to go. Count separately those whose only destination is the planning unit itself.
  7. NOT SELECTED: the planning units that no read row selects as an origin. Tigermoth replants each into itself in every period. Count them; do not list them.
  8. WHAT A CLASS HAS IN COMMON, for B1, B2 and C, each when it has more than five planning units: for each group of step 2 other than Plunit, the attributes its planning units carry, with their counts. Keep the groups in which three attributes or fewer cover the whole class.

Report

Short, in this order. A class with nothing in it gets one line that says so.

  1. One line: the number of planning units, of rows read, of rows ignored, and H.
  2. A: each row with its number, the cell and what is wrong. For A1, say that the description cannot be run until the workbook is corrected and imported again. Then the cells that matched only once the spaces at their ends were removed, and a suggestion to remove those spaces.
  3. B: for B1 and for B2, how many, their names (the first twenty if there are more) and what they have in common; for B2, the first period without an option. Say what it means: when such a planning unit is clearfelled in those periods, its area has nowhere to be replanted.
  4. C: the same, with the first period in which every option leads to Bareland. Say what it means: when such a planning unit is clearfelled in those periods, its area leaves the estate. That can be intended, so ask.
  5. D: the counts of steps 6 and 7.

Do not describe your method. Propose a change only if the user asks for one, and then work from sheet_replanting.

Stop and ask

Stop and ask the user when Plunits or Replanting does not have its headings in row 4, or when a heading you need is not where this procedure says.