forsys-sp / forsysr

An R implementation of the ForSys program
GNU General Public License v3.0
8 stars 3 forks source link

ceiling error #96

Closed michelledayusfs closed 1 year ago

michelledayusfs commented 1 year ago
# Run forsys the original way and filter for the specific priority weighting combo
run_outputs_preset = forsys::run(
  return_outputs = TRUE,
  write_outputs = TRUE,
  stand_data = shp,
  scenario_name = "patchmax_forsys_preset",
  stand_id_field = "LMU_ID",
  stand_area_field = "Acres",
  global_threshold = 'OwnerClass == "USDA FOREST SERVICE"',
  scenario_priorities = c("preset_priority"),
  scenario_output_fields = c("Acres", "Am4RevBio_PCP", "prob_8p_PCP", "res_depart_PCP"),
  run_with_patchmax = TRUE,
  patchmax_proj_size = 500,
  patchmax_proj_number = 3,
  patchmax_SDW = 1,
  patchmax_EPW = 0, 
  patchmax_sample_frac = 1
)

Writing data to C:/GitHub/forsysr/output/patchmax_forsys_preset Subsetting stands where OwnerClass == "USDA FOREST SERVICE" (23.83% excluded) Weighting scenario 1 of 1: 1 Combined priority assigned to weightedPriority Starting year 1 ---------------- Error in patchmax::simulate_projects(geom = geom, St_id = pull(geom, !!stand_id_field), : unused arguments (P_ceiling = pull(geom, !!proj_ceiling_field), P_ceiling_max = proj_ceiling)

michelledayusfs commented 1 year ago

It looks like patchmax is now requiring this (looking at the forsys code). Can this be run without it?

codyevers commented 1 year ago

I pushed a new forsys update that should fix this issue. @michelledayusfs can you confirm?

michelledayusfs commented 1 year ago

Still getting the error, and I did a pull request, restarted R and then cleaned and rebuilt.

Error in patchmax::simulate_projects(geom = geom, St_id = pull_field(geom, : unused arguments (P_ceiling = pull_field(geom, global_ceiling_field), P_ceiling_max = global_ceiling_value)

codyevers commented 1 year ago

Did you also pull and rebuild patchmax? Looks like the problem is within the patchmax package

Message ID: @.***>

michelledayusfs commented 1 year ago

No. Github said it wasn't updated, and I checked on line. Did you push your changes?

codyevers commented 1 year ago

My bad :-(  Just pushed. Sorry for the headache... On Jan 31, 2023 at 8:51 AM -0800, Michelle Day @.***>, wrote:

No. Github said it wasn't updated, and I checked on line. Did you push your changes? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>

michelledayusfs commented 1 year ago

It won't clean and rebuild. Looks like the same error I got before. Can you check on your end?

codyevers commented 1 year ago

Works on my end. Can you attach your script just so I can confirm?

This what I'm using...

shp <- st_read("~/Downloads/SERAL_sample/SERAL_sample.shp") %>%
  calculate_pcp(fields = c('Am4RevBio','prob_8p','res_depart')) %>%
  combine_priorities(
    fields = c('Am4RevBio_PCP','prob_8p_PCP','res_depart_PCP'),
    weights = c(1,1,1),
    new_field = 'preset_priority')

run_outputs_preset = forsys::run(
  return_outputs = TRUE,
  write_outputs = TRUE,
  stand_data = shp,
  scenario_name = "patchmax_forsys_preset",
  stand_id_field = "LMU_ID",
  stand_area_field = "Acres",
  global_threshold = 'OwnerClass == "USDA FOREST SERVICE"',
  scenario_priorities = c("preset_priority"),
  scenario_output_fields = c("Acres", "Am4RevBio_PCP", "prob_8p_PCP", "res_depart_PCP"),
  run_with_patchmax = TRUE,
  patchmax_proj_size = 500,
  patchmax_proj_number = 3,
  patchmax_SDW = 1,
  patchmax_EPW = 0,
  patchmax_sample_frac = 1
)

On Jan 31, 2023 at 9:02 AM -0800, Michelle Day @.***>, wrote:

It won't clean and rebuild. Looks like the same error I got before. Can you check on your end? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.***>

michelledayusfs commented 1 year ago

I cannot update patchmax: ** byte-compile and prepare package for lazy loading Error : package or namespace load failed for 'patchmax' in loadNamespace(package, lib.loc): cyclic namespace dependency detected when loading 'patchmax', already loading 'patchmax' Error: unable to load R code in package 'patchmax' Execution halted ERROR: lazy loading failed for package 'patchmax'

Exited with status 1.

codyevers commented 1 year ago

OK, I think I fixed this. Try pulling and building patchmax one more time. On Jan 31, 2023 at 9:25 AM -0800, Michelle Day @.***>, wrote:

Error : package or namespace load failed for 'patchmax' in loadNamespace(package, lib.loc): cyclic namespace dependency detected when loading 'patchmax', already loading 'patchmax' Error: unable to load R code in package 'patchmax'

michelledayusfs commented 1 year ago

New error:

set.seed(12345)
# Run forsys the original way and filter for the specific priority weighting combo
run_outputs_patchceiling = forsys::run(
  return_outputs = TRUE,
  write_outputs = TRUE,
  stand_data = shp,
  scenario_name = "forsys_patchceiling",
  stand_id_field = "LMU_ID",
  stand_area_field = "Acres",
  global_threshold = 'OwnerClass == "USDA FOREST SERVICE"',
  scenario_priorities = c("res_depart_SPM"),
  scenario_output_fields = c("Acres", "Am4RevBio_PCP", "prob_8p_PCP", "res_depart_PCP"),
  run_with_patchmax = TRUE,
  patchmax_proj_size = 500,
  patchmax_proj_number = 10,
  patchmax_SDW = 1,
  patchmax_EPW = 0, 
  patchmax_sample_frac = 0.1,
  annual_target_field = "Acres",
  annual_target = 2500
)

Writing data to C:/GitHub/forsysr/output/forsys_patchceiling Subsetting stands where OwnerClass == "USDA FOREST SERVICE" (23.83% excluded) Weighting scenario 1 of 1: 1 Error in select(): ! Problem while evaluating all_of(fields). Run rlang::last_error() to see where the error occurred.

We can screen share in a couple of minutes.

michelledayusfs commented 1 year ago

Fixed.