<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.swarma.org/index.php?action=history&amp;feed=atom&amp;title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B</id>
	<title>使用python制造渗流模型 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.swarma.org/index.php?action=history&amp;feed=atom&amp;title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B"/>
	<link rel="alternate" type="text/html" href="https://wiki.swarma.org/index.php?title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;action=history"/>
	<updated>2026-11-03T18:44:41Z</updated>
	<subtitle>本wiki的该页面的版本历史</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.swarma.org/index.php?title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;diff=34702&amp;oldid=prev</id>
		<title>13944556914：/* 拟合cluster size的分布 */</title>
		<link rel="alternate" type="text/html" href="https://wiki.swarma.org/index.php?title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;diff=34702&amp;oldid=prev"/>
		<updated>2024-05-21T03:22:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;拟合cluster size的分布&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024年5月21日 (二) 03:22的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l110&quot; &gt;第110行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第110行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;category&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;python]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Category&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;待润色&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;[[category:旧词条迁移&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>13944556914</name></author>
	</entry>
	<entry>
		<id>https://wiki.swarma.org/index.php?title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;diff=15473&amp;oldid=prev</id>
		<title>思无涯咿呀咿呀：创建页面，内容为“==简介==  关于渗流模型的简介我们可以看这个页面：渗流模型  ==构建最基本的渗流模型==  调用包并设定参数  &lt;syntaxhighlight…”</title>
		<link rel="alternate" type="text/html" href="https://wiki.swarma.org/index.php?title=%E4%BD%BF%E7%94%A8python%E5%88%B6%E9%80%A0%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;diff=15473&amp;oldid=prev"/>
		<updated>2020-10-16T09:40:39Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“==简介==  关于渗流模型的简介我们可以看这个页面：&lt;a href=&quot;/index.php?title=%E6%B8%97%E6%B5%81%E6%A8%A1%E5%9E%8B&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;渗流模型（页面不存在）&quot;&gt;渗流模型&lt;/a&gt;  ==构建最基本的渗流模型==  调用包并设定参数  &amp;lt;syntaxhighlight…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==简介==&lt;br /&gt;
&lt;br /&gt;
关于渗流模型的简介我们可以看这个页面：[[渗流模型]]&lt;br /&gt;
&lt;br /&gt;
==构建最基本的渗流模型==&lt;br /&gt;
&lt;br /&gt;
调用包并设定参数&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    from pylab import *&lt;br /&gt;
    from scipy.ndimage import measurements&lt;br /&gt;
    import statsmodels.api as sm&lt;br /&gt;
&lt;br /&gt;
    L = 100&lt;br /&gt;
    r = rand(L,L)&lt;br /&gt;
    p = 0.4&lt;br /&gt;
    z = r &amp;lt; p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
绘图&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_1.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    imshow(z, origin='lower', interpolation='nearest')&lt;br /&gt;
    colorbar()&lt;br /&gt;
    title(&amp;quot;Matrix&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==标记不同的cluster==&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_2.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    lw, num = measurements.label(z)&lt;br /&gt;
    imshow(lw, origin='lower', interpolation='nearest')&lt;br /&gt;
    colorbar()&lt;br /&gt;
    title(&amp;quot;Labeled clusters&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
可以随机洗牌cluster label使得颜色更清楚&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_3.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    b = arange(lw.max() + 1)&lt;br /&gt;
    shuffle(b)&lt;br /&gt;
    shuffledLw = b[lw]&lt;br /&gt;
    imshow(shuffledLw, origin='lower', interpolation='nearest')&lt;br /&gt;
    colorbar()&lt;br /&gt;
    title(&amp;quot;Labeled clusters&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
还可以令cluster的颜色与大小正比&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_4.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    area = measurements.sum(z, lw, index=arange(lw.max() + 1))&lt;br /&gt;
    areaImg = area[lw]&lt;br /&gt;
    im3 = imshow(areaImg, origin='lower', interpolation='nearest')&lt;br /&gt;
    colorbar()&lt;br /&gt;
    title(&amp;quot;Clusters by area&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==给最大cluster加一个方框==&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_5.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    im3 = imshow(areaImg, origin='lower', interpolation='nearest')&lt;br /&gt;
    colorbar()&lt;br /&gt;
    title(&amp;quot;Clusters by area&amp;quot;)&lt;br /&gt;
    sliced = measurements.find_objects(areaImg == areaImg.max())&lt;br /&gt;
    if(len(sliced) &amp;gt; 0):&lt;br /&gt;
        sliceX = sliced[0][1]&lt;br /&gt;
        sliceY = sliced[0][0]&lt;br /&gt;
        plotxlim=im3.axes.get_xlim()&lt;br /&gt;
        plotylim=im3.axes.get_ylim()&lt;br /&gt;
        plot([sliceX.start, sliceX.start, sliceX.stop, sliceX.stop, sliceX.start], \&lt;br /&gt;
                          [sliceY.start, sliceY.stop, sliceY.stop, sliceY.start, sliceY.start], \&lt;br /&gt;
                          color=&amp;quot;red&amp;quot;)&lt;br /&gt;
        xlim(plotxlim)&lt;br /&gt;
        ylim(plotylim)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==拟合cluster size的分布==&lt;br /&gt;
&lt;br /&gt;
[[File:Percolation_figure_6.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    def RankOrderPlot(data):&lt;br /&gt;
        d=array(data)&lt;br /&gt;
        d = d[d&amp;gt;0]&lt;br /&gt;
        t=array(sorted(d,key=lambda x:-x))&lt;br /&gt;
        r=array(range(1,len(d)+1))   &lt;br /&gt;
        y = log(t)&lt;br /&gt;
        x = log(r)&lt;br /&gt;
        X = sm.add_constant(x, prepend=True)&lt;br /&gt;
        res = sm.OLS(y,X).fit()&lt;br /&gt;
        C,beta = res.params&lt;br /&gt;
        plt.plot(r,t,&amp;quot;o&amp;quot;,color=&amp;quot;b&amp;quot;)&lt;br /&gt;
        plt.plot(r,exp(C)*r**beta,&amp;quot;r-&amp;quot;)&lt;br /&gt;
        plt.xscale('log')&lt;br /&gt;
        plt.yscale('log')&lt;br /&gt;
        plt.text(max(r)/2,max(t)/100,&amp;quot;beta = &amp;quot; + str(round(beta,2)))&lt;br /&gt;
        print beta&lt;br /&gt;
         &lt;br /&gt;
    RankOrderPlot(area)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[category:python]]&lt;br /&gt;
[[category:旧词条迁移]]&lt;/div&gt;</summary>
		<author><name>思无涯咿呀咿呀</name></author>
	</entry>
</feed>