diff --git a/Project.toml b/Project.toml index ebbcfd6..dd8d572 100644 --- a/Project.toml +++ b/Project.toml @@ -2,6 +2,7 @@ name = "MCMphotolysis" uuid = "37f95c2c-7f9b-11e8-13ad-816be0d1e117" authors = ["Peter Bräuer "] version = "0.1.0" +julia = "0.7-" [deps] DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" diff --git a/README.md b/README.md index 9c34a7f..e23081b 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,49 @@ Install the Package by adding it to your environment using `Pkg` ```julia using Pkg Pkg.add("https://github.com/pb866/MCMphotolysis.git") +Pkg.instantiate() Pkg.precomile() ``` or go to the package manager typing `]` in the julia prompt and in the package manager the following commands: -```julia +``` add https://github.com/pb866/MCMphotolysis.git +instantiate precompile ``` -### Trouble shooting of common errors + +Usage +----- + +After installation run the following lines in the REPL or write a julia +script with the following lines and call it from the terminal. + +```julia +using MCMphotolysis +jvals = j_oldpars("") +``` + +If you haven't installed the package directly to your Julia default environment, +you need to activate the environment first. + +Call function `j_oldpars` handing over the scenario name, i.e. the name of +the TUV input file without the `.txt` file ending. If you only want the data +returned in the REPL without file output, set the optional keyword argument +`output = false`. +Function `j_oldpars` returns a dictionary with entries for a DataFrame with +the _j_ values (`:jvals`), where the `:order` of magnitude is stored in a +different array, arrays with the solor zenith angles (`:deg`/`:rad`), +an array with LsqFit output, statistical data (`:σ`, `:RMSE`, and `:R2`). +Moreover, a folder `params_` is created, where parameters are +printed to `parameters.dat` and parameterisations are visualised in +`.pdf`. + + +Trouble shooting of common errors +--------------------------------- If you get an error message, follow the the instructions of the error message, e.g. @@ -43,3 +74,14 @@ Pkg.build("PyPlot") You can get the system python version by typing `which python` in the terminal and copying the output. + + +Version history +=============== + +Version 0.1.0 +------------- + +- Function `j_oldpars` to write the legacy MCM parameterisations and statistical + data to a text file and plot the parameterisations in a pdf compiled in the + folder `params_` diff --git a/src/MCMparameters.jl b/src/MCMparameters.jl deleted file mode 100644 index 1e993e6..0000000 --- a/src/MCMparameters.jl +++ /dev/null @@ -1,6 +0,0 @@ -using Pkg -Pkg.activate(".") -using MCMphotolysis - -jvals = j_oldpars("testM4", output = false) -jvals = j_oldpars("testM4") diff --git a/src/MCMphotolysis.jl b/src/MCMphotolysis.jl index 27a6b3a..a53eab5 100644 --- a/src/MCMphotolysis.jl +++ b/src/MCMphotolysis.jl @@ -34,14 +34,22 @@ function __init__() end """ - j_oldpars(scen) + j_oldpars(scen::String; output::Bool=true) Read reactions from a TUV output file named `scen`.txt, derive MCM l,m,n-parameterisations -for photolysis, plot the _j_ values from TUV and the parameterisation for all reactions -to a pdf and print the j values and errors/statistical data to a text file in a folder -`params_`. -Return solar zenith angle as tuple of arrays with deg/rad, the TUV _j_ value data, -and the fit data (as array with entries for each reaction). +for photolysis and return a dictionary with the following entries: + +- `:jvals`: DataFrame with j values (devided by maximum order of magnitude, i.e. without the `e-...`) +- `:order`: Vector with order of magnitudes +- `:deg`/`:rad`: Vector with solar zenith angles in deg/rad +- `:fit`: Vector with LsqFit data +- `:σ`: Vector of Vectors with σ-values for the 95% confidence interval for the `l`, `m`, and `n` parameters +- `:RMSE`: Vector of root mean square errors +- `:R2`: Vector of correlation cofficients R² + +If output is set to `true` (_default_), _j_ values from TUV and the parameterisations +for all reactions are plotted to a pdf and _j_ values and errors/statistical data +are printed to a text file in a folder named `params_`. """ function j_oldpars(scen::String; output::Bool=true) # Initialise system time and output path/file name diff --git a/src/fitTUV.jl b/src/fitTUV.jl index 559a24b..2ff6884 100644 --- a/src/fitTUV.jl +++ b/src/fitTUV.jl @@ -3,10 +3,12 @@ ######################################### """ - fit_j(jvals) + fit_j(jvals, sza) -Derive MCM parameterisations for dataframe jvals with χ-dependent _j_ values. - j / s^-1 = l·cos^m(χ)·exp(-n·sec(χ)) +Derive MCM parameterisations for DataFrame `jvals` with `sza`-dependent _j_ values. + j / s^-1 = l·cos^m(sza)·exp(-n·sec(sza))] + +The Vector of solar zenith angles `sza` must be in rad. """ function fit_jold(jvals,sza) diff --git a/src/output.jl b/src/output.jl index 498d4cf..8d49502 100644 --- a/src/output.jl +++ b/src/output.jl @@ -1,8 +1,9 @@ """ - plot_j(jvals, iofolder, fit, systime) + plot_j(jvals::Dict{Symbol,Any},systime::DateTime,iofolder::String,ifile::String) -Plot j values saved in dataframe jvals and parameterisations derived from parameters -in fit to file parameters.dat in the iofolder together with the time of creation (time). +Plot j values saved in `jvals[:jvals]` and parameterisations derived from parameters +in `jvals[:fit]` to file `ifile.pdf` in the `iofolder` together with the +`systime` of creation. """ function plot_jold(jvals::Dict{Symbol,Any},systime::DateTime,iofolder::String,ifile::String) @@ -49,13 +50,11 @@ end #function plot_j """ - wrt_params(rxn, fit, sigma, rmse, R2, iofolder, time) + wrt_params(jvals, iofolder, systime) -For each reaction (rxn), from param in fit and sigma, print parameters -and 95% confidence together with RMSE and R^2 to file 'parameters.dat' -in the designated output folder (iofolder). - -Print the time of creation (time) to the output file. +Write the parameters, statistical data, and reaction labels stored in the +dictionary `jvals` to the file `parameters.dat` in the `iofolder` and state +the `systime` of creation. """ function wrt_params(jvals, iofolder, systime) diff --git a/src/rdfiles.jl b/src/rdfiles.jl index e313548..fa8d7a9 100644 --- a/src/rdfiles.jl +++ b/src/rdfiles.jl @@ -1,8 +1,11 @@ """ - get_fnames(scen) + get_fnames(scen, output) -From the scenario name (scen) used in TUV derive names for the TUV output file +From the scenario name (scen) used in TUV, derive names for the TUV output file and the output folder. + +If `output` is `true`, create a output folder `./params_`. Ask to overwrite, +if folder already exists. """ function setup_files(scen, output) # Test script argument and ask for input file, if missing