Skip to content

Commit

Permalink
Use CRLF line endings, and other small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jedick committed Jun 23, 2020
1 parent da60b81 commit 4da580b
Show file tree
Hide file tree
Showing 9 changed files with 2,154 additions and 2,151 deletions.
9 changes: 3 additions & 6 deletions R/readhead.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# readhead.R
# read header information from a GWB data file 20200523

# a function to exclude type= ... at end of line with names 20200526
line2name <- function(LINE) gsub("\ *type=.*", "", LINE)

# a function to read the *numeric* values in a data block
# 'i' is the line number for the header line in the file
readblock <- function(LINES, ihead, i) {
Expand All @@ -29,11 +26,11 @@ readblock <- function(LINES, ihead, i) {

readhead <- function(LINES, quiet = FALSE) {
# find header lines before data blocks
iT <- grep("^\\*\ temperatures", LINES)
iP <- grep("^\\*\ pressures", LINES)
iT <- grep("^\\*\ temperatures\\s*$", LINES)
iP <- grep("^\\*\ pressures\\s*$", LINES)
iadh <- grep("^\\*\ debye.*adh", LINES)
ibdh <- grep("^\\*\ debye.*bdh", LINES)
ibdot <- grep("^\\*\ bdot", LINES)
ibdot <- grep("^\\*\ bdot\\s*$", LINES)
ico2_1 <- grep("* c co2 1", LINES, fixed = TRUE)
ico2_2 <- grep("* c co2 2", LINES, fixed = TRUE)
ico2_3 <- grep("* c co2 3", LINES, fixed = TRUE)
Expand Down
8 changes: 8 additions & 0 deletions R/readlogK.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
# 20200523 jmd initial version
# 20200525 revision to move not-reading logic to calclogK()

# a function to exclude type= ... at end of line with names 20200526
# also remove formula= (occurs in thermo.com.V8.R6+.tdat) 20200623
line2name <- function(LINE) {
LINE <- gsub("\ *type=.*", "", LINE)
LINE <- gsub("\ *formula=.*", "", LINE)
LINE
}

readlogK <- function(file, quiet = FALSE) {
# read the GWB data file
message(paste("Reading file", file))
Expand Down
3 changes: 2 additions & 1 deletion R/writedat.R
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,6 @@ writedat <- function(outfile, LINES, HEAD, LOGK, ADDS, infile, DH.method, a0_ion
}

# write the output to file
writeLines(out, outfile)
# use CRLF lineendings (better for Windows users) 20200623
writeLines(out, outfile, sep = "\r\n")
}
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ remotes::install_github("jedick/logKcalc", build_vignettes = TRUE)
## Features

* Change the temperature and pressure for log*K* calculations.
* Update parameters for activity and osmotic coefficients (Debye-Hückel, H<sub>2</sub>O, CO<sub>2</sub>) for specified *T* and *P*.
* Add new species to the output file.
* List data references in the output file (requires CHNOSZ version > 1.3.6).
* Make plots comparing log*K* values from two data files.

## TODO (planned features)

* Update activity coefficient model blocks (Debye-Hückel, H<sub>2</sub>O, CO<sub>2</sub>) for specified *T* and *P*.
Loading

0 comments on commit 4da580b

Please sign in to comment.