TNC-NMFO / NWLAND

carbon accounting model
0 stars 0 forks source link

iesm data processing error, unknown location, unknown cause #86

Closed sbassett closed 2 years ago

sbassett commented 2 years ago
end raster processing year 2010 ; l 9 Forest ; v 2 Soil Tue Oct 05 00:14:30 2021 
Error in `$<-.data.frame`(`*tmp*`, "Component", value = "Soil") : 
  replacement has 1 row, data has 0

top return = https://stackoverflow.com/questions/29814912/error-replacement-has-x-rows-data-has-y

sbassett commented 2 years ago

@aj1s I have no idea where this error originates. I'm going to go through line by line..

end raster processing year 2010 ; l 9 Forest ; v 2 Soil Tue Oct 05 02:23:26 2021 
Error in `$<-.data.frame`(`*tmp*`, "Component", value = "Soil") : 
  replacement has 1 row, data has 0
> traceback()
3: stop(sprintf(ngettext(N, "replacement has %d row, data has %d", 
       "replacement has %d rows, data has %d"), N, nrows), domain = NA)
2: `$<-.data.frame`(`*tmp*`, "Component", value = "Soil")
1: `$<-`(`*tmp*`, "Component", value = "Soil")
sbassett commented 2 years ago

Error appears to originate between lines 829 and 843. Likely line 833.

sbassett commented 2 years ago
> df_curr$Component = comp_names[v]
Error in `$<-.data.frame`(`*tmp*`, Component, value = "Soil") : 
  replacement has 1 row, data has 0

checking constituent elements

> comp_names[v]
[1] "Soil"
> df_curr$Component
NULL
> df_curr
[1] Region    Land_Type Ownership
<0 rows> (or 0-length row.names)

Why does df_curr have no rows?

sbassett commented 2 years ago

It looks like I misspecified the Land_Type attribute in one of the input datasets. I have codes (e.g. 40) instead of landtype name (e.g. "Desert") in the Land_Type field of caland+df

> head(caland_df)
  Land_Cat_ID Region_ID Region Land_Type_ID Land_Type Ownership_ID Ownership   Area_sqm
1     4205001        42 C08081           50        50            1       BLM 3425772600
2     4206001        42 C08081           60        60            1       BLM  749928600
3     4205006        42 C08081           50        50            6   Private 2482391700
4     4210001        42 C08081          100       100            1       BLM  353312100
5     4208001        42 C08081           80        80            1       BLM   82989000
6     4209001        42 C08081           90        90            1       BLM  634898700
> head(caland_df$Land_Type == lt[dl])
[1] FALSE FALSE FALSE FALSE FALSE FALSE
> lt[dl]
[1] "Desert"

source of the error is traced to nwland_landcat_2021_10_04_integer_areasqm.csv will fix

sbassett commented 2 years ago

all working now estimating somewhere between 10 and 32 days for this processing to be completed [(3.5 hours3maps75sim-years)/24 hours-per-day = 32.8125 days 😱

sbassett commented 2 years ago

apparent success

end raster processing year 2080 ; l 12 Developed_all ; v 2 Soil Sat Oct 09 11:22:09 2021 
>   
> # now write the output table  
> write.csv(df_out, paste0(out_name), row.names = FALSE)
> 
> cat("finish proc_iesm_climate.r", date(), "\n")
finish proc_iesm_climate.r Sat Oct 09 11:22:10 2021