raddleverse / MimiCIAM.jl

MIT License
2 stars 1 forks source link

MimiCIAM.jl

This is a work-in-progress respository for a Julia-Mimi implementation the CIAM model adapted from Diaz, 2016.

Preparing the Software Environment

Your first step is to install MimiCIAM.jl itself, which you can do as follows in Julia:

import Pkg; Pkg.add("MimiCIAM")

You probably also want to install the Mimi package into your julia environment, so that you can use some of the tools in there:

Pkg.add("Mimi")

Running the Model

The model uses the Mimi framework and it is highly recommended to read the Mimi documentation first to understand the code structure. The basic way to access a copy of the default MimiFAIRv2 model and explore the resuts is the following:

The basic way to access a copy of the default MimiCIAM model is the following:

using MimiCIAM
m = MimiCIAM.get_model()
run(m)

Keyword Arguments

The get_model() function has the following signature:

get_model(;
    initfile = nothing,
    fixed::Bool = true,
    t::Int = 20,
    noRetreat::Bool = false,
    allowMaintain::Bool = false,
    popinput::Int = 0)

which includes several optional keyword arguments to customize the CIAM model you wish to run:

we do not recommend altering the following without consultation with the authors as changes from the default are experimental

Initialization File

The initfile parameter above takes a path to a file that must be specially formatted as the init.txt file at "data/batch/init.csv":

run_name,lslr,subset,ssp,ssp_simplified
base,lsl_rcp85_p50.csv,false,IIASAGDP_SSP5_v9_130219,5

This file will indicate the data to import for a given run, the bulk of this work being done in MimiCIAM.import_model_data. The file contains several parameters:

In order to make creation of such a file easier, we provide an (unexported) file creation function MimiCIAM.write_init_file(run_name::String, outputdir::String, init_settings::Dict) which writes the initialization file for a specificied run_name into outputdir using init_settings found in init_settings.

Note that init_settings is a Dictionary with one entry per parameter, best shown through the following example:

run_name = "ctrl+SSP5"

init_settings = Dict(
        :init_filename   => string("$run_name", "_init.csv"),
        :lslrfile        => "lsl_rcp85_p50.csv",
        :subset          => false,
        :ssp             => "IIASAGDP_SSP5_v9_130219",
        :ssp_simplified  => 5
    )

MimiCIAM.write_init_file(run_name, outputdir, init_settings)

Exploring Model Results

There are several options for exploring the results of a run model, many of which are described in the Mimi.jl documentation here. In addition, we offer some custom (unexported) functions including the following for a model m.

MimiCIAM.write_ciam(m; runname::String = "base", sumsegs::String = "seg", varnames::Bool = false, tag::Bool = false)

Write out model results to CSV file using arguments:

MimiCIAM.write_optimal_costs(m; outputdir::String = joinpath(@__DIR__,"..","output"), runname="base")

Write out optimal adaptation costs for model m with runname runname into outputdirectory outputdir.