Skip to content

bug: soilid data rank number is being improperly assigned due to a missing dataframe sorting step #256

Description

@jjmaynard

Description

Current 'rank_soils' function is missing a dataframe sorting step required to correctly assign a number ranking for the 'rank_data' field returned from the api.

Steps To Reproduce

create point in app and populate user data with values that are similar to a soil with a low location rank. Because of the incorrect ordering of the dataframe, the component where 'rank_data' = 1 will not be the component with the highest 'score_data'.

Expected behavior

Willamette has the highest "score_data":0.942 and is correctly assigned the top "rank_data":"1"

Corrected rank_soils return with texture class entered for 112-155cm depth and correct sorting
# Sort dataframe to correctly assign Rank_Data
D_final = D_final.sort_values(by=["soilID_rank_data", "Score_Data"], ascending=[False, False])
{
   "metadata":{
      "location":"us",
      "model":"v2"
   },
   "soilRank":[
      {
         "name":"Woodburn",
         "component":"Woodburn",
         "componentID":25270809,
         "score_data_loc":0.913,
         "rank_data_loc":"1",
         "score_data":0.906,
         "rank_data":"2",
         "score_loc":0.92,
         "rank_loc":1,
         "componentData":"Data Complete"
      },
      {
         "name":"Willamette",
         "component":"Willamette",
         "componentID":25270986,
         "score_data_loc":0.765,
         "rank_data_loc":"2",
         "score_data":0.942,
         "rank_data":"1",
         "score_loc":0.588,
         "rank_loc":2,
         "componentData":"Data Complete"
      },
      {
         "name":"Amity",
         "component":"Amity",
         "componentID":25270996,
         "score_data_loc":0.571,
         "rank_data_loc":"3",
         "score_data":0.906,
         "rank_data":"3",
         "score_loc":0.237,
         "rank_loc":3,
         "componentData":"Data Complete"
      },
      {
         "name":"Dayton",
         "component":"Dayton",
         "componentID":25270995,
         "score_data_loc":0.407,
         "rank_data_loc":"4",
         "score_data":0.794,
         "rank_data":"4",
         "score_loc":0.02,
         "rank_loc":4,
         "componentData":"Data Complete"
      }
   ]
}

Actual behavior

Current results for the test point: 44.63165, -123.19684

Willamette has highest "score_data" but is ranked 2 for "rank_data" Current rank_soils return with texture class entered for 112-155cm depth with missing sorting step
{
   "metadata":{
      "location":"us",
      "model":"v2"
   },
   "soilRank":[
      {
         "name":"Woodburn",
         "component":"Woodburn",
         "componentID":25270809,
         "score_data_loc":0.913,
         "rank_data_loc":"1",
         "score_data":0.906,
         "rank_data":"1",
         "score_loc":0.92,
         "rank_loc":1,
         "componentData":"Data Complete"
      },
      {
         "name":"Willamette",
         "component":"Willamette",
         "componentID":25270986,
         "score_data_loc":0.765,
         "rank_data_loc":"2",
         "score_data":0.942,
         "rank_data":"2",
         "score_loc":0.588,
         "rank_loc":2,
         "componentData":"Data Complete"
      },
      {
         "name":"Amity",
         "component":"Amity",
         "componentID":25270996,
         "score_data_loc":0.571,
         "rank_data_loc":"3",
         "score_data":0.906,
         "rank_data":"3",
         "score_loc":0.237,
         "rank_loc":3,
         "componentData":"Data Complete"
      },
      {
         "name":"Dayton",
         "component":"Dayton",
         "componentID":25270995,
         "score_data_loc":0.407,
         "rank_data_loc":"4",
         "score_data":0.794,
         "rank_data":"4",
         "score_loc":0.02,
         "rank_loc":4,
         "componentData":"Data Complete"
      }
   ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions