commit e41b11e19341c258aa252bbbed3f02165b4654f6 Author: nidichaogequ Date: Tue Oct 24 18:46:43 2023 +0800 Initial feedstock commit with conda-smithy 3.21.1. diff --git a/conda-forge.yml b/conda-forge.yml new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/conda-forge.yml @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml new file mode 100644 index 0000000..702498e --- /dev/null +++ b/recipe/meta.yaml @@ -0,0 +1,77 @@ +{% set name = "gdptools" %} +{% set version = "0.0.15.dev0" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/gdptools-{{ version }}.tar.gz + sha256: c21cae1bbd2edb69dbe815078c07fc8e74fde0f0608d6efa12cdc52cdbdb251e + +build: + entry_points: + - gdptools = gdptools.__main__:main + noarch: python + script: {{ PYTHON }} -m pip install . -vv + number: 0 + +requirements: + host: + - python >=3.6,<3.10 + - pip + - poetry-core >=1.0.0 + run: + - python >=3.6,<3.10 + - python-attr >=0.3.2,<0.4.0 + # - geopandas ==0.11.1 + - geopandas + - netcdf4 >=1.5.8,<2.0.0 + - numpy >=1.22.4,<2.0.0 + - cftime >=1.6.0,<2.0.0 + - click <8 + - pydap >=3.2.2,<4.0.0 + - pandas >=1.4.2,<2.0.0 + - scipy >=1.8.1,<2.0.0 + # - shapely ==1.8.4 + - shapely + - pystac >=1.4.0,<2.0.0 + # - pyproj >=3.3.1,<4.0.0 + - pyproj + - zarr >=2.11.3,<3.0.0 + - pygeoapi >=0.11.0,<0.12.0 + - rioxarray >=0.11.1,<0.12.0 + - rasterstats >=0.16.0,<0.17.0 + - intake >=0.6.5,<0.7.0 + - rasterio >=1.2.10,<2.0.0 + - metpy >=1.3.0,<2.0.0 + - dask-core >=2022.6.0,<2023.0.0 + - xarray >=2022.3.0,<2023.0.0 + # - pygeos ==0.12.0 + - pygeos + - requests >=2.28.0,<3.0.0 + +test: + files: + - tests/ + requires: + - pip + - pytest + imports: + - gdptools + commands: + # Some of the pins are too aggressive making the package impossible to install. + # - pip check + - gdptools --help + - pytest -s -rxs -v tests/ + +about: + home: https://code.usgs.gov/wma/nhgf/toolsteam/gdptools + summary: Gdptools + license: Unlicense + license_file: + - LICENSE.md + +extra: + recipe-maintainers: + - ocefpaf diff --git a/recipe/tests/__init__.py b/recipe/tests/__init__.py new file mode 100644 index 0000000..b438fd7 --- /dev/null +++ b/recipe/tests/__init__.py @@ -0,0 +1 @@ +"""Test suite for the gdptools package.""" diff --git a/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/Readme.txt b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/Readme.txt new file mode 100644 index 0000000..cfff5f7 --- /dev/null +++ b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/Readme.txt @@ -0,0 +1,69 @@ +TM_WORLD_BORDERS-0.1.ZIP + +Provided by Bjorn Sandvik, thematicmapping.org + +Use this dataset with care, as several of the borders are disputed. + +The original shapefile (world_borders.zip, 3.2 MB) was downloaded from the Mapping Hacks website: +http://www.mappinghacks.com/data/ + +The dataset was derived by Schuyler Erle from public domain sources. +Sean Gilles did some clean up and made some enhancements. + + +COLUMN TYPE DESCRIPTION + +Shape Polygon Country/area border as polygon(s) +FIPS String(2) FIPS 10-4 Country Code +ISO2 String(2) ISO 3166-1 Alpha-2 Country Code +ISO3 String(3) ISO 3166-1 Alpha-3 Country Code +UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code +NAME String(50) Name of country/area +AREA Long Integer(7) Land area, FAO Statistics (2002) +POP2005 Double(10,0) Population, World Polulation Prospects (2005) +REGION Short Integer(3) Macro geographical (continental region), UN Statistics +SUBREGION Short Integer(3) Geogrpahical sub-region, UN Statistics +LON FLOAT (7,3) Longitude +LAT FLOAT (6,3) Latitude + + +CHANGELOG VERSION 0.3 - 30 July 2008 + +- Corrected spelling mistake (United Arab Emirates) +- Corrected population number for Japan +- Adjusted long/lat values for India, Italy and United Kingdom + + +CHANGELOG VERSION 0.2 - 1 April 2008 + +- Made new ZIP archieves. No change in dataset. + + +CHANGELOG VERSION 0.1 - 13 March 2008 + +- Polygons representing each country were merged into one feature +- Åland Islands was extracted from Finland +- Hong Kong was extracted from China +- Holy See (Vatican City) was added +- Gaza Strip and West Bank was merged into "Occupied Palestinean Territory" +- Saint-Barthelemy was extracted from Netherlands Antilles +- Saint-Martin (Frensh part) was extracted from Guadeloupe +- Svalbard and Jan Mayen was merged into "Svalbard and Jan Mayen Islands" +- Timor-Leste was extracted from Indonesia +- Juan De Nova Island was merged with "French Southern & Antarctic Land" +- Baker Island, Howland Island, Jarvis Island, Johnston Atoll, Midway Islands + and Wake Island was merged into "United States Minor Outlying Islands" +- Glorioso Islands, Parcel Islands, Spartly Islands was removed + (almost uninhabited and missing ISO-3611-1 code) + +- Added ISO-3166-1 codes (alpha-2, alpha-3, numeric-3). Source: + https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html + http://unstats.un.org/unsd/methods/m49/m49alpha.htm + http://www.fysh.org/~katie/development/geography.txt +- AREA column has been replaced with data from UNdata: + Land area, 1000 hectares, 2002, FAO Statistics +- POPULATION column (POP2005) has been replaced with data from UNdata: + Population, 2005, Medium variant, World Population Prospects: The 2006 Revision +- Added region and sub-region codes from UN Statistics Division. Source: + http://unstats.un.org/unsd/methods/m49/m49regin.htm +- Added LAT, LONG values for each country diff --git a/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.dbf b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.dbf new file mode 100644 index 0000000..64ea895 Binary files /dev/null and b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.dbf differ diff --git a/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.prj b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.prj new file mode 100644 index 0000000..0ae685b --- /dev/null +++ b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] diff --git a/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shp b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shp new file mode 100644 index 0000000..63e155c Binary files /dev/null and b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shp differ diff --git a/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shx b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shx new file mode 100644 index 0000000..18af94b Binary files /dev/null and b/recipe/tests/data/TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shx differ diff --git a/recipe/tests/data/cape_cod_tmax.nc b/recipe/tests/data/cape_cod_tmax.nc new file mode 100644 index 0000000..e1c0f84 Binary files /dev/null and b/recipe/tests/data/cape_cod_tmax.nc differ diff --git a/recipe/tests/data/cape_cod_wghts.csv b/recipe/tests/data/cape_cod_wghts.csv new file mode 100644 index 0000000..5e50af9 --- /dev/null +++ b/recipe/tests/data/cape_cod_wghts.csv @@ -0,0 +1,78 @@ +hru_id_nat,i,j,wght +1217,9,18,0.022744122070211464 +1217,9,17,0.024620824183491406 +1217,9,16,0.014939612320755339 +1217,8,16,0.003963238914406158 +1217,9,15,0.002299557241614022 +1217,8,15,0.015833906533294924 +1217,9,14,0.0008012859141177159 +1217,8,14,0.020944966126137134 +1217,8,13,0.013959028687718112 +1217,7,13,0.00015313520445743914 +1217,9,12,0.004017683927152676 +1217,9,11,0.009485699613290413 +1217,9,10,0.01241746668309033 +1217,8,10,0.006932316796670766 +1217,9,9,0.015258530319191773 +1217,8,9,0.012491177358300182 +1217,9,8,0.012464609871633218 +1217,8,8,0.017405909496496882 +1217,9,7,0.0016143948184593638 +1217,8,12,0.014309536699131358 +1217,8,11,0.00241496247511827 +1217,8,7,0.022530153430548455 +1217,7,7,0.00010532443251238961 +1217,9,6,7.300196486826311e-05 +1217,8,6,0.020445960818613503 +1217,7,6,0.006237653989117274 +1217,9,5,0.0007178858346077458 +1217,8,5,0.02121697047271652 +1217,7,5,0.021585618044517023 +1217,8,4,0.002083913565295211 +1217,6,5,0.0015820951653392065 +1217,5,5,0.004467308316028747 +1217,6,4,0.023488776187106472 +1217,5,3,0.012377274024593321 +1217,4,3,0.024891334384705012 +1217,5,2,0.0010750798258428009 +1217,7,4,0.01884313751383016 +1217,7,3,0.00023293155304667258 +1217,6,3,0.003886357258806238 +1217,4,2,0.023497376331002358 +1217,4,1,0.01170413946463823 +1217,2,2,0.0005780913789913731 +1217,3,1,0.02414444668831482 +1217,2,1,0.00963138994245831 +1217,4,18,0.019072332167324093 +1217,3,18,0.008361629964153825 +1217,2,18,5.7386768346766896e-05 +1217,4,17,0.007762583494824791 +1217,3,17,0.023422548582144966 +1217,2,17,0.01802680887131437 +1217,4,16,0.0030897458725556775 +1217,1,17,0.0020753901712984965 +1217,3,16,0.0197481239393868 +1217,8,18,0.010108446543529683 +1217,7,18,0.022117914323161555 +1217,8,17,0.01786984685516808 +1217,7,17,0.02271404128061403 +1217,7,16,0.013129121654692745 +1217,7,15,0.0068117987381928246 +1217,7,14,0.002556252126022518 +1217,6,18,0.020665128286216226 +1217,5,18,0.025099812099784156 +1217,6,17,0.0058312492575826064 +1217,5,17,0.007060052922998738 +1217,5,16,3.492303506934438e-05 +1217,2,16,0.024179748566782275 +1217,1,16,0.02059988923363395 +1217,2,15,0.00020728334023654757 +1217,1,15,0.007969023653145963 +1217,1,13,0.005095433483413696 +1217,1,12,0.0022806429059589986 +1217,4,5,0.0011510770285818692 +1217,4,4,0.022922811536604987 +1217,3,4,0.007926587170044857 +1217,3,3,0.014794128325871916 +1217,3,2,0.0179817281530367 +1217,5,4,0.025237730888437133 diff --git a/recipe/tests/data/cc_dm_wght_file.csv b/recipe/tests/data/cc_dm_wght_file.csv new file mode 100644 index 0000000..4d2ba40 --- /dev/null +++ b/recipe/tests/data/cc_dm_wght_file.csv @@ -0,0 +1,838 @@ +,hru_id_nat,i,j,wght +0,1217,24,68,0.00020150872437667988 +1,1217,25,68,0.0009250846277287126 +2,1217,23,67,0.0004928995583311905 +3,1217,24,67,0.001622302510185213 +4,1217,22,67,0.00014597891724816203 +5,1217,20,66,5.90209967561535e-05 +6,1217,21,66,0.0005132161189964269 +7,1217,22,66,0.00024174542687392233 +8,1217,20,65,0.0009215651367398074 +9,1217,27,69,0.0008363972315184544 +10,1217,26,68,0.0014891090157059248 +11,1217,27,68,0.0011205172160968786 +12,1217,26,67,0.0015023485128345727 +13,1217,27,67,0.0013287095916309675 +14,1217,26,66,0.0015254405467882931 +15,1217,27,66,0.00120747004288764 +16,1217,26,65,0.0017188885745783205 +17,1217,27,65,0.0017291414985994608 +18,1217,25,64,0.0008204731285304912 +19,1217,25,67,0.0017322390380204483 +20,1217,23,66,0.00038844649799918207 +21,1217,24,66,0.0013971824688081783 +22,1217,25,66,0.0017322445530070273 +23,1217,23,65,0.001202852489136868 +24,1217,24,65,0.0015686054682408942 +25,1217,25,65,0.0016693937510274168 +26,1217,23,64,0.001726081764895869 +27,1217,24,64,0.00118984724665982 +28,1217,23,63,0.0017322899353260967 +29,1217,19,65,0.00040898888768843805 +30,1217,18,64,0.0009478188545845991 +31,1217,19,64,0.0017056152087902977 +32,1217,18,63,0.001732360825773453 +33,1217,19,63,0.0017323468081457578 +34,1217,18,62,0.0017323660820429253 +35,1217,19,62,0.0017323520937716419 +36,1217,18,61,0.0017323713250098618 +37,1217,21,65,9.147409891132019e-05 +38,1217,22,65,0.0003543343771246205 +39,1217,20,64,0.0013772701830964563 +40,1217,21,64,0.0005214365142975962 +41,1217,22,64,0.0014463123708996512 +42,1217,20,63,0.0017323327102709946 +43,1217,21,63,0.0016354277306717554 +44,1217,22,63,0.00173230427385377 +45,1217,20,62,0.001732338025240247 +46,1217,21,62,0.001732323876466776 +47,1217,17,64,5.820098614114366e-05 +48,1217,16,63,0.00039036397539205225 +49,1217,14,62,2.295840622401913e-05 +50,1217,13,61,0.00016157098238727945 +51,1217,11,59,0.0007115054151179785 +52,1217,9,58,3.073270814303423e-06 +53,1217,8,57,1.1710836585679613e-06 +54,1217,9,57,0.0009627396917638087 +55,1217,8,56,0.0008728894838490467 +56,1217,9,56,0.0017325180349332012 +57,1217,7,55,0.0007269712074707245 +58,1217,8,55,0.0017319514861996392 +59,1217,10,58,0.0009191070949502904 +60,1217,11,58,0.001732305716779229 +61,1217,10,57,0.0017325000043912327 +62,1217,11,57,0.001732486805641994 +63,1217,10,56,0.00173250494600391 +64,1217,11,56,0.0017324917766662275 +65,1217,9,55,0.0017325229339193143 +66,1217,10,55,0.0017325098744201085 +67,1217,11,55,0.0017324967344992885 +68,1217,9,54,0.0017325278197426349 +69,1217,6,54,0.000558291655889709 +70,1217,5,53,0.0003594506478740643 +71,1217,6,53,0.001665731142796698 +72,1217,4,52,0.00012864133254034552 +73,1217,5,52,0.0015272322164382398 +74,1217,6,52,0.0017325759828547744 +75,1217,4,51,0.001086833719098905 +76,1217,5,51,0.0017325933608506846 +77,1217,17,63,0.0014586224068942092 +78,1217,15,62,0.0008658031779408065 +79,1217,16,62,0.0017022982699554429 +80,1217,17,62,0.0017323799900595095 +81,1217,15,61,0.001732412720124671 +82,1217,16,61,0.001732399002046983 +83,1217,17,61,0.001732385203660553 +84,1217,15,60,0.0017324178616872315 +85,1217,16,60,0.0017324041729841891 +86,1217,15,59,0.0015889327075743176 +87,1217,14,61,0.0012797025499573964 +88,1217,12,60,0.0003869890093977437 +89,1217,13,60,0.001538829071012939 +90,1217,14,60,0.0017324314700801957 +91,1217,12,59,0.00169331322717141 +92,1217,13,59,0.0017323331535786443 +93,1217,14,59,0.0013863724740699821 +94,1217,12,58,0.001732468512853336 +95,1217,13,58,0.0017324551239336437 +96,1217,14,58,0.0012405834377017212 +97,1217,19,61,0.0017323573660763753 +98,1217,17,60,0.0017305934352224435 +99,1217,18,60,0.0017323765546780616 +100,1217,19,60,0.0016852967823812845 +101,1217,17,59,0.0007352693668583995 +102,1217,18,59,0.0008916211314519702 +103,1217,19,59,0.00018135586771843504 +104,1217,16,59,0.0008702234925444087 +105,1217,15,58,0.00037855798503216934 +106,1217,15,57,0.0007106097965380821 +107,1217,15,56,0.0001403452532466594 +108,1217,15,54,0.00034324659928723243 +109,1217,12,57,0.0017324735265007117 +110,1217,13,57,0.0017324601669813078 +111,1217,14,57,0.0016849341360563853 +112,1217,12,56,0.001732478526932763 +113,1217,13,56,0.001138683602045612 +114,1217,14,56,0.0010749798043289452 +115,1217,12,55,0.0017324835141665075 +116,1217,13,55,0.0011895584263489183 +117,1217,14,55,5.250648568873239e-05 +118,1217,12,54,0.0017324884882089354 +119,1217,19,55,3.316230911265928e-05 +120,1217,17,54,0.00025524979831339774 +121,1217,10,54,0.0017325147896606495 +122,1217,11,54,0.0017325016791498535 +123,1217,9,53,0.0017325326924017084 +124,1217,10,53,0.0017325196917424698 +125,1217,11,53,0.0017325066106341084 +126,1217,9,52,0.0017325375519232817 +127,1217,10,52,0.0017325245806716096 +128,1217,11,52,0.0017325115289665346 +129,1217,9,51,0.0017325423983112498 +130,1217,10,51,0.0017325294564543674 +131,1217,13,54,0.0016976015405935478 +132,1217,14,54,0.0003668260663915127 +133,1217,12,53,0.0017324934490791997 +134,1217,13,53,0.0017324802071071082 +135,1217,14,53,0.0011425802230131976 +136,1217,12,52,0.001732498396796576 +137,1217,13,52,0.001637000467429305 +138,1217,14,52,0.0007688820831435399 +139,1217,12,51,0.0009122523595199469 +140,1217,13,51,0.00026306845626803224 +141,1217,16,54,7.212219437558846e-05 +142,1217,15,53,0.0013896898066986419 +143,1217,16,53,0.000969458551958157 +144,1217,15,52,0.00013976609720271665 +145,1217,11,51,0.0015490497868740321 +146,1217,9,50,0.0012088263105527405 +147,1217,10,50,0.0004610424665130705 +148,1217,11,50,9.99528594048819e-06 +149,1217,9,49,3.2501796898966896e-08 +150,1217,26,64,0.0014704473673479604 +151,1217,27,64,0.0017322262458727552 +152,1217,25,63,0.0017322610176556427 +153,1217,26,63,0.0017322464385437822 +154,1217,27,63,0.0017322317792434865 +155,1217,25,62,0.0012922490743782118 +156,1217,26,62,0.0017207440530449677 +157,1217,27,62,0.0017322372992479545 +158,1217,26,61,0.00020916215783843046 +159,1217,22,62,0.001732309647461054 +160,1217,20,61,0.001732343326888927 +161,1217,21,61,0.0016693667250149717 +162,1217,22,61,0.0010493414654920272 +163,1217,20,60,0.00100949890079742 +164,1217,21,60,0.00017060496733460647 +165,1217,24,63,0.0017322755165794536 +166,1217,23,62,0.0017042714034151774 +167,1217,24,62,0.001334592198916397 +168,1217,23,61,0.0003704486598667758 +169,1217,24,61,2.5278089298500944e-06 +170,1217,27,61,0.0008467360819315416 +171,1217,18,54,0.0001785455058862403 +172,1217,19,54,0.00014235376458394323 +173,1217,17,53,0.0003544310103301036 +174,1217,7,54,0.0017179305778752276 +175,1217,8,54,0.0017325407693867844 +176,1217,7,53,0.0017325584523628216 +177,1217,8,53,0.001732545612625345 +178,1217,7,52,0.0017325632530287923 +179,1217,8,52,0.0017325504427218035 +180,1217,7,51,0.001732568040571324 +181,1217,8,51,0.0017325552596893265 +182,1217,7,50,0.0017297542184971204 +183,1217,8,50,0.0014530216350134443 +184,1217,3,50,0.0003478393688163777 +185,1217,3,49,0.0011846451568442468 +186,1217,6,51,0.0017325807409560405 +187,1217,4,50,0.0017252351270132342 +188,1217,5,50,0.0017325980763976492 +189,1217,6,50,0.0017325854859540487 +190,1217,4,49,0.0017326152593131296 +191,1217,5,49,0.001732602778861597 +192,1217,6,49,0.001732590217862859 +193,1217,4,48,0.0017326199192547102 +194,1217,5,48,0.0017242116235943502 +195,1217,6,48,0.000882242550980743 +196,1217,7,49,0.001375444751360191 +197,1217,8,49,0.00035405698938678154 +198,1217,7,48,2.6046729227107153e-05 +199,1217,2,48,0.00011446006985338612 +200,1217,3,48,0.001697846270163626 +201,1217,2,47,0.0005721590019428738 +202,1217,3,47,0.001732636907128201 +203,1217,2,46,0.0008853165391815448 +204,1217,3,46,0.0017326415115246866 +205,1217,2,45,0.0011051509265268835 +206,1217,4,47,0.0017326245661344621 +207,1217,5,47,0.0007826346320702871 +208,1217,4,46,0.001357993264503461 +209,1217,5,46,7.791138277591351e-06 +210,1217,4,45,0.0006027093084042386 +211,1217,4,44,0.00016264691447237517 +212,1217,4,43,2.59158307194838e-06 +213,1217,3,45,0.0017326461028952746 +214,1217,2,44,0.0012606136413924121 +215,1217,3,44,0.001732650681249333 +216,1217,2,43,0.001233549890215783 +217,1217,3,43,0.0016662172064344006 +218,1217,2,42,0.001214142616327765 +219,1217,3,42,0.0013449218754567121 +220,1217,6,41,2.007782766533938e-06 +221,1217,7,41,0.0003779721001043682 +222,1217,8,41,0.0005982008350583553 +223,1217,8,40,0.0009479223607180097 +224,1217,6,39,0.0012356791066201562 +225,1217,7,39,0.0012360204969152965 +226,1217,4,41,0.00016063244331448567 +227,1217,4,40,0.0012968267123194188 +228,1217,5,40,0.00011314195157276712 +229,1217,3,39,0.0017326733782454934 +230,1217,4,39,0.0017326612726758137 +231,1217,5,39,0.00165756502798856 +232,1217,3,38,0.0017326778787764255 +233,1217,9,40,8.624654654312529e-05 +234,1217,2,41,0.001122870646046223 +235,1217,3,41,0.0016226729298456965 +236,1217,2,40,0.0009790548517062804 +237,1217,3,40,0.0017326688647790421 +238,1217,2,39,0.0007027596776956692 +239,1217,2,38,0.00030008875564573696 +240,1217,8,39,0.0013155318961704833 +241,1217,6,38,0.0017326414082010507 +242,1217,7,38,0.001641977262241441 +243,1217,8,38,0.0003856186070066677 +244,1217,6,37,0.0017269761960565933 +245,1217,7,37,0.000469984009345878 +246,1217,6,36,0.0010622652107056799 +247,1217,4,38,0.0017326658025912482 +248,1217,5,38,0.0017326536457429563 +249,1217,3,37,0.0013826423193841792 +250,1217,4,37,0.0017326703195809474 +251,1217,5,37,0.0017326581921168214 +252,1217,3,36,0.000488721360034425 +253,1217,4,36,0.0017261986148676967 +254,1217,5,36,0.001672093750449106 +255,1217,4,35,0.0006958839447070482 +256,1217,2,37,1.458330349101129e-06 +257,1217,5,35,0.0014800502511677215 +258,1217,5,34,2.75085700392301e-05 +259,1217,6,35,0.00044092871270221814 +260,1217,6,34,3.0412455554989154e-05 +261,1217,30,71,3.697188004709842e-06 +262,1217,28,70,9.48187832349033e-05 +263,1217,29,70,0.0005560754410910417 +264,1217,33,72,9.132306870092234e-05 +265,1217,31,71,0.0004467961802572812 +266,1217,32,71,0.0005024998838794304 +267,1217,33,71,0.0005067228222199957 +268,1217,31,70,9.738826870031808e-05 +269,1217,26,69,0.00015268089101154803 +270,1217,34,72,0.0006121234380373229 +271,1217,35,72,0.0006526198297485993 +272,1217,34,71,0.00038228578968184184 +273,1217,35,71,0.00014886288337211665 +274,1217,34,70,0.0008678816256891953 +275,1217,35,70,0.001502014633169788 +276,1217,33,69,0.0009848746720160896 +277,1217,34,69,0.001732092291502496 +278,1217,30,70,0.0006562488638452186 +279,1217,28,69,0.0013215345443233601 +280,1217,29,69,0.00019412305736733951 +281,1217,28,68,0.0001336109981518278 +282,1217,28,67,0.0004761689840011074 +283,1217,29,67,8.900187123765293e-05 +284,1217,30,67,0.0009183605659504058 +285,1217,33,70,0.0005231451461886608 +286,1217,32,68,0.0002975420642761562 +287,1217,31,67,0.0002136109297867592 +288,1217,32,67,0.0002836395562326846 +289,1217,31,66,0.0008959467523488151 +290,1217,32,66,0.00039131531467794623 +291,1217,35,69,0.0017320768160987298 +292,1217,33,68,0.0009834435345095931 +293,1217,34,68,0.0014668768808194206 +294,1217,35,68,0.0017320826503436368 +295,1217,33,67,0.001080375012507631 +296,1217,34,67,0.0015321130763830194 +297,1217,35,67,0.001732088471105642 +298,1217,33,66,0.0006496067246207795 +299,1217,34,66,0.0017214678477815645 +300,1217,35,66,0.0017320942784078046 +301,1217,28,66,0.0014049699715119584 +302,1217,29,66,0.001681623351147365 +303,1217,30,66,0.0017321704169877194 +304,1217,28,65,0.001712876196845142 +305,1217,29,65,0.0016900607830008486 +306,1217,30,65,0.001732176064875459 +307,1217,28,64,0.0017322114771796534 +308,1217,29,64,0.0017321966283185045 +309,1217,30,64,0.0017321816993404273 +310,1217,28,63,0.0017322170397918218 +311,1217,33,65,0.001732130709578446 +312,1217,34,65,0.001732115430953869 +313,1217,35,65,0.001732100072257282 +314,1217,33,64,0.0012543410860989114 +315,1217,34,64,0.000862681241174495 +316,1217,35,64,0.0014898203551640008 +317,1217,35,63,0.0005132048747695041 +318,1217,31,65,0.0017321610265370899 +319,1217,32,65,0.0017321459081032463 +320,1217,31,64,0.0017321666902229246 +321,1217,32,64,0.0016320100341060194 +322,1217,31,63,0.0017321723404936313 +323,1217,32,63,0.0006767085562812079 +324,1217,30,62,0.00173219292808863 +325,1217,31,62,0.0017321779773771927 +326,1217,32,62,0.0005289077722334223 +327,1217,30,61,0.0017321985223877053 +328,1217,36,72,0.0004103463809399059 +329,1217,37,72,0.0004616066685577359 +330,1217,38,72,0.0005857925098295744 +331,1217,36,71,0.0010180104504753326 +332,1217,37,71,0.0008838376788366325 +333,1217,38,71,0.0007555043984361362 +334,1217,36,70,0.0015715095281463168 +335,1217,39,72,0.0007714446702918311 +336,1217,40,72,0.00016752984708553556 +337,1217,39,71,0.0002854317667037599 +338,1217,40,71,2.129200141956155e-06 +339,1217,39,70,0.00031211440695817273 +340,1217,39,69,0.0003696148954350125 +341,1217,37,70,0.0013557231586815138 +342,1217,38,70,0.0009219130219520477 +343,1217,36,69,0.001149222967057658 +344,1217,37,69,0.0016012197808361421 +345,1217,38,69,0.0010178446302626693 +346,1217,36,68,0.001731883839633748 +347,1217,37,68,0.0016226798939246707 +348,1217,38,68,0.0012975586469447585 +349,1217,36,67,0.0017320729740325396 +350,1217,37,67,0.0017320573969022042 +351,1217,39,68,9.113371567150175e-06 +352,1217,39,66,8.161317794077708e-05 +353,1217,38,65,0.0017320535157831006 +354,1217,39,65,0.001008973470790108 +355,1217,38,64,0.0017320593835940255 +356,1217,38,67,0.0010018981537346097 +357,1217,36,66,0.0017320788104928755 +358,1217,37,66,0.0017320632625143291 +359,1217,38,66,0.00145731517759914 +360,1217,36,65,0.001732084633497294 +361,1217,37,65,0.001732069114663811 +362,1217,36,64,0.0017320904430448152 +363,1217,37,64,0.0017320749533550346 +364,1217,36,63,0.001732096239159089 +365,1217,37,63,0.001495477685740889 +366,1217,39,64,0.0016900794268206328 +367,1217,40,64,0.0003290214866853069 +368,1217,38,63,0.0017197933586179284 +369,1217,39,63,0.0017320496172572584 +370,1217,40,63,0.001193636640448738 +371,1217,38,62,0.001066887471308669 +372,1217,39,62,0.0017320554872811262 +373,1217,40,62,0.0017219126741506213 +374,1217,38,61,0.0001885296170009164 +375,1217,39,61,0.0013144621248971913 +376,1217,41,63,4.6189579106451006e-05 +377,1217,41,62,0.00036262441063861456 +378,1217,41,61,0.001160088674285299 +379,1217,41,60,0.0008382146936727215 +380,1217,42,60,0.0004857435337188818 +381,1217,42,59,0.00026498697342768697 +382,1217,35,62,1.8543724900133392e-07 +383,1217,33,59,7.949139323194541e-05 +384,1217,36,62,0.0008109839013030544 +385,1217,37,62,0.00031745683620058987 +386,1217,36,58,0.000287279220012728 +387,1217,40,61,0.001673002042493694 +388,1217,40,60,0.0008780717301003903 +389,1217,33,58,0.0016742663508621896 +390,1217,34,58,0.0012224471243838205 +391,1217,35,58,0.00027179940497654473 +392,1217,33,57,0.0017321761110708747 +393,1217,34,57,0.0017321610656623491 +394,1217,33,56,0.0017321817261157066 +395,1217,34,56,0.001732166709840627 +396,1217,33,55,0.0015825989187894884 +397,1217,34,55,0.0017321723406817809 +398,1217,35,57,0.0016324698830881717 +399,1217,36,57,0.0014424509369484022 +400,1217,35,56,0.0017321516133862029 +401,1217,36,56,0.0016751842099218353 +402,1217,37,56,0.0006948693924786104 +403,1217,35,55,0.0017321572733419552 +404,1217,36,55,0.0017321421257946673 +405,1217,37,55,0.0017321268980590124 +406,1217,35,54,0.0017321629199609175 +407,1217,38,56,5.455775187384457e-05 +408,1217,38,55,0.0011996454781791942 +409,1217,38,54,0.00021678493883005992 +410,1217,36,54,0.0014706600180724005 +411,1217,37,54,0.0013641252995124156 +412,1217,35,53,0.0017321685532676828 +413,1217,36,53,0.0004132645294759722 +414,1217,35,52,0.0017321741732754868 +415,1217,36,52,0.0013554989754980076 +416,1217,37,52,9.286851084058043e-05 +417,1217,35,51,0.0012153623096409212 +418,1217,36,51,0.001732164748764944 +419,1217,38,51,0.0011483416191373254 +420,1217,39,51,0.00046980703132647346 +421,1217,38,50,0.001732140126197096 +422,1217,39,50,0.0012110351566601003 +423,1217,40,50,0.00017337928915647538 +424,1217,29,63,0.0017322022201730267 +425,1217,30,63,0.0017321873204087606 +426,1217,28,62,0.0017322225890311442 +427,1217,29,62,0.0017322077986336875 +428,1217,28,61,0.001719713749571535 +429,1217,29,61,0.0017322133637289697 +430,1217,28,60,0.0005868556324573992 +431,1217,29,60,0.0016897861195046676 +432,1217,29,59,0.0005333349159439171 +433,1217,31,61,0.0017321836008736173 +434,1217,32,61,0.0012082958668627704 +435,1217,30,60,0.0017322041033251377 +436,1217,31,60,0.0017223459367542522 +437,1217,32,60,0.0001110108475316313 +438,1217,30,59,0.0016947862287778265 +439,1217,31,59,0.0017321492865682248 +440,1217,32,59,0.0005972277564484012 +441,1217,30,58,0.0010194863921599599 +442,1217,31,58,0.0017322003911816677 +443,1217,32,58,0.0017321854770193663 +444,1217,30,57,1.2980401154313356e-05 +445,1217,31,57,0.0013655154055251353 +446,1217,32,57,0.001732191076255852 +447,1217,31,56,0.0001402894052694262 +448,1217,32,56,0.0014802879366871734 +449,1217,32,55,0.0002721398764179373 +450,1217,33,54,0.0012086133691379902 +451,1217,34,54,0.0017321779581995237 +452,1217,33,53,0.00032627409148636605 +453,1217,34,53,0.00152255825845781 +454,1217,34,52,0.0008847874193781072 +455,1217,34,51,3.20734202774621e-05 +456,1217,43,47,8.110885533619536e-06 +457,1217,42,47,0.001311529210834058 +458,1217,41,46,0.0007956254344367804 +459,1217,42,46,0.0017144451584240347 +460,1217,40,45,0.00025378117649014353 +461,1217,41,45,5.849371040574931e-05 +462,1217,42,45,0.001323265185451836 +463,1217,40,44,0.0008755069622016907 +464,1217,41,44,0.0002644726356375163 +465,1217,42,44,0.0006369311743111917 +466,1217,45,45,5.202697920200626e-05 +467,1217,45,44,0.00028555212886365467 +468,1217,45,43,0.00030908572276521753 +469,1217,37,51,0.0011299174918130257 +470,1217,35,50,0.0003551455139370071 +471,1217,36,50,0.0016766092010196923 +472,1217,37,50,0.0017321552888561157 +473,1217,36,49,0.000496879643423772 +474,1217,37,49,0.001684142567877852 +475,1217,37,48,0.0003930844680135786 +476,1217,41,50,9.408233408593684e-05 +477,1217,40,49,0.0010735462436886176 +478,1217,41,49,0.0015214537552601544 +479,1217,42,49,5.624545984429147e-05 +480,1217,40,48,0.0017321209975716323 +481,1217,41,48,0.001719524819107224 +482,1217,42,48,0.0005032329939440772 +483,1217,40,47,0.0013147829461803348 +484,1217,41,47,0.0016752486006002512 +485,1217,38,49,0.0017321457935003867 +486,1217,39,49,0.0016961554271872244 +487,1217,38,48,0.001484494589882018 +488,1217,39,48,0.0014741493898395345 +489,1217,38,47,8.040614993684604e-05 +490,1217,39,47,0.0004178306910103744 +491,1217,40,43,0.0013157175777220224 +492,1217,41,43,0.0013646386381831032 +493,1217,40,42,0.0008356000513960982 +494,1217,41,42,0.001009869248026753 +495,1217,40,41,0.0002661904949932875 +496,1217,41,41,0.0016573601663768865 +497,1217,40,40,3.208073693481574e-08 +498,1217,41,40,0.001418942777551063 +499,1217,41,39,0.0008611391392185912 +500,1217,43,46,0.0008934483681513356 +501,1217,44,46,0.0004317848178671641 +502,1217,43,45,0.0017320920380561747 +503,1217,44,45,0.001223009377949763 +504,1217,43,44,0.0017064535483762606 +505,1217,44,44,0.001732082313666037 +506,1217,42,43,2.022762616349753e-05 +507,1217,43,43,0.0016308428737102118 +508,1217,44,43,0.0017233260289423887 +509,1217,45,42,0.00085921483352507 +510,1217,45,41,0.001591964315451284 +511,1217,46,41,0.0006121502151965193 +512,1217,45,40,0.0017320898455289234 +513,1217,46,40,0.0016103409778277207 +514,1217,47,40,5.66322543183407e-05 +515,1217,43,42,0.0010153966855511417 +516,1217,44,42,0.0017320938235251826 +517,1217,42,41,0.0001464578778273258 +518,1217,43,41,0.0005640696611524683 +519,1217,44,41,0.0017217232337201254 +520,1217,42,40,0.0010244909070772639 +521,1217,43,40,0.0011727727795402942 +522,1217,44,40,0.0017321052804726172 +523,1217,42,39,0.0017321415602643544 +524,1217,43,39,0.0017321263148646912 +525,1217,47,39,0.0008780936852762386 +526,1217,47,38,0.001115108450650197 +527,1217,44,39,0.0017321109891358618 +528,1217,42,38,0.0017321471979357083 +529,1217,43,38,0.0017321319814358805 +530,1217,44,38,0.0017321166845933249 +531,1217,42,37,0.0016566280529422858 +532,1217,43,37,0.001732137634833967 +533,1217,44,37,0.001732122366867528 +534,1217,42,36,0.0013531338277476142 +535,1217,43,36,0.00173214327506594 +536,1217,44,36,0.0017321280359859784 +537,1217,45,39,0.0017320955830666016 +538,1217,46,39,0.0017320800967085077 +539,1217,45,38,0.0017321013074164987 +540,1217,46,38,0.0017320858499137724 +541,1217,45,37,0.001732107018568858 +542,1217,46,37,0.0017320915899269656 +543,1217,45,36,0.00173195696643227 +544,1217,46,36,0.000707298366951511 +545,1217,45,35,0.0017321184013418189 +546,1217,46,35,0.0005542535973239645 +547,1217,47,37,0.0005940200773625349 +548,1217,47,36,1.6582062650368927e-05 +549,1217,42,35,0.001068194093055058 +550,1217,43,35,0.0017321489021394968 +551,1217,44,35,0.0017321336919332863 +552,1217,42,34,0.0008429285011032869 +553,1217,43,34,0.001732154516073437 +554,1217,44,34,0.0017321393347259433 +555,1217,42,33,0.000712568551061729 +556,1217,43,33,0.001732160116878234 +557,1217,44,33,0.0017321449643940025 +558,1217,42,32,0.0008065886099945703 +559,1217,41,38,0.00039650450941222984 +560,1217,41,37,3.597891129666109e-05 +561,1217,45,34,0.0017321240730046132 +562,1217,46,34,0.0007639680150441578 +563,1217,45,33,0.0017321297315175586 +564,1217,46,33,0.001197378997832658 +565,1217,45,32,0.0017321353768950602 +566,1217,46,32,0.0009041242328565492 +567,1217,45,31,0.0017061649118550373 +568,1217,46,31,0.00013131433487464445 +569,1217,44,30,0.0017321617746776363 +570,1217,45,30,0.0017321466283008564 +571,1217,43,32,0.0017321657045611168 +572,1217,44,32,0.0017321505809329478 +573,1217,42,31,0.0008031317334247426 +574,1217,43,31,0.0017321712791385853 +575,1217,44,31,0.00173215618435451 +576,1217,42,30,0.0008727130510391511 +577,1217,43,30,0.0017321768406180333 +578,1217,42,29,0.0009113549398292848 +579,1217,43,29,0.0017321823890223708 +580,1217,42,28,0.0012605294776286192 +581,1217,47,29,0.0012730899940615991 +582,1217,48,29,0.00026811822275927714 +583,1217,47,28,0.0017321274085079722 +584,1217,48,28,0.0008842031022009641 +585,1217,46,30,0.0007005481428614669 +586,1217,44,29,0.0017321673519070328 +587,1217,45,29,0.0017321522343549784 +588,1217,46,29,0.0016047630668574791 +589,1217,44,28,0.0017321729160576233 +590,1217,45,28,0.0017321578273228405 +591,1217,46,28,0.001732142658142184 +592,1217,44,27,0.0017321784671504709 +593,1217,45,27,0.0017321634072208 +594,1217,46,27,0.0017321482668273957 +595,1217,43,28,0.0017321879243439283 +596,1217,42,27,0.001723317466081515 +597,1217,43,27,0.0017321934466084255 +598,1217,42,26,0.0017322138259592806 +599,1217,43,26,0.0017321989558142356 +600,1217,42,25,0.0017322192933117353 +601,1217,43,25,0.0017322044519813434 +602,1217,42,24,0.0017322247476439182 +603,1217,43,24,0.0017322099351310511 +604,1217,42,23,0.001732230188971904 +605,1217,47,27,0.0014368311953287648 +606,1217,48,27,7.954422876281438e-05 +607,1217,47,26,0.0012759061921143388 +608,1217,47,25,0.001002367935066656 +609,1217,47,24,4.5004777800562115e-05 +610,1217,44,26,0.0017321840051865943 +611,1217,45,26,0.0017321689740555939 +612,1217,46,26,0.0017321538624586034 +613,1217,44,25,0.0017321895301666537 +614,1217,45,25,0.0017321745278367185 +615,1217,46,25,0.0016929984307725854 +616,1217,44,24,0.0017321950421209276 +617,1217,45,24,0.0013752404721698865 +618,1217,46,24,0.00024605631077978133 +619,1217,44,23,0.0016726159301070867 +620,1217,43,23,0.0017322154052633373 +621,1217,41,22,0.0017322502916232436 +622,1217,42,22,0.0017322356172961232 +623,1217,43,22,0.0017322208623992445 +624,1217,41,21,0.001732255678153958 +625,1217,42,21,0.001732241032629578 +626,1217,43,21,0.0015583644126477693 +627,1217,41,20,0.00122399435560376 +628,1217,42,20,0.0012442202501850494 +629,1217,43,20,0.000649284849168353 +630,1217,45,23,0.00015905186815899386 +631,1217,44,22,0.0008629586651288349 +632,1217,44,21,0.00013110164916531645 +633,1217,41,27,0.00020961349721136771 +634,1217,41,26,0.0011308468235099217 +635,1217,40,25,3.9767373571777056e-05 +636,1217,41,25,0.0016481451141087495 +637,1217,40,24,0.0007266309871252826 +638,1217,41,24,0.0017322394796179775 +639,1217,33,21,0.00014690381479006735 +640,1217,31,20,0.00024206340725423464 +641,1217,32,20,0.0009947059876528805 +642,1217,34,21,0.0012155484929464468 +643,1217,35,21,0.001390470202620854 +644,1217,34,20,0.0017323611117632614 +645,1217,35,20,0.0017323470593593527 +646,1217,34,19,0.00173236627042157 +647,1217,38,22,4.253426425998812e-05 +648,1217,36,21,0.001341619123531161 +649,1217,37,21,0.001070379843892373 +650,1217,38,21,0.0014661504266658405 +651,1217,36,20,0.0017323329263049343 +652,1217,37,20,0.0017323187126187553 +653,1217,38,20,0.0017323044183039779 +654,1217,33,20,0.0016026729080160392 +655,1217,31,19,0.0016490732104355592 +656,1217,32,19,0.001732394075468647 +657,1217,33,19,0.001732380213289407 +658,1217,31,18,0.0017324129160147133 +659,1217,32,18,0.0017323991634338165 +660,1217,33,18,0.0017323853301540217 +661,1217,31,17,0.0017324179621728342 +662,1217,32,17,0.0017324042385231646 +663,1217,31,16,0.0017324229954873154 +664,1217,36,19,0.0017323381427284607 +665,1217,37,19,0.001732323957903718 +666,1217,38,19,0.0017323096924381784 +667,1217,36,18,0.0017323433462352327 +668,1217,37,18,0.0017323291902626812 +669,1217,38,18,0.0014908714296122498 +670,1217,36,17,0.001627441813183215 +671,1217,37,17,0.0017112895206101287 +672,1217,38,17,0.0009429911179394324 +673,1217,36,16,0.0003148624460132309 +674,1217,35,19,0.0017323522469086957 +675,1217,34,18,0.0017323714161883996 +676,1217,35,18,0.001732357421547955 +677,1217,33,17,0.0017323904341365504 +678,1217,34,17,0.0017323765490626817 +679,1217,35,17,0.0017323625832922262 +680,1217,33,16,0.0017323955252508737 +681,1217,34,16,0.0017323816690538263 +682,1217,35,16,0.0017291102298801397 +683,1217,33,15,0.0017324006035066531 +684,1217,40,19,0.0014709589187213482 +685,1217,39,18,0.00045881118421681557 +686,1217,40,18,7.974014015976719e-06 +687,1217,37,16,0.00048243282238834783 +688,1217,38,16,1.2026924116358975e-05 +689,1217,30,19,0.0002392685942156281 +690,1217,28,18,0.0006097744342568301 +691,1217,29,18,0.00033154015803669654 +692,1217,30,18,0.0014343292854140386 +693,1217,28,17,0.0016686288066964608 +694,1217,29,17,0.0017324451673679433 +695,1217,30,17,0.0017324316051370483 +696,1217,28,16,0.0017324635953700665 +697,1217,27,18,3.9337600202860875e-05 +698,1217,27,17,7.452516412756977e-06 +699,1217,27,16,0.0003247073085859663 +700,1217,27,15,0.0010559785688593593 +701,1217,26,14,0.00013522608639083303 +702,1217,29,16,0.001732450142826824 +703,1217,30,16,0.0017324366095360574 +704,1217,28,15,0.0017324685290627067 +705,1217,29,15,0.0017324551054548171 +706,1217,30,15,0.0017324416010887022 +707,1217,28,14,0.0017324734499365281 +708,1217,29,14,0.0017324600552606228 +709,1217,30,14,0.0017324465798116446 +710,1217,28,13,0.0017324783580089567 +711,1217,29,13,0.001732464992253376 +712,1217,32,16,0.0017324093007362901 +713,1217,31,15,0.0017324280159585457 +714,1217,32,15,0.001732414350095097 +715,1217,31,14,0.0017324330235931763 +716,1217,32,14,0.00173241938662418 +717,1217,31,13,0.001732438018393377 +718,1217,32,13,0.00173242441031959 +719,1217,31,12,0.0017324430003883794 +720,1217,32,12,0.00173242942119749 +721,1217,31,11,0.0017324479695824699 +722,1217,27,14,0.0016383926332013978 +723,1217,26,13,4.945015763850111e-05 +724,1217,27,13,0.0014754337066293424 +725,1217,27,12,3.528985290600089e-05 +726,1217,39,23,0.00011997406582392182 +727,1217,40,23,0.001585108124415857 +728,1217,41,23,0.0017322448921192751 +729,1217,39,22,0.0012383565131119513 +730,1217,40,22,0.0017322648853922821 +731,1217,39,21,0.001732284727467156 +732,1217,40,21,0.0017322702430988932 +733,1217,39,20,0.0017322900433811798 +734,1217,40,20,0.0017322755878462104 +735,1217,39,19,0.0017322953463460408 +736,1217,41,19,0.0011785521798354617 +737,1217,42,19,1.2844095427958752e-05 +738,1217,34,15,0.0016272878821177166 +739,1217,35,15,0.00051140429278673 +740,1217,33,14,0.0017324056689109197 +741,1217,34,14,0.0011914693737507369 +742,1217,33,13,0.0017324107214757908 +743,1217,34,13,0.0009097465494046575 +744,1217,33,12,0.001732415761216996 +745,1217,34,12,0.001355850644998053 +746,1217,35,12,0.001153401516345535 +747,1217,33,11,0.0017324207881540972 +748,1217,34,11,0.0017324070762635522 +749,1217,35,11,0.001248938049198465 +750,1217,33,10,0.0017324258022828548 +751,1217,34,10,0.0017324121192365577 +752,1217,35,10,0.001305668123148813 +753,1217,33,9,0.001732430803617234 +754,1217,34,9,0.001535986661352341 +755,1217,35,9,0.0003865224708863206 +756,1217,36,12,0.00014543441421789076 +757,1217,36,11,4.82024465505773e-05 +758,1217,36,10,2.2471562236666833e-05 +759,1217,36,9,8.28265559242395e-07 +760,1217,33,8,0.0017324357921800295 +761,1217,34,8,0.0014897008360493585 +762,1217,35,8,2.466920314098982e-06 +763,1217,33,7,0.0004827378485012676 +764,1217,34,7,0.00031523297368343345 +765,1217,30,13,0.0017324515457142742 +766,1217,28,12,0.0010718732042310328 +767,1217,29,12,0.0017324699164481064 +768,1217,30,12,0.0017324564988205704 +769,1217,28,11,0.0007396007162071882 +770,1217,29,11,0.001732474827854682 +771,1217,30,11,0.0017324614391278385 +772,1217,28,10,0.0011624907794642856 +773,1217,29,10,0.001732479726482503 +774,1217,30,10,0.0017324663666528697 +775,1217,32,11,0.0017324344192597026 +776,1217,31,10,0.0017324529259944664 +777,1217,32,10,0.0017324394045240862 +778,1217,31,9,0.0017324578696261723 +779,1217,32,9,0.00173244437701665 +780,1217,30,8,0.0017324761833957705 +781,1217,31,8,0.0017324628004841208 +782,1217,32,8,0.0017324493367466259 +783,1217,30,7,0.0017324810726451689 +784,1217,31,7,0.0017324677185857115 +785,1217,27,10,0.00012526541608982983 +786,1217,26,9,0.00010973185739481415 +787,1217,27,9,0.00029162157821221486 +788,1217,25,8,6.89141574745386e-05 +789,1217,26,8,0.00028969332373517077 +790,1217,25,7,4.68194314303024e-05 +791,1217,26,7,5.20811362144037e-07 +792,1217,28,9,0.0008769948468172218 +793,1217,29,9,0.0017324846123462877 +794,1217,30,9,0.001732471281401348 +795,1217,28,8,0.0011805862747097744 +796,1217,29,8,0.0017324894854602543 +797,1217,28,7,0.0017206093155073857 +798,1217,29,7,0.001732494345831387 +799,1217,28,6,0.0017325123569302354 +800,1217,29,6,0.001732499193477256 +801,1217,28,5,0.0017325171629788052 +802,1217,27,7,0.0002850611277094448 +803,1217,26,6,9.795885452624786e-05 +804,1217,27,6,0.0014286968854863062 +805,1217,26,5,0.0007921034568303572 +806,1217,27,5,0.0017325302166627543 +807,1217,25,4,1.1841990260434277e-06 +808,1217,26,4,0.001118546372497137 +809,1217,27,4,0.0017325349811328854 +810,1217,32,7,0.0013668111107565867 +811,1217,30,6,0.0017324859491471478 +812,1217,31,6,0.0017324726239573256 +813,1217,32,6,0.0005551276812567624 +814,1217,30,5,0.001732490812938864 +815,1217,31,5,0.0017258645286687849 +816,1217,32,5,0.0005564178636316856 +817,1217,30,4,0.0015239836900741881 +818,1217,31,4,0.0003350694158026754 +819,1217,32,4,8.456684855503856e-05 +820,1217,29,5,0.0017325040284062268 +821,1217,28,4,0.0017325219563260371 +822,1217,29,4,0.0015044661570868948 +823,1217,28,3,0.0017325267369914738 +824,1217,29,3,0.0008899212352694668 +825,1217,28,2,0.0014025730709808228 +826,1217,29,2,0.0008755888534728868 +827,1217,28,1,0.00013136338799496735 +828,1217,29,1,3.0132297467041544e-05 +829,1217,25,3,0.001197758665399931 +830,1217,26,3,0.0016416379551319404 +831,1217,27,3,0.0014453312251362465 +832,1217,25,2,5.2628649115467694e-06 +833,1217,26,2,0.0006213916381265454 +834,1217,27,2,5.619668150487062e-06 +835,1217,30,3,4.1434615020939995e-05 +836,1217,31,3,8.48290455225462e-06 diff --git a/recipe/tests/data/gridmet_DRB_example.ipynb b/recipe/tests/data/gridmet_DRB_example.ipynb new file mode 100644 index 0000000..04d65cb --- /dev/null +++ b/recipe/tests/data/gridmet_DRB_example.ipynb @@ -0,0 +1,163 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "6fd04c86-82b8-466f-81df-0a53926fa420", + "metadata": {}, + "outputs": [], + "source": [ + "import fsspec\n", + "import xarray as xr\n", + "import hvplot.xarray\n", + "import hvplot.pandas\n", + "import hvplot.dask\n", + "# import intake\n", + "import os\n", + "import warnings\n", + "# import intake_xarray\n", + "import geopandas as gpd\n", + "from pynhd import NLDI, WaterData\n", + "# from dask.distributed import LocalCluster, Client\n", + "# from gdptools.helpers import get_shp_bounds_w_buffer, build_subset\n", + "# from helpers import configure_cluster\n", + "\n", + "warnings.filterwarnings('ignore')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "edf27719-ce97-4d35-a7b0-8065b26874f7", + "metadata": {}, + "outputs": [], + "source": [ + "# USGS gage 01482100 Delaware River at Del Mem Bridge at Wilmington De\n", + "gage_id = '01482100'\n", + "nldi = NLDI()\n", + "del_basins = nldi.get_basins(gage_id)\n", + "huc12_basins = WaterData('huc12').bygeom(del_basins.geometry[0])\n", + "\n", + "import pandas as pd\n", + "param_json = \"https://mikejohnson51.github.io/opendap.catalog/cat_params.json\"\n", + "grid_json = \"https://mikejohnson51.github.io/opendap.catalog/cat_grids.json\"\n", + "params = pd.read_json(param_json)\n", + "grids = pd.read_json(grid_json)\n", + "\n", + "_id = \"gridmet\"\n", + "_varname = \"daily_maximum_temperature\"\n", + "tc = params.query(\"id == @_id & varname == @_varname\")\n", + "print(type(tc), len(tc))\n", + "tc" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7d819411-bb81-46e2-8305-42f9f2c396d1", + "metadata": {}, + "outputs": [], + "source": [ + "# Create a dictionary of parameter dataframes for each variable\n", + "vars = [\"tmmn\", \"tmmx\"]\n", + "var_params = []\n", + "for var in vars:\n", + " var_params.append(params.query(\"id == @_id & variable == @var\"))\n", + "param_dict = dict(zip(vars, var_params))\n", + "param_dict.get('tmmn')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d1876e8-4b97-49eb-8d72-0f97843fef3b", + "metadata": {}, + "outputs": [], + "source": [ + "# Create a dictionary of grid dataframes for each variable\n", + "var_grid = []\n", + "for var in vars:\n", + " gridid = param_dict.get(var)['grid_id'].values[0]\n", + " var_grid.append(grids.query('grid_id == @gridid'))\n", + "grid_dict = dict(zip(vars, var_grid))\n", + "grid_dict.get('tmmn')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "75be1872-a9c1-42b1-84d4-eaf85e9d63d1", + "metadata": {}, + "outputs": [], + "source": [ + "import tempfile\n", + "from gdptools.helpers import calc_weights_catalog\n", + "wghtf = calc_weights_catalog(\n", + " params_json=param_dict.get(\"tmmn\"),\n", + " grid_json=grid_dict.get(\"tmmn\"),\n", + " shp_file=huc12_basins,\n", + " shp_poly_idx='huc12',\n", + " wght_gen_file=tempfile.NamedTemporaryFile().name,\n", + " wght_gen_proj=6931,\n", + " )\n", + "\n", + "tmp = 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "70139be4-efcd-4d47-9302-0142b7990cb4", + "metadata": {}, + "outputs": [], + "source": [ + "from gdptools.run_weights_engine import RunWghtEngine\n", + "eng = RunWghtEngine()\n", + "eng.initialize(\n", + " param_dict=param_dict,\n", + " grid_dict=grid_dict,\n", + " wghts=wghtf,\n", + " gdf=huc12_basins,\n", + " gdf_poly_idx='huc12',\n", + " start_date=\"2020-01-01\",\n", + " end_date=\"2020-01-07\"\n", + ")\n", + "ngdf, nvals = eng.run(numdiv=1) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "36812590-fb33-4162-bf22-f6455bea4ee8", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.9.13", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + }, + "vscode": { + "interpreter": { + "hash": "3365295dbac4842fc2bf269a7ec44c70d326e0f953d0b638b14de2730fd8846e" + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/recipe/tests/data/hru_1210.cpg b/recipe/tests/data/hru_1210.cpg new file mode 100644 index 0000000..7edc66b --- /dev/null +++ b/recipe/tests/data/hru_1210.cpg @@ -0,0 +1 @@ +UTF-8 diff --git a/recipe/tests/data/hru_1210.dbf b/recipe/tests/data/hru_1210.dbf new file mode 100644 index 0000000..3919b8b Binary files /dev/null and b/recipe/tests/data/hru_1210.dbf differ diff --git a/recipe/tests/data/hru_1210.prj b/recipe/tests/data/hru_1210.prj new file mode 100644 index 0000000..be961b9 --- /dev/null +++ b/recipe/tests/data/hru_1210.prj @@ -0,0 +1 @@ +PROJCS["USA_Contiguous_Albers_Equal_Area_Conic_USGS_version",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",23.0],UNIT["Meter",1.0]] diff --git a/recipe/tests/data/hru_1210.qmd b/recipe/tests/data/hru_1210.qmd new file mode 100644 index 0000000..e45f3ec --- /dev/null +++ b/recipe/tests/data/hru_1210.qmd @@ -0,0 +1,26 @@ + + + + + + dataset + + + + + + + + + + 0 + 0 + + + + + false + + + + diff --git a/recipe/tests/data/hru_1210.shp b/recipe/tests/data/hru_1210.shp new file mode 100644 index 0000000..520ea0e Binary files /dev/null and b/recipe/tests/data/hru_1210.shp differ diff --git a/recipe/tests/data/hru_1210.shx b/recipe/tests/data/hru_1210.shx new file mode 100644 index 0000000..4fe78d0 Binary files /dev/null and b/recipe/tests/data/hru_1210.shx differ diff --git a/recipe/tests/data/hru_1217.cpg b/recipe/tests/data/hru_1217.cpg new file mode 100644 index 0000000..7edc66b --- /dev/null +++ b/recipe/tests/data/hru_1217.cpg @@ -0,0 +1 @@ +UTF-8 diff --git a/recipe/tests/data/hru_1217.dbf b/recipe/tests/data/hru_1217.dbf new file mode 100644 index 0000000..4e264be Binary files /dev/null and b/recipe/tests/data/hru_1217.dbf differ diff --git a/recipe/tests/data/hru_1217.prj b/recipe/tests/data/hru_1217.prj new file mode 100644 index 0000000..be961b9 --- /dev/null +++ b/recipe/tests/data/hru_1217.prj @@ -0,0 +1 @@ +PROJCS["USA_Contiguous_Albers_Equal_Area_Conic_USGS_version",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",29.5],PARAMETER["Standard_Parallel_2",45.5],PARAMETER["Latitude_Of_Origin",23.0],UNIT["Meter",1.0]] diff --git a/recipe/tests/data/hru_1217.qmd b/recipe/tests/data/hru_1217.qmd new file mode 100644 index 0000000..e45f3ec --- /dev/null +++ b/recipe/tests/data/hru_1217.qmd @@ -0,0 +1,26 @@ + + + + + + dataset + + + + + + + + + + 0 + 0 + + + + + false + + + + diff --git a/recipe/tests/data/hru_1217.shp b/recipe/tests/data/hru_1217.shp new file mode 100644 index 0000000..35d3a0b Binary files /dev/null and b/recipe/tests/data/hru_1217.shp differ diff --git a/recipe/tests/data/hru_1217.shx b/recipe/tests/data/hru_1217.shx new file mode 100644 index 0000000..5cab040 Binary files /dev/null and b/recipe/tests/data/hru_1217.shx differ diff --git a/recipe/tests/data/test_easy.cpg b/recipe/tests/data/test_easy.cpg new file mode 100644 index 0000000..7edc66b --- /dev/null +++ b/recipe/tests/data/test_easy.cpg @@ -0,0 +1 @@ +UTF-8 diff --git a/recipe/tests/data/test_easy.dbf b/recipe/tests/data/test_easy.dbf new file mode 100644 index 0000000..1d8cedd Binary files /dev/null and b/recipe/tests/data/test_easy.dbf differ diff --git a/recipe/tests/data/test_easy.prj b/recipe/tests/data/test_easy.prj new file mode 100644 index 0000000..0ae685b --- /dev/null +++ b/recipe/tests/data/test_easy.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] diff --git a/recipe/tests/data/test_easy.qmd b/recipe/tests/data/test_easy.qmd new file mode 100644 index 0000000..b66ad0f --- /dev/null +++ b/recipe/tests/data/test_easy.qmd @@ -0,0 +1,43 @@ + + + + + + dataset + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + false + + + + + + + + + + + + diff --git a/recipe/tests/data/test_easy.shp b/recipe/tests/data/test_easy.shp new file mode 100644 index 0000000..190a390 Binary files /dev/null and b/recipe/tests/data/test_easy.shp differ diff --git a/recipe/tests/data/test_easy.shx b/recipe/tests/data/test_easy.shx new file mode 100644 index 0000000..a4b9e41 Binary files /dev/null and b/recipe/tests/data/test_easy.shx differ diff --git a/recipe/tests/data/wght_cat_cape_cod.csv b/recipe/tests/data/wght_cat_cape_cod.csv new file mode 100644 index 0000000..179575e --- /dev/null +++ b/recipe/tests/data/wght_cat_cape_cod.csv @@ -0,0 +1,95 @@ +,hru_id_nat,i,j,wght +0,1217,9,21,0.010385113453602842 +1,1217,8,21,0.003508973537762682 +2,1217,9,20,0.022090459915468343 +3,1217,8,20,0.020671836365909205 +4,1217,9,19,0.02271996923093199 +5,1217,8,19,0.0058229364058856765 +6,1217,9,18,0.013130850948726316 +7,1217,7,21,0.002499708961998342 +8,1217,7,20,0.02509912823800202 +9,1217,6,20,0.01907290544540379 +10,1217,7,19,0.007056794046585599 +11,1217,6,19,0.007743171650448804 +12,1217,5,19,0.02343208521623885 +13,1217,5,20,0.008358360009321298 +14,1217,4,20,5.6304754023110946e-05 +15,1217,4,19,0.018038942623158215 +16,1217,3,19,0.002082110439914532 +17,1217,4,18,0.024177247306878126 +18,1217,7,18,3.058806916741606e-05 +19,1217,6,18,0.003133768911694372 +20,1217,5,18,0.01978963322082683 +21,1217,3,18,0.020592573781125896 +22,1217,2,18,0.0006779503538345632 +23,1217,4,17,0.00021576524621362992 +24,1217,3,17,0.00797284270189162 +25,1217,2,17,0.009323334115058987 +26,1217,2,16,0.009768515305339655 +27,1217,3,15,0.005075664829726569 +28,1217,2,15,0.01743384274228927 +29,1217,3,14,0.0022756226309730244 +30,1217,2,14,0.01442984758966935 +31,1217,12,21,0.002418114956077962 +32,1217,11,21,0.005944155635677215 +33,1217,10,21,0.0030931603519837817 +34,1217,11,20,0.022762084768619167 +35,1217,10,20,0.010084165757596571 +36,1217,11,19,0.024608163241500173 +37,1217,10,19,0.01787644564343566 +38,1217,11,18,0.014923935364042525 +39,1217,12,20,0.006536717433879459 +40,1217,12,19,0.0009529187233115947 +41,1217,12,18,0.0036493919105850176 +42,1217,12,17,0.0031233321508102496 +43,1217,10,18,0.003938599372807205 +44,1217,10,17,0.01583026756714666 +45,1217,9,17,0.0068161788051025705 +46,1217,10,16,0.020942460541649045 +47,1217,9,16,0.002562250969507334 +48,1217,10,15,0.013969186760700913 +49,1217,9,15,0.00015357587823515385 +50,1217,11,17,0.002309316633566189 +51,1217,11,16,0.0008031353112737044 +52,1217,11,14,0.004008510213053036 +53,1217,10,14,0.01430469320305944 +54,1217,11,13,0.009482736241314193 +55,1217,10,13,0.0024214527631840465 +56,1217,11,12,0.012429001451739542 +57,1217,10,12,0.006927664633561424 +58,1217,11,11,0.015252125133789787 +59,1217,10,11,0.012474795340704148 +60,1217,10,10,0.01743436239008998 +61,1217,10,9,0.022524074494531237 +62,1217,9,9,0.00011695690400420476 +63,1217,10,8,0.020419512554429007 +64,1217,11,10,0.012463668266503875 +65,1217,11,9,0.0016145023958267295 +66,1217,11,8,7.190817319719135e-05 +67,1217,11,7,0.0007142824231105722 +68,1217,10,6,0.0020928772251331764 +69,1217,9,8,0.0062604598757939065 +70,1217,10,7,0.02123177604161553 +71,1217,9,7,0.021592198036589162 +72,1217,8,7,0.0015857604617338804 +73,1217,9,6,0.018835090571409606 +74,1217,8,6,0.023471986923080997 +75,1217,9,5,0.00023870638976033662 +76,1217,8,5,0.0038741797919178036 +77,1217,7,7,0.0044579421384705635 +78,1217,6,7,0.0011460055994972607 +79,1217,7,6,0.025232954953369958 +80,1217,6,6,0.022937590033638138 +81,1217,7,5,0.01237675581737259 +82,1217,6,5,0.02488293379972019 +83,1217,5,5,0.014798783786828095 +84,1217,6,4,0.02349295723714499 +85,1217,7,4,0.0010609558457634189 +86,1217,5,4,0.018009192964290276 +87,1217,6,3,0.011688343114585689 +88,1217,5,3,0.02413199781462915 +89,1217,5,2,0.006115341450878622 +90,1217,4,2,0.009725631408042223 +91,1217,5,6,0.007927047239565093 +92,1217,4,4,0.0005700874784422043 +93,1217,4,3,0.009637791593042252 diff --git a/recipe/tests/support.py b/recipe/tests/support.py new file mode 100644 index 0000000..1aa574d --- /dev/null +++ b/recipe/tests/support.py @@ -0,0 +1,15 @@ +"""Typeguard support for tests.""" +import pytest + +try: + import typeguard # noqa: F401 +except ImportError: + has_typeguard = False +else: + has_typeguard = True + + +skip_if_typeguard = pytest.mark.skipif( + has_typeguard, + reason="Broken if Typeguard is enabled", +) diff --git a/recipe/tests/test_RWE_Class.py b/recipe/tests/test_RWE_Class.py new file mode 100644 index 0000000..7ed66ed --- /dev/null +++ b/recipe/tests/test_RWE_Class.py @@ -0,0 +1,138 @@ +"""Testing ancillary functions.""" +from typing import Any + +import geopandas as gpd +import numpy as np +import numpy.typing as npt +import pandas as pd +import pytest +import xarray as xr +from pyproj.crs import CRS +from pyproj.exceptions import CRSError + +from gdptools.ancillary import _check_for_intersection +from gdptools.ancillary import _generate_weights_pershp +from gdptools.ancillary import _get_cells_poly +from gdptools.ancillary import _get_crs +from gdptools.ancillary import _get_data_via_catalog +from gdptools.ancillary import _get_shp_file +from gdptools.gdp_data_class import CatGrids +from gdptools.gdp_data_class import CatParams + + +@pytest.mark.parametrize( + "crs", + [ + "epsg:4326", + 4326, + "+proj=longlat +a=6378137 +f=0.00335281066474748 +pm=0 +no_defs", + ], +) +def test__get_crs(crs: Any) -> None: + """Test the get_crs function.""" + crs = _get_crs(crs) + assert isinstance(crs, CRS) + + +@pytest.mark.parametrize( + "crs", + [ + "espg:4326", + 43, + "+a=6378137 +f=0.00335281066474748 +pm=0 +no_defs", + ], +) +def test__get_bad_crs(crs: Any) -> None: + """Test the get_crs function.""" + with pytest.raises(CRSError): + crs = _get_crs(crs) + + +@pytest.fixture +def param_json() -> pd.DataFrame: + """Return parameter json.""" + param_json = "https://mikejohnson51.github.io/opendap.catalog/cat_params.json" + params = pd.read_json(param_json) + _id = "gridmet" # noqa + _varname = "daily_maximum_temperature" # noqa + return params.query("id == @_id & varname == @_varname") + + +@pytest.fixture +def grid_json() -> pd.DataFrame: + """Return grid json.""" + grid_json = "https://mikejohnson51.github.io/opendap.catalog/cat_grids.json" + grids = pd.read_json(grid_json) + _gridid = 176 # noqa + return grids.query("grid_id == @_gridid") + + +@pytest.fixture +def gdf() -> gpd.GeoDataFrame: + """Create xarray dataset.""" + return gpd.read_file("./tests/data/hru_1210.shp") + + +@pytest.fixture +def catparam(param_json) -> CatParams: + """Return CatParams.""" + return CatParams(**param_json.to_dict("records")[0]) + + +@pytest.fixture +def catgrid(grid_json) -> CatGrids: + """Return CatGrids.""" + return CatGrids(**grid_json.to_dict("records")[0]) + + +@pytest.fixture +def is_degrees(gdf, catparam, catgrid) -> bool: + is_intersect, is_degrees, is_0_360 = _check_for_intersection( + params_json=catparam, grid_json=catgrid, gdf=gdf + ) + return is_degrees + + +@pytest.fixture +def bounds(gdf, catgrid, is_degrees) -> npt.NDArray[np.double]: + """Get bounds.""" + gdf, bounds = _get_shp_file(gdf, catgrid, is_degrees) + return bounds + + +@pytest.fixture +def xarray(catparam, catgrid, bounds) -> xr.Dataset: + """Create xarray dataset.""" + return _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + + +def test__get_cells_poly(catparam, catgrid, bounds) -> None: + """Test _get_cells_poly.""" + ds = _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + assert isinstance(ds, xr.DataArray) + gdf = _get_cells_poly( + xr_a=ds, x=catgrid.X_name, y=catgrid.Y_name, var=catparam.varname, crs_in=4326 + ) + assert isinstance(gdf, gpd.GeoDataFrame) + + +def test__generate_weights_pershape(gdf, catparam, catgrid, bounds) -> None: + """Test _generate_weights_pershape.""" + ds = _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + assert isinstance(ds, xr.DataArray) + grid_cells = _get_cells_poly( + xr_a=ds, + x=catgrid.X_name, + y=catgrid.Y_name, + var=catparam.varname, + crs_in=catgrid.proj, + ) + assert isinstance(grid_cells, gpd.GeoDataFrame) + df = _generate_weights_pershp( + poly=gdf, + poly_idx="hru_id_nat", + grid_cells=grid_cells, + grid_cells_crs=catgrid.proj, + wght_gen_crs=6931, + ) + assert isinstance(df, pd.DataFrame) diff --git a/recipe/tests/test_ancillary.py b/recipe/tests/test_ancillary.py new file mode 100644 index 0000000..fa5c945 --- /dev/null +++ b/recipe/tests/test_ancillary.py @@ -0,0 +1,128 @@ +"""Testing ancillary functions.""" +from typing import Any + +import geopandas as gpd +import numpy as np +import numpy.typing as npt +import pandas as pd +import pytest +import xarray as xr +from pyproj.crs import CRS +from pyproj.exceptions import CRSError + +from gdptools.ancillary import _check_for_intersection +from gdptools.ancillary import _generate_weights_pershp +from gdptools.ancillary import _get_cells_poly +from gdptools.ancillary import _get_crs +from gdptools.ancillary import _get_data_via_catalog +from gdptools.ancillary import _get_shp_file +from gdptools.gdp_data_class import CatGrids +from gdptools.gdp_data_class import CatParams + + +@pytest.mark.parametrize( + "crs", + [ + "epsg:4326", + 4326, + "+proj=longlat +a=6378137 +f=0.00335281066474748 +pm=0 +no_defs", + ], +) +def test__get_crs(crs: Any) -> None: + """Test the get_crs function.""" + crs = _get_crs(crs) + assert isinstance(crs, CRS) + + +@pytest.mark.parametrize( + "crs", + [ + "espg:4326", + 43, + "+a=6378137 +f=0.00335281066474748 +pm=0 +no_defs", + ], +) +def test__get_bad_crs(crs: Any) -> None: + """Test the get_crs function.""" + with pytest.raises(CRSError): + crs = _get_crs(crs) + + +@pytest.fixture +def catparam() -> CatParams: + """Return parameter json.""" + param_json = "https://mikejohnson51.github.io/opendap.catalog/cat_params.json" + params = pd.read_json(param_json) + _id = "gridmet" # noqa + _varname = "daily_maximum_temperature" # noqa + tc = params.query("id == @_id & varname == @_varname") + return CatParams(**tc.to_dict("records")[0]) + + +@pytest.fixture +def catgrid() -> CatGrids: + """Return grid json.""" + grid_json = "https://mikejohnson51.github.io/opendap.catalog/cat_grids.json" + grids = pd.read_json(grid_json) + _gridid = 176 # noqa + tc = grids.query("grid_id == @_gridid") + return CatGrids(**tc.to_dict("records")[0]) + + +@pytest.fixture +def gdf() -> gpd.GeoDataFrame: + """Create xarray dataset.""" + return gpd.read_file("./tests/data/hru_1210.shp") + + +@pytest.fixture +def is_degrees(gdf, catparam, catgrid) -> bool: + is_intersect, is_degrees, is_0_360 = _check_for_intersection( + params_json=catparam, grid_json=catgrid, gdf=gdf + ) + return is_degrees + +@pytest.fixture +def bounds(gdf, catgrid, is_degrees) -> npt.NDArray[np.double]: + """Get bounds.""" + gdf, bounds = _get_shp_file(gdf, catgrid, is_degrees) + return bounds + + +@pytest.fixture +def xarray(catparam, catgrid, bounds) -> xr.Dataset: + """Create xarray dataset.""" + return _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + + +def test__get_cells_poly(catparam, catgrid, bounds) -> None: + """Test _get_cells_poly.""" + ds = _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + print(ds) + assert isinstance(ds, xr.DataArray) + gdf = _get_cells_poly( + xr_a=ds, x="lon", y="lat", var="daily_maximum_temperature", crs_in=4326 + ) + assert isinstance(gdf, gpd.GeoDataFrame) + + +def test__generate_weights_pershape(gdf, catparam, catgrid, bounds) -> None: + """Test _generate_weights_pershape.""" + ds = _get_data_via_catalog(catparam, catgrid, bounds, "2020-01-01") + assert isinstance(ds, xr.DataArray) + grid_cells = _get_cells_poly( + xr_a=ds, + x="lon", + y="lat", + var="daily_maximum_temperature", + crs_in=catgrid.proj, + ) + assert isinstance(grid_cells, gpd.GeoDataFrame) + df = _generate_weights_pershp( + poly=gdf, + poly_idx="hru_id_nat", + grid_cells=grid_cells, + grid_cells_crs=catgrid.proj, + wght_gen_crs=6931, + ) + assert isinstance(df, pd.DataFrame) diff --git a/recipe/tests/test_main.py b/recipe/tests/test_main.py new file mode 100644 index 0000000..da38b9d --- /dev/null +++ b/recipe/tests/test_main.py @@ -0,0 +1,17 @@ +"""Test cases for the __main__ module.""" +import pytest +from click.testing import CliRunner + +from gdptools import __main__ + + +@pytest.fixture +def runner() -> CliRunner: + """Fixture for invoking command-line interfaces.""" + return CliRunner() + + +def test_main_succeeds(runner: CliRunner) -> None: + """It exits with a status code of zero.""" + result = runner.invoke(__main__.main) + assert result.exit_code == 0 diff --git a/recipe/tests/test_run_wght_engine.py b/recipe/tests/test_run_wght_engine.py new file mode 100644 index 0000000..54e058e --- /dev/null +++ b/recipe/tests/test_run_wght_engine.py @@ -0,0 +1,127 @@ +"""Testing run_wght_engine functions.""" +from pathlib import Path +from tempfile import TemporaryDirectory +from typing import Dict + +import geopandas as gpd +import numpy as np +import pandas as pd +import pytest + +from gdptools.gdp_data_class import CatGrids +from gdptools.gdp_data_class import CatParams +from gdptools.helpers import calc_weights_catalog +from gdptools.run_weights_engine import RunWghtEngine + +# from .support import skip_if_typeguard + +gm_vars = ["aet", "pet", "PDSI"] + + +@pytest.fixture +def param_dict(vars=gm_vars) -> Dict: + """Return parameter json.""" + param_json = "https://mikejohnson51.github.io/opendap.catalog/cat_params.json" + params = pd.read_json(param_json) + _id = "terraclim" # noqa + var_params = [ + params.query( + "id == @_id & variable == @_var", local_dict={"_id": _id, "_var": _var} + ) + for _var in vars + ] + return dict(zip(vars, var_params)) + + +@pytest.fixture +def grid_dict(vars=gm_vars) -> Dict: + """Return grid json.""" + grid_json = "https://mikejohnson51.github.io/opendap.catalog/cat_grids.json" + grids = pd.read_json(grid_json) + _gridid = 116 # noqa + var_grid = [ + grids.query( + "grid_id == @_gridid", local_dict={"_gridid": _gridid, "_var": _var} + ) + for _var in vars + ] + return dict(zip(vars, var_grid)) + + +@pytest.fixture +def gdf() -> gpd.GeoDataFrame: + """Create xarray dataset.""" + return gpd.read_file("./tests/data/hru_1210.shp") + + +@pytest.fixture +def poly_idx() -> str: + """Return poly_idx.""" + return "hru_id_nat" + + +@pytest.fixture +def wght_gen_proj() -> int: + """Return wght gen projection.""" + return 6931 + + +# @skip_if_typeguard +def test__rwe( + param_dict, grid_dict, gdf, poly_idx, wght_gen_proj, tvars=gm_vars +) -> None: + """Test rwe.""" + cp = CatParams(**param_dict.get(tvars[0]).to_dict("records")[0]) + cg = CatGrids(**grid_dict.get(tvars[0]).to_dict("records")[0]) + wghtf = calc_weights_catalog( + params_json=cp, + grid_json=cg, + shp_file=gdf, + shp_poly_idx=poly_idx, + wght_gen_proj=wght_gen_proj, + ) + assert isinstance(wghtf, pd.DataFrame) + + eng = RunWghtEngine() + + eng.initialize( + param_dict=param_dict, + grid_dict=grid_dict, + wghts=wghtf, + gdf=gdf, + gdf_poly_idx=poly_idx, + start_date="1980-01-01", + end_date="1980-12-31", + ) + + ngdf, nvals = eng.run(numdiv=1) + + test_arr = np.asarray( + [ + [3.5844913], + [0.0], + [43.21665], + [68.13543], + [83.542114], + [93.33581], + [49.084114], + [35.92661], + [26.799622], + [63.00365], + [50.600002], + [1.9948304], + ] + ) + + np.testing.assert_allclose(test_arr, nvals[0]) + + with TemporaryDirectory() as tmpdirname: + success = eng.finalize( + gdf=ngdf, + vals=nvals, + p_opath=tmpdirname, + prefix="terraclimetest", + ) + file = Path(tmpdirname) / "terraclimetest.nc" + assert success + assert file.exists()