# Retrieving parameter values

**URL:** <https://forum.mimiframework.org/t/retrieving-parameter-values/37>\
**Category:** Uncategorized\
**Created:** [March 24, 2019, 9:07am UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37 "2019-03-24T09:07:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrising](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/jrising/32/7_2.png) [@jrising](https://forum.mimiframework.org/u/jrising)\
**Post date:** [March 24, 2019, 9:07am UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/1 "2019-03-24T09:07:09Z")

</div>

Suppose that I have an un-run model, which has its external parameters filled in. How can I get the values of these parameters?

Previously, I could say `m.external_parameters[:paramname].values`. I can’t figure out how to do this in the new version, except to run the model, and then I can say: `get_param_value(m.mi.components[:ComponentName], :paramname).data`

Is that the intended approach? (I couldn’t figure out a reasonable way to use the `components` function to help with this.)

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [March 25, 2019, 10:30pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/2 "2019-03-25T22:30:21Z")

</div>

Hi James, so am I right in saying that what you would ideally like to do here is access the values of the external parameters that have been filled in without running the model?

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [March 25, 2019, 10:50pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/3 "2019-03-25T22:50:48Z")

</div>

In this case, once the model is run, it seems the intended way to get the value is `model[:ComponentName, :ParamName]`. Per your question about an unrun model, that wouldn’t work since there’s no model instance of an unrun model, and this function requires a model instance. I can probably add an error message and we could also discuss possibilities for an unrun model if that’s useful. The parameters are held in `m.md.external_params`, but we haven’t written API functions to make it easy to access those and deal with their types, so would probably want to think on that.

---

<div class="post-metadata">

**Author:** ![jrising](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/jrising/32/7_2.png) [@jrising](https://forum.mimiframework.org/u/jrising)\
**Post date:** [March 26, 2019, 4:15pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/4 "2019-03-26T16:15:29Z")

</div>

I can work with that! It’s worth flagging that I’ll be going outside of the API, but I understand that the general solution is likely to be somewhat involved: it would be nice to be able to run any function that does not require the model to have been run without running it.

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [March 26, 2019, 11:42pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/5 "2019-03-26T23:42:15Z")

</div>

Yes that makes sense, the arrays are of special type `TimestepArray` so that may be a little tricky, I’m happy to look into it with you though.

---

<div class="post-metadata">

**Author:** ![FrankErrickson](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/frankerrickson/32/13_2.png) [@FrankErrickson](https://forum.mimiframework.org/u/FrankErrickson)\
**Post date:** [April 16, 2019, 1:14am UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/6 "2019-04-16T01:14:36Z")

</div>

I second @jrising’s suggestion. I find myself in a situation where it would be helpful to run functions that don’t require a solved model.

---

<div class="post-metadata">

**Author:** ![FrankErrickson](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/frankerrickson/32/13_2.png) [@FrankErrickson](https://forum.mimiframework.org/u/FrankErrickson)\
**Post date:** [October 8, 2019, 4:22pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/7 "2019-10-08T16:22:05Z")

</div>

To ask a slightly related follow up question, is it possible to get information about the number of timesteps a created (but un-run) Mimi model has? For instance I want to pre-allocate an array with the proper size to store some results, but haven’t run the model yet.

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [October 9, 2019, 8:34pm UTC](https://forum.mimiframework.org/t/retrieving-parameter-values/37/8 "2019-10-09T20:34:16Z")

</div>

So you want to know the length of your tilmestep dimension, that you set with something like `set_dimension!(mymodel, :time, 2015:5:2110)`? Sure there are a few functions you can use.

The easiest way is probably to use the exported `dim_keys` function, which will return an Array of the dimension keys for the `:time` dimension can give you the dimension keys as follows

```auto
using Mimi, MimiDICE2010
m = MimiDICE2010.get_model()
time_dim_keys = dim_keys(m, :time)
len = length(time_dim_keys)

```
