Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
Update README with usage of function j_oldpars. Add version history.
Add Julia version ("0.7-") to Project.toml.
Remove script MCMparameters.jl from src folder.
Updated docstrings.
  • Loading branch information
Peter Bräuer committed Nov 12, 2018
1 parent f03d3ae commit 279a831
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 28 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name = "MCMphotolysis"
uuid = "37f95c2c-7f9b-11e8-13ad-816be0d1e117"
authors = ["Peter Bräuer <pb866@york.ac.uk>"]
version = "0.1.0"
julia = "0.7-"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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("<scenario name>")
```

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_<scenario name>` is created, where parameters are
printed to `parameters.dat` and parameterisations are visualised in
`<scenario name>.pdf`.


Trouble shooting of common errors
---------------------------------

If you get an error message, follow the the instructions of the error message, e.g.

Expand All @@ -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_<scenario name>`
6 changes: 0 additions & 6 deletions src/MCMparameters.jl

This file was deleted.

20 changes: 14 additions & 6 deletions src/MCMphotolysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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_<scen>`.
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_<scen>`.
"""
function j_oldpars(scen::String; output::Bool=true)
# Initialise system time and output path/file name
Expand Down
8 changes: 5 additions & 3 deletions src/fitTUV.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 8 additions & 9 deletions src/output.jl
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions src/rdfiles.jl
Original file line number Diff line number Diff line change
@@ -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_<scen>`. Ask to overwrite,
if folder already exists.
"""
function setup_files(scen, output)
# Test script argument and ask for input file, if missing
Expand Down

0 comments on commit 279a831

Please sign in to comment.