Skip to content

Commit

Permalink
Merge pull request #16 from pepijn-devries/work-in-progress
Browse files Browse the repository at this point in the history
Fix for migrated server
  • Loading branch information
pepijn-devries authored Nov 8, 2023
2 parents 6450c00 + f2888cb commit 44ab4ee
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: CopernicusMarine
Type: Package
Title: Search Download and Handle Data from Copernicus Marine Service Information
Version: 0.0.9
Date: 2023-08-21
Version: 0.1.0
Date: 2023-11-08
Authors@R: c(person("Pepijn", "de Vries", role = c("aut", "cre", "dtc"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-7961-6646")))
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CopernicusMarine v0.0.7 (Release date: 2023-02-10)
CopernicusMarine v0.0.9 (Release date: 2023-08-21)
-------------

* Updates in order to comply with latest CRAN
policies
* Bug fix in log-in routine

CopernicusMarine v0.0.6 (Release date: 2023-01-23)
Expand Down
5 changes: 4 additions & 1 deletion R/copernicus_download_motu.r
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ copernicus_download_motu <- function(
message(crayon::white("Preparing download..."))

product_services <- copernicus_product_services(product) %>% dplyr::filter(layer == {{layer}})


if (nrow(product_services) == 0)
stop("No services available, please check if you specified the 'product' and 'layer' name correctly, and whether the layer has a MOTU service.")

if (!"motu" %in% names(product_services) || is.na(product_services$motu))
return(invisible(FALSE))

Expand Down
2 changes: 1 addition & 1 deletion R/copernicus_product_details.r
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ copernicus_product_details <- function(product, layer, variable) {
if (missing(layer) && !missing(variable)) stop("Variable specified without layer.")
if (missing(product)) product <- ""
result <- .try_online({
sprintf("https://cmems-be.lobelia.earth/api/dataset/%s?variant=detailed-v2", product) %>%
sprintf("https://data-be-prd.marine.copernicus.eu/api/dataset/%s?variant=detailed-v2", product) %>%
httr::GET()
}, "Copernicus")
if (is.null(result)) return(NULL)
Expand Down
2 changes: 1 addition & 1 deletion R/copernicus_product_metadata.r
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
copernicus_product_metadata <- function(product) {
meta_data <-
.try_online({
sprintf("https://cmems-be.lobelia.earth/api/metadata/%s", product) %>%
sprintf("https://data-be-prd.marine.copernicus.eu/api/metadata/%s", product) %>%
httr::GET()
}, "Copernicus")
if (is.null(meta_data)) return(NULL)
Expand Down
2 changes: 1 addition & 1 deletion R/copernicus_products_list.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ copernicus_products_list <- function(..., info_type = c("list", "meta")) {
payload[names(payload_mod)] <- payload_mod
result <- .try_online({
httr::POST(
"https://cmems-be.lobelia.earth/api/datasets",
"https://data-be-prd.marine.copernicus.eu/api/datasets",
body = payload,
encode = "json")
}, "Copernicus")
Expand Down
3 changes: 3 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ library(CopernicusMarine)
```

> `{CopernicusMarine}` Easily access information from <https://data.marine.copernicus.eu>
[![version](https://www.r-pkg.org/badges/version/CopernicusMarine)](https://CRAN.R-project.org/package=CopernicusMarine)
![cranlogs](https://cranlogs.r-pkg.org/badges/CopernicusMarine)


## Overview

Expand Down
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

> `{CopernicusMarine}` Easily access information from
> <https://data.marine.copernicus.eu>
> [![version](https://www.r-pkg.org/badges/version/CopernicusMarine)](https://CRAN.R-project.org/package=CopernicusMarine)
> ![cranlogs](https://cranlogs.r-pkg.org/badges/CopernicusMarine)
## Overview

Expand Down Expand Up @@ -61,8 +63,8 @@ Subsetting data using MOTU server
</h3>

The code below assumes that you have registered your account details
using `options(CopernicusMarine_uid = "my_user_name")` and
`options(CopernicusMarine_pwd = "my_password")`. If you are comfortable
using `option(CopernicusMarine_uid = "my_user_name")` and
`option(CopernicusMarine_pwd = "my_password")`. If you are comfortable
that it is secure enough, you can also store these options in your
`.Rprofile` such that they will be loaded each session. Otherwise, you
can also provide your account details as arguments to the functions.
Expand Down Expand Up @@ -112,20 +114,20 @@ your product. First you can list files available for a specific product:
``` r
cop_ftp_files <- copernicus_ftp_list("GLOBAL_ANALYSISFORECAST_PHY_001_024", "cmems_mod_glo_phy-cur_anfc_0.083deg_P1D-m")
cop_ftp_files
#> # A tibble: 818 x 8
#> # A tibble: 1,112 x 8
#> flags len protocol size month day time url
#> <chr> <int> <chr> <int> <chr> <int> <chr> <chr>
#> 1 -rw-rw-r-- 1 ftp 1937968861 Oct 14 06:10 ftp://nrt.cmems-du.eu~
#> 2 -rw-rw-r-- 1 ftp 1937978851 Oct 14 06:08 ftp://nrt.cmems-du.eu~
#> 3 -rw-rw-r-- 1 ftp 1937888467 Oct 14 06:07 ftp://nrt.cmems-du.eu~
#> 4 -rw-rw-r-- 1 ftp 1938380754 Oct 14 06:06 ftp://nrt.cmems-du.eu~
#> 5 -rw-rw-r-- 1 ftp 1938177028 Oct 14 06:09 ftp://nrt.cmems-du.eu~
#> 6 -rw-rw-r-- 1 ftp 1938234339 Oct 14 06:08 ftp://nrt.cmems-du.eu~
#> 7 -rw-rw-r-- 1 ftp 1938285902 Oct 14 06:08 ftp://nrt.cmems-du.eu~
#> 8 -rw-rw-r-- 1 ftp 1937954892 Oct 14 06:10 ftp://nrt.cmems-du.eu~
#> 9 -rw-rw-r-- 1 ftp 1937964478 Oct 14 06:09 ftp://nrt.cmems-du.eu~
#> 10 -rw-rw-r-- 1 ftp 1937962443 Oct 14 06:06 ftp://nrt.cmems-du.eu~
#> # ... with 808 more rows
#> <chr> <int> <chr> <dbl> <chr> <int> <chr> <chr>
#> 1 -rw-rw-r-- 1 ftp 1937968861 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 2 -rw-rw-r-- 1 ftp 1937978851 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 3 -rw-rw-r-- 1 ftp 1937888467 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 4 -rw-rw-r-- 1 ftp 1938380754 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 5 -rw-rw-r-- 1 ftp 1938177028 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 6 -rw-rw-r-- 1 ftp 1938234339 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 7 -rw-rw-r-- 1 ftp 1938285902 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 8 -rw-rw-r-- 1 ftp 1937954892 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 9 -rw-rw-r-- 1 ftp 1937964478 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> 10 -rw-rw-r-- 1 ftp 1937962443 Oct 14 2022 ftp://nrt.cmems-du.eu~
#> # i 1,102 more rows
```

Downloading the first file can be done with
Expand Down Expand Up @@ -170,21 +172,21 @@ GDAL utils.

A Copernicus account comes with several terms of use. One of these is
that you [properly
cite](https://help.marine.copernicus.eu/en/articles/4444611-how-to-cite-copernicus-marine-products-and-services)
cite](https://help.marine.copernicus.eu/en/articles/4444611-how-to-cite-or-reference-copernicus-marine-products-and-services)
the data you use in publications. In fact, we also have credit the data
used in this documentation, which can be easily done with the following
code:

``` r
copernicus_cite_product("GLOBAL_ANALYSISFORECAST_PHY_001_024")
#> $doi
#> [1] "E.U. Copernicus Marine Service Information; Global Ocean 1/12° Physics Analysis and Forecast updated Daily - GLOBAL_ANALYSISFORECAST_PHY_001_024 (2016-10-14). DOI:10.48670/moi-00016"
#> [1] "E.U. Copernicus Marine Service Information; Global Ocean Physics Analysis and Forecast - GLOBAL_ANALYSISFORECAST_PHY_001_024 (2016-10-14). DOI:10.48670/moi-00016"
```

## Resources

- [E.U. Copernicus Marine Service
Information](https://data.marine.copernicus.eu)
- [Global Ocean 1/12° Physics Analysis and Forecast updated Daily -
- [Global Ocean Physics Analysis and Forecast -
GLOBAL_ANALYSISFORECAST_PHY_001_024 (2016-10-14);
DOI:10.48670/moi-00016](https://doi.org/10.48670/moi-00016)
Binary file modified man/figures/README-leaflet-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 44ab4ee

Please sign in to comment.