Batch file for automatic conversion added

This commit is contained in:
Ruben Hartenstein (PEA4-Fe) 2021-01-20 10:07:29 +01:00
parent 1a26e7796b
commit 8addcea3ba
5 changed files with 1814 additions and 0 deletions

View File

1
AutoConversion.cmd Normal file
View File

@ -0,0 +1 @@
R CMD BATCH --no-save OpusData.R

1744
DPT/Rng02_Rng2630_01_0.DPT Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,10 @@ file_path <- paste(path, file_name, sep = "")
# Convert opus binary file into extractable data # Convert opus binary file into extractable data
data <- read_opus_univ(file_path, extract = "spc",atm_comp_minus4offset = FALSE) data <- read_opus_univ(file_path, extract = "spc",atm_comp_minus4offset = FALSE)
#Cut the beginning (ugly solution)
file_path <- substr(file_path, start = 4, stop = nchar(file_path))
# Extract data # Extract data
data_x_values <- data[[file_path]]$wavenumbers data_x_values <- data[[file_path]]$wavenumbers
data_y_values <- as.numeric(data[[file_path]]$spc[1,]) data_y_values <- as.numeric(data[[file_path]]$spc[1,])

65
OpusData.Rout Normal file
View File

@ -0,0 +1,65 @@
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R ist freie Software und kommt OHNE JEGLICHE GARANTIE.
Sie sind eingeladen, es unter bestimmten Bedingungen weiter zu verbreiten.
Tippen Sie 'license()' or 'licence()' für Details dazu.
R ist ein Gemeinschaftsprojekt mit vielen Beitragenden.
Tippen Sie 'contributors()' für mehr Information und 'citation()',
um zu erfahren, wie R oder R packages in Publikationen zitiert werden können.
Tippen Sie 'demo()' für einige Demos, 'help()' für on-line Hilfe, oder
'help.start()' für eine HTML Browserschnittstelle zur Hilfe.
Tippen Sie 'q()', um R zu verlassen.
> #!/usr/bin/env Rscript
>
> # Package installation, execute once
> #if (!require("remotes")) install.packages("remotes")
> #remotes::install_github("philipp-baumann/simplerspec")
>
> # Attach package to workspace, execute with every new session
> library("simplerspec")
Lade nötiges Paket: foreach
>
> # Determine file path
> path <- paste(getwd(), "\\OPUS\\", sep = "")
> file_name <- "Rng02_Rng2630_01.0"
> file_path <- paste(path, file_name, sep = "")
>
> # Convert opus binary file into extractable data
> data <- read_opus_univ(file_path, extract = "spc",atm_comp_minus4offset = FALSE)
Extracted spectra data from file: <OpusData\OPUS\Rng02_Rng2630_01.0>
>
> #Cut the beginning (ugly solution)
> file_path <- substr(file_path, start = 4, stop = nchar(file_path))
>
> # Extract data
> data_x_values <- data[[file_path]]$wavenumbers
> data_y_values <- as.numeric(data[[file_path]]$spc[1,])
>
> # Set working directory to path where the result file should appear
> setwd(paste(path, "..\\DPT", sep = ""))
>
> # Convert data into dataframe
> data <- data.frame(data_x_values, data_y_values, row.names = NULL)
>
> # Replace last "." with "_", add ".DPT" and create file
> file_name <- paste(sub(".([^.]*)$", "_\\1", file_name), ".DPT", sep = "")
> file.create(file_name)
[1] TRUE
>
> # Fill file with dataframe
> write.table(data, file_name, row.names = FALSE, col.names = FALSE, sep=",")
>
>
>
>
>
>
> proc.time()
User System verstrichen
0.50 0.12 0.67