# Example of usage of the Chesapeake Bay atlas (https://doi.org/10.17882/99441) # MACAN webinar of 2024-09-05, pst-laurent@vims.edu # # Use package 'seacarb' to derive carbonate chemistry variables such as # saturation states and pCO2 from the alkalinity and DIC available in the # atlas. # Import the different libraries that we will need. # If a library/package isn't already installed on your computer, type: # install.packages( 'name_of_library' ) library( ncdf4 ) # To read NetCDF files. library( seacarb ) # To model the inorganic carbon system. # Read from the atlas the different variables that we will need. We specifically # select bottom fields since this is where bivalves live. atla <- nc_open( 'atlas_chesbay_v20240319.nc' ) long <- ncvar_get( atla, 'longitude' ) # Dims: 348 lati <- ncvar_get( atla, 'latitude' ) # Dims: 567 salt <- ncvar_get( atla, 'salinity_bottom' ) # Dims: 348x567x12 (PSU ). temp <- ncvar_get( atla, 'temperature_bottom' ) # Dims: 348x567x12 (deg.C ). dic <- ncvar_get( atla, 'DIC_bottom' ) # Dims: 348x567x12 (umol/kg). ta <- ncvar_get( atla, 'TA_bottom' ) # Dims: 348x567x12 (umol/kg). nc_close( atla ) # Close file once done. rm( atla ) # No longer necessary. # We will focus on Mobjack Bay, and more specifically the monitoring station # WE4.1 which is roughly at the mouth of that Bay in water of depth ~6meters. lo_s <- - 76.34634 # LOngitude of Station. la_s <- 37.31181 # LAtitude of Station. # Spatially interpolate the atlas' fields at this particular station. # Begin by noting the DIMensions of the atlas' Fields (fdim), then find the # four points that surround the station, and finally, conduct a bilinear # interpolation, for each field of interest, and each MONTh of the year. fdim <- dim( salt ) # 348, 567, 12. # Four neighbors surrounding the station: (i1,j1),(i2,j1),(i1,j2),(i2,j2). # (0