Skip to content

Commit 2bc60d5

Browse files
committed
spelling check + minor + bump version 0.7
1 parent c24356a commit 2bc60d5

8 files changed

Lines changed: 27 additions & 35 deletions

File tree

.RDataTmp

-38.8 MB
Binary file not shown.

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Package: GeoPressureTemplate
22
Title: These are the Goal of my Study (One Line, Title Case)
3-
Version: 0.6
3+
URL: https://github.com/Rafnuss/GeoPressureTemplate
4+
Description: More detailed description of my research objective with my dataset available (one paragraph).
45
Authors@R:
56
person("Raphaël", "Nussbaumer", , "rafnuss@gmail.com", role = c("aut", "cre"),
67
comment = c(ORCID = "0000-0002-8185-1020"))
7-
Description: More detailed description of my research objective with my dataset available (one paragraph).
88
License: GPL (>= 3)
9-
URL: https://github.com/Rafnuss/GeoPressureTemplate
9+
Version: 0.7
1010
Depends:
1111
R (>= 3.5.0)
1212
Imports:
@@ -35,4 +35,4 @@ VignetteBuilder:
3535
knitr
3636
Encoding: UTF-8
3737
Roxygen: list(markdown = TRUE)
38-
RoxygenNote: 7.1.2
38+
RoxygenNote: 7.2.1

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GeoPressureTemplate
22

3-
Analysing geolocator data with pressure is full of potential, but the the path is long and the journey can be challenging. `GeoPressureTemplate` is a [Github repository template](https://docs.github.com/articles/creating-a-repository-from-a-template/) for a startup R project to make that journey easier.
3+
Analyzing geolocator data with pressure is full of potential, but the the path is long and the journey can be challenging. `GeoPressureTemplate` is a [Github repository template](https://docs.github.com/articles/creating-a-repository-from-a-template/) for a start-up R project to make that journey easier.
44

55
## What is this template and who is it for? :mag_right:
66

@@ -11,7 +11,7 @@ In essence, it contains the code from all the [GeoPressureManual](https://raphae
1111
## What do you need to use this template? :computer:
1212

1313
- Geolocator data containing pressure, light and activity data.
14-
- Have read the [GeoPressureManual](https://raphaelnussbaumer.com/GeoPressureManual) (:warning: You should be familar with the **full process involved** before starting with your own project)
14+
- Have read the [GeoPressureManual](https://raphaelnussbaumer.com/GeoPressureManual) (:warning: You should be familiar with the **full process involved** before starting with your own project)
1515
- Basic R experience (I'm using the [tidyverse](https://www.tidyverse.org/) syntax here).
1616
- A [Github account](https://github.com/signup).
1717

@@ -20,7 +20,7 @@ In essence, it contains the code from all the [GeoPressureManual](https://raphae
2020

2121
Following the recommendations of [rrrpkg](https://github.com/ropensci/rrrpkg), the project contains:
2222
1. Standard description files at the root (`DESCRIPTION`, `.Rproj`, `README.md`, `LICENCES`,...).
23-
2. `data/` folder containing the raw geolocator data, the pressure and light labelled files and the data generated with the code from `analysis/`. Note that you could instead keep the geolocator and labelization files seperately in a `raw-data/` folder, following `usethis()` standard.
23+
2. `data/` folder containing the raw geolocator data, the pressure and light labelled files and the data generated with the code from `analysis/`. Note that you could instead keep the geolocator and labelization files separately in a `raw-data/` folder, following `usethis()` standard.
2424
3. `analysis/` contains all the `.R` code used for your project.
2525
4. `report/` reads the data generated and produces sharable results (figures, html page, manuscript, etc...).
2626
<details>
@@ -113,7 +113,7 @@ devtools::install()
113113

114114
## Start analysing the data :chart_with_upwards_trend:
115115

116-
Now that you are set-up, it's time to start the serious work. :grimacing: Follow the order of the `.R` code in the `analysis/` folder. They follow the same order as the GeoPressureManual (but with different numerotation to be able to analyse multiple track at the same time).
116+
Now that you are set-up, it's time to start the serious work. :grimacing: Follow the order of the `.R` code in the `analysis/` folder. They follow the same order as the GeoPressureManual (but with different numeration to be able to analyse multiple track at the same time).
117117

118118
| GeoPressureTemplate analysis | GeoPressureManual |
119119
|---|---|
@@ -126,7 +126,7 @@ Now that you are set-up, it's time to start the serious work. :grimacing: Follow
126126
| `5-3-wind-graph_analyse.R` | [5. Wind graph - Outputs](https://raphaelnussbaumer.com/GeoPressureManual/wind-graph.html#compute-the-transition-probability-1) |
127127
| `99-combined.R` | Run all steps for multiple tracks. |
128128

129-
In order to keep your code clean, we isolate all the key paramters used in all functions in the `gpr_setting.xlsx` spreadsheet located in the `data/` folder. You can adjust these parameters seperatly for each track or add any informations on your individuals bird that might be useful for your analysis.
129+
In order to keep your code clean, we isolate all the key parameters used in all functions in the `gpr_setting.xlsx` spreadsheet located in the `data/` folder. You can adjust these parameters separately for each track or add any information on your individuals bird that might be useful for your analysis.
130130

131131
<details>
132132
<summary>Click to see explanations on the parameters of <code>gpr_setting.xlsx</code></summary>
@@ -145,12 +145,12 @@ In order to keep your code clean, we isolate all the key paramters used in all f
145145
|map_max_sample |300 |see [`geopressure_map()`](https://raphaelnussbaumer.com/GeoPressureR/reference/geopressure_map.html) |
146146
|map_margin |30 |see [`geopressure_map()`](https://raphaelnussbaumer.com/GeoPressureR/reference/geopressure_map.html) |
147147
|prob_map_s |1 |see [`geopressure_prob_map()`](https://raphaelnussbaumer.com/GeoPressureR/reference/geopressure_prob_map.html) |
148-
|prob_map_s_calib | |Alternative value for `prob_map_s` for calibration site. Useful for species living in moutain only during calibration. |
148+
|prob_map_s_calib | |Alternative value for `prob_map_s` for calibration site. Useful for species living in mountain only during calibration. |
149149
|prob_map_thr |0.9 |see [`geopressure_prob_map()`](https://raphaelnussbaumer.com/GeoPressureR/reference/geopressure_prob_map.html) |
150150
|shift_k |0 |see [`find_twilights()`](https://raphaelnussbaumer.com/GeoPressureR/reference/find_twilights.html) |
151151
|kernel_adjust |1.4 |see [Calibration of light data](https://raphaelnussbaumer.com/GeoPressureManual/light-map.html#calibrate-zenith-angles) |
152152
|calib_lon |17.05 |Longitude of the calibration site. |
153-
|calib_lat |48.9 |Latitude of the calibrataion site. |
153+
|calib_lat |48.9 |Latitude of the calibration site. |
154154
|calib_1_start |2017-06-20 |Start date of the first calibration period. |
155155
|calib_1_end |2017-08-05 |End date of the first calibration period. |
156156
|calib_2_start | |Start date of the second calibration period. |
@@ -162,7 +162,6 @@ In order to keep your code clean, we isolate all the key paramters used in all f
162162
|thr_gs |120 |see [`graph_create()`](https://raphaelnussbaumer.com/GeoPressureR/reference/graph_create.html) |
163163
|thr_as |100 |see [`graph_add_wind()`](https://raphaelnussbaumer.com/GeoPressureR/reference/graph_add_wind.html) |
164164
|low_speed_fix |15 |see [`flight_prob()`](https://raphaelnussbaumer.com/GeoPressureR/reference/flight_prob.html) |
165-
|ringNo | |Ring number if available (not used). |
166165
|scientific_name |Acrocephalus arundinaceus|see [`flight_bird()`](https://raphaelnussbaumer.com/GeoPressureR/reference/flight_bird.html) |
167166
|common_name |Great Reed Warbler | |
168167
|mass | |see [`flight_bird()`](https://raphaelnussbaumer.com/GeoPressureR/reference/flight_bird.html) |
@@ -182,12 +181,12 @@ The main idea is to produce report templates (`_name_of_the_report_template.Rmd`
182181
3. Look at `make_reports.R` script to see how you can generate the HTML for multiple tracks and reports templates at once.
183182
4. Edit `index.Rmd` as you wishes
184183
5. Run `{r} render_site('./reports')` (also provided at the bottom of `make_reports.R`) to generate the full website in `docs/`.
185-
6. Push your changes on Gihub and create your [Github Page](https://rstudio.github.io/distill/publish_website.html#github-pages).
184+
6. Push your changes on Github and create your [Github Page](https://rstudio.github.io/distill/publish_website.html#github-pages).
186185

187186

188187
## Advanced options :link:
189188

190189
- Generate your DOI with [Zenodo](https://docs.github.com/en/repositories/archiving-a-github-repository/referencing-and-citing-content) (e.g., https://zenodo.org/record/6720386)
191190
- Generate a citation file with [`usethis::use_citation`](https://usethis.r-lib.org/reference/use_citation.html) and [`cffr`](https://github.com/ropensci/cffr).
192-
- Use [`renv`](https://rstudio.github.io/renv/index.html) to make your work reproducable.
191+
- Use [`renv`](https://rstudio.github.io/renv/index.html) to make your work reproducible.
193192
- Export your data on [Movebank](https://www.movebank.org/cms/movebank-content/import-custom-tabular-data).

analysis/1-pressure.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ if (debug) {
108108

109109

110110
# Filter stationary period based on the number of pressure datapoint available
111-
thr_dur <- gpr$thr_dur # 24*4 # duration in hour. Decrease this value down to gpr$thr_dur
111+
thr_dur <- gpr$thr_dur # duration in hour. Decrease this value zero if possible
112112
res <- as.numeric(difftime(pam$pressure$date[2], pam$pressure$date[1], units = "hours"))
113113
sta_id_keep <- pam$pressure %>%
114114
filter(!isoutlier & sta_id > 0) %>%
@@ -122,7 +122,6 @@ pam_short$pressure <- pam_short$pressure %>%
122122
mutate(sta_id = ifelse(sta_id %in% sta_id_keep, sta_id, NA))
123123

124124
# Query pressure map
125-
# We overwrite the setting parameter for resolution to make query faster at first
126125
pressure_maps <- geopressure_map(pam_short$pressure,
127126
extent = c(gpr$extent_N, gpr$extent_W, gpr$extent_S, gpr$extent_E),
128127
scale = gpr$map_scale,

analysis/3-static.R

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ gdl <- "18LX"
1818
load(paste0("data/1_pressure/", gdl, "_pressure_prob.Rdata"))
1919
load(paste0("data/2_light/", gdl, "_light_prob.Rdata"))
2020

21-
# Defint the threashold of the stationay period to consider
21+
# Define the threshold of the stationary period to consider
2222
thr_sta_dur <- gpr$thr_dur # in hours
2323

2424
sta_pres <- unlist(lapply(pressure_prob, function(x) raster::metadata(x)$sta_id))
@@ -52,11 +52,6 @@ static_prob <- mapply(function(light, pressure, flight) {
5252
# define static prob as the product of light and pressure prob
5353
static_prob <- light * pressure
5454

55-
# replace na by zero
56-
# tmp <- values(static_prob)
57-
# tmp[is.na(tmp)] <- 0
58-
# values(static_prob) <- tmp
59-
6055
# define metadata
6156
metadata(static_prob) <- metadata(pressure)
6257
metadata(static_prob)$flight <- flight
@@ -84,7 +79,7 @@ tmp[!is.na(tmp)] <- 0
8479
tmp[lat_calib_id, lon_calib_id] <- 1
8580
values(static_prob[[1]]) <- tmp
8681

87-
if (!is.na(gpr$calib_2_start) & abs(difftime(gpr$calib_2_end, gpr$crop_end, units = "days"))<3) {
82+
if (!is.na(gpr$calib_2_start) & abs(difftime(gpr$calib_2_end, gpr$crop_end, units = "days")) < 3) {
8883
if (!is.na(gpr$calib_2_lat)) {
8984
lon_calib_id <- which.min(abs(gpr$calib_2_lon - lon))
9085
lat_calib_id <- which.min(abs(gpr$calib_2_lat - lat))
@@ -123,7 +118,7 @@ if (debug) {
123118
# impact your code
124119
pam_diff <- pam
125120
pam_diff$pressure <- pam_diff$pressure %>%
126-
left_join(path_modified_ts_bind %>% dplyr::select(c("date","pressure0")), by="date") %>%
121+
left_join(path_modified_ts_bind %>% dplyr::select(c("date", "pressure0")), by = "date") %>%
127122
rename(obs_ref = pressure0)
128123

129124
trainset_write(pam_diff, "data/1_pressure/labels/", filename = paste0(pam$id, "_act_pres"))
@@ -135,7 +130,8 @@ if (debug) {
135130
twl_path <- left_join(twl, path_modified) %>%
136131
mutate(
137132
twilight = twilight(twilight,
138-
lon = lon, lat = lat, rise = rise, zenith = 96)
133+
lon = lon, lat = lat, rise = rise, zenith = 96
134+
)
139135
) %>%
140136
filter(!is.na(twilight))
141137

@@ -145,14 +141,14 @@ if (debug) {
145141
series = ifelse(twl$rise, "Rise", "Set"),
146142
timestamp = strftime(twl$twilight, "%Y-%m-%dT00:00:00Z", tz = "UTC"),
147143
value = (as.numeric(format(twl$twilight, "%H")) * 60 + as.numeric(format(twl$twilight, "%M"))
148-
+ gpr$shift_k / 60 + 60 * 12) %% (60 * 24),
144+
+ gpr$shift_k / 60 + 60 * 12) %% (60 * 24),
149145
label = ifelse(is.na(twl$delete), "", ifelse(twl$delete, "Delete", ""))
150146
),
151147
data.frame(
152148
series = ifelse(twl_path$rise, "Set_ref", "Rise_ref"),
153149
timestamp = strftime(twl_path$twilight, "%Y-%m-%dT00:00:00Z", tz = "UTC"),
154150
value = (as.numeric(format(twl_path$twilight, "%H")) * 60 + as.numeric(format(twl_path$twilight, "%M"))
155-
+ gpr$shift_k / 60 + 60 * 12) %% (60 * 24),
151+
+ gpr$shift_k / 60 + 60 * 12) %% (60 * 24),
156152
label = ""
157153
)
158154
),

analysis/5-1-wind-graph_download.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1+
library(GeoPressureR)
12
library(ecmwfr)
23

34
# Define which track to work with
45
gdl <- "18LX"
56

67
# Load
8+
load(paste0("data/1_pressure/", gdl, "_pressure_prob.Rdata"))
79
load(paste0("data/3_static/", gdl, "_static_prob.Rdata"))
810

911
# Set credential
10-
Sys.setenv( cds_key="Insert_your_CDS_API_KEY_here")
11-
Sys.setenv( cds_user="Insert_your_CDS_UID_here")
12+
Sys.setenv(cds_key = "Insert_your_CDS_API_KEY_here")
13+
Sys.setenv(cds_user = "Insert_your_CDS_UID_here")
1214

1315
# You can see them with
1416
# usethis::edit_r_environ()
1517
# cds_key <- Sys.getenv("cds_key")
1618
# cds_user <- Sys.getenv("cds_user")
1719

18-
graph_download_wind(pam,
19-
area = static_prob,
20-
# cds_key="Insert_your_CDS_API_KEY_here"
21-
# cds_user="Insert_your_CDS_UID_here"
22-
)
20+
graph_download_wind(pam, area = static_prob)
2321

2422
# Check request at https://cds.climate.copernicus.eu/cdsapp#!/yourrequests

analysis/99-combined.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dir.create("data/5_wind_graph", showWarnings = FALSE)
3535
for (i in seq(1, length(gdl_list))) {
3636
gdl <- gdl_list[i]
3737
source("analysis/5-1-wind-graph_download.R")
38-
# Use job to avoid blocking your console.
38+
# You can also make this request with a background job in Rstudio (https://solutions.rstudio.com/r/jobs/)
3939
# rstudioapi::jobRunScript("analysis/5-1-wind-graph_download.R",
4040
# name = paste0("wind_graph_download_", gdl),
4141
# workingDir = ".",

data/gpr_settings.xlsx

-134 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)