Smithsonian / ForestGEO

🌱🌳Web app helping a global network of scientists and forest research sites manage and validate data. Collaboration between the Smithsonian Institution's Forest Global Earth Observatory (ForestGEO), Microsoft, and CodeDay.
12 stars 4 forks source link

screenDiam validation #115

Open illume opened 2 years ago

illume commented 2 years ago

See "instructions for writing a validation function". Below are notes from the spec, the original validation function (in the PHP language), and the SQL table structure.

screenDiam Check for diameter range (d <0 and d> maxpossible raises an error). "SELECT TempID FROM ".$fileName." WHERE DBH<>0 AND (DBH>".$maxDBH." OR DBH<".$minDBH.") AND Errors<>'NONE' Minimum DBH for a stem is often 1.0, but this depends on whether site uses mm or cm. Local Checks to see if a tree’s diameter at breastheight (DBH) is within a predefined range.  Note that some sites record data in millimeters and others in centimeters, so minimum DBH is often 1.0 but not always.

Some was done on this already: see https://github.com/ForestGeoHack/ForestGEO/issues/107#issuecomment-1284336104

siddheshraze commented 9 months ago

Here is an updated procedure to run this and mark its errors in the CMVErrors table! Function's been reviewed with GPT so it should work as intended, but full testing is still pending:

create
    definer = azureroot@`%` procedure ValidateScreenMeasuredDiameterMinMax(IN minDBH decimal(10, 2), IN maxDBH decimal(10, 2))
BEGIN
    INSERT INTO forestgeo_bci.cmverrors (CoreMeasurementID, ValidationErrorID)
    SELECT
        CoreMeasurementID,
        2 AS ValidationErrorID
    FROM
        forestgeo_bci.coremeasurements
    WHERE
        MeasuredDBH < minDBH OR MeasuredDBH > maxDBH;
END;
justinpac commented 4 months ago

This is still pending because it needs to be integrated with the species limits table.