Closed dancrear closed 9 months ago
Hi @dancrear,
Thanks for your report. I've scaled down your subset and created the following reprex which does reproduce your issue:
library(CopernicusMarine)
library(stars)
destination <- tempfile("copernicus", fileext = ".nc")
cms_download_subset(
destination = destination,
product = "GLOBAL_ANALYSISFORECAST_PHY_001_024",
layer = "cmems_mod_glo_phy-so_anfc_0.083deg_P1D-m",
variable = "so",
region = c(-150,-40,-140,-35),
timerange = c("2021-03-01 UTC", "2021-04-01 UTC"),
verticalrange = c(0, 10),
overwrite = TRUE)
sal <- read_stars(destination)
print(sal)
Which produces:
stars object with 4 dimensions and 1 attribute
attribute(s):
Min. 1st Qu. Median Mean 3rd Qu. Max.
copernicus456838124d5d.nc 33.90225 34.5031 34.68702 34.74365 34.9466 35.74508
dimension(s):
from to offset delta refsys x/y
x 1 121 -150 0.08333 NA [x]
y 1 61 -34.96 -0.08333 NA [y]
depth 1 1 0.494 [m] NA NA
time 1 31 2021-03-01 12:00:00 UTC 1 days POSIXct
Where I can see that indeed only 1 depth layer is downloaded whereas the product specification lists multiple depth layers. I will look into this and hoop to fix this soon. I will post my findings/fixes here.
Cheers,
Pepijn
Hi @dancrear,
After some testing it would appear that the verticalrange
range needs to be specified as negative numbers, as it is below the sea surface. So if you use verticalrange = c(0,-10)
, you should get multiple depth layers. I will update the documentation to make this more clear, it took me a while to figure this out as well...
This is taken care of in commit https://github.com/pepijn-devries/CopernicusMarine/pull/32/commits/e5d46f215c2bc4f5c7b2efc4e50289b8f338053f
Awesome! I really appreciate you figuring this out. Using your advice I was able to download the correct data as well. Again, thank you for developing a package that is so easy for ecologists like myself to use.
Hi @pepijn-devries
One more question. I'm wondering if there is a size limit for downloaded file. Using the code below I was able to download salinity data from surface to 55m depth, but beyond that I receive the error:
Failed to collect information from job-check. HTTP 400 Bad Request.
I was hoping to pull data from the surface down to 500m. It looks like they have data available to +5000m so I'm wondering if there is file size limit given the volume of the area I need.
cms_download_subset( destination = destination, product = “GLOBAL_ANALYSISFORECAST_PHY_001_024”, layer = "cmems_mod_glo_phy-so_anfc_0.083deg_P1D-m", variable = "so", region = c(-150,-40,-70,40), timerange = c("2021-03-01 UTC", "2021-04-01 UTC"), verticalrange = c(0, -500), overwrite = TRUE)
Thanks, Dan
Hi @dancrear,
Yes, for subsetting data Copernicus has set a file size limit on their server. So you need to split up your request and stitch them together afterwards. You can also download the complete set with cms_download_stac
.
The error message that you get isn't very helpful. I will see if I can generate a more informative error message.
Cheers,
Pepijn
Hi,
Your package has been great and I really appreciate you developing it! When I use the code below, I end up only downloading the top layer of salinity when I wish to download surface and subsurface data. I’m pretty sure salinity data at depth is available because in the Copernicus Marine Data Store form I can adjust the depth range I want. I've noticed the same issue for other variables from the same product. I have tried to follow the example here. I have also tried switching the values around and using negatives, but no matter what I try the data pull only has one layer (valid_min: 0.494024991989136, valid_max: 0.494024991989136). I can't tell if there's something wrong with the request on my end or the database end.
cms_download_subset( destination = destination, product = “GLOBAL_ANALYSISFORECAST_PHY_001_024”, layer = "cmems_mod_glo_phy-so_anfc_0.083deg_P1D-m", variable = "so", region = c(-150,-40,-70,40), timerange = c("2021-03-01 UTC", "2021-04-01 UTC"), verticalrange = c(0, 10), overwrite = TRUE)
Thanks, Dan