Skip to content

Brickman

Ben Tupper edited this page Nov 28, 2024 · 3 revisions

Brickman data

About

What we call the “Brickman” data, is a suite of outputs of model runs using the BNAM. Runs were made for “PRESENT” (1982–2013), 2055 and 2075. For the latter two parameters were set to account for two scenarios: RCP4.5 (intermediate case) and RCP8.5 (business as usual case). For all years and scenarios both annual mean and monthly mean projections were produced.

This is a link to the paper describing the model construction and outputs.

What model data do we have on hand?

We have developed a small database of these scenarios and years, and we provide tools to allow you so easily read these into data objects that you can manipulate.

First we can read in a small table (aka database) that provides information about the files we have provided.

DB = brickman_database() |>
  print()
## # A tibble: 82 × 4
##    scenario year    interval var  
##    <chr>    <chr>   <chr>    <chr>
##  1 PRESENT  PRESENT ann      MLD  
##  2 PRESENT  PRESENT ann      Sbtm 
##  3 PRESENT  PRESENT ann      SSS  
##  4 PRESENT  PRESENT ann      SST  
##  5 PRESENT  PRESENT ann      Tbtm 
##  6 PRESENT  PRESENT ann      U    
##  7 PRESENT  PRESENT ann      V    
##  8 PRESENT  PRESENT ann      Xbtm 
##  9 PRESENT  PRESENT mon      MLD  
## 10 PRESENT  PRESENT mon      Sbtm 
## # ℹ 72 more rows

Your might be wondering “what are these variables?” Some details can be found by calling brickman_variables(),

brickman_variables("all")
## # A tibble: 18 × 5
##    name  group  longname    description               units    
##    <chr> <chr>  <chr>       <chr>                     <chr>    
##  1 depth static Bathy_depth bathymetric depth         "m"      
##  2 mask  static land_mask   land mask                 ""       
##  3 SST   ann    SST_ann     annual SST                "C"      
##  4 SST   mon    SST         monthly SST               "C"      
##  5 MLD   ann    MLD_ann     annual mixed layer depth  "m"      
##  6 MLD   mon    MLD         monthly mixed layer depth "m"      
##  7 SSS   ann    SSS_ann     annual SSS                "psu"    
##  8 SSS   mon    SSS         monthly SSS               "psu"    
##  9 Tbtm  ann    Tbtm_ann    annual Tbtm               "C"      
## 10 Tbtm  mon    Tbtm        monthly Tbtm              "C"      
## 11 Sbtm  ann    Sbtm_ann    annual Sbtm               "psu"    
## 12 Sbtm  mon    Sbtm        monthly Sbtm              "psu"    
## 13 Xbtm  ann    Xbtm_ann    annual Xbtm               "unknown"
## 14 Xbtm  mon    Xbtm        monthly Xbtm              "unknown"
## 15 U     ann    U_ann       annual U                  "m/s"    
## 16 U     mon    U           monthly U                 "m/s"    
## 17 V     ann    V_ann       annual V                  "m/s"    
## 18 V     mon    V           monthly V                 "m/s"

Read Brickman model data into R

Read in model data by first filtering the database to just the files you want. It’s important to keep in mind that to keep things simple you’ll want to read in “shape” compatible groups. For instance, it is complicated to read into one R object a dataset that mixes single-layer static variables (like depth) with multi-layer variables (like monthly SST). So, we have put some restrictions on the groupings you can read in one go.

Let’s start by reading in the static variables.

db = DB |>
  dplyr::filter(interval == "static")
static_vars = read_brickman(db)
static_vars
## stars object with 2 dimensions and 2 attributes
## attribute(s):
##        Min. 1st Qu.   Median     Mean  3rd Qu.     Max. NA's
## depth     5 60.2631 145.0126 923.3138 1703.552 4964.409 4983
## mask      1  1.0000   1.0000   1.0000    1.000    1.000 4983
## dimension(s):
##   from  to offset    delta refsys point x/y
## x    1 121 -74.93  0.08226 WGS 84 FALSE [x]
## y    1  89  46.08 -0.08226 WGS 84 FALSE [y]

OK, we read two static variable: depth and mask. The printout shows a statistical summary of each variable including how many NAs (missing or “not available”) values. Note that mask has pixel values of either 1 or NA. It also shows something about the geometry/dimensions. In this case our variables have just x (east-west) and y (south-north) dimensionalities.

That’s it. Filter the database to what you want and then read the data. And, now, we can do the usual stuff with the space-time arrays (aka stars). Of course, these are static variables meaning they don’t change in time - there’s no time-iness to them, but whatever.

plot(static_vars['depth'], axes = TRUE)

Let’s try some non-static variables by loading monthly data - say RCP85 for 2075. So, we filter the table and then read those variable.

db = DB |>
  dplyr::filter(scenario == "RCP85", 
                year == 2075,
                interval == "mon")
x = read_brickman(db)
x
## stars object with 3 dimensions and 8 attributes
## attribute(s):
##              Min.      1st Qu.       Median         Mean      3rd Qu.
## MLD    1.01127517  5.188425422 15.077325821 19.203468161 28.110147476
## Sbtm  22.72784424 32.119906425 34.454338074 33.564421845 34.941211700
## SSS   15.61822033 30.504541874 30.948341370 31.406357837 31.939316273
## SST    0.84497827  7.999758005 13.929839611 13.630253277 19.051631451
## Tbtm   0.74468768  4.001685858  7.768758297  7.369697369  9.249178886
## U     -0.22471914 -0.010182445 -0.002215136 -0.009042294  0.001126237
## V     -0.19030032 -0.009814290 -0.002245136 -0.007339959  0.001396833
## Xbtm  -0.04662703  0.001123656  0.002673889  0.007115667  0.006559871
##               Max.  NA's
## MLD   111.33813477 59796
## Sbtm   35.70283508 59796
## SSS    36.40741730 59796
## SST    27.80369568 59796
## Tbtm   25.78357315 59796
## U       0.09090719 59796
## V       0.08733927 59796
## Xbtm    0.21393159 59796
## dimension(s):
##       from  to offset    delta refsys point      values x/y
## x        1 121 -74.93  0.08226 WGS 84 FALSE        NULL [x]
## y        1  89  46.08 -0.08226 WGS 84 FALSE        NULL [y]
## month    1  12     NA       NA     NA    NA Jan,...,Dec

Whoa! Eight variables and now with a third dimension (“month”). Things get complicated in a hurry, but no worries. Let’s plot the time series for the sea floor temperature (Tbtm).

plot(x['Tbtm'], axes = FALSE)

Extract point data from a stars object

We provide a small dataset of select observational buoys from the Gulf of Maine. The data provides simple metadata and location information. For any of these buoys you can use the NERACOOS Mariner’s Dashboard to click on a buoy such as Buoy E01 located off of the midcoast area.

buoys = gom_buoys()
buoys
## Simple feature collection with 6 features and 3 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -70.4277 ymin: 42.3233 xmax: -65.9267 ymax: 44.10163
## Geodetic CRS:  WGS 84
## # A tibble: 6 × 4
##   name  longname            id                geometry
## * <chr> <chr>               <chr>          <POINT [°]>
## 1 wms   Western Maine Shelf B01    (-70.4277 43.18065)
## 2 cms   Central Maine Shelf E01     (-69.3578 43.7148)
## 3 pb    Penobscot Bay       F01   (-68.99689 44.05495)
## 4 ems   Eastern Maine Shelf I01   (-68.11359 44.10163)
## 5 jb    Jordan Basin        M01   (-67.88029 43.49041)
## 6 nec   Northeast Channel   N01     (-65.9267 42.3233)
plot(x['Tbtm'] |> dplyr::filter(month == "Jan"), axes = FALSE, reset = FALSE)
plot(sf::st_geometry(buoys), col = "orange", pch = 20, add = TRUE)
text(buoys, labels = buoys$id, adj = c(1,1), col = "blue", cex = 0.8)

Now we can extract the data for each month (12) and each variable (8) for each buoy (6). There are two shapes of results you can request. “long” form (the default) in which each row holds one variable for one month for each point. It will have 12 x 8 x 6 = 576 rows. It may feel awkward to work with long form data at first, but this form is super handy when manipulating data. The other form, “wide”, has more human-eye appeal because each row has the data for one point at one month but has all of the variables. “wide” form results will have 12 x 6 = 72 rows. We’ll extract each for below to compare.

First the default “long” form.

long_values = extract_brickman(x, buoys)
long_values
## # A tibble: 576 × 4
##    point name  month value
##    <chr> <chr> <chr> <dbl>
##  1 p1    MLD   Jan   28.2 
##  2 p1    MLD   Feb   26.2 
##  3 p1    MLD   Mar   14.4 
##  4 p1    MLD   Apr    7.63
##  5 p1    MLD   May    4.15
##  6 p1    MLD   Jun    2.45
##  7 p1    MLD   Jul    2.16
##  8 p1    MLD   Aug    2.74
##  9 p1    MLD   Sep    6.85
## 10 p1    MLD   Oct   14.8 
## # ℹ 566 more rows

Each row holds just one measurement for one variable, and, as predicted, we have 12 x 8 x 6 = 576 rows.

Now let’s extract the same data, but this time to a “wide” form. Note that we end up with the predicted 12 x 6 = 72 rows. Now we have all 8 variable measurements per point per month on a single row.

wide_values = extract_brickman(x, buoys, form = "wide")
wide_values
## # A tibble: 72 × 10
##    point month   MLD  Sbtm   SSS   SST  Tbtm          U         V       Xbtm
##    <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>      <dbl>     <dbl>      <dbl>
##  1 p1    Jan   28.2   32.5  31.1  5.38  7.18 -0.00114    0.000563  0.000373 
##  2 p1    Feb   26.2   32.2  31.2  3.94  6.23  0.000150   0.00149   0.000659 
##  3 p1    Mar   14.4   32.0  30.8  3.72  5.61  0.000291  -0.00401   0.00141  
##  4 p1    Apr    7.63  32.0  30.2  5.62  5.77  0.00138   -0.00406  -0.000471 
##  5 p1    May    4.15  32.0  30.0  9.45  6.40  0.00124    0.000674  0.000503 
##  6 p1    Jun    2.45  32.2  29.8 14.0   6.86  0.00120    0.00152   0.000690 
##  7 p1    Jul    2.16  32.4  30.0 17.2   7.10  0.0000825  0.00151   0.000380 
##  8 p1    Aug    2.74  32.4  30.3 18.5   7.24  0.0000935  0.000438 -0.0000370
##  9 p1    Sep    6.85  32.4  30.5 17.5   7.42 -0.000390  -0.00102   0.000375 
## 10 p1    Oct   14.8   32.4  30.7 14.2   8.06  0.000132  -0.000916  0.000586 
## # ℹ 62 more rows

Just what you want to do with the data may help you determine which form you prefer.

Clone this wiki locally