diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57ff732 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Unit test output and cache +__pycache__/ +*.pyc + +# Temporary files +*.*~ +*.swp +*.swo + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..aa25161 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +sudo: false + +language: python + +install: + - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; + - bash miniconda.sh -b -p $HOME/miniconda + - export PATH="$HOME/miniconda/bin:$PATH" + - hash -r + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + - conda info -a + - conda install numpy pandas numba scipy statsmodels + +script: + - python -m unittest discover + diff --git a/README.md b/README.md index 928541c..b092aba 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,10 @@

-[![Documentation Status](https://readthedocs.org/projects/geostatspy/badge/?version=latest)](https://geostatspy.readthedocs.io/en/latest/?badge=latest) -## GeostatsPy Package +## GeostatsPy Package [![Build Status](https://travis-ci.org/GeostatsGuy/GeostatsPy.svg?branch=master)](https://travis-ci.org/GeostatsGuy/GeostatsPy) +======= +[![Documentation Status](https://readthedocs.org/projects/geostatspy/badge/?version=latest)](https://geostatspy.readthedocs.io/en/latest/?badge=latest) The GeostatsPy Package brings GSLIB: Geostatistical Library (Deutsch and Journel, 1998) functions to Python. GSLIB is extremely robust and practical set of code for building spatial modeling workflows. I need it in Python to support my students in my **Data Analytics**, **Geostatistics** and **Machine Learning** courses. diff --git a/geostatspy/tests/__init__.py b/geostatspy/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/geostatspy/tests/sample_data.csv b/geostatspy/tests/sample_data.csv new file mode 100644 index 0000000..dea4a59 --- /dev/null +++ b/geostatspy/tests/sample_data.csv @@ -0,0 +1,263 @@ +X,Y,Facies,Porosity,Perm,AI +100.0,900.0,1.0,0.10018682419124399,1.3638904728480539,5110.699751465372 +100.0,800.0,0.0,0.10794662863411604,12.576844998606088,4671.458560255537 +100.0,700.0,0.0,0.08535672421423313,5.984520458439763,6127.548005958979 +100.0,600.0,0.0,0.10845998338418149,2.4466782403893257,5201.6379955872735 +100.0,500.0,0.0,0.10246834117698145,1.9522636749783289,3835.2703222930277 +100.0,400.0,0.0,0.11057876909492648,3.6919076901654972,5295.267190821814 +100.0,300.0,0.0,0.08893621261119132,1.0735819048532833,6744.996105715771 +100.0,200.0,0.0,0.10209362141625762,2.396189192554137,5947.338115410894 +100.0,100.0,1.0,0.13745312416710517,5.727602877832081,5823.241782736519 +200.0,900.0,1.0,0.13706175229991896,14.771314229160836,5621.146994439374 +200.0,800.0,1.0,0.12598387676231093,10.675435560783528,4292.700500464626 +200.0,700.0,0.0,0.12175428949827675,3.0858253664765947,5397.40021829629 +200.0,600.0,0.0,0.09514727800973659,0.9625654663384925,4619.7864776869155 +200.0,500.0,0.0,0.087499881453658,1.8232715185978983,4949.880889907528 +200.0,400.0,0.0,0.09858270435157662,4.571021440257367,5789.623270093056 +200.0,300.0,0.0,0.10744025130132935,13.581879773101154,7881.898531340294 +200.0,200.0,0.0,0.0935419548437891,0.40880328351223283,6104.848941026725 +200.0,100.0,0.0,0.07994472198843103,0.7345484564681812,6485.732295975461 +300.0,900.0,1.0,0.11151587797289962,27.99981687958923,4183.46677337813 +300.0,800.0,1.0,0.1194685079421786,61.005351844470965,5224.543978491442 +300.0,700.0,1.0,0.13419997284825042,44.595946033674956,4556.5405550607975 +300.0,600.0,1.0,0.16120488730589033,190.7401408446768,3997.088593646979 +300.0,500.0,1.0,0.10717381422834814,13.301607456849725,5684.914852310402 +300.0,400.0,1.0,0.11167357347256232,10.851073760851108,5499.752990128663 +300.0,300.0,0.0,0.1052373047910865,6.312197651179605,4715.683507460024 +300.0,200.0,0.0,0.10326165223728052,2.817351328372321,6217.196211644737 +300.0,100.0,0.0,0.09905700249175467,3.188778219134942,6456.338011724537 +400.0,900.0,0.0,0.07849403285877754,1.1098023610952135,5440.288662248112 +400.0,800.0,0.0,0.1104477685531558,4.116216873588337,5956.295434393631 +400.0,700.0,1.0,0.12278782591133688,18.826989146673785,4937.336807748967 +400.0,600.0,1.0,0.12083589292013495,5.97043070310137,4040.57250873449 +400.0,500.0,1.0,0.11396159676653493,132.12410961253704,4459.0133101291285 +400.0,400.0,1.0,0.08384223178759119,5.558784777140966,5953.7824802191335 +400.0,300.0,1.0,0.1179838625060697,1.9926762138348477,5557.63834672926 +400.0,200.0,0.0,0.11689957793243001,6.63131132293633,6735.728918514027 +400.0,100.0,0.0,0.06638102407189893,0.03361069489937714,6124.087440854833 +500.0,900.0,0.0,0.09336675168329747,1.3079442741673917,4873.950935685428 +500.0,800.0,0.0,0.08401707123081659,0.7714038236026848,5284.835639100413 +500.0,700.0,0.0,0.10982278843797226,52.50087041178072,6581.836027891874 +500.0,600.0,1.0,0.12196972451794875,8.22227139497363,5296.785236768361 +500.0,500.0,1.0,0.11985363617695435,3.1422874718956963,5051.547696751199 +500.0,400.0,0.0,0.11143977089356705,6.312197651179605,5515.918645534619 +500.0,300.0,0.0,0.09471855319762608,11.788525755442995,4240.0227490702 +500.0,200.0,0.0,0.10037281186136107,0.402478092400951,5768.851277156438 +500.0,100.0,0.0,0.06993975273254027,1.182514940322063,5197.506850991071 +600.0,900.0,1.0,0.14600473158981542,18.071089880107582,4440.401730748488 +600.0,800.0,1.0,0.12137293556138709,4.776925425457075,5471.197107530598 +600.0,700.0,0.0,0.10991150299301086,12.384495645219042,3595.5869773974437 +600.0,600.0,0.0,0.05887104264089544,0.03725675658534492,5621.468640733969 +600.0,500.0,0.0,0.07368657740084095,0.48257707102042086,4270.019657633609 +600.0,400.0,1.0,0.11214952488143126,22.804211917465146,5675.209132205283 +600.0,300.0,1.0,0.13341010804037962,22.701075125761736,5364.430671451201 +600.0,200.0,1.0,0.12170227213797734,73.9866480319918,4811.007728101518 +600.0,100.0,1.0,0.14649982394984506,42.39604391131162,4204.1508932377155 +700.0,900.0,1.0,0.11125780753511684,0.381031646211926,3919.7849828185913 +700.0,800.0,1.0,0.12320599862579112,13.174392727828975,4466.6193570157275 +700.0,700.0,1.0,0.1148840501157201,5.12137770994541,4058.3242577645387 +700.0,600.0,1.0,0.18968184243131853,464.77304833297944,3182.259679934904 +700.0,500.0,1.0,0.17177371654277374,348.6815876283871,3980.4722264374973 +700.0,400.0,1.0,0.12063598644266421,4.193052587390703,3893.032687418438 +700.0,300.0,0.0,0.12697231845933518,0.5013064337715765,4347.680865636528 +700.0,200.0,1.0,0.13667649353915268,8.450500017603046,4313.194321155285 +700.0,100.0,1.0,0.10838419196977514,2.11324738778481,5504.17143343777 +800.0,900.0,1.0,0.15206097968587176,68.36286112289045,5382.350273474711 +800.0,800.0,1.0,0.15460803670450146,29.06543342101495,5319.652740514587 +800.0,700.0,1.0,0.15911477281586128,82.66957696390789,2920.1973131034138 +800.0,600.0,1.0,0.19832813338553315,59.45468028222567,2298.917392200183 +800.0,500.0,1.0,0.17944802223309722,279.4348221732339,3342.034948496855 +800.0,400.0,1.0,0.1474692737105485,46.47821054038469,5167.071594520237 +800.0,300.0,1.0,0.10372638294927211,18.9331113323464,3999.0610204834256 +800.0,200.0,1.0,0.1057604137970291,11.57250657318402,3402.261798857431 +800.0,100.0,0.0,0.12440704926026902,7.739105135779566,5274.532659565403 +900.0,900.0,0.0,0.11759455123520711,12.433996190862308,6242.704810094636 +900.0,800.0,0.0,0.10260877074429514,2.433846781545574,5657.883398019215 +900.0,700.0,1.0,0.13078550068697872,19.97702041281352,4541.434124808648 +900.0,600.0,1.0,0.16519963959010553,62.67596715191265,2794.921230412734 +900.0,500.0,1.0,0.19958388057499551,86.86469299265028,2716.5968735884826 +900.0,400.0,1.0,0.1991077239238541,18.660459484410445,3982.360726777215 +900.0,300.0,1.0,0.1406246255964449,17.31411759076002,3338.73403489898 +900.0,200.0,0.0,0.10135617001222788,4.557779673990306,4554.984615776822 +900.0,100.0,0.0,0.09183376067354754,1.280257266170677,4573.656072180477 +925.0,559.0,1.0,0.2075981221200499,525.3793796125435,3226.116793522202 +935.0,559.0,1.0,0.2092532233957145,625.725523039946,3193.3655110673967 +945.0,559.0,1.0,0.18590380102131016,369.9805178277887,3058.3876856845577 +955.0,559.0,1.0,0.17832305472109494,74.21505759018655,3386.1827215568474 +965.0,559.0,1.0,0.20896639093400027,378.94247488541754,3322.665656530933 +975.0,559.0,1.0,0.2245147587202604,1023.1567776518684,3309.412238228444 +985.0,559.0,1.0,0.23295841115618188,133.73898872639396,3187.198825182578 +995.0,559.0,1.0,0.22165605381661185,54.80614211610685,2742.649452634195 +1005.0,559.0,1.0,0.22165605381661185,54.80614211610685,2742.649452634195 +925.0,549.0,1.0,0.19654212899117618,353.7121062825318,3275.8281348319874 +935.0,549.0,1.0,0.19136570536641626,245.14674778001998,3076.564247084902 +945.0,549.0,1.0,0.1907762011220936,164.89569165399195,3331.0222319933587 +955.0,549.0,1.0,0.18139882087201276,374.29892530151193,3181.5572811391635 +965.0,549.0,1.0,0.18822009683141872,456.83576323433107,3317.2562515741765 +975.0,549.0,1.0,0.2227008194875126,285.52968267604166,3465.918196667594 +985.0,549.0,1.0,0.24229788453620238,99.35594227710553,3233.4447606608182 +995.0,549.0,1.0,0.21447855585342995,246.21586459169467,2834.925618311057 +1005.0,549.0,1.0,0.21447855585342995,246.21586459169467,2834.925618311057 +925.0,539.0,1.0,0.20392992009294553,211.16329588243832,3442.8852448752787 +935.0,539.0,1.0,0.19907220623896849,89.89307252309634,3240.7814534418203 +945.0,539.0,1.0,0.19522038771290134,151.09631939624126,3474.8212193385225 +955.0,539.0,1.0,0.19815604331036252,359.2057732737164,3505.604576525038 +965.0,539.0,1.0,0.19780205325321315,617.27394109991,2944.344742173761 +975.0,539.0,1.0,0.22527343013470633,329.0261331338964,3351.6034016058543 +985.0,539.0,1.0,0.22356118298096953,152.0306802975061,3269.944400255212 +995.0,539.0,1.0,0.20050107484347834,159.74556607773835,2856.748634914292 +1005.0,539.0,1.0,0.20050107484347834,159.74556607773835,2856.748634914292 +925.0,529.0,1.0,0.19635772198806625,409.2985499932747,2394.1738426580587 +935.0,529.0,1.0,0.2075408187872148,238.8721410340954,3133.6801438572866 +945.0,529.0,1.0,0.2078759152529629,898.5872876653083,3110.7326293619726 +955.0,529.0,1.0,0.19808107794511898,1113.9710764628417,3177.6357369561765 +965.0,529.0,1.0,0.19928274642627056,1191.4849647008493,2931.668141248503 +975.0,529.0,1.0,0.2146116177653603,1548.094062498347,3167.185377313024 +985.0,529.0,1.0,0.22406365741576706,385.59631385452775,3116.0136471282876 +995.0,529.0,1.0,0.2116381417477095,276.1608148189531,2669.2745699982497 +1005.0,529.0,1.0,0.2116381417477095,276.1608148189531,2669.2745699982497 +925.0,519.0,1.0,0.18876582402416361,220.99558652039218,2538.1855753476148 +935.0,519.0,1.0,0.20958367751439044,429.289556119189,2948.6137087539378 +945.0,519.0,1.0,0.20627125818708453,1450.5330939819567,3008.422992418992 +955.0,519.0,1.0,0.21331998563906807,2090.638557801792,2315.9419221443127 +965.0,519.0,1.0,0.22965374044739356,2642.999828972705,2717.4590163884686 +975.0,519.0,1.0,0.21879677475334774,1040.3675293907656,2784.4248376102805 +985.0,519.0,1.0,0.20709801642801917,281.0099138594848,2839.159065668519 +995.0,519.0,1.0,0.21260272075704478,54.667195282273234,2577.7146778135007 +1005.0,519.0,1.0,0.21260272075704478,54.667195282273234,2577.7146778135007 +925.0,509.0,1.0,0.18985144235596524,168.0346557528904,2137.5149609128725 +935.0,509.0,1.0,0.21153396434575372,1320.4968619506328,2818.455336238058 +945.0,509.0,1.0,0.20591855287461144,659.9865777458823,2502.904719915323 +955.0,509.0,1.0,0.2277136561074601,1525.247066045778,2512.061433701275 +965.0,509.0,1.0,0.20798639973492844,605.3038112818624,2247.4715596804244 +975.0,509.0,1.0,0.22703799834762295,719.6093510171057,2419.2556554475095 +985.0,509.0,1.0,0.20660543914946353,91.83711164988883,2076.4911788252653 +995.0,509.0,1.0,0.19927234618347278,14.661910482018534,2351.3543713635427 +1005.0,509.0,1.0,0.19927234618347278,14.661910482018534,2351.3543713635427 +925.0,499.0,1.0,0.19786345368149705,185.68966667503764,2227.215119628385 +935.0,499.0,1.0,0.213924597348356,523.287810211899,2579.032897299612 +945.0,499.0,1.0,0.19442558315123515,600.7116981506385,2339.3572605686804 +955.0,499.0,1.0,0.19938031919416188,315.07226366189417,2756.5495551183203 +965.0,499.0,1.0,0.19127781068923955,415.0530640821479,2381.5104381106858 +975.0,499.0,1.0,0.21740828360471964,408.8535113419191,1844.1668803881744 +985.0,499.0,1.0,0.21342793626643802,68.27614792959895,2547.5261134441866 +995.0,499.0,1.0,0.20922111737419552,169.78032672940213,2630.578997625163 +1005.0,499.0,1.0,0.20922111737419552,169.78032672940213,2630.578997625163 +925.0,489.0,1.0,0.19561230864987633,344.2839811807561,2653.4374982350755 +935.0,489.0,1.0,0.20194309984966863,550.7403587655334,2899.8267922145255 +945.0,489.0,1.0,0.19952748417329852,137.00335797419163,2655.69543549023 +955.0,489.0,1.0,0.20618564732979894,249.76808399105948,2685.9304338434076 +965.0,489.0,1.0,0.20534096806908547,41.43092508296011,2693.8071298072646 +975.0,489.0,1.0,0.22555335012900568,21.109084754022472,2412.8753300711987 +985.0,489.0,1.0,0.1969456211901015,73.13304020087203,2672.29456724355 +995.0,489.0,1.0,0.18831110868471468,460.4949857426108,2792.8043217380523 +1005.0,489.0,1.0,0.18831110868471468,460.4949857426108,2792.8043217380523 +925.0,479.0,1.0,0.19223291500649764,366.57498513142997,3126.7984486193573 +935.0,479.0,1.0,0.19651470295711743,452.95916107296637,2947.867712578927 +945.0,479.0,1.0,0.20824651444544548,23.41595847021097,2813.2301872491407 +955.0,479.0,1.0,0.20540411482941018,4.015954970545069,2546.560835401157 +965.0,479.0,1.0,0.21622317470145136,68.437274365465,3029.119013684801 +975.0,479.0,1.0,0.1959977814900462,69.33657649142626,2493.128177193382 +985.0,479.0,1.0,0.1942432774430868,81.31672089206798,2621.528995670652 +995.0,479.0,1.0,0.16769734077515258,76.67720137514318,2745.5456567551855 +1005.0,479.0,1.0,0.16769734077515258,76.67720137514318,2745.5456567551855 +925.0,469.0,1.0,0.18024305266361995,369.44423191597554,3433.3810778594775 +935.0,469.0,1.0,0.20337301639403482,245.14674778001998,3374.4426934694548 +945.0,469.0,1.0,0.2010123933857162,14.209132333085824,3239.517314438908 +955.0,469.0,1.0,0.19843590793422866,26.197239001014434,2889.1966473390326 +965.0,469.0,1.0,0.200588514509073,40.789886887729786,3116.3938138089197 +975.0,469.0,1.0,0.1943485253522326,416.3344045606811,2304.41713684666 +985.0,469.0,1.0,0.18796688149247742,151.01415200154116,2569.096425577473 +995.0,469.0,1.0,0.18146665223898334,646.7189487151862,2822.556788984021 +1005.0,469.0,1.0,0.18146665223898334,646.7189487151862,2822.556788984021 +925.0,459.0,1.0,0.18532291404493628,579.3179045066872,4149.705567190633 +935.0,459.0,1.0,0.2116349007534024,260.54616698711834,3668.518208908684 +945.0,459.0,1.0,0.2232238565572045,177.91139026648986,3574.787913386569 +955.0,459.0,1.0,0.19922487350618795,45.002088129135004,3394.563038166401 +965.0,459.0,1.0,0.18090574103604964,103.53069238756798,3102.1966694917683 +975.0,459.0,1.0,0.20806782677296598,88.77542744068776,2843.973554477442 +985.0,459.0,1.0,0.19364734282390905,344.5337721876469,2951.5872720153757 +995.0,459.0,1.0,0.18624075307576238,1135.5884275632898,2802.2655388604135 +1005.0,459.0,1.0,0.18624075307576238,1135.5884275632898,2802.2655388604135 +925.0,449.0,1.0,0.17985589181923073,259.5559738640502,4147.03237568935 +935.0,449.0,1.0,0.2093733665840673,368.50760137930894,4249.477922991474 +945.0,449.0,1.0,0.23789231081184453,174.61958317465863,3740.5994456874278 +955.0,449.0,1.0,0.20780606693481368,61.005351844470965,3445.0957923341525 +965.0,449.0,1.0,0.19819511711595827,73.57194467648296,3337.286626573305 +975.0,449.0,1.0,0.19952883717122133,122.74712331197824,2899.2308585889577 +985.0,449.0,1.0,0.19423405559520981,383.92198022722357,3327.8320693052033 +995.0,449.0,1.0,0.1852697170934972,545.8689156884968,3262.2669449312775 +1005.0,449.0,1.0,0.1852697170934972,545.8689156884968,3262.2669449312775 +201.0,456.0,0.0,0.09968221870817712,0.5463959629187493,5018.355476445646 +211.0,456.0,0.0,0.07740535665876827,0.43645710737711724,4999.634872784169 +221.0,456.0,0.0,0.10822248050597075,0.2737837397153913,4257.198482372141 +231.0,456.0,0.0,0.10357339843049425,0.9326711138286439,4281.907990808904 +241.0,456.0,0.0,0.09313734054099268,0.7360149791993681,4766.594300854964 +251.0,456.0,0.0,0.09228212733852648,0.7130272981334832,5227.566288186138 +201.0,446.0,0.0,0.08267911881572712,0.31032797267368556,4746.224951607103 +211.0,446.0,0.0,0.10489346220941345,0.5016701504871297,4627.935734352864 +221.0,446.0,0.0,0.1121867117233961,0.6507562210309606,4186.979661503931 +231.0,446.0,0.0,0.1234558897601921,0.35334816427350557,4576.391083162268 +241.0,446.0,0.0,0.09943140324201918,0.9433861691159693,4856.784760507655 +251.0,446.0,0.0,0.10725296895334706,1.9793525100133869,4876.582564762905 +201.0,436.0,0.0,0.09586813032902072,0.31623539424022756,5255.707995681127 +211.0,436.0,0.0,0.10810412933158932,0.3828321787797189,4406.232269328367 +221.0,436.0,0.0,0.10458030441376456,4.985772347998514,4359.1690217357545 +231.0,436.0,0.0,0.10198737625284975,2.011553152601819,4483.7827572542255 +241.0,436.0,0.0,0.0960614479710341,3.1640129342516694,4798.220252935908 +251.0,436.0,0.0,0.10986886188543475,2.202042074477867,5174.155582831291 +201.0,426.0,0.0,0.09616707565190083,0.4006578015120845,5263.542111743446 +211.0,426.0,0.0,0.10444379104925805,1.7139536256900871,4867.80459935529 +221.0,426.0,0.0,0.10423892063222241,2.620725151300174,4996.621627891104 +231.0,426.0,0.0,0.10646956540316789,5.584039758436255,4919.074870716937 +241.0,426.0,0.0,0.09597424750004933,0.590701575557933,5209.507569206991 +251.0,426.0,0.0,0.08326918052585465,0.24445087389329032,5570.604404653525 +201.0,416.0,0.0,0.10317334563812994,1.5521195665011494,5473.343862218812 +211.0,416.0,0.0,0.10973001787024043,1.2115980317465367,5363.998058418278 +221.0,416.0,0.0,0.10183590509771795,4.138668288411445,5408.955497093306 +231.0,416.0,0.0,0.08159289710132997,1.943786569251602,5467.410117069775 +241.0,416.0,0.0,0.08297152556632098,0.5937081471987925,5731.918531206584 +251.0,416.0,0.0,0.11384977187874785,1.0033744546457903,5822.467913838125 +201.0,406.0,0.0,0.09858270435157662,4.571021440257367,5789.623270093056 +211.0,406.0,0.0,0.10364690186820885,2.826048978412023,5683.5528504490685 +221.0,406.0,0.0,0.10409211224825231,1.530877715603478,5791.529776705401 +231.0,406.0,0.0,0.0880967322180378,1.2006634066229918,5764.338393414016 +241.0,406.0,0.0,0.07219228150018958,0.34299559770877763,6204.9475063556365 +251.0,406.0,0.0,0.07135772855421804,1.0185888839639048,6044.486026143713 +201.0,396.0,0.0,0.11365358854454079,1.4752865402881519,5683.619880648882 +211.0,396.0,0.0,0.11413052637449723,6.36852896198514,5725.334802781438 +221.0,396.0,0.0,0.11498230686072514,0.8991287746885953,5772.1825917557 +231.0,396.0,0.0,0.09135158345036162,1.030291011375062,5971.466274069611 +241.0,396.0,0.0,0.09963507408426875,1.4204257299867942,6255.668308908236 +251.0,396.0,0.0,0.09295427633788103,0.8022151446504413,6213.100647936569 +201.0,386.0,0.0,0.11889014528873754,4.711549832089875,5696.740780184675 +211.0,386.0,0.0,0.11271513828169996,2.144124484134272,5937.92900548158 +221.0,386.0,0.0,0.14165700755559646,3.4460967873394956,6305.590360606948 +231.0,386.0,0.0,0.1274481105185351,2.1006404933952365,5691.475918731471 +241.0,386.0,0.0,0.10514933027040006,0.5449119052681606,5680.9896082083815 +251.0,386.0,0.0,0.08289516284596656,0.5697675833337121,5895.900484378325 +201.0,376.0,0.0,0.10783466796944925,0.9182404003856058,6070.362674039411 +211.0,376.0,0.0,0.11970485845340621,2.9560284928568463,5859.477679769183 +221.0,376.0,0.0,0.11289206795985547,3.7957615701260514,6148.386967430093 +231.0,376.0,0.0,0.11456252183289292,1.4186240258325578,5591.9291346610025 +241.0,376.0,0.0,0.09624602263115413,1.241846658854499,5800.226128065682 +251.0,376.0,0.0,0.08879656556555302,0.40939670309416426,5290.61725591188 +40.0,549.0,0.0,0.11159446423668314,2.186525420561202,6519.29330571062 +230.0,29.0,0.0,0.11796601310652917,0.848444180656019,6107.466787905807 +690.0,529.0,1.0,0.18673720699448343,316.90568880056463,4271.013147559264 +110.0,259.0,0.0,0.08688612813045882,12.144336437558085,5942.766464621166 +450.0,229.0,0.0,0.08526905920082242,3.9473714335717456,6138.579098727007 +560.0,939.0,1.0,0.13214850118240914,6.479178858727886,5104.153053063214 +970.0,989.0,0.0,0.0891661217482469,0.44187179088902173,6053.16212044729 +360.0,529.0,1.0,0.13517419728679567,12.90486889495081,4985.293154130806 +700.0,489.0,1.0,0.1640145438005751,625.0451589318956,4224.931395988109 +120.0,289.0,0.0,0.10052014274924166,1.9064384478835712,6115.571892204628 +90.0,829.0,1.0,0.11970309241760027,6.638529531331295,4234.889604734567 +980.0,659.0,1.0,0.18716373311859175,478.1938753637771,2843.838754094008 +490.0,289.0,0.0,0.09196996878307279,36.724741335579154,5604.037890512683 +780.0,669.0,1.0,0.1756422563791495,629.1384684008476,3140.692477069736 +50.0,779.0,1.0,0.0917248411501537,0.6565636993406234,6197.834381182198 +430.0,589.0,1.0,0.13905700549937713,13.124324084599463,3981.017070347753 +130.0,489.0,0.0,0.09935128197945234,8.681914709234288,4954.088776991004 +280.0,929.0,1.0,0.1291288837957473,73.61197546126017,4235.867739996235 + diff --git a/geostatspy/tests/test.py b/geostatspy/tests/test.py new file mode 100644 index 0000000..8e76dd7 --- /dev/null +++ b/geostatspy/tests/test.py @@ -0,0 +1,515 @@ +import numpy as np +import pandas as pd +import os +import unittest + +from geostatspy import geostats + + +class UnitTest(unittest.TestCase): + + def setUp(self): + # Any inputs go here + + this_dir = os.path.dirname(os.path.abspath(__file__)) # Get current directory + sample_data_path = this_dir + '/sample_data.csv' # Set data file path + self.sample_data = pd.read_csv(sample_data_path, sep=',') + + return + + def test_locate(self): + # Inputs + # xx = + # iis = + # iie = + # x = + + # Test answers + # j_test = + + # Call function + # j_output = geostats.locate(xx, iis, iie, x) + + # Testing + # np.testing.assert_allclose(j_output, j_test, atol=0.01) + + return + + def test_dlocate(self): + # Inputs + # xx = + # iis = + # iie = + # x = + + # Test answers + # j_test = + + # Call function + # j_output = geostats.locate(xx, iis, iie, x) + + # Testing + # np.testing.assert_allclose(j_output, j_test, atol=0.01) + + return + + def test_powint(self): + # Inputs + # xlow = + # xhigh = + # ylow = + # yhigh = + # xval = + # power = + + # Test answers + # powint_test = + + # Call function + # powint_output = geostats.powint(self, xlow, xhigh, ylow, yhigh, xval, power) + + # Testing + # np.testing.assert_allclose(powint_output, powint_test, atol=0.01) + + return + + def test_dsortem(self): + # Inputs + # ib = + # ie = + # a = + # iperm = + + # Test answers + # a_test = + # b_test = + # c_test = + # d_test = + # e_test = + # f_test = + # g_test = + # h_test = + # dsortem_test = [a_test, b_test, c_test, d_test, e_test, f_test, g_test, h_test] + + # Call function + # dsortem_output = geostats.dsortem(ib, ie, a, iperm, b=0, c=0, d=0, e=0, f=0, g=0, h=0) + + # Testing + # np.testing.assert_allclose(dsortem_output, dsortem_test, atol=0.01) + + return + + def test_gauinv(self): + # Inputs + # p = + + # Test answers + # xp_test = + + # Call function + # xp_output = geostats.gauinv(p) + + # Testing + # np.testing.assert_allclose(xp_output, xp_test, atol=0.01) + + return + + def test_gcum(self): + # Inputs + # x = + + # Test answers + # gcum_test = + + # Call function + # gcum_output = geostats.gcum(x) + + # Testing + # np.testing.assert_allclose(gcum_output, gcum_test, atol=0.01) + + return + + def test_dpowint(self): + # Inputs + # xlow = + # xhigh = + # ylow = + # yhigh = + # xval = + # pwr = + + # Test answers + # dpowint_test = + + # Call function + # dpowint_output = geostats.dpowint(xlow, xhigh, ylow, yhigh, xval, pwr) + + # Testing + # np.testing.assert_allclose(lag_output, lag_test, atol=0.01) + + return + + def test_setup_rotmat(self): + # Inputs + # c0 = + # nst = + # it = + # cc = + # ang = + # pmx = + + # Test answers + # rotmat_test = + # maxcov_test = + + # Call function + # rotmat_output, maxcov_output = geostats.setup_rotmat(c0, nst, it, cc, ang, pmx) + + # Testing + # np.testing.assert_allclose(rotmat_output, rotmat_test, atol=0.01) + # np.testing.assert_allclose(maxcov_output, maxcov_test, atol=0.01) + + return + + def test_cova2(self): + # Inputs + # x1 = + # y1 = + # x2 = + # y2 = + # nst = + # c0 = + # pmx = + # cc = + # aa = + # it = + # ang = + # anis = + # rotmat = + # maxcov = + + # Test answers + # cova2_test = + + # Call function + # cova2_output = geostats.cova2(x1, y1, x2, y2, nst, c0, pmx, cc, aa, it, ang, anis, rotmat, maxcov) + + # Testing + # np.testing.assert_allclose(cova2_output, cova2_test, atol=0.01) + + return + + def test_ksol_numpy(self): + # Inputs + # neq = + # a = + # r = + + # Test answers + # s_test = + + # Call function + # s_output = geostats.ksol_numpy(neq, a, r) + + # Testing + # np.testing.assert_allclose(s_output, s_test, atol=0.01) + + return + + def test_correct_trend(self): + # Inputs + # trend = + + # Test answers + # trend_test = + + # Call function + # trend_output = geostats.correct_trend(trend) + + # Testing + # np.testing.assert_allclose(trend_output, trend_test, atol=0.01) + + return + + def test_ordrel(self): + # Inputs + # ivtype = + + # Test answers + # ccdfo_test = + + # Call function + # ccdfo_output = geostats.ordrel(ivtype) + + # Testing + # np.testing.assert_allclose(ccdfo_output, ccdfo_test, atol=0.01) + + return + + def test_declus(self): + # Inputs + # df = + # xcol = + # ycol = + # vcol = + # iminmax = + # noff = + # ncell = + # cmin = + # cmax = + + # Test answers + # wtopt_test = + # xcs_mat_test = + # vrcr_mat_test = + + # Call function + # wtopt_output, xcs_mat_output, vrcr_mat_output = geostats.declus(df, xcol, ycol, vcol, iminmax, noff, ncell, cmin, cmax) + + # Testing + # np.testing.assert_allclose(wtopt_output, wtopt_test, atol=0.01) + # np.testing.assert_allclose(xcs_mat_output, xcs_mat_test, atol=0.01) + # np.testing.assert_allclose(vrcr_mat_output, vrcr_mat_test, atol=0.01) + + return + + def test_gam(self): + # Inputs + # array = + # tmin = + # tmax = + # xsiz = + # ysiz = + # ixd = + # iyd = + # nlag = + # isill = + + # Test answers + # lag_test = + # vario_test = + # npp_test = + + # Call function + # lag_output, vario_output, npp_output = geostats.gam(array, tmin, tmax, xsiz, ysiz, ixd, iyd, isill) + + # Testing + # np.testing.assert_allclose(lag_output, lag_test, atol=0.01) + # np.testing.assert_allclose(vario_output, vario_test, atol=0.01) + # np.testing.assert_allclose(npp_output, npp_test, atol=0.01) + + return + + def test_gamv(self): + # Inputs + df = self.sample_data + xcol = "X" + ycol = "Y" + vcol = "Porosity" + tmin = 0 + tmax = 1500 + xlag = 100 + xltol = 25 + nlag = 7 + azm = 0 + atol = 90 + bandwh = 25 + isill = 1 + + # Test answers + dis_test = [0.0, 17.31, 93.002, 199.258, 300.349, 400.174, 501.166, 600.773, 0.0] + vario_test = [0.0, 0.056, 0.139, 0.201, 0.381, 0.357, 1.058, 0.172, 0.0] + npp_test = [522.0, 5032.0, 2168.0, 504.0, 372.0, 376.0, 312.0, 116.0, 0.0] + + # Call function + dis_output, vario_output, npp_output = geostats.gamv(df, xcol, ycol, vcol, tmin, tmax, xlag, xltol, nlag, azm, + atol, bandwh, isill) + + # Testing + np.testing.assert_allclose(dis_output, dis_test, atol=0.01) + np.testing.assert_allclose(vario_output, vario_test, atol=0.01) + np.testing.assert_allclose(npp_output, npp_test, atol=0.01) + + return + + def test_variogram_loop(self): + # Inputs + # x = + # y = + # vr = + # xlag = + # xltol = + # nlag = + # azm = + # atol = + # bandwh = + + # Test answers + # dis_test = + # vario_test = + # npp_test = + + # Call function + # dis_output, vario_output, npp_output = geostats.variogram_loop(x, y, vr, xlag, xltol, nlag, azm, atol, bandwh) + + # Testing + # np.testing.assert_allclose(dis_output, dis_test, atol=0.01) + # np.testing.assert_allclose(vario_output, vario_test, atol=0.01) + # np.testing.assert_allclose(npp_output, npp_test, atol=0.01) + + return + + def test_varmapv(self): + # Inputs + # df = + # xcol = + # ycol = + # tmin = + # tmax = + # nxlag = + # nylag = + # dxlag = + # dylag = + # minnp = + # isill = + + # Test answers + # gamf_test = + # nppf_test = + + # Call function + # gamf_output, nppf_output = geostats.varmapv(df, xcol, ycol, vcol, tmin, tmax, nxlag, nylag, dxlag, dylag, minnp, isill) + + # Testing + # np.testing.assert_allclose(gamf_output, gamf_test, atol=0.01) + # np.testing.assert_allclose(nppf_output, nppf_test, atol=0.01) + + return + + def test_vmodel(self): + # Inputs + # nlag = + # xlag = + # azm = + # vario = + + # Test answers + # index_test = + # h_test = + # gam_test = + # cov_test = + # ro_test = + + # Call function + # index_output, h_output, gam_output, cov_output, ro_output = geostats.vmodel(nlag, xlag, azm, vario) + + # Testing + # np.testing.assert_allclose(index_output, index_test, atol=0.01) + # np.testing.assert_allclose(h_output, h_test, atol=0.01) + # np.testing.assert_allclose(gam_output, gam_test, atol=0.01) + # np.testing.assert_allclose(cov_output, cov_test, atol=0.01) + # np.testing.assert_allclose(ro_output, ro_test, atol=0.01) + + return + + def test_nscore(self): + # Inputs + # df = + # vcol = + # wcol = None + # ismooth = False + # dfsmooth = None + # smcol = 0 + # smwcol = 0 + + # Test answers + # ns_test = + # vr_test = + # wt_ns_test = + + # Call function + # ns_output, vr_output, wt_ns_output = geostats.nscore(df, vcol, wcol=None, ismooth=False, dfsmooth=None, smcol=0, smwcol=0) + + # Testing + # np.testing.assert_allclose(ns_output, ns_test, atol=0.01) + # np.testing.assert_allclose(vr_output, vr_test, atol=0.01) + # np.testing.assert_allclose(wt_ns_output, wt_ns_test, atol=0.01) + + return + + def test_kb2d(self): + # Inputs + # df = + # xcol = + # ycol = + # vcol = + # tmin = + # tmax = + # nx = + # xmn = + # xsiz = + # ny = + # ymn = + # ysiz = + # nxdis = + # nydis = + # ndmin = + # ndmax = + # radius = + # ktype = + # skmean = + # vario = + + # Test answers + # kmap_test = + # vmap_test = + + # Call function + # kmap_output, vmap_output = geostats.kb2d(df, xcol, ycol, vcol, tmin, tmax, nx, xmn, xsiz, ny, ymn, ysiz, nxdis, nydis, ndmin, ndmax, radius, ktype, skmean, vario) + + # Testing + # np.testing.assert_allclose(kmap_output, kmap_test, atol=0.01) + # np.testing.assert_allclose(vmap_output, vmap_test, atol=0.01) + + return + + def test_ik2d(self): + # Inputs + # df = + # xcol = + # ycol = + # vcol = + # ivtype = + # tmax = + # koption = + # ncut = + # thresh = + # gcdf = + # trend = + # tmin = + # tmax = + # nx = + # xmn = + # xsiz = + # ny = + # ymn = + # ysiz = + # ndmin = + # ndmax = + # radius = + # ktype = + # vario = + + # Test answers + # ikout_test = + + # Call function + # ikout_output = geostats.ik2d(df, xcol, ycol, vcol, ivtype, koption, ncut, thresh, gcdf, trend, tmin, tmax, nx, xmn, xsiz, ny, ymn, ysiz, ndmin, ndmax, radius, ktype, vario) + + # Testing + # np.testing.assert_allclose(ikout_output, ikout_test, atol=0.01) + + return + + if __name__ == '__main__': + unittest.main()