a `§»eÑã @sàdZddlZddlZdZzpzddlmZdZWnJeyxzddl mZdZWn"eyrddlmZdZYn0Yn0Wes˜e dƒnes–e dƒ0dd„Z dd d d gfd d „Z d d gfd d„Z dd„Zdd„Zdd„ZdS)aN MicaSense Downwelling Light Sensor Utilities Copyright 2017 MicaSense, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. éNFTzUnable to import pysolarcCst|gd¢dS)N)çNŸt"ð?gš™™™™™ù?ç®Gázö?)Ún)Ú__multilayer_transmission)Úphi©rú/code/opendm/dls.pyÚfresnel1sr rrgà?c Cs¸t |¡}t d||t |¡d¡}||||||||d}||||||||d}d|d||d|}|dkršd}|dkr¦d}t |¡r´d}|S)zLcompute fresnel transmission between media with refractive indices n1 and n2ééçð?rg)ÚnpÚcosÚsqrtÚsinÚisnan) rÚn1Ún2Ú polarizationÚf1Úf2ZRsZRpÚTrrrÚ__fresnel_transmission5s  $$  rcCsfd}t |¡}tdt|ƒdƒD]@}||}||d}t t |¡|¡}|t||||d9}q |S)Nr rr )r)r ÚcopyÚrangeÚlenÚarcsinrr)rrrrZphi_effÚirrrrrrIs  rcCs@t |¡t |¡t |¡t |¡t |¡ f}t |¡ ¡S)z/Convert pysolar coordinates to NED coordinates.)r rrÚarrayÚ transpose)Ú sunAzimuthÚ sunAltitudeÚelementsrrrÚned_from_pysolarTs  ýr#cCsÜ|\}}}t | ¡}t | ¡}t | ¡}t | ¡}t | ¡} t | ¡} t ||dg| |dggd¢g¡} t |d| ggd¢|d|gg¡} t gd¢d| | gd| | gg¡} t | t | | ¡¡}t ||¡}|S)zEGenerate an orientation vector from yaw/pitch/roll angles in radians.r)rrr )rr r)r rr)r rrrÚdot)ÚposeZoriÚyawÚpitchÚrollÚc1Ús1Úc2Ús2Úc3Ús3ZRyawZRpitchZRrollÚRrrrrÚget_orientation`s       """ r0c Cs d}d}ddl}| ¡è| d¡z0t |d|d|¡}t |d|d|¡}WnBty–t |d|d|¡}dt |d|d|¡}Yn0t   t   |¡¡}t   t   |¡¡}|dt j }t ||ƒ} t   t||ƒ¡} t  t  | | ¡¡} Wdƒn1s0Y| | | ||fS)z. compute the sun angle using pysolar functionsrNÚignorer é´r )ÚwarningsÚcatch_warningsÚ simplefilterÚpysolarZ get_altitudeZ get_azimuthÚAttributeErrorZ GetAltitudeZ GetAzimuthr ÚradiansrÚpir#r0Úarccosr$) Úpositionr%Z utc_datetimeZsensor_orientationÚaltitudeÚazimuthr3r!r ZnSunZnSensorÚanglerrrÚcompute_sun_angleys$     2r?)Ú__doc__Únumpyr ÚimpZ havePysolarZ pysolar.solarZsolarr6Ú ImportErrorZ Pysolar.solarÚprintr rrr#r0r?rrrrÚs.      ÿ