<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<blockquote type="cite">
<pre wrap="">What you want is to use a model set. This is a still poorly understood feature
and I'm open to suggestions for how to make this more "obvious" (part of the
difficulty in that has been supporting a multitude of different use cases
simultaneously). You can read about that here:
<a class="moz-txt-link-freetext" href="http://docs.astropy.org/en/v1.0.4/modeling/models.html">http://docs.astropy.org/en/v1.0.4/modeling/models.html</a>
In short, a <b class="moz-txt-star"><span class="moz-txt-tag">*</span>model set<span class="moz-txt-tag">*</span></b> is what you want if you want to represent a collection
of independent instances of the same model with different parameters.</pre>
</blockquote>
wahh... quite powerful. Sorry to have missed that part of the
documentation. This is really great and solves quite a number of
issues I had in mind.<br>
<br>
At the end, I need to choose between (the examples below would need
extra lines/variables, but this is I hope explicit enough):<br>
<br>
1- for i in range(N) : ModelT += MyModel(par1= , par2= , par3= )<br>
<br>
(each Model being the same MyModel but with different instances
provided as going through the for loop)<br>
<br>
(I could also use model_instance = ModelT(....) to set the
parameters after the fact as you suggested)<br>
<br>
or<br>
<br>
2- ModelT = MyModel(par1=[...], par2=[...], par3=[...], n_models=N)<br>
<br>
The second option (model set) seems quite natural. It also has the
advantages to have both the "parameters" as an array including all
parameters (2d array), and each individual parameter (par1, par2,
par3) as an individual array (I checked that 'parameters' and e.g.,
'par1' are views of each others so when I modify one the other one
is also modified, via a setter/view I guess -> great!).<br>
<br>
=> However, I don't know how to slice the model set then (e.g.,
compute ModelT(x) just using e.g., the 1st and 3rd model of that
set). By the way, with a compound model, I guess I cannot do
ModelT[[0,2]] to access only model 1 and 3.<br>
<br>
=> More generally, and as mentioned in a previous email, I would
also like to be able to add more instances of MyModel, or remove
some of them.<br>
<br>
With Option 1, I can just do ModelT = ModelT + MyModel(par1=, par2=,
par3=) to add one<br>
<br>
or<br>
<br>
ModelT = ModelT[0] + ModelT[2] to remove one (as you suggested)<br>
<br>
Could you do that easily with a model set? (1- compute the output on
a slice of the models, a selected subset, and later on add or even
remove completely one of the models in the model set?).<br>
<br>
Anyways, this is quite amazing. I was a bit dubious when I started
to examine the possibility to use the astropy.modeling. I am more
than convinced now and this is going well beyond what I had imagined
(and I haven't seen everything yet by far). Thanks so much for these
developments!<br>
<br>
Eric<br>
<br>
</body>
</html>