AustralianAntarcticDivision / bgmfiles

Example BGM Files for the Atlantis whole-of-ecosystem model
https://australianantarcticdivision.github.io/bgmfiles/
1 stars 0 forks source link

function to build long form box by face table #5

Open mdsumner opened 7 years ago

mdsumner commented 7 years ago

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/atlantis-ecosystem-model/j5pVXqY7TKQ

noba_file  <- bgmfiles::bgmfiles("Nordic")

library(rbgm)

## BGM is a doubly-connected-edge-list
## here in 'related tables' form
noba_edge_list <- bgmfile(noba_file)

library(dplyr)
noba_edge_list$boxes %>% dplyr::select(.bx0, botz, area) %>% 
  inner_join(noba_edge_list$facesXboxes, ".bx0") %>% 
  inner_join(noba_edge_list$faces, c("iface" = ".fx0"))
##etc.
RMORSEcode commented 7 years ago

Hi Mike,

I thought I had it, but then realized the lengths of the files were wrong - using your approach above results in a length of 506, whereas the file I am trying to recreate is 568 lines long. Using atlantistools, the BGM is read in and converted to long/loat for all of boxN.vert which resulted in 632 lines. Your solution (above) does not appear to include the vertices where the boxN.ibox is a NaN, which in Cecilie's file is 60 lines, so your solution plus those NaNs gets to 566 lines, still 2 lines short. I'm scratching my head as to what they could be... does not seem to be a repeat to connect points as far as I can tell.

cecilie=read.table('file:////GitHub/NoBA/corners_neighbours_nordic.txt', sep='\t', header = T) sum(is.nan(cecilie$neighbour))

mdsumner commented 7 years ago

Thanks for checking! Work in progress, needs a rethink. I'll have another go soon. If you have thoughts on other conversions feel free to post them as issues too.

RMORSEcode commented 7 years ago

It looks like the NOBA bgm file that the this long format table was created from may be different from what is in this repository (or there wan an error creating the file). There are 7 faces (rows) listed for box zero in the long format table, but in the 'Nordic' bgmfile there are 8 faces, and one of the 7 in the table lists NaN as a neighbor but it should be box 15.

mdsumner commented 7 years ago

Thanks again, that's helpful detail I will fix! Do you know a master source of the Nordic bgm?