The FjordLight
package has been built
explicitly to facilitate the use of Arctic fjord PAR dataset developed
via the FACE-IT project.
FACE-IT has received funding from the European Union’s Horizon 2020
research and innovation programme under grant agreement no. 869154. This
dataset was a development of that created by Gattuso et al. (2020).
Below one will find a range of examples that should help to clarify the useful order of these functions in a workflow. All of these examples are also available within the help files for the given functions.
With 64 GB of RAM (a typical desktop) your computer should have no
problem loading the data, even with the most extensive fjords. With 4 GB
(a typical laptop) you can only handle the smaller fjords: ‘kong’,
‘young’, and ‘nuup’. However if you do not need the monthly
PARbottom
time series, the package should work with all
fjords. In this case, when calling the fl_LoadFjord()
function, set the TS
argument to FALSE
(this
is the default value).
# Choose a fjord from the list above
fjord <- "kong"
# If the file has already been downloaded a message will be shown
# NB: For this example we use 'dirdata = tempdir()',
# but this will not save the data on our computer.
fl_DownloadFjord(fjord, dirdata = tempdir())
#> ---> downloading fjord kong
#> kong downloaded in directory /tmp/RtmpwyfW1E
WANT_TIME_SERIES <- TRUE
fjorddata <- fl_LoadFjord(fjord, dirdata = tempdir(), TS = WANT_TIME_SERIES)
str(fjorddata, list.len = 15)
#> List of 31
#> $ name : chr "kong"
#> $ longitude : num [1:321(1d)] 11.2 11.2 11.2 11.2 11.2 ...
#> $ latitude : num [1:290(1d)] 78.9 78.9 78.9 78.9 78.9 ...
#> $ Months : num [1:8(1d)] 3 4 5 6 7 8 9 10
#> $ Years : num [1:20(1d)] 2003 2004 2005 2006 2007 ...
#> $ irradianceLevel : num [1:101(1d)] 0.001 0.0011 0.0012 0.00132 0.00145 ...
#> $ depth : num [1:321, 1:290] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
#> $ elevation : num [1:321, 1:290] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
#> $ area : num [1:321, 1:290] 0.00983 0.00983 0.00983 0.00983 0.00983 ...
#> $ AreaOfCoastalZone : num 205
#> $ AreaOfShallowZone : num 106
#> $ site_average_longitude: num 11.8
#> $ site_average_latitude : num 79
#> $ MonthlyPARbottom : num [1:321, 1:290, 1:8, 1:20] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
#> $ ClimPARbottom : num [1:321, 1:290, 1:8] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
#> [list output truncated]
To save the file to your computer (highly recommended):
# All depths (what = "o" ; o for Ocean), as raster
all_bathy <- flget_bathymetry(fjorddata, what = "o", mode = "raster", PLOT = TRUE)
# Coastal zone [0-200m] (what = "c" ; c for Coastal), as raster
coastal_bathy <- flget_bathymetry(fjorddata, what = "c", mode = "raster", PLOT = TRUE)
# Shallow zone [0-50m] (what = "sl" ; s for Shallow, l to add land), as raster
shallow_land <- flget_bathymetry(fjorddata, what = "sl", mode = "raster", PLOT = TRUE)
# Just land; note the difference in colour palette
just_land <- flget_bathymetry(fjorddata, what = "l", mode = "raster", PLOT = TRUE)
# As a data.frame (mode = "df" : longitude, latitude, depth)
sea <- flget_bathymetry(fjorddata, what = "s", mode = "df", PLOT = FALSE)
cz <- flget_bathymetry(fjorddata, what = "c", mode = "df", PLOT = FALSE)
# you may add letter "l" if you want land elevation
sealand <- flget_bathymetry(fjorddata, what = "sl", mode = "df")
# Example of structure
str(sealand)
#> 'data.frame': 57541 obs. of 3 variables:
#> $ longitude: num 11.2 11.2 11.2 11.2 11.2 ...
#> $ latitude : num 79.1 79.1 79.1 79.1 79.1 ...
#> $ depth : num -5.93 -5.71 -7.92 -7.58 -7.17 ...
# PAR0m and PARbottom for July
P07 <- flget_climatology(fjorddata, optics = "PAR0m", period = "Clim", month = 7, PLOT = TRUE)
print(P07)
#> class : RasterLayer
#> dimensions : 290, 321, 93090 (nrow, ncol, ncell)
#> resolution : 0.00462, 0.000883 (x, y)
#> extent : 11.1738, 12.65682, 78.85438, 79.11045 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> source : memory
#> names : PAR0m_Jul
#> values : 13.52273, 32.43196 (min, max)
Pb7 <- flget_climatology(fjorddata, optics = "PARbottom", period = "Clim", month = 7, PLOT = TRUE)
print(Pb7)
#> class : RasterLayer
#> dimensions : 290, 321, 93090 (nrow, ncol, ncell)
#> resolution : 0.00462, 0.000883 (x, y)
#> extent : 11.1738, 12.65682, 78.85438, 79.11045 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> source : memory
#> names : PARbottom_Jul
#> values : 6.354513e-37, 30.41457 (min, max)
# PARbottom Global
PbG <- flget_climatology(fjorddata, optics = "PARbottom", period = "Global", PLOT = TRUE)
print(PbG)
#> class : RasterLayer
#> dimensions : 290, 321, 93090 (nrow, ncol, ncell)
#> resolution : 0.00462, 0.000883 (x, y)
#> extent : 11.1738, 12.65682, 78.85438, 79.11045 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> source : memory
#> names : PARbottom_Global
#> values : 2.293755e-24, 18.12253 (min, max)
# PAR0m, Kpar, and PARbottom for year 2012 as 3 columns data.frame
P02012 <- flget_climatology(fjorddata, optics = "PAR0m", period = "Yearly", year = 2012, mode = "df")
k2012 <- flget_climatology(fjorddata, optics = "Kpar", period = "Yearly", year = 2012, mode = "df")
Pb2012 <- flget_climatology(fjorddata, optics = "PARbottom", period = "Yearly", year = 2012, mode = "df")
head(Pb2012)
#> longitude latitude PARbottom_2012
#> 1 11.17611 79.11 NaN
#> 2 11.18073 79.11 NaN
#> 3 11.18535 79.11 NaN
#> 4 11.18997 79.11 NaN
#> 5 11.19459 79.11 NaN
#> 6 11.19921 79.11 NaN
If you want the data as a data.frame:
# first get pixels area
area <- flget_area(fjorddata, mode = "df")
# Then bind the data frames and remove rows with missing values
PAR_area <- cbind(sea, area[3], P02012[3], k2012[3], Pb2012[3])
PAR_area <- PAR_area[complete.cases(PAR_area),]
head(PAR_area)
#> longitude latitude depth PixArea_km2 PAR0m_2012 Kpar_2012
#> 2575 11.21307 79.07910 -36.889999 0.009637292 12.87865 0.3419367
#> 2586 11.21307 79.08881 -38.180000 0.009628833 16.58163 0.2488136
#> 2587 11.21307 79.08970 -29.215000 0.009628064 14.24307 0.2460494
#> 2588 11.21307 79.09058 -22.024952 0.009627295 14.53227 0.2430139
#> 2893 11.21769 79.10382 -4.611521 0.009615759 13.06282 0.3080032
#> 2894 11.21769 79.10471 -3.893572 0.009614990 13.07713 0.3287133
#> PARbottom_2012
#> 2575 1.744743
#> 2586 10.009634
#> 2587 8.727513
#> 2588 10.029481
#> 2893 1.343848
#> 2894 1.260982
# Years 2003 to 2004 - months July to August
mts <- flget_PARbottomMonthlyTS(fjorddata, month = 7:8, year = 2003:2004, PLOT = TRUE)
print(mts)
#> class : RasterStack
#> dimensions : 290, 321, 93090, 4 (nrow, ncol, ncell, nlayers)
#> resolution : 0.00462, 0.000883 (x, y)
#> extent : 11.1738, 12.65682, 78.85438, 79.11045 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> names : MonthlyPARbottom.2003.07, MonthlyPARbottom.2003.08, MonthlyPARbottom.2004.07, MonthlyPARbottom.2004.08
#> min values : 4.123321e-40, 0.000000e+00, 0.000000e+00, 2.662467e-44
#> max values : 32.26019, 19.93828, 26.65807, 18.68446
# Or as a data.frame
mts_2003 <- flget_PARbottomMonthlyTS(fjorddata, year = 2003, PLOT = FALSE, mode = "df")
head(mts_2003)
#> longitude latitude MonthlyPARbottom.2003.03 MonthlyPARbottom.2003.04
#> 1 11.17611 79.11 NaN NaN
#> 2 11.18073 79.11 NaN NaN
#> 3 11.18535 79.11 NaN NaN
#> 4 11.18997 79.11 NaN NaN
#> 5 11.19459 79.11 NaN NaN
#> 6 11.19921 79.11 NaN NaN
#> MonthlyPARbottom.2003.05 MonthlyPARbottom.2003.06 MonthlyPARbottom.2003.07
#> 1 NaN NaN NaN
#> 2 NaN NaN NaN
#> 3 NaN NaN NaN
#> 4 NaN NaN NaN
#> 5 NaN NaN NaN
#> 6 NaN NaN NaN
#> MonthlyPARbottom.2003.08 MonthlyPARbottom.2003.09 MonthlyPARbottom.2003.10
#> 1 NaN NaN NaN
#> 2 NaN NaN NaN
#> 3 NaN NaN NaN
#> 4 NaN NaN NaN
#> 5 NaN NaN NaN
#> 6 NaN NaN NaN
# One may create their own functions
fG <- flget_Pfunction(fjorddata, type = "coastal", period = "Global", plot = FALSE)
# Then you can use it; for instance :
irradiance_levels <- c(0.1, 1, 10)
fG(irradiance_levels)
#> [1] 17.762922 9.656415 1.905183
# Or load the pre-calculated values as a 2 column data.frame
f2012 <- flget_Pfunction(fjorddata, type = "coastal", period = "Yearly", year = 2012, mode = "df")
str(f2012)
#> 'data.frame': 101 obs. of 2 variables:
#> $ irradianceLevel: num 0.001 0.0011 0.0012 0.00132 0.00145 ...
#> $ Pcoastal_2012 : num 31.2 31 30.7 30.5 30.3 ...
# Plot P-functions
fGlob <- flget_Pfunction(fjorddata, type = "coastal", period = "Global", PLOT = TRUE, lty = 1, col = 1, lwd = 2,
Main = paste(fjord, "coastal P-functions"), ylim = c(0, 50))