AustralianAntarcticDivision / angstroms

Tools for model grid data (with raster in R)
http://australianantarcticdivision.github.io/angstroms/
4 stars 1 forks source link

weird bug #14

Closed mdsumner closed 5 years ago

mdsumner commented 5 years ago

Wat

This code errors the first time, but try again and it works. So there must be some weird scoping problem or something I've overlooked.


## create NetCDF templates for Atlantis hydro
library(ncdf4)

### FOR TRANSPORT NC FILE
transp_filename <- sprintf("%s_transport.nc", tempfile())
mass_filename  <- sprintf("%s_mass.nc", tempfile())
transp_params <- ""
mass_params <- ""

bgmfilepath <- bgmfiles::bgmfiles("antarctica_28")
library(angstroms)
create_transport(transp_filename, model_title = "Transport file Antarctica_28", bgmfilepath = bgmfilepath, 
                              bgmlevels = 1:9, time_steps = Sys.time() + (1:10) * 24 * 3600)
Error in ncvar_put(nc_transp, "pt1_x", v1$x) : 
  ncvar_put: error: you asked to write 90 values, but the passed data array only has 0 entries!
In addition: Warning messages:
1: Unknown or uninitialised column: 'p0'. 
2: Length of logical index must be 1 or 180, not 0 
3: Unknown or uninitialised column: 'p0'. 
 Error in ncvar_put(nc_transp, "pt1_x", v1$x) : 
  ncvar_put: error: you asked to write 90 values, but the passed data array only has 0 entries! 
mdsumner commented 5 years ago

fixed (I think) in dec7204

bgm$facesXverts[bgm$facesXverts[[".p0"]] == 1, ] %>%  dplyr::inner_join(ll, ".vx0")

rather than

bgm$facesXverts[bgm$facesXverts$.p0 == 1, ] %>%  dplyr::inner_join(ll, ".vx0")

because the $ flips on the . or something?