Last updated: 2024-09-19

Checks: 7 0

Knit directory: oae_ccs_roms/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20240919) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version c9f35a0. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Unstaged changes:
    Modified:   code/Workflowr_project_managment.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/read_data.Rmd) and HTML (docs/read_data.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd c9f35a0 vgfroh 2024-09-19 first map
html 16549e7 vgfroh 2024-09-19 Build site.
Rmd 210c100 vgfroh 2024-09-19 setup project
html 2e8d326 jens-daniel-mueller 2024-09-19 Build site.
html 7591977 jens-daniel-mueller 2024-09-19 Build site.
Rmd a97392c jens-daniel-mueller 2024-09-19 setup project

Read this

this is the script to open the data

# Testing file
# /work/loher/ROMS/Alk_enh_formatted_2024_08 ##regridded v2
# /net/sea/work/loher/ROMS/Pactcs30_Alk_enhanced_2024_08 ## original grids v2

# setting main path to read files
# path_ROMSv2_results <- 
#   "/net/sea/work/loher/ROMS/Pactcs30_Alk_enhanced_2024_08/" 

library(ncdf4)
library(tidync)
library(stars)
Loading required package: abind
Loading required package: sf
Linking to GEOS 3.11.1, GDAL 3.4.1, PROJ 7.2.1; sf_use_s2() is TRUE
WARNING: different compile-time and runtime versions for GEOS found:
Linked against: 3.11.1-CAPI-1.17.1 compiled against: 3.9.1-CAPI-1.14.2
It is probably a good idea to reinstall sf, and maybe rgeos and rgdal too
library(tidyverse)
── Attaching packages
───────────────────────────────────────
tidyverse 1.3.2 ──
✔ ggplot2 3.4.4     ✔ purrr   1.0.2
✔ tibble  3.2.1     ✔ dplyr   1.1.3
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
# #reading/opening a specific nc file
# nc <- nc_open(paste0(path_ROMSv2_results,
#                      "Pactcs30_Alk_enhanced_ColumbiaRiver_1x/avg/ColumbiaRiver_1x_2010_monthly.nc"))
# 
# print(nc)

# #loading nc file into tidync
# columbia1x_interior <-
#   tidync(paste0(path_ROMSv2_results,
#                 "Pactcs30_Alk_enhanced_ColumbiaRiver_1x/avg/ColumbiaRiver_1x_2010_monthly.nc"))
# 
# # filtering nc to a subset of dimensions, then producing a table of certain
# # variables within the subset
# sub_columbia1x_interior <- columbia1x_interior %>%
#   hyper_filter(s_rho = s_rho <= 100) %>% 
#   hyper_tibble(select_var = c("Alk", "DIC"),
#                force = TRUE)
# 
# #read in ALK and DIC info from the nc file
# testtable <- read_ncdf(paste0(
#   path_ROMSv2_results,"Pactcs30_Alk_enhanced_ColumbiaRiver_1x/avg/ColumbiaRiver_1x_2010_monthly.nc"),
#   var = c("Alk", "DIC"), make_units = FALSE)
# # compile into a table
# testtable <- testtable %>% as_tibble()
# # extract the year and month from the time stamp
# testtable <- testtable %>% mutate(year = year(time), month = month(time))
# 
# ######
#For the regridded standard files:
path_ROMSv2RG_results <- 
 "/net/sea/work/loher/ROMS/Alk_enh_formatted_2024_08/"

#reading/opening a specific nc file
nc <- nc_open(paste0(path_ROMSv2RG_results,
                     "ColumbiaRiver/ColumbiaRiver_2010-2015_1x.nc"))

print(nc)
File /net/sea/work/loher/ROMS/Alk_enh_formatted_2024_08/ColumbiaRiver/ColumbiaRiver_2010-2015_1x.nc (NC_FORMAT_NETCDF4):

     9 variables (excluding dimension variables):
        float Alk[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged Alkalinity
            units: mMol m-3
            missing_value: NaN
            _FillValue: NaN
        float DIC[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged Dissolved inorganic carbon
            units: mMol C m-3
            missing_value: NaN
            _FillValue: NaN
        float PO4[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged Phosphate
            units: mMol P m-3
            missing_value: NaN
            _FillValue: NaN
        float SiO3[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged Silicate
            units: mMol Si m-3
            missing_value: NaN
            _FillValue: NaN
        float salt[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged salinity
            units: PSU
            missing_value: NaN
            _FillValue: NaN
        float temp[lon,lat,depth,time]   (Chunking: [96,88,1,1])  
            long_name: averaged potential temperature
            units: Celsius
            missing_value: NaN
            _FillValue: NaN
        float FG_CO2[lon,lat,time]   (Chunking: [96,88,1])  
            long_name: averaged Air-sea flux of CO2
            units: mmol/m2/s
            missing_value: NaN
            _FillValue: NaN
        float PCO2OC[lon,lat,time]   (Chunking: [96,88,1])  
            long_name: averaged PCO2OC
            units: not looked up yet
            missing_value: NaN
            _FillValue: NaN
        float pCO2air[lon,lat,time]   (Chunking: [96,88,1])  
            long_name: averaged Atmospheric pCO2
            units: ppm
            missing_value: NaN
            _FillValue: NaN

     4 dimensions:
        time  Size:1096   *** is unlimited *** 
            standard_name: time
            calendar: 365_day
            axis: T
            long_name: Averaged time since 2010-01-01
            units: days since 2010-01-01
        lon  Size:96 
            standard_name: longitude
            long_name: longitude
            units: degrees_east
            axis: X
        lat  Size:88 
            standard_name: latitude
            long_name: latitude
            units: degrees_north
            axis: Y
        depth  Size:16 
            axis: Z
            long_name: depth
            units: m
            remark: positive down

    5 global attributes:
        CDI: Climate Data Interface version 2.2.1 (https://mpimet.mpg.de/cdi)
        Conventions: CF-1.6
        history: Tue Aug 20 20:38:27 2024: cdo --history -s -P 12 -f nc4 -selvar,Alk,DIC,PO4,salt,SiO3,temp -remapbil,/net/sea/work/loher/ROMS/Alk_enh_formatted_2024_08/griddes_ColumbiaRiver /nfs/sea/work/loher/ROMS/Pactcs30_Alk_enhanced_2024_08/Pactcs30_Alk_enhanced_ColumbiaRiver_1x/avg/z_pactcs30_2010-2015_avg.00000.nc /net/sea/work/loher/ROMS/Alk_enh_formatted_2024_08/ColumbiaRiver/pactcs30_2010-2015_avg.00000_1x.nc
        CDO: Climate Data Operators version 2.2.0 (https://mpimet.mpg.de/cdo)
        cdo_openmp_thread_number: 12
nc <- read_ncdf(paste0(path_ROMSv2RG_results,
                     "ColumbiaRiver/ColumbiaRiver_2010-2015_1x.nc"), 
          var = "FG_CO2")
Will return stars object with 9259008 cells.
No projection information found in nc file. 
 Coordinate variable units found to be degrees, 
 assuming WGS84 Lat/Lon.
nc <- nc %>% 
  slice(time, 1
      ) 
  ggplot() + 
  geom_stars(data = nc)

# 
# #loading nc file into tidync
# columbia1x_regrid <-
#   tidync(paste0(path_ROMSv2RG_results,
#                 "ColumbiaRiver/pactcs30_2010-2015_avg.01092_1x.nc"))
# 
# # filtering nc to a subset of dimensions, then producing a table of certain
# # variables within the subset ie only top depth on the last day, Alk
# alk_columbia1x_regrid <- columbia1x_regrid %>%
#   hyper_filter(depth = depth <= 0, time = index == 16
#                ) %>%
#   hyper_tibble(select_var = c("Alk"),
#                force = TRUE)
# #plotting basic on map
# alk_C_sf <- st_as_sf(alk_columbia1x_regrid, coords = c("lon", "lat"), crs = 4326)
# ggplot(data = alk_C_sf) + geom_sf(aes(color = Alk)) + theme_minimal() +
#   labs(title = "Columbia River Final Alkalinity", 
#        x = "Longitude", y = "Latitude")
# 
# #repeat for DIC
# dic_columbia1x_regrid <- columbia1x_regrid %>%
#   hyper_filter(depth = depth <= 0, time = index == 16
#   ) %>%
#   hyper_tibble(select_var = c("DIC"),
#                force = TRUE)
# dic_C_sf <- st_as_sf(dic_columbia1x_regrid, coords = c("lon", "lat"), crs = 4326)
# ggplot(data = dic_C_sf) + geom_sf(aes(color = DIC)) + theme_minimal() +
#   labs(title = "Columbia River Final DIC", 
#        x = "Longitude", y = "Latitude")
# 
# 
# 
# 
# ## This section: what does it do/what is the point
# #read in ALK and DIC info from the nc file
# testtable <- read_ncdf(paste0(
#   path_ROMSv2RG_results,"ColumbiaRiver/pactcs30_2010-2015_avg.01092_1x.nc"),
#   var = c("Alk"), make_units = FALSE)
# # compile into a table
# testtable <- testtable %>% as_tibble()
# # extract the year and month from the time stamp
# testtable <- testtable %>% mutate(year = year(time), month = month(time))

vhjgvj


sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.5

Matrix products: default
BLAS:   /usr/local/R-4.2.2/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.2.2/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.5.2   stringr_1.5.0   dplyr_1.1.3     purrr_1.0.2    
 [5] readr_2.1.3     tidyr_1.3.0     tibble_3.2.1    ggplot2_3.4.4  
 [9] tidyverse_1.3.2 stars_0.6-0     sf_1.0-9        abind_1.4-5    
[13] tidync_0.4.0    ncdf4_1.19      workflowr_1.7.0

loaded via a namespace (and not attached):
 [1] fs_1.5.2            lubridate_1.9.0     httr_1.4.4         
 [4] rprojroot_2.0.3     tools_4.2.2         backports_1.4.1    
 [7] bslib_0.4.1         utf8_1.2.2          R6_2.5.1           
[10] KernSmooth_2.23-20  DBI_1.1.3           colorspace_2.0-3   
[13] withr_2.5.0         tidyselect_1.2.0    processx_3.8.0     
[16] compiler_4.2.2      git2r_0.30.1        cli_3.6.1          
[19] rvest_1.0.3         RNetCDF_2.6-1       xml2_1.3.3         
[22] labeling_0.4.2      sass_0.4.4          scales_1.2.1       
[25] classInt_0.4-8      callr_3.7.3         proxy_0.4-27       
[28] digest_0.6.30       rmarkdown_2.18      pkgconfig_2.0.3    
[31] htmltools_0.5.3     highr_0.9           dbplyr_2.2.1       
[34] fastmap_1.1.0       rlang_1.1.1         readxl_1.4.1       
[37] rstudioapi_0.15.0   PCICt_0.5-4.3       jquerylib_0.1.4    
[40] generics_0.1.3      farver_2.1.1        jsonlite_1.8.3     
[43] googlesheets4_1.0.1 magrittr_2.0.3      ncmeta_0.3.5       
[46] Rcpp_1.0.10         munsell_0.5.0       fansi_1.0.3        
[49] lifecycle_1.0.3     stringi_1.7.8       whisker_0.4        
[52] yaml_2.3.6          grid_4.2.2          parallel_4.2.2     
[55] promises_1.2.0.1    crayon_1.5.2        haven_2.5.1        
[58] hms_1.1.2           knitr_1.41          ps_1.7.2           
[61] pillar_1.9.0        reprex_2.0.2        glue_1.6.2         
[64] evaluate_0.18       getPass_0.2-2       modelr_0.1.10      
[67] vctrs_0.6.4         tzdb_0.3.0          httpuv_1.6.6       
[70] cellranger_1.1.0    gtable_0.3.1        assertthat_0.2.1   
[73] cachem_1.0.6        xfun_0.35           lwgeom_0.2-10      
[76] broom_1.0.5         e1071_1.7-12        later_1.3.0        
[79] class_7.3-20        googledrive_2.0.0   gargle_1.2.1       
[82] units_0.8-0         timechange_0.1.1    ellipsis_0.3.2