
    (gB                     t    d dl Z d dlZd dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ ddlmZmZ d Zd	 Zd
 Zd Zy)    N)settings)get_object_or_404)Projeto)DadosTermicos   )&obter_diferenciais_temperatura_paredes/obter_diferenciais_temperatura_insolacao_paredec                    t        t        |       }t        j                  j	                  t
        j                  d|j                   d|j                   d      }t        j                  j                  |      st        d| d      t        j                  |d      }|d	   j                  }|d
   j                  }|d   j                  }|||fS )Nidarquivos_climaticos//dados_climaticos_.csv
O arquivo     não foi encontrado.;)septemperature_2mumidade_absolutacalor_latente)r   r   ospathjoinr   BASE_DIRnome_projetoexistsFileNotFoundErrorpdread_csvvalues)
projeto_idprojetocaminho_csvdadostemperaturas_externasumidade_absoluta_externacalor_latente_aguas          5C:\grfgraph\atual\cag\calculotermica\cargasparedes.pycarregar_temperaturas_projeto2r)      s    J7G'',,x004HI]I]H^^pqx  rF  rF  qG  GK  3L  MK77>>+&*[M9N OPP KK-E!"23::$%78??/66 ":<NNN    c                    t        t        |       }t        j                  j	                  t
        j                  d|j                   d|j                   d      }t        j                  j                  |      st        d| d      t        j                  |d      }t        j                  |d	         |d	<   ||d	   j                  j                  d
k\  |d	   j                  j                  dk  z     }|d   j                  }|S )Nr   r   r   r   r   r   r   )	delimitertime      r   )r   r   r   r   r   r   r   r   r   r   r   r   to_datetimedthourr    )r!   r"   r#   df_climatico	df_diurnotemperaturass         r(   carregar_temperaturas_projetor6      s    J7G'',,x004HI]I]H^^pqx  rF  rF  qG  GK  3L  MK77>>+&*[M9N OPP;;{c:L>>,v*>?Ll6255::a?LQWDXD[D[D`D`dfDfghI-.55Lr*   c                    t        |       }|j                  }g }t        |d| d       }t        |d| d       }t        |d| d       }	|dk(  r||z
  }
n"t               }| d| }|j	                  |      }
|
|
|	|	|z  |
z  }|S )Ntipo_parede_area_parede_coeficiente_parede_externa_)r6   temperatura_internagetattrr   get)r!   paredetermicos
orientacaor%   r=   carga_termicatipo_paredearea_paredecoeficiente_paredediferencialdiferenciais_temperaturakeys                r(   calcular_carga_termica_parederJ   ,   s    9*E"66M&L"=tDK&L"=tDK +>zl)KTRi+.AA#I#K Qzl+.2237;#:?Q?]*[8;Fr*   c                 
   t               }t        | d| d       }|j                  |t        j                  d            }t        | d| d       }t        | d| d       }||
||z  |z  }|S t        j                  d      }|S )Ndiferencial_insolacao_   r9   r:   )r	   r>   r?   npzeros)r@   rB   diferenciais_insolacaorI   diferencial_insolacaorE   rF   carga_insolacaos           r(   calcular_carga_insolacao_parederS   B   s    LN
&2:,?
FC266sBHHRLI&L"=tDK +>zl)KTR#5#A,{:=RR  ((2,r*   )r   pandasr   numpyrN   django.confr   django.shortcutsr   projeto.modelsr   termicos.modelsr   ctermicacalcr   r	   r)   r6   rJ   rS    r*   r(   <module>r\      s2    	     . " ) qO ,r*   