diff --git a/docs/sphinx/source/reference/iotools.rst b/docs/sphinx/source/reference/iotools.rst index 14271cf3ee..d06d8cf74d 100644 --- a/docs/sphinx/source/reference/iotools.rst +++ b/docs/sphinx/source/reference/iotools.rst @@ -38,6 +38,7 @@ of sources and file formats relevant to solar energy modeling. iotools.get_cams iotools.read_cams iotools.parse_cams + iotools.get_mines_horizon A :py:class:`~pvlib.location.Location` object may be created from metadata in some files. diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index 9e295dbc3c..26fe1428c3 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -27,6 +27,8 @@ Enhancements (:issue:`1732`, :pull:`1737`) * Added function to retrieve horizon data from PVGIS :py:func:`pvlib.iotools.get_pvgis_horizon`. (:issue:`1290`, :pull:`1395`) +* Added function to retrieve horizon data from MINES Paris Tech + :py:func:`pvlib.iotools.get_mines_horizon`. (:pull:`1295`) * Added ``map_variables`` argument to the :py:func:`pvlib.iotools.read_tmy3` in order to offer the option of mapping column names to standard pvlib names. (:issue:`1517`, :pull:`1623`) diff --git a/pvlib/data/test_mines_horizon_profile.csv b/pvlib/data/test_mines_horizon_profile.csv new file mode 100644 index 0000000000..f089031462 --- /dev/null +++ b/pvlib/data/test_mines_horizon_profile.csv @@ -0,0 +1,361 @@ +horizon_azimuth,horizon_elevation +0.0,10.320263619601478 +1.0,10.56852307588421 +2.0,11.05596816694823 +3.0,10.968764987334554 +4.0,10.879113340056572 +5.0,10.787088368429442 +6.0,10.842078593189507 +7.0,11.036791629350772 +8.0,11.344112405210296 +9.0,11.944550743427882 +10.0,12.590007667787257 +11.0,13.24771479855563 +12.0,14.330053396583368 +13.0,14.491963651919598 +14.0,14.651238707949783 +15.0,14.169258285206444 +16.0,14.624982206396933 +17.0,14.578541124750023 +18.0,14.870554858616718 +19.0,14.935457650823611 +20.0,15.0885315603635 +21.0,15.190088466395054 +22.0,15.33145561982695 +23.0,15.504411243487064 +24.0,15.704214531903538 +25.0,15.774951233725517 +26.0,15.736377862229702 +27.0,15.735010131533558 +28.0,15.80532920991757 +29.0,15.90048706845416 +30.0,15.562376743242108 +31.0,14.969868365300536 +32.0,14.846224347531232 +33.0,14.910233160117354 +34.0,15.112747240400124 +35.0,15.1037056947202 +36.0,15.207432857359825 +37.0,15.365316536748322 +38.0,15.526876627504071 +39.0,15.430121121416176 +40.0,15.343197592629206 +41.0,15.39124137357418 +42.0,15.437148538610506 +43.0,15.480146484676022 +44.0,15.474453050537594 +45.0,15.545530715101824 +46.0,15.626068363262007 +47.0,15.53817303896001 +48.0,15.502418784989016 +49.0,15.463292561073986 +50.0,15.51420625373984 +51.0,15.561788864983146 +52.0,15.577098556018726 +53.0,15.57046369330897 +54.0,15.560410096586438 +55.0,15.435612684278311 +56.0,15.178053340596838 +57.0,14.798812711862055 +58.0,14.506600336489898 +59.0,13.62767821148156 +60.0,13.137822490940168 +61.0,12.95266715659998 +62.0,12.636295538240788 +63.0,12.373858003774371 +64.0,12.206681398571888 +65.0,12.05685341989992 +66.0,11.92699758978141 +67.0,11.785557213475192 +68.0,11.631153635710772 +69.0,11.429099444793705 +70.0,10.942468403983554 +71.0,10.556904900984174 +72.0,10.373295363721018 +73.0,10.22821296633413 +74.0,10.249779592450404 +75.0,10.58049427611687 +76.0,10.747107448796925 +77.0,10.747545068762392 +78.0,10.82636662450043 +79.0,10.92538924046796 +80.0,11.040785599178705 +81.0,11.022204832172733 +82.0,11.002496149905753 +83.0,11.08044192270151 +84.0,11.34775928870693 +85.0,11.502447676409547 +86.0,11.338071947093896 +87.0,11.28750615781779 +88.0,11.106624881791376 +89.0,10.924303060463114 +90.0,10.541237629032665 +91.0,10.1141461562587 +92.0,9.790963765540566 +93.0,10.035046487291524 +94.0,10.369204122877676 +95.0,10.567692491243424 +96.0,10.764517676833991 +97.0,10.911145566196089 +98.0,11.088791761329958 +99.0,11.21288332358327 +100.0,11.140293139405117 +101.0,10.872824219096293 +102.0,10.603469106650794 +103.0,10.441690772406128 +104.0,10.180985771079738 +105.0,9.90380433600949 +106.0,9.553298188962929 +107.0,9.245936317079597 +108.0,9.317680796694018 +109.0,9.352543229630866 +110.0,9.43922640479924 +111.0,9.283718172133549 +112.0,9.160483486901722 +113.0,9.333705596690615 +114.0,9.323248204205411 +115.0,8.976928556774784 +116.0,8.765232099343535 +117.0,8.95666272693918 +118.0,9.210393230809252 +119.0,9.477625227580049 +120.0,9.787108931422086 +121.0,9.998019983750993 +122.0,10.30293879106047 +123.0,10.595659250660816 +124.0,10.764177822255878 +125.0,10.93676685206997 +126.0,11.115501428851838 +127.0,11.0646459144231 +128.0,11.057580551504271 +129.0,11.12085365606258 +130.0,11.18106273766655 +131.0,11.238163427902288 +132.0,11.195603334428675 +133.0,11.14932201360796 +134.0,10.817597013877409 +135.0,10.482919404056744 +136.0,10.14561532131684 +137.0,9.806016412655447 +138.0,9.323559224995243 +139.0,8.855366780624362 +140.0,8.689349817299734 +141.0,8.579422438717867 +142.0,8.562007740248864 +143.0,8.512237579902807 +144.0,8.561619656576145 +145.0,8.644424855461327 +146.0,8.489493764119734 +147.0,8.38108046434231 +148.0,8.29469198070077 +149.0,8.31857536329897 +150.0,8.487216417598493 +151.0,8.41459537173012 +152.0,8.150390224698576 +153.0,7.904330127429618 +154.0,7.206001362202318 +155.0,7.149434691103619 +156.0,6.808615088732718 +157.0,6.860137073746221 +158.0,6.89886088133605 +159.0,6.560633463341427 +160.0,6.04725903513457 +161.0,5.660545559259077 +162.0,5.609699678704124 +163.0,5.840311111223997 +164.0,5.773133251703264 +165.0,5.704117572586686 +166.0,5.845494295224175 +167.0,5.767647440240476 +168.0,5.690338362300757 +169.0,5.697179013028664 +170.0,5.644206814614982 +171.0,5.590401076666938 +172.0,5.498576794985385 +173.0,5.104608891478555 +174.0,4.852850505303378 +175.0,4.671052849775862 +176.0,4.82258619680894 +177.0,4.76562338511152 +178.0,4.564458500818268 +179.0,4.823769362259609 +180.0,4.892620908003659 +181.0,4.697219993107892 +182.0,4.236482231975257 +183.0,3.91718179691071 +184.0,3.819129024277921 +185.0,3.624955710033917 +186.0,3.404418530443192 +187.0,3.303309711413893 +188.0,3.057915072627845 +189.0,2.632177718914165 +190.0,2.240774928760433 +191.0,1.7219095525118049 +192.0,1.467307320935693 +193.0,1.1528110840681194 +194.0,0.8357269183074622 +195.0,0.5633936505577092 +196.0,0.2651291931273941 +197.0,0.0013208630375368 +198.0,-0.1954186781322184 +199.0,-0.411974771096332 +200.0,-0.7505155418721463 +201.0,-0.7955650720924079 +202.0,-0.797635421377629 +203.0,-0.8038440352184065 +204.0,-0.806646561260243 +205.0,-0.8117507049800733 +206.0,-0.8251828224261357 +207.0,-0.8362014364482809 +208.0,-0.8405883055589155 +209.0,-0.8469373693383468 +210.0,-0.8423638186023027 +211.0,-0.846727099644128 +212.0,-0.8557872297968525 +213.0,-0.8786354952539019 +214.0,-0.8925684067869163 +215.0,-0.9044353908685012 +216.0,-0.8702800163456172 +217.0,-0.8509996112085301 +218.0,-0.8610872855402006 +219.0,-0.8572692351542837 +220.0,-0.7783267550293934 +221.0,-0.7352469204675663 +222.0,-0.7939547520516015 +223.0,-0.8105041205240219 +224.0,-0.786303845558534 +225.0,-0.7773666224357054 +226.0,-0.7704871236801382 +227.0,-0.7594762024896473 +228.0,-0.7397839082557862 +229.0,-0.7221967399428696 +230.0,-0.7079324183139396 +231.0,-0.6892504348371303 +232.0,-0.6747715914380132 +233.0,-0.6663426356901091 +234.0,-0.6517494371466048 +235.0,-0.6331668442939896 +236.0,-0.6073353106461542 +237.0,-0.5882814898098515 +238.0,-0.5873012893221498 +239.0,-0.5773414774272905 +240.0,-0.5669943148119039 +241.0,-0.5440883286993651 +242.0,-0.534135716484374 +243.0,-0.5320454363730226 +244.0,-0.5205739837156188 +245.0,-0.5153609122465739 +246.0,-0.4997221663375881 +247.0,-0.4881166005567736 +248.0,-0.4823552425933714 +249.0,-0.4749852676148456 +250.0,-0.4718366994559307 +251.0,-0.4717703597263461 +252.0,-0.4660468321648511 +253.0,-0.4504405695231866 +254.0,-0.4480746700176395 +255.0,-0.4455366940286682 +256.0,-0.4461434901660221 +257.0,-0.4649750843308304 +258.0,-0.45696882195058 +259.0,-0.4437411893990327 +260.0,-0.4377309020453438 +261.0,-0.4359325744123888 +262.0,-0.4357522991795567 +263.0,-0.4325002323979513 +264.0,-0.4280815050069458 +265.0,-0.4223539060621003 +266.0,-0.4177067315769387 +267.0,-0.4098973315022177 +268.0,-0.4053900364361775 +269.0,-0.4049113436378577 +270.0,-0.3983156622643076 +271.0,-0.3968783856864618 +272.0,-0.3824522305761942 +273.0,-0.3807721830232515 +274.0,-0.3765087427614192 +275.0,-0.3638437053847499 +276.0,-0.3543657145797108 +277.0,-0.3575506294484337 +278.0,-0.3591628049238636 +279.0,-0.3591179496506895 +280.0,-0.3604712971455558 +281.0,-0.3510320203037443 +282.0,-0.3292617939830876 +283.0,-0.3125297274762416 +284.0,-0.3141518675253984 +285.0,-0.3066551075068592 +286.0,-0.2979842234008136 +287.0,-0.2980686678915621 +288.0,-0.2981523791662686 +289.0,-0.3022950459673214 +290.0,-0.3007980528256365 +291.0,-0.3039481135517793 +292.0,-0.2912394566649491 +293.0,-0.2869780268209979 +294.0,-0.2886204149041578 +295.0,-0.2826148543271943 +296.0,-0.2644871131405015 +297.0,-0.2442193216895289 +298.0,-0.0636421330538415 +299.0,0.0274649018395962 +300.0,0.1190477313518852 +301.0,0.2110517407539725 +302.0,0.3079737308131581 +303.0,0.4890212294454025 +304.0,0.5928385861902122 +305.0,0.6753729703247171 +306.0,0.7686773602237131 +307.0,0.8619843767306026 +308.0,1.0340554428788606 +309.0,1.1198410519002802 +310.0,1.205382987341714 +311.0,1.2906240032707172 +312.0,1.3755075217023285 +313.0,1.5439802121500736 +314.0,1.627461224666051 +315.0,1.7103687622842 +316.0,1.7926522658174533 +317.0,1.8742628589713304 +318.0,2.035279024585114 +319.0,2.1145964174534946 +320.0,2.1930647486322097 +321.0,2.263648071226961 +322.0,2.33335097922754 +323.0,2.469997115617242 +324.0,2.5368867427218817 +325.0,2.6027887838306287 +326.0,2.667682104388122 +327.0,2.7315478238190614 +328.0,2.856132055877719 +329.0,2.9168238174183885 +330.0,3.388413728520153 +331.0,3.8963901270270296 +332.0,4.301941478093377 +333.0,4.7127399264336205 +334.0,4.7857525781715164 +335.0,4.857136350061577 +336.0,4.995052807841868 +337.0,5.126581151179431 +338.0,5.189986790740501 +339.0,5.391130947758894 +340.0,5.677841899267803 +341.0,5.837802921970733 +342.0,5.9979957083776485 +343.0,6.206456634038168 +344.0,6.398952728893084 +345.0,6.591559289719546 +346.0,6.683430921242239 +347.0,6.806120091575737 +348.0,6.954098308282043 +349.0,7.166882043659863 +350.0,7.379086215329749 +351.0,7.590546245776761 +352.0,7.801096812496296 +353.0,8.154638791982931 +354.0,8.537643111255665 +355.0,8.904198786363292 +356.0,9.198744549804308 +357.0,9.491244398684204 +358.0,9.78147295583302 +359.0,10.069209728268776 diff --git a/pvlib/iotools/__init__.py b/pvlib/iotools/__init__.py index 6f6a254a60..fdc5cba926 100644 --- a/pvlib/iotools/__init__.py +++ b/pvlib/iotools/__init__.py @@ -22,3 +22,4 @@ from pvlib.iotools.sodapro import get_cams # noqa: F401 from pvlib.iotools.sodapro import read_cams # noqa: F401 from pvlib.iotools.sodapro import parse_cams # noqa: F401 +from pvlib.iotools.sodapro import get_mines_horizon # noqa: F401 diff --git a/pvlib/iotools/sodapro.py b/pvlib/iotools/sodapro.py index 9fb4602e09..1241d962fa 100644 --- a/pvlib/iotools/sodapro.py +++ b/pvlib/iotools/sodapro.py @@ -368,3 +368,81 @@ def read_cams(filename, integrated=False, label=None, map_variables=True): with open(str(filename), 'r') as fbuf: content = parse_cams(fbuf, integrated, label, map_variables) return content + + +def get_mines_horizon(latitude, longitude, altitude=None, ground_offset=0, + url='http://toolbox.1.webservice-energy.org/service/wps', + **kwargs): + """Retrieve horizon profile from Shuttle Radar Topography Mission (SRTM). + + Service is provided by MINES ParisTech - Armines (France) + + Parameters + ---------- + latitude: float + in decimal degrees, between -90 and 90, north is positive (ISO 19115) + longitude : float + in decimal degrees, between -180 and 180, east is positive (ISO 19115) + altitude: float, optional + Altitude in meters. If None, then the altitude is determined from the + NASA SRTM database. + ground_offset: float, default 0 + Vertical offset in meters for the point of view for which to calculate + horizon profile. + url: str, default: 'http://toolbox.1.webservice-energy.org/service/wps' + Base URL for MINES ParisTech horizon profile API + kwargs: + Optional parameters passed to requests.get. + + Returns + ------- + data : pd.Series + Pandas Series of the retrived horizon elevation angles. Index is the + corresponding horizon azimuth angles. + metadata : dict + Metadata + + Notes + ----- + The azimuthal resolution is one degree. Also, the returned horizon + elevations can also be negative. + """ + if altitude is None: # API will then infer altitude + altitude = -999 + + # Manual formatting of the input parameters separating each by a semicolon + data_inputs = f"latitude={latitude};longitude={longitude};altitude={altitude}" # noqa: E501 + + params = { + 'service': 'WPS', + 'request': 'Execute', + 'identifier': 'compute_horizon_srtm', + 'version': '1.0.0', + 'ground_offset': ground_offset, + } + + # The DataInputs parameter of the URL has to be manually formatted and + # added to the base URL as it contains sub-parameters seperated by + # semi-colons, which gets incorrectly formatted by the requests function + # if passed using the params argument. + res = requests.get(url + '?DataInputs=' + data_inputs, params=params, + **kwargs) + + # The response text is first converted to a StringIO object as otherwise + # pd.read_csv raises a ValueError stating "Protocol not known: + #