generated from WHOIGit/minimal-edi-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzooplankton-transect-inventory-edi-package.Rmd
97 lines (76 loc) · 4.21 KB
/
zooplankton-transect-inventory-edi-package.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
title: "Zooplankton sample inventory package based on Minimal EDI package generated using EMLassemblyline and ediutilities"
author: "Joe Futrelle, Stace Beaulieu, Kate Morkeski"
date: "r Sys.Date()"
output: html_notebook
---
Libraries used
```{r}
# two of the required packages are installed from GitHub
# library(remotes)
# remotes::install_github("EDIorg/EMLassemblyline")
# remotes::install_github("WHOIGit/ediutilities")
library(EMLassemblyline)
library(ediutilities)
library(here)
library(lubridate)
library(dplyr)
```
Read data tables
```{r}
inventory <- read.csv(here('nes-lter-zooplankton-transect-inventory-v2.csv'))
# inventory is ready to submit as-is
```
```{r}
meta <- read.csv(here('nes-lter-zooplankton-tow-metadata-v2-input.csv'))
meta$datetime_UTC_start <- dmy_hms(paste(meta$date_start_UTC, meta$time_start_UTC))
meta$datetime_UTC_end <- dmy_hms(paste(meta$date_end_UTC, meta$time_end_UTC))
meta <- meta |>
relocate(datetime_UTC_start, .after = sample_name) |>
relocate(datetime_UTC_end, .before = lat_start) |>
select(-date_start_UTC, -time_start_UTC, -date_end_UTC, -time_end_UTC) |>
rename(event = sample_name) |>
rename(decimalLatitudeStart = lat_start) |>
rename(decimalLongitudeStart = lon_start) |>
rename(decimalLatitudeEnd= lat_end) |>
rename(decimalLongitudeEnd = lon_end) |>
rename(net_max_depth = net_max_depth_m) |>
rename(max_wire_out = max_wire_out_m) |>
rename(wire_rate_out = wire_rate_out_m_min) |>
rename(wire_rate_in = wire_rate_in_m_min) |>
rename(vol_filtered_335 = vol_filtered_m3_335)|>
rename(vol_filtered_150 = vol_filtered_m3_150)
write.csv(meta, 'nes-lter-zooplankton-tow-metadata-v2.csv', row.names=FALSE)
```
Read the Excel metadata template and generate text templates used by
EMLassemblyline
```{r}
# Alex provided metadata in csv files, so use below write.table steps instead of excel_to_template
#excel_to_template(here('NES-LTER_Transect_Sample_Inventory'), 'nes-lter-zooplankton', rights='CC0', file_type=".md")
write.table(read.csv("nes-lter-zooplankton-tow-metadata-v2-column-headers.csv", sep=","), "attributes_nes-lter-zooplankton-tow-metadata-v2.txt", quote = FALSE, na="", sep="\t", row.names = FALSE)
write.table(read.csv("nes-lter-zooplankton-transect-inventory-v2-column-headers.csv", sep=","), "attributes_nes-lter-zooplankton-transect-inventory-v2.txt", quote = FALSE, na="", sep="\t", row.names = FALSE)
write.table(read.csv("nes-lter-zooplankton-transect-inventory-v2-categoricalVariablesHeaders.csv", sep=","), "catvars_nes-lter-zooplankton-transect-inventory-v2.txt", quote = FALSE, na="", sep="\t", row.names = FALSE)
write.table(read.csv("nes-lter-zooplankton-tow-metadata-v2-categoricalVariablesHeaders.csv", sep=","), "catvars_nes-lter-zooplankton-tow-metadata-v2.txt", quote = FALSE, na="", sep="\t", row.names = FALSE)
write.table(read.csv("personnel.csv", sep=","), "personnel.txt", quote = FALSE, na="", sep="\t", row.names = FALSE)
```
Generate the package and insert the parent project node into the resulting EML
```{r}
temp_coverage <- temporal_coverage(meta$datetime_UTC_start)
# use package ID assigned in vortex README
pkg_id <- 'knb-lter-nes.24.2'
make_eml(path = here(),
dataset.title ='Zooplankton sample inventory for Northeast U.S. Shelf Long Term Ecological Research (NES-LTER) Transect cruises, ongoing since 2017',
data.table = c('nes-lter-zooplankton-transect-inventory-v2.csv', 'nes-lter-zooplankton-tow-metadata-v2.csv'),
#data.table = c('inventory.csv', 'meta.csv'),
data.table.description = c('Zooplankton sample inventory for NES-LTER Transect cruises', 'Zooplankton tow metadata for NES-LTER Transect cruises'),
data.table.name = c('nes-lter-zooplankton-transect-inventory', 'nes-lter-zooplankton-tow-metadata'),
data.table.quote.character = c('"','"'),
temporal.coverage = temp_coverage,
geographic.description = "NES-LTER Transect",
geographic.coordinates = geographic_coordinates(meta$decimalLatitudeStart, meta$decimalLongitudeStart), # Not including end-of-tow coordinates
maintenance.description = "ongoing",
user.id = "NES",
user.domain = "LTER",
package.id = pkg_id)
project_insert(pkg_id,'parent_project_NESI-II_RAPID_OOI.txt')
```