lp
chartsvignettes/Plot_StandingKatz_lp.Rmd
Plot_StandingKatz_lp.Rmd
If we invoke the function getStandingKatzCurve
without any parameters, by defult it will use a Tpr=1.3
for the low-pressure set of Tpr
curves and plot it.
If we want to specify a Tpr curve:
Or for a couple of Tpr curves, we specify a vector with 2 or more components:
Tpr
datasetThe returning object of getStandingKatzCurve
is a list of dataframes, which contains a dataframe for each of the Tpr
curves specified:
class(result) # class of the object `result` is a list of dataframes
names(result) # name of each dataframe within the list
[1] "list"
[1] "1.05" "1.1"
For Tpr = 1.05
:
# A tibble: 52 x 5
Ppr z isNear Ppr_near diff
<dbl> <dbl> <lgl> <dbl> <dbl>
1 0.204 0.937 TRUE 0.2 4.00e- 3
2 0.3 0.905 TRUE 0.3 -5.55e-17
3 0.405 0.866 TRUE 0.4 5.00e- 3
4 0.504 0.829 TRUE 0.5 4.00e- 3
5 0.602 0.79 TRUE 0.6 2.00e- 3
6 0.7 0.748 TRUE 0.7 -1.11e-16
7 1 0.589 TRUE 1 0.
8 1.20 0.44 TRUE 1.2 3.00e- 3
9 1.30 0.35 TRUE 1.3 10.00e- 4
10 1.33 0.319 FALSE 1.33 0.
# … with 42 more rows
And, for Tpr = 1.1
:
# A tibble: 86 x 5
Ppr z isNear Ppr_near diff
<dbl> <dbl> <lgl> <dbl> <dbl>
1 0.225 0.942 FALSE 0.225 0
2 0.253 0.933 FALSE 0.253 0
3 0.279 0.926 FALSE 0.279 0
4 0.321 0.912 FALSE 0.321 0
5 0.349 0.903 FALSE 0.349 0
6 0.378 0.895 FALSE 0.378 0
7 0.415 0.882 FALSE 0.415 0
8 0.444 0.874 FALSE 0.444 0
9 0.456 0.869 FALSE 0.456 0
10 0.504 0.854 TRUE 0.5 0.004
# … with 76 more rows
lp
Standing-Katz curvesOr we can plot all the lp
Standing-Katz curves:
# view all the `Tpr` SK individual charts
tpr_vec <- getStandingKatzTpr(pprRange = "lp")
result <- getStandingKatzCurve(tpr_vec, toSave = FALSE, toView = FALSE)
The plotting function in getStandingKatzCurve
has a default value for the Y scale of 0.2 to 1.2, just to make the plot uniform. But you can change that.
Let’s say you don’t like the Tpr
curve at 1.7 (shown above), just change the ylim
parameter:
And here is the list of dataframes of the digitized points for the lp
Standing-Katz curves:
[1] "1.05" "1.1" "1.2" "1.3" "1.4" "1.5" "1.6" "1.7" "1.8" "1.9"
[11] "2" "2.2" "2.4" "2.6" "2.8" "3"
We have this other simpler function that will return only the data without saving, plotting or viewing the object. It is called getStandingKatzData
:
library(zFactor)
tpr_vec <- c(1.05, 1.3, 1.5)
all_tpr2 <- getStandingKatzData(tpr_vec)
names(all_tpr2)
[1] "1.05" "1.3" "1.5"
Similarly, to what we did with getStandingKatzCurve
, we could extract a dataframe for any Tpr:
# A tibble: 37 x 5
Ppr z isNear Ppr_near diff
<dbl> <dbl> <lgl> <dbl> <dbl>
1 0.202 0.978 TRUE 0.2 0.002
2 0.303 0.967 TRUE 0.3 0.00300
3 0.404 0.958 TRUE 0.4 0.004
4 0.506 0.948 TRUE 0.5 0.006
5 0.701 0.929 TRUE 0.7 0.001000
6 0.801 0.919 TRUE 0.8 0.001
7 1 0.9 TRUE 1 0
8 1.30 0.875 TRUE 1.3 0.004
9 1.50 0.859 TRUE 1.5 0.00500
10 1.80 0.836 TRUE 1.8 0.00300
# … with 27 more rows
Tpr
curvesTo be able to plot multiple Tpr curves in one figure we have to convert the multiple dataframes to a tidy
dataset. We will take a look on two ways of doing this:
Following from the previous example, we have to create a tidy dataset from the list of dataframes.
Let’s plot the curves:
library(data.table)
library(ggplot2)
# join the dataframes with rbindlist adding an identifier column
all_tpr_df <- data.table::rbindlist(all_tpr2, idcol = TRUE)
colnames(all_tpr_df)[1] <- "Tpr" # name the identifier as Tpr
ggplot(all_tpr_df, aes(x=Ppr, y=z, group=Tpr, color=Tpr)) +
geom_line() +
geom_point()
Tpr
curves of Standing-Katz chartUsing lapply
, getStandingKatzData
and data.table::rbindlist
:
library(zFactor)
library(ggplot2)
library(data.table)
tpr_vec <- c(1.05, 1.1, 1.2, 1.3, 1.5, 1.6, 1.7, 1.9, 2.0, 2.4, 2.6, 2.8, 3.0)
all_tpr2 <- (lapply(tpr_vec, function(x) getStandingKatzData(tpr = x)))
names(all_tpr2) <- tpr_vec
all_tpr_df <- data.table::rbindlist(all_tpr2, idcol = TRUE)
colnames(all_tpr_df)[1] <- "Tpr"
ggplot(all_tpr_df, aes(x=Ppr, y=z, group=Tpr, color=Tpr)) +
geom_line() +
geom_point()
Or the one-liner:
If you just prefer the low range Tpr
curves:
library(zFactor)
library(ggplot2)
library(data.table)
low_tpr_vec <- c(1.05, 1.1, 1.2, 1.3, 1.4)
low_tpr_li <- (lapply(low_tpr_vec, function(x) getStandingKatzData(tpr = x)))
names(low_tpr_li) <- low_tpr_vec
low_tpr_df <- data.table::rbindlist(low_tpr_li, idcol = TRUE)
colnames(low_tpr_df)[1] <- "Tpr"
ggplot(low_tpr_df, aes(x=Ppr, y=z, group=Tpr, color=Tpr)) +
geom_line() +
geom_point()
With the one liner:
Tpr
curveslibrary(zFactor)
library(ggplot2)
library(data.table)
med_tpr_vec <- c(1.5, 1.6, 1.7, 1.8, 1.9)
med_tpr_li <- (lapply(med_tpr_vec, function(x) getStandingKatzData(tpr = x)))
names(med_tpr_li) <- med_tpr_vec
med_tpr_df <- data.table::rbindlist(med_tpr_li, idcol = TRUE)
colnames(med_tpr_df)[1] <- "Tpr"
ggplot(med_tpr_df, aes(x=Ppr, y=z, group=Tpr, color=Tpr)) +
geom_line() +
geom_point()
The one liner:
Tpr
curveslibrary(zFactor)
library(ggplot2)
library(data.table)
hi_tpr_vec <- c(2.0, 2.4, 2.6, 2.8, 3.0)
hi_tpr_li <- (lapply(hi_tpr_vec, function(x) getStandingKatzData(tpr = x)))
names(hi_tpr_li) <- hi_tpr_vec
hi_tpr_df <- data.table::rbindlist(hi_tpr_li, idcol = TRUE)
colnames(hi_tpr_df)[1] <- "Tpr"
ggplot(hi_tpr_df, aes(x=Ppr, y=z, group=Tpr, color=Tpr)) +
geom_line() +
geom_point()
By performing a summary of the tidy dataset we can learn a lot more of the data we are plotting:
# A tibble: 117 x 6
Tpr Ppr z isNear Ppr_near diff
<chr> <dbl> <dbl> <lgl> <dbl> <dbl>
1 2 0.3 0.989 TRUE 0.3 -5.55e-17
2 2 0.403 0.985 TRUE 0.4 3.00e- 3
3 2 0.505 0.982 TRUE 0.5 5.00e- 3
4 2 0.702 0.977 TRUE 0.7 2.00e- 3
5 2 0.801 0.974 TRUE 0.8 1.00e- 3
6 2 1.00 0.969 TRUE 1 2.00e- 3
7 2 1.2 0.963 TRUE 1.2 -2.22e-16
8 2 1.50 0.956 TRUE 1.5 10.00e- 4
9 2 1.60 0.954 TRUE 1.6 2.00e- 3
10 2 1.80 0.95 TRUE 1.8 5.00e- 3
# … with 107 more rows
Tpr Ppr z isNear
Length:117 Min. :0.300 Min. :0.937 Mode :logical
Class :character 1st Qu.:2.001 1st Qu.:0.981 FALSE:1
Mode :character Median :3.806 Median :1.000 TRUE :116
Mean :3.880 Mean :1.005
3rd Qu.:5.606 3rd Qu.:1.030
Max. :8.005 Max. :1.097
Ppr_near diff
Min. :0.300 Min. :0.000000
1st Qu.:2.000 1st Qu.:0.002000
Median :3.800 Median :0.004000
Mean :3.877 Mean :0.003641
3rd Qu.:5.600 3rd Qu.:0.005000
Max. :8.000 Max. :0.010000
With this we are in a position to compare the original Standing-Katz chart against the most common compresssibility correlations.