<commit_before>"""
===========================
Solar vertical insolation algorithm based on ArcGIS Solar Analyst
===========================
File history and credits:
<NAME>  script development          10.08.13
<NAME>  adaptation for CEA tool     12.04.16

"""
from __future__ import division

import arcgisscripting
import datetime
import os

import arcpy
import ephem
import numpy as np
import pandas as pd
from simpledbf import Dbf5

from cea.utilities import epwreader

__author__ = "<NAME>"
__copyright__ = "Copyright 2013, Architecture and Building Systems - ETH Zurich"
__credits__ = ["<NAME>", "<NAME>"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"


def solar_radiation_vertical(locator, path_arcgis_db, latitude, longitude, year, gv, weather_path):
    """
    algorithm to calculate the hourly solar isolation in vertical building surfaces.
    The algorithm is based on the Solar Analyst Engine of ArcGIS 10.
    For more info check the integrated demand model of Fonseca et al. 2015. Appl. energy.

    Parameters
    ----------
    path_geometry : string
        path to file buildings_geometry.shp
    path_boundary: renovation
        path to file zone_of_study.shp
    path_arcgis_db: boolean
        path to default database of Arcgis. Generally of the form c:\users\your_name\Documents\Arcgis\Default.gdb
    latitude: float
        latitude north  at the centre of the location
    longitude: float
        latitude north
    timezone: integer
        timezone (UTC)
    year: integer
        year of calculation
    path_dem_raster: string
        path to terrain file
    weather_daily_data: string
        path to weather_day.csv file
    prop_architecture_flag: boolean
        True, get properties about the construction and architecture, otherwise False.
    prop_HVAC_flag: boolean
        True, get properties about types of HVAC systems, otherwise False.
    gv: GlobalVariables
        an instance of globalvar.GlobalVariables with the constants
        to use (like `list_uses` etc.)
    Returns
    -------
    radiation: .csv
        solar radiation file in vertical surfaces of buildings stored in path_output
    """

    if year == 1800: #only for brussels case study
        latitude = 49.8333339
        longitude = 4.36748667

    # Set environment settings
    arcpy.env.workspace = path_arcgis_db
    arcpy.env.overwriteOutput = True
    arcpy.CheckOutExtension("spatial")

    # local variables
    aspect_slope = "FROM_DEM"
    heightoffset = 1
    Simple_CQ = path_arcgis_db + '\\' + 'Simple_CQ'
    Simple_context = path_arcgis_db + '\\' + 'Simple_context'
    dem_rasterfinal = path_arcgis_db + '\\' + 'DEM_All2'
    observers = path_arcgis_db + '\\' + 'observers'
    DataFactorsBoundaries = locator.get_temporary_file('DataFactorsBoundaries.csv')
    DataFactorsCentroids = locator.get_temporary_file('DataFactorsCentroids.csv')
    DataradiationLocation = locator.get_temporary_file('RadiationYear.csv')

    # calculate sunrise
    sunrise = calc_sunrise(range(1,366), year, longitude, latitude, gv)

    # calcuate daily transmissivity and daily diffusivity
    weather_data = epwreader.epw_reader(weather_path)[['dayofyear', 'exthorrad_Whm2',<commit_msg>Revert "Temporal code for running brussels case"<commit_after>"""
===========================
Solar vertical insolation algorithm based on ArcGIS Solar Analyst
===========================
File history and credits:
<NAME>  script development          10.08.13
<NAME>  adaptation for CEA tool     12.04.16

"""
from __future__ import division

import arcgisscripting
import datetime
import os

import arcpy
import ephem
import numpy as np
import pandas as pd
from simpledbf import Dbf5

from cea.utilities import epwreader

__author__ = "<NAME>"
__copyright__ = "Copyright 2013, Architecture and Building Systems - ETH Zurich"
__credits__ = ["<NAME>", "<NAME>"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"


def solar_radiation_vertical(locator, path_arcgis_db, latitude, longitude, year, gv, weather_path):
    """
    algorithm to calculate the hourly solar isolation in vertical building surfaces.
    The algorithm is based on the Solar Analyst Engine of ArcGIS 10.
    For more info check the integrated demand model of Fonseca et al. 2015. Appl. energy.

    Parameters
    ----------
    path_geometry : string
        path to file buildings_geometry.shp
    path_boundary: renovation
        path to file zone_of_study.shp
    path_arcgis_db: boolean
        path to default database of Arcgis. Generally of the form c:\users\your_name\Documents\Arcgis\Default.gdb
    latitude: float
        latitude north  at the centre of the location
    longitude: float
        latitude north
    timezone: integer
        timezone (UTC)
    year: integer
        year of calculation
    path_dem_raster: string
        path to terrain file
    weather_daily_data: string
        path to weather_day.csv file
    prop_architecture_flag: boolean
        True, get properties about the construction and architecture, otherwise False.
    prop_HVAC_flag: boolean
        True, get properties about types of HVAC systems, otherwise False.
    gv: GlobalVariables
        an instance of globalvar.GlobalVariables with the constants
        to use (like `list_uses` etc.)
    Returns
    -------
    radiation: .csv
        solar radiation file in vertical surfaces of buildings stored in path_output
    """

    # Set environment settings
    arcpy.env.workspace = path_arcgis_db
    arcpy.env.overwriteOutput = True
    arcpy.CheckOutExtension("spatial")

    # local variables
    aspect_slope = "FROM_DEM"
    heightoffset = 1
    Simple_CQ = path_arcgis_db + '\\' + 'Simple_CQ'
    Simple_context = path_arcgis_db + '\\' + 'Simple_context'
    dem_rasterfinal = path_arcgis_db + '\\' + 'DEM_All2'
    observers = path_arcgis_db + '\\' + 'observers'
    DataFactorsBoundaries = locator.get_temporary_file('DataFactorsBoundaries.csv')
    DataFactorsCentroids = locator.get_temporary_file('DataFactorsCentroids.csv')
    DataradiationLocation = locator.get_temporary_file('RadiationYear.csv')

    # calculate sunrise
    sunrise = calc_sunrise(range(1,366), year, longitude, latitude, gv)

    # calcuate daily transmissivity and daily diffusivity
    weather_data = epwreader.epw_reader(weather_path)[['dayofyear', 'exthorrad_Whm2',
{'fraction_non_alphanumeric': 0.09113376583256101, 'fraction_numerical': 0.013283904850169911, 'mean_word_length': 3.5059151009046623, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892700', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1886, 'n_words': 589}