Closed j-harbin closed 2 years ago
Perhaps the following answers the question from @richardsc but I'm not paying enough attention to be sure what the issue is actually about.
library(argoFloats)
file <- "SD5903586_001.nc"
A <- readProfiles(system.file("extdata", file, package="argoFloats"))
#> Warning in readProfiles(system.file("extdata", file, package = "argoFloats")): Of 1 profiles read, 1 has >10% of BBP700 values with QC flag of 4, signalling bad data.
#> The indices of the bad profiles are as follows.
#> 1
#> Warning in readProfiles(system.file("extdata", file, package = "argoFloats")): Of 1 profiles read, 1 has >10% of chlorophyllA values with QC flag of 4, signalling bad data.
#> The indices of the bad profiles are as follows.
#> 1
#> Warning in readProfiles(system.file("extdata", file, package = "argoFloats")): Of 1 profiles read, 1 has >10% of oxygen values with QC flag of 4, signalling bad data.
#> The indices of the bad profiles are as follows.
#> 1
B <- useAdjusted(A)
cat("Original data\n")
#> Original data
cat(oce::vectorShow(A[[1]][["pressure"]]))
#> A[[1]][["pressure"]] [1:548, 1:1]: 4.2, 6.0, ..., 977.9, 999.9
cat(oce::vectorShow(A[[1]]@data$pressure))
#> A[[1]]@data$pressure [1:548, 1:1]: 4.2, 6.0, ..., 977.9, 999.9
cat(oce::vectorShow(A[[1]][["pressureAdjusted"]]))
#> A[[1]][["pressureAdjusted"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
cat(oce::vectorShow(A[[1]]@data$pressureAdjusted))
#> A[[1]]@data$pressureAdjusted [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
cat("Result from useAdjusted()\n")
#> Result from useAdjusted()
cat(oce::vectorShow(B[[1]][["pressure"]]))
#> B[[1]][["pressure"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
cat(oce::vectorShow(B[[1]]@data$pressure))
#> B[[1]]@data$pressure [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
cat(oce::vectorShow(B[[1]][["pressureAdjusted"]]))
#> B[[1]][["pressureAdjusted"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
cat(oce::vectorShow(B[[1]]@data$pressureAdjusted))
#> B[[1]]@data$pressureAdjusted [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
Created on 2021-12-02 by the reprex package (v2.0.1)
Also, if the Q is about as.ctd()
, note that
library(argoFloats)
library(oce)
file <- "SD5903586_001.nc"
A <- readProfiles(system.file("extdata", file, package="argoFloats"))
B <- useAdjusted(A)
cat("Original data\n")
cat(oce::vectorShow(A[[1]][["pressure"]]))
cat(oce::vectorShow(A[[1]]@data$pressure))
cat(oce::vectorShow(A[[1]][["pressureAdjusted"]]))
cat(oce::vectorShow(A[[1]]@data$pressureAdjusted))
Actd <- as.ctd(A[[1]])
cat(oce::vectorShow(Actd[["pressure"]]))
cat(oce::vectorShow(Actd@data$pressure))
cat(oce::vectorShow(Actd[["pressureAdjusted"]]))
cat(oce::vectorShow(Actd@data$pressureAdjusted))
cat("Result from useAdjusted()\n")
cat(oce::vectorShow(B[[1]][["pressure"]]))
cat(oce::vectorShow(B[[1]]@data$pressure))
cat(oce::vectorShow(B[[1]][["pressureAdjusted"]]))
cat(oce::vectorShow(B[[1]]@data$pressureAdjusted))
Bctd <- as.ctd(B[[1]])
cat(oce::vectorShow(Bctd[["pressure"]]))
cat(oce::vectorShow(Bctd@data$pressure))
cat(oce::vectorShow(Bctd[["pressureAdjusted"]]))
cat(oce::vectorShow(Bctd@data$pressureAdjusted))
yields
Original data
A[[1]][["pressure"]] [1:548, 1:1]: 4.2, 6.0, ..., 977.9, 999.9
A[[1]]@data$pressure [1:548, 1:1]: 4.2, 6.0, ..., 977.9, 999.9
A[[1]][["pressureAdjusted"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
A[[1]]@data$pressureAdjusted [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
Actd[["pressure"]] [1:548]: 4.2, 6.0, ..., 977.9, 999.9
Actd@data$pressure [1:548]: 4.2, 6.0, ..., 977.9, 999.9
Actd[["pressureAdjusted"]] [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Actd@data$pressureAdjusted [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Result from useAdjusted()
B[[1]][["pressure"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
B[[1]]@data$pressure [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
B[[1]][["pressureAdjusted"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
B[[1]]@data$pressureAdjusted [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
Bctd[["pressure"]] [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Bctd@data$pressure [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Bctd[["pressureAdjusted"]] [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Bctd@data$pressureAdjusted [1:548]: 4.23, 6.03, ..., 977.93, 999.93
The Stale-bot has marked this issue as Stale, because no new comments have been added in the past 30 days. Unless a comment is added within the next 7 days, the Stale-bot will close the issue. The purpose of these automated actions is to prevent the developers from forgetting about unattended tasks. Note that adding a "pinned" label will turn this action off for a given issue.
I see that you answered this on December 02nd, and I'm just noticing it now. In summary, useAdjusted
works by copying over the adjusted field (ie. not because we told [[
to grab the adjusted field). This means if you do the following:
useAdjusted
If you do ctd[["temperature"]] you will be receiving the adjusted values. Hope this helps @richardsc. Thanks for the code @dankelley .
library(argoFloats)
library(oce)
#> Loading required package: gsw
file <- "SD5903586_001.nc"
A <- readProfiles(system.file("extdata", file, package="argoFloats"))
B <- useAdjusted(A)
cat(oce::vectorShow(A[[1]][["pressure"]]))
#> A[[1]][["pressure"]] [1:548, 1:1]: 4.2, 6.0, ..., 977.9, 999.9
cat(oce::vectorShow(B[[1]][["pressure"]]))
#> B[[1]][["pressure"]] [1:548, 1:1]: 4.23, 6.03, ..., 977.93, 999.93
Bctd <- as.ctd(B[[1]])
cat(oce::vectorShow(Bctd[["pressure"]]))
#> Bctd[["pressure"]] [1:548]: 4.23, 6.03, ..., 977.93, 999.93
Created on 2022-01-20 by the reprex package (v2.0.0)
I'm creating an issue for Clark's question he had regarding
useAdjusted
. We know if the user doesuseAdjusted
, and then for example, doesx[["temperature"]]
, they WILL get the adjusted data. We want to figure out if it's because A) copied thetemperatureAdjusted
intotemperature
OR B) because we told[[
to grabtemperatureAdjusted
even thoughtemperature
is specified.This is relevant in his work because he:
useAdjusted
on itThe question is will the
temperature
in his ctd object be the ADJUSTED data (which would be the case if we copied the adjusted field in theuseAdjusted
) OR will his ctd object have the unadjusted data (which would be the case if we simply told[[
to extract adjusted data).I tried to make a test case for this where I changed the adjusted values in an argo float to be all 100 (something that's easy to distinguish), but because of the restraints of
argoFloats
, which I agree with, I'm not allowed to go[[ <-
. This is because it's highly discouraged for users to change data within a float. (See code below)Created on 2021-12-02 by the reprex package (v2.0.0)
I'll take a deeper look at this, but it does suggest once I have a test case that the docs should be updated to be more clear. Further to that, I'll take this opportunity to suggest we add the
useAdjusted
diagram back into the help docs foruseAdjusted
. I say this because whenever I have a question aboutuseAdjusted
I refer back to this diagram in the tweet thread.