Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support quality test report #99

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion R/calc_parameter_chunk_size.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ calc_parameter_chunk_size.data <- function(ds) {
#' calculate the full chunk size
#' @param ds dataset
calc_chunk_size <- function(ds) {

chunk_size <- ds$next_offset - ds$offset
return(chunk_size)
}
2 changes: 2 additions & 0 deletions R/create_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ create_dataset <- function(header_data) {
"b15-c16-t104-a1" = c(read_class = "parameter", block_type_name = "me_test_report_ab"),
"b15-c16-t0-a64" = c(read_class = "data", block_type_name = "ab_no_atm_comp"),
"b15-c16-t0-a0" = c(read_class = "data", block_type_name = "ab"),
# https://github.com/spectral-cockpit/opusreader2/issues/81
"b15-c16-t96-a0" = c(read_class = "parameter", block_type_name = "quality_test_report"),
# channel code 48: save reflectance (settings
"b15-c48-t112-a0" = c(read_class = "parameter", block_type_name = "quant_report_refl"),
"b15-c48-t104-a1" = c(read_class = "parameter", block_type_name = "me_test_report_refl"), # check "a1"
Expand Down
1 change: 1 addition & 0 deletions R/get_nice_parameter_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ sort_list_by <- function(dataset_list) {
"lab_and_process_param_raw",
"lab_and_process_param_processed",
"info_block",
"quality_test_report",
"history",
"report_unknown",
"unknown"
Expand Down
24 changes: 11 additions & 13 deletions R/parse_chunk.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' @keywords internal
#' @family parsing
parse_chunk <- function(ds,raw) UseMethod("parse_chunk")
parse_chunk <- function(ds, raw) UseMethod("parse_chunk")



Expand All @@ -15,8 +15,7 @@ parse_chunk <- function(ds,raw) UseMethod("parse_chunk")
#' @inheritParams parse_chunk
#'
#' @keywords internal
parse_chunk.default <- function(ds,raw) {

parse_chunk.default <- function(ds, raw) {
return(ds)
}

Expand All @@ -26,10 +25,10 @@ parse_chunk.default <- function(ds,raw) {
#' @inheritParams parse_chunk
#'
#' @keywords internal
parse_chunk.text <- function(ds,raw) {

parse_chunk.text <- function(ds, raw) {
text <- read_character(
raw, ds$offset+1, n = ds$chunk_size, n_char = ds$chunk_size
raw, ds$offset + 1,
n = ds$chunk_size, n_char = ds$chunk_size
)

ds$text <- text
Expand All @@ -41,9 +40,8 @@ parse_chunk.text <- function(ds,raw) {
#' @inheritParams parse_chunk
#'
#' @keywords internal
parse_chunk.parameter <- function(ds,raw) {

if (ds$text_type %in% c(104, 112, 144)) {
parse_chunk.parameter <- function(ds, raw) {
if (ds$text_type %in% c(104, 112, 96, 144)) { # added text typ
cursor <- ds$offset + 13
} else {
cursor <- ds$offset + 1
Expand All @@ -56,7 +54,6 @@ parse_chunk.parameter <- function(ds,raw) {
result_list <- list()

repeat {

parameter_name <- read_character(raw, cursor, n = 1, n_char = 3)

if (parameter_name == "END") {
Expand All @@ -82,7 +79,8 @@ parse_chunk.parameter <- function(ds,raw) {
parameter_value <- read_double(raw, cursor_value, n = 1L)
} else if (type_index %in% c(3, 4, 5)) {
parameter_value <- read_character(
raw, cursor_value, n = 1L, n_char = 2*parameter_size
raw, cursor_value,
n = 1L, n_char = 2 * parameter_size
)
}

Expand All @@ -108,6 +106,7 @@ parse_chunk.parameter <- function(ds,raw) {
names(result_list) <- parameter_names

ds$parameters <- result_list

return(ds)
}

Expand All @@ -117,8 +116,7 @@ parse_chunk.parameter <- function(ds,raw) {
#'
#' @keywords internal
parse_chunk.data <- function(ds, raw) {

data <- read_float(raw, ds$offset+1, n = ds$chunk_size)
data <- read_float(raw, ds$offset + 1, n = ds$chunk_size)

ds$data <- data
return(ds)
Expand Down
10 changes: 2 additions & 8 deletions R/parse_header.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parse_header <- function(raw) {

all_cursors <- seq(start_cursor, header_length, 12L)

out <- lapply(all_cursors, function(x) test_header_parse(raw, x))
out <- lapply(all_cursors, function(x) parse_header_impl(raw, x))

out[sapply(out, is.null)] <- NULL

Expand All @@ -32,7 +32,7 @@ dec_to_ascii <- function(n) {



test_header_parse <- function(raw, cursor) {
parse_header_impl <- function(raw, cursor) {
offset <- read_signed_int(raw, cursor + 8L)

if (offset <= 0L) {
Expand All @@ -41,12 +41,6 @@ test_header_parse <- function(raw, cursor) {
chunk_size <- read_signed_int(raw, cursor + 4L)
next_offset <- offset + 4L * chunk_size

# if(next_offset > length(raw)){
# browser()
# chunk_size <- length(raw) - offset
# }


repeat_list <- list(
block_type = read_unsigned_int(raw, cursor),
channel_type = read_unsigned_int(raw, cursor + 1L),
Expand Down
4 changes: 4 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ knitr
landcareresearch
MERCHANTABILITY
MLOps
MPA
NeedsCompilation
NONINFRINGEMENT
nz
Expand All @@ -49,6 +50,7 @@ OPUSLab
opusreader
ORCID
PARAM
parsable
Philipp
PhSm
postfixed
Expand All @@ -72,9 +74,11 @@ ScRf
ScSm
Sila
simplerspec
sofware
str
STR
sublicense
testhat
testthat
texttype
thhe
Expand Down
9 changes: 3 additions & 6 deletions tests/testthat/test-create_dataset.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
test_that("that a dataset is correctly cearted", {

header_data <- list(
block_type = 0,
text_type = 104,
channel_type = 0,
channel_type = 0,
additional_type = 64
)

Expand All @@ -17,7 +16,7 @@ test_that("that a dataset is correctly cearted", {
header_data <- list(
block_type = 100,
text_type = 104,
channel_type = 0,
channel_type = 0,
additional_type = 64
)

Expand All @@ -37,13 +36,11 @@ test_that("that a dataset is correctly cearted", {
header_data <- list(
block_type = 15,
text_type = 0,
channel_type = 48,
channel_type = 48,
additional_type = 64
)

ds <- create_dataset(header_data)

expect_equal(ds$block_type_name, "refl_no_atm_comp")


})