From f7b749ce64c001319065e42663551f1f619e4df8 Mon Sep 17 00:00:00 2001 From: jwhite Date: Tue, 10 Dec 2024 08:11:11 -0500 Subject: [PATCH] added hyper par explore to variogram notebook - yikes --- ...standing_variograms_and_realizations.ipynb | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/examples/understanding_variograms_and_realizations.ipynb b/examples/understanding_variograms_and_realizations.ipynb index 236b321..73227dc 100644 --- a/examples/understanding_variograms_and_realizations.ipynb +++ b/examples/understanding_variograms_and_realizations.ipynb @@ -171,6 +171,127 @@ "\n", "\n" ] + }, + { + "cell_type": "markdown", + "id": "eba1e58f-48fa-4b48-b268-f3da3d484cf8", + "metadata": {}, + "source": [ + "# These go to 11...\n", + "\n", + "Now let's explore what happens when we introduce hyper parameteres on the property variogram. In essense, we are now going to treat the bearing, anisotropy, and correlation length of the above variogram as themselves being described by variograms - wat?! Its like geostatistical inception..." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "066d8f57-6c0c-4d1f-8112-baff57fc7c9c", + "metadata": {}, + "outputs": [], + "source": [ + "nrow = 80\n", + "ncol = 50\n", + "x = np.cumsum(np.ones((nrow,ncol)),axis=1)\n", + "y = np.cumsum(np.ones((nrow,ncol)),axis=0)\n", + "area = 1\n", + "active = 1\n", + "mean = 1 #log10 HK mean\n", + "var = 0.1 #log10 HK variance\n", + "ec = x.flatten()\n", + "nc = y.flatten()\n", + "transtype = 0 #not log transformed\n", + "vtype = 1 #exponential variogram\n", + "power = 0\n", + "nreal = 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4efe47ec-95d4-4644-893b-f240c6385e9a", + "metadata": {}, + "outputs": [], + "source": [ + "def plot_real(b_mean, b_var,b_corrlen,b_anisotropy,b_bearing,\n", + " a_mean, a_var, a_corrlen,a_anisotropy,a_bearing,\n", + " c_mean, c_var, c_corrlen,c_anisotropy,c_bearing ):\n", + " fig, axes = plt.subplots(1,4,figsize=(10,3))\n", + " #axes.clear()\n", + " #reset the random seed so that the underlying pseudo random numbers dont change\n", + " lib.initialize_randgen(1123455)\n", + " # generate one realization\n", + " barr = lib.fieldgen2d_sva(ec,nc,area,int(active),b_mean,b_var,b_corrlen,b_anisotropy,b_bearing,transtype,vtype,power,nreal)\n", + " \n", + " cb = axes[0].imshow(barr[:,0].reshape((nrow,ncol)),cmap=\"magma\")\n", + " plt.colorbar(cb,ax=axes[0])\n", + " axes[0].set_title(\"bearing\")\n", + " \n", + " aarr = lib.fieldgen2d_sva(ec,nc,area,int(active),a_mean,a_var,a_corrlen,a_anisotropy,a_bearing,transtype,vtype,power,nreal)\n", + " \n", + " cb = axes[1].imshow(aarr[:,0].reshape((nrow,ncol)),cmap=\"magma\")\n", + " axes[1].set_title(\"aniso\")\n", + " plt.colorbar(cb,ax=axes[1])\n", + " \n", + " carr = lib.fieldgen2d_sva(ec,nc,area,int(active),c_mean,c_var,c_corrlen,c_anisotropy,c_bearing,transtype,vtype,power,nreal)\n", + " \n", + " cb = axes[2].imshow(carr[:,0].reshape((nrow,ncol)),cmap=\"magma\")\n", + " axes[2].set_title(\"corrlen\")\n", + " plt.colorbar(cb,ax=axes[2])\n", + " \n", + " arrs = lib.fieldgen2d_sva(ec,nc,area,int(active),mean,var,carr[:,0],aarr[:,0],barr[:,0],transtype,vtype,power,nreal)\n", + " # plot\n", + " \n", + " cb = axes[3].imshow(arrs[:,0].reshape((nrow,ncol)),vmin=0.0,vmax=2,cmap=\"magma\")\n", + " axes[3].set_title(\"HK\")\n", + " plt.colorbar(cb,ax=axes[3])\n", + " #$plt.colorbar(cb,ax=axes,label=\"$log_{10}$ HK\")\n", + " for ax in axes:\n", + " #ax.set_xlabel(\"column\")\n", + " #ax.set_ylabel(\"row\")\n", + " #ax.set_title(\"a random realization of HK\",loc=\"left\")\n", + " ax.set_xticks([])\n", + " ax.set_yticks([])\n", + " \n", + " plt.show()\n", + " \n", + " " + ] + }, + { + "cell_type": "markdown", + "id": "77c2cc90-803f-4c6d-b857-045ce0788676", + "metadata": {}, + "source": [ + "The 'b_' prefix is the for bearing variogram, 'a_' is the anisotropy variogram, and, you guessed it, 'c_' is for the correlation length variogram...This is complex stuff, but we found that these sliders really helped us start to build some intution regarding how these hyper parameters interact...." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c844dc6-c255-4361-addd-c8ef8e0796de", + "metadata": {}, + "outputs": [], + "source": [ + "_ = interact(plot_real,b_mean=(0,90,1), b_var=(0.1,50,1),b_corrlen=(1,100,10),b_anisotropy=(1,10,0.5),b_bearing=(0,90,1),\n", + " a_mean=(1,10,1), a_var=(0.1,10.0,0.1),a_corrlen=(10,500,10),a_anisotropy=(1,10,0.5),a_bearing=(0,90,1),\n", + " c_mean=(1,50,1), c_var=(0.1,50.0,0.1),c_corrlen=(1,1000,10),c_anisotropy=(1,50,1),c_bearing=(0,90,1),)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9d33a4ee-4706-402c-a65b-5d833da48ebb", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d85e0325-afb4-4aa1-a08c-5643017e6513", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {