Skip to content

Commit e55b0a4

Browse files
committed
deploy: cf160d7
1 parent ead45fa commit e55b0a4

File tree

55 files changed

+274
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+274
-269
lines changed

tutorials/1_models-quick-fit.html

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ <h2>2) Fit a Polynomial model: Choose fitter wisely<a class="headerlink" href="#
688688
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Text(0, 0.5, &#39;$y_1$&#39;)
689689
</pre></div>
690690
</div>
691-
<img alt="_images/3634bb8b4c277819f7ce4c233fc84552a8f897def45ba7df53cedd5578cf8fde.png" src="_images/3634bb8b4c277819f7ce4c233fc84552a8f897def45ba7df53cedd5578cf8fde.png" />
691+
<img alt="_images/2599989f34957c875699451791904b2274c11a2e2bc68012705be41fe1a092b1.png" src="_images/2599989f34957c875699451791904b2274c11a2e2bc68012705be41fe1a092b1.png" />
692692
</div>
693693
</div>
694694
<p>To fit this data let’s remember the three steps: model, fitter and perform fit.</p>
@@ -714,9 +714,9 @@ <h2>2) Fit a Polynomial model: Choose fitter wisely<a class="headerlink" href="#
714714
Model set size: 1
715715
Degree: 3
716716
Parameters:
717-
c0 c1 c2 c3
718-
------------------ ------------------ ------------------ ------------------
719-
-8.414565124986794 11.315131284061778 -5.936420715916029 1.0350472068170264
717+
c0 c1 c2 c3
718+
------------------ ----------------- ----------------- -----------------
719+
-9.539737981721931 13.13686821526471 -6.59469741384606 1.106942942692932
720720
</pre></div>
721721
</div>
722722
</div>
@@ -749,9 +749,9 @@ <h2>2) Fit a Polynomial model: Choose fitter wisely<a class="headerlink" href="#
749749
Model set size: 1
750750
Degree: 3
751751
Parameters:
752-
c0 c1 c2 c3
753-
------------------- -------------------- ------------------ ------------------
754-
0.20564283089638824 -0.15716654941300878 -1.239243988919935 0.4355616696000767
752+
c0 c1 c2 c3
753+
------------------- ------------------- ------------------- -------------------
754+
0.05827388205687127 -0.9985633709289792 -0.5044587963099965 0.30779273029154025
755755
</pre></div>
756756
</div>
757757
</div>
@@ -786,7 +786,7 @@ <h3>Compare results<a class="headerlink" href="#compare-results" title="Link to
786786
</div>
787787
</div>
788788
<div class="cell_output docutils container">
789-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared with LinearLSQFitter: 1.7254506507627694
789+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared with LinearLSQFitter: 1.8508835268899093
790790
</pre></div>
791791
</div>
792792
</div>
@@ -799,7 +799,7 @@ <h3>Compare results<a class="headerlink" href="#compare-results" title="Link to
799799
</div>
800800
</div>
801801
<div class="cell_output docutils container">
802-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared with SimplexLSQFitter: 4.580753153741815
802+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared with SimplexLSQFitter: 5.074823984271411
803803
</pre></div>
804804
</div>
805805
</div>
@@ -818,10 +818,10 @@ <h3>Compare results<a class="headerlink" href="#compare-results" title="Link to
818818
</div>
819819
</div>
820820
<div class="cell_output docutils container">
821-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.legend.Legend at 0x7ff08227ba10&gt;
821+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.legend.Legend at 0x7f5ef5539850&gt;
822822
</pre></div>
823823
</div>
824-
<img alt="_images/b2cb6953351ca9c5f39fbc468440cdd51731a2b59186590a4e26b1d805a046f3.png" src="_images/b2cb6953351ca9c5f39fbc468440cdd51731a2b59186590a4e26b1d805a046f3.png" />
824+
<img alt="_images/7a6733b3fb0ae20d77bdd6eb3754bced5da6de6dc31264045bde5643e73b2965.png" src="_images/7a6733b3fb0ae20d77bdd6eb3754bced5da6de6dc31264045bde5643e73b2965.png" />
825825
</div>
826826
</div>
827827
<p>Results are as espected, the fit performed with the linear fitter is better than the second, non linear one.</p>
@@ -858,7 +858,7 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
858858
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Text(0, 0.5, &#39;$y_2$&#39;)
859859
</pre></div>
860860
</div>
861-
<img alt="_images/9424b3add19b739bc9cbfc66cf567663995d37f79f0e0ac2bab63e87ff87f7d1.png" src="_images/9424b3add19b739bc9cbfc66cf567663995d37f79f0e0ac2bab63e87ff87f7d1.png" />
861+
<img alt="_images/6dd81643931b491f78dfdc497c02ba5cd2a724d940ed81ad662329bd6911b94a.png" src="_images/6dd81643931b491f78dfdc497c02ba5cd2a724d940ed81ad662329bd6911b94a.png" />
862862
</div>
863863
</div>
864864
<p>Let’s do our three steps to make the fit we want. For this fit we’re going to use a non-linear fitter, <code class="docutils literal notranslate"><span class="pre">LevMarLSQFitter</span></code>, because the model we need (<code class="docutils literal notranslate"><span class="pre">Gaussian1D</span></code>) is non-linear in the parameters.</p>
@@ -883,9 +883,9 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
883883
Outputs: (&#39;y&#39;,)
884884
Model set size: 1
885885
Parameters:
886-
amplitude mean stddev
887-
------------------ ------------------- ------------------
888-
10.161667885872756 0.16429784623682972 10.000409076033547
886+
amplitude mean stddev
887+
----------------- -------------------- -----------------
888+
9.995883804181737 -0.34004726579476496 10.17125839102595
889889
</pre></div>
890890
</div>
891891
</div>
@@ -911,7 +911,7 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
911911
</div>
912912
</div>
913913
<div class="cell_output docutils container">
914-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.05133544 0.06625433 0.06645726]
914+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.05048654 0.06965048 0.06992814]
915915
</pre></div>
916916
</div>
917917
</div>
@@ -932,9 +932,9 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
932932
</div>
933933
</div>
934934
<div class="cell_output docutils container">
935-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Amplitude: 10.161667885872756 +\- 0.2265732649327809
936-
Mean: 0.16429784623682972 +\- 0.2573991704994828
937-
Standard Deviation: 10.000409076033547 +\- 0.2577930649461142
935+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Amplitude: 9.995883804181737 +\- 0.22469208943894217
936+
Mean: -0.34004726579476496 +\- 0.26391377689507484
937+
Standard Deviation: 10.17125839102595 +\- 0.2644392980327242
938938
</pre></div>
939939
</div>
940940
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;&gt;:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
@@ -943,11 +943,11 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
943943
&lt;&gt;:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
944944
&lt;&gt;:4: SyntaxWarning: invalid escape sequence &#39;\-&#39;
945945
&lt;&gt;:6: SyntaxWarning: invalid escape sequence &#39;\-&#39;
946-
/tmp/ipykernel_3529/1659586526.py:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
946+
/tmp/ipykernel_3540/1659586526.py:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
947947
&quot;Amplitude: {} +\- {}&quot;.format(best_fit_gauss.amplitude.value, np.sqrt(cov_diag[0]))
948-
/tmp/ipykernel_3529/1659586526.py:4: SyntaxWarning: invalid escape sequence &#39;\-&#39;
948+
/tmp/ipykernel_3540/1659586526.py:4: SyntaxWarning: invalid escape sequence &#39;\-&#39;
949949
print(&quot;Mean: {} +\- {}&quot;.format(best_fit_gauss.mean.value, np.sqrt(cov_diag[1])))
950-
/tmp/ipykernel_3529/1659586526.py:6: SyntaxWarning: invalid escape sequence &#39;\-&#39;
950+
/tmp/ipykernel_3540/1659586526.py:6: SyntaxWarning: invalid escape sequence &#39;\-&#39;
951951
&quot;Standard Deviation: {} +\- {}&quot;.format(
952952
</pre></div>
953953
</div>
@@ -978,7 +978,7 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
978978
</div>
979979
</div>
980980
<div class="cell_output docutils container">
981-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[10.16166902 0.1642994 10.00040685]
981+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 9.9958822 -0.34004602 10.17126165]
982982
</pre></div>
983983
</div>
984984
</div>
@@ -992,9 +992,9 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
992992
</div>
993993
</div>
994994
<div class="cell_output docutils container">
995-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Amplitude: 10.16166901860214 +\- 0.2180138118181192
996-
Mean: 0.1642993992949413 +\- 0.24767662180935193
997-
Standard Deviation: 10.00040684622568 +\- 0.24805566376335159
995+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Amplitude: 9.995882201165184 +\- 0.2183918959101891
996+
Mean: -0.34004601987526745 +\- 0.256517214073858
997+
Standard Deviation: 10.17126165173596 +\- 0.25702807522378746
998998
</pre></div>
999999
</div>
10001000
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;&gt;:1: SyntaxWarning: invalid escape sequence &#39;\-&#39;
@@ -1003,11 +1003,11 @@ <h2>3) Fit a Gaussian: Let’s compare to scipy<a class="headerlink" href="#fit-
10031003
&lt;&gt;:1: SyntaxWarning: invalid escape sequence &#39;\-&#39;
10041004
&lt;&gt;:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
10051005
&lt;&gt;:3: SyntaxWarning: invalid escape sequence &#39;\-&#39;
1006-
/tmp/ipykernel_3529/2222327920.py:1: SyntaxWarning: invalid escape sequence &#39;\-&#39;
1006+
/tmp/ipykernel_3540/2222327920.py:1: SyntaxWarning: invalid escape sequence &#39;\-&#39;
10071007
print(&quot;Amplitude: {} +\- {}&quot;.format(p_opt[0], np.sqrt(p_cov[0, 0])))
1008-
/tmp/ipykernel_3529/2222327920.py:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
1008+
/tmp/ipykernel_3540/2222327920.py:2: SyntaxWarning: invalid escape sequence &#39;\-&#39;
10091009
print(&quot;Mean: {} +\- {}&quot;.format(p_opt[1], np.sqrt(p_cov[1, 1])))
1010-
/tmp/ipykernel_3529/2222327920.py:3: SyntaxWarning: invalid escape sequence &#39;\-&#39;
1010+
/tmp/ipykernel_3540/2222327920.py:3: SyntaxWarning: invalid escape sequence &#39;\-&#39;
10111011
print(&quot;Standard Deviation: {} +\- {}&quot;.format(p_opt[2], np.sqrt(p_cov[2, 2])))
10121012
</pre></div>
10131013
</div>
@@ -1023,7 +1023,7 @@ <h3>Compare results<a class="headerlink" href="#id1" title="Link to this heading
10231023
</div>
10241024
</div>
10251025
<div class="cell_output docutils container">
1026-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared using astropy.modeling: 0.9258750059366527
1026+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared using astropy.modeling: 0.944715147396767
10271027
</pre></div>
10281028
</div>
10291029
</div>
@@ -1036,7 +1036,7 @@ <h3>Compare results<a class="headerlink" href="#id1" title="Link to this heading
10361036
</div>
10371037
</div>
10381038
<div class="cell_output docutils container">
1039-
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared using scipy: 0.9258750059343416
1039+
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Reduced Chi Squared using scipy: 0.9447151474018781
10401040
</pre></div>
10411041
</div>
10421042
</div>
@@ -1054,10 +1054,10 @@ <h3>Compare results<a class="headerlink" href="#id1" title="Link to this heading
10541054
</div>
10551055
</div>
10561056
<div class="cell_output docutils container">
1057-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.legend.Legend at 0x7ff0821b5cd0&gt;
1057+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.legend.Legend at 0x7f5ef4f971d0&gt;
10581058
</pre></div>
10591059
</div>
1060-
<img alt="_images/9d65948539694d6a9224f22edf286e6e920acf5805cb94eeeb84f92f19db8cf0.png" src="_images/9d65948539694d6a9224f22edf286e6e920acf5805cb94eeeb84f92f19db8cf0.png" />
1060+
<img alt="_images/cde6f3c949fb75493dbcea1b87215794d4ac7fffa2fdea3f36b30e5948d61e9f.png" src="_images/cde6f3c949fb75493dbcea1b87215794d4ac7fffa2fdea3f36b30e5948d61e9f.png" />
10611061
</div>
10621062
</div>
10631063
<p><strong>Conclusion:</strong> Choose the method most convenient for every case you need to fit. We recomend <code class="docutils literal notranslate"><span class="pre">astropy.modeling</span></code> because is easier to write the name of the function you want to fit than to remember the expression every time we want to use it. Also, <code class="docutils literal notranslate"><span class="pre">astropy.modeling</span></code> becomes useful with more complicated models like <a class="reference external" href="http://docs.astropy.org/en/stable/modeling/#compound-models">two gaussians</a> plus a <a class="reference external" href="http://docs.astropy.org/en/stable/modeling/#blackbody-radiation">black body</a>, but that is another tutorial.</p>
@@ -1109,7 +1109,7 @@ <h2>4) Exercise: Your turn to choose<a class="headerlink" href="#exercise-your-t
11091109
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Text(0, 0.5, &#39;$y_3$&#39;)
11101110
</pre></div>
11111111
</div>
1112-
<img alt="_images/5224aeb98f66c2f8304a7ecdd3d93e75f3acdf064da194bc12dfc2cfbbe1e7e0.png" src="_images/5224aeb98f66c2f8304a7ecdd3d93e75f3acdf064da194bc12dfc2cfbbe1e7e0.png" />
1112+
<img alt="_images/8aa54b9792fc13374e1ac574202e4a6427d221b9f0edd309906c5774fa208870.png" src="_images/8aa54b9792fc13374e1ac574202e4a6427d221b9f0edd309906c5774fa208870.png" />
11131113
</div>
11141114
</div>
11151115
</section>

tutorials/2_user-defined-model.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ <h3>Basic custom model<a class="headerlink" href="#basic-custom-model" title="Li
952952
</div>
953953
</div>
954954
<div class="cell_output docutils container">
955-
<img alt="_images/24135eafbd14b54450eed59c1ae24f404f505b30373f968e7df2d50c45cdd5e1.png" src="_images/24135eafbd14b54450eed59c1ae24f404f505b30373f968e7df2d50c45cdd5e1.png" />
955+
<img alt="_images/703fa0868fbba6f599174299b5f84e97b670a253763ce8f965258dc2f560cd77.png" src="_images/703fa0868fbba6f599174299b5f84e97b670a253763ce8f965258dc2f560cd77.png" />
956956
</div>
957957
</div>
958958
<p>We can define a simple custom model by specifying which parameters we want to fit.</p>
@@ -987,7 +987,7 @@ <h3>Basic custom model<a class="headerlink" href="#basic-custom-model" title="Li
987987
</div>
988988
</div>
989989
<div class="cell_output docutils container">
990-
<img alt="_images/ac1e52875373be7a4aa495eee650190f661c4e6642de0056788bc12e67cc3d38.png" src="_images/ac1e52875373be7a4aa495eee650190f661c4e6642de0056788bc12e67cc3d38.png" />
990+
<img alt="_images/cd0876bf852b45f8811ad113532d37f94f41bc20b48b3ca59ab46cb5177059c6.png" src="_images/cd0876bf852b45f8811ad113532d37f94f41bc20b48b3ca59ab46cb5177059c6.png" />
991991
</div>
992992
</div>
993993
<div class="cell docutils container">
@@ -1002,9 +1002,9 @@ <h3>Basic custom model<a class="headerlink" href="#basic-custom-model" title="Li
10021002
Outputs: (&#39;y&#39;,)
10031003
Model set size: 1
10041004
Parameters:
1005-
a b c
1006-
------------------ ------------------- ------------------
1007-
0.9630822728838254 -2.0772743996397858 1.1574457550030477
1005+
a b c
1006+
------------------ ------------------- ----------------
1007+
0.9516741086904221 -2.0392833256485625 1.15307525374791
10081008
</pre></div>
10091009
</div>
10101010
</div>
@@ -1031,7 +1031,7 @@ <h3>Basic custom model<a class="headerlink" href="#basic-custom-model" title="Li
10311031
</div>
10321032
</div>
10331033
<div class="cell_output docutils container">
1034-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>np.float64(0.9086643008789133)
1034+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>np.float64(0.9168271560292492)
10351035
</pre></div>
10361036
</div>
10371037
</div>
@@ -1068,7 +1068,7 @@ <h3>Full custom model<a class="headerlink" href="#full-custom-model" title="Link
10681068
</div>
10691069
</div>
10701070
<div class="cell_output docutils container">
1071-
<img alt="_images/aa86d06f804511d672ff4e69ad8f237c819ee6177a90a20c6bed207a8e013b7c.png" src="_images/aa86d06f804511d672ff4e69ad8f237c819ee6177a90a20c6bed207a8e013b7c.png" />
1071+
<img alt="_images/ce5e35625e32e97aca53a6a30bf9da312dfd462de71eb2bab5fc28a94ac20bbe.png" src="_images/ce5e35625e32e97aca53a6a30bf9da312dfd462de71eb2bab5fc28a94ac20bbe.png" />
10721072
</div>
10731073
</div>
10741074
<p>For the full custom model we can easily set the <strong>derivative of the function</strong>, which is used by different <a class="reference external" href="http://docs.astropy.org/en/stable/modeling/#id21">fitters</a>, for example the <code class="docutils literal notranslate"><span class="pre">LevMarLSQFitter()</span></code>.</p>
@@ -1115,7 +1115,7 @@ <h3>Full custom model<a class="headerlink" href="#full-custom-model" title="Link
11151115
</div>
11161116
</div>
11171117
<div class="cell_output docutils container">
1118-
<img alt="_images/46b1bb6d1edea5e2d4d8c9d60dd07646a8debdf5975655bac0b281f852baff67.png" src="_images/46b1bb6d1edea5e2d4d8c9d60dd07646a8debdf5975655bac0b281f852baff67.png" />
1118+
<img alt="_images/73e29b6c1d8175d93367fdd7722fd89930f1187217deb91452b9b4ed72b18fa6.png" src="_images/73e29b6c1d8175d93367fdd7722fd89930f1187217deb91452b9b4ed72b18fa6.png" />
11191119
</div>
11201120
</div>
11211121
<div class="cell docutils container">
@@ -1130,9 +1130,9 @@ <h3>Full custom model<a class="headerlink" href="#full-custom-model" title="Link
11301130
Outputs: (&#39;y&#39;,)
11311131
Model set size: 1
11321132
Parameters:
1133-
a b c d
1134-
----------------- ------------------ ------------------ ------------------
1135-
3.010622137988566 1.9989300570434283 3.9905960395565723 1.0039014197353062
1133+
a b c d
1134+
------------------ ------------------ ----------------- ------------------
1135+
2.8859510397819435 1.9877027580241713 4.082655746288697 0.9908546289146978
11361136
</pre></div>
11371137
</div>
11381138
</div>
@@ -1144,7 +1144,7 @@ <h3>Full custom model<a class="headerlink" href="#full-custom-model" title="Link
11441144
</div>
11451145
</div>
11461146
<div class="cell_output docutils container">
1147-
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>np.float64(2.618555709093496)
1147+
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>np.float64(2.822160801510391)
11481148
</pre></div>
11491149
</div>
11501150
</div>
@@ -1177,7 +1177,7 @@ <h3>Exercise<a class="headerlink" href="#id4" title="Link to this heading">#</a>
11771177
</div>
11781178
</div>
11791179
<div class="cell_output docutils container">
1180-
<img alt="_images/d5efcd2189269486eef4f8676216c111d7a1c6daeebf90c8e7fe0efea475bd38.png" src="_images/d5efcd2189269486eef4f8676216c111d7a1c6daeebf90c8e7fe0efea475bd38.png" />
1180+
<img alt="_images/67fdfbc60b77570e7297b92e6bf0c78e8c01e46c4f61f765b86fcc345488c03c.png" src="_images/67fdfbc60b77570e7297b92e6bf0c78e8c01e46c4f61f765b86fcc345488c03c.png" />
11811181
</div>
11821182
</div>
11831183
</section>

0 commit comments

Comments
 (0)