예제 #1
0
    def get_meteo_data_monthly(self, met_param, station, months):
        """
       This function get monthly value for a parameter
       :param met_param: the type of meterological parameter
       :param station: the name of the meteorological station (string)
       :param months: the months of interest as string or as int (0 is january)
       :return: A list with the value of the month of interest
       """
        # get whole data
        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)
        datam = self._meteo_data[met_param]
        station = find_string(station, datam['station_name'], self._cutoff)

        # get data by month
        months = list(months)
        data_month = []
        jan_ind = datam.columns.get_loc(conf.month_name[0])
        for m in months:
            if isinstance(m, float) or isinstance(m, int):
                data_month.append(
                    float(datam.loc[datam['station_name'] ==
                                    station, :].iloc[:, jan_ind + m]))
            else:
                m_name = find_string(m, conf.month_name, self._cutoff)
                data_month.append(datam.loc[datam['station_name'] == station,
                                            m_name].iloc[0])

        return data_month
예제 #2
0
파일: kbob.py 프로젝트: CREM-APP/OSEM
    def get_value(self, techno, indicator, language="ENG", ener_type=None):
        """
        This function load one value of the kbob as a function of the user choice

        :param techno: string - the technology chosen
        :param indicator: string - the requested indicator
        :param language: string - the requested language
        :return: float - the value of the indicator
        """
        self._check_language(language)

        # in case we only want useful or final energy
        if ener_type is not None:
            all_techno = self.data.loc[self.data["EnerType"] == ener_type, :]
            all_techno = all_techno[language].values.tolist()
        else:
            all_techno = self.data[language].values.tolist()

        # find string
        tech_found = find_string(techno, all_techno, self._cutoff)
        indi_found_lang = find_string(indicator,
                                      self.index_translation[language],
                                      self._cutoff)

        indi_found = self.index_translation.loc[
            self.index_translation[language] == indi_found_lang,
            'ENG'].values[0]

        return self.data.loc[self.data[language] == tech_found,
                             indi_found].values[0]
예제 #3
0
    def get_objective(self, politic_type, objective_type, return_year=True):
        """
        This function return the political objective
        :param objective_type: string - the type of objective (C02 emisson, primary energy, etc.)
        :param politic_type: string - the name of the political frame work
        :param return_year: bool- if True return the reference and objective year
        """

        # match the strings proposed by the user
        objective_found = find_string(objective_type, self._name_objective,
                                      self._cutoff)
        politic_found = find_string(politic_type, self.db_obj.index,
                                    self._cutoff)

        # get the objective
        objective_value = self.db_obj.loc[politic_found, objective_found]

        # year
        if return_year:
            year_ref = self.db_obj.loc[politic_found, "reference_year"]
            year_obj = self.db_obj.loc[politic_found, "objective_year"]
            objective_dict = {
                'value': objective_value,
                'year_ref': year_ref,
                'year_obj': year_obj
            }
            return objective_dict
        else:
            return objective_value
예제 #4
0
    def get_meteo_data_annual(self, met_param, station):
        """
        This function get annual value for a parameter
        :param met_param: the type of meterological parameters
        :param station: the name of the meteorological station (string)
        :return:
        """

        # get data
        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)
        datam = self._meteo_data[met_param]
        station = find_string(station, datam['station_name'], self._cutoff)

        return datam.loc[datam['station_name'] == station,
                         self._col_name[-1]].iloc[0]
예제 #5
0
    def get_energy_final(self, data_heating, temp_building=None):
        """
        This function return the final energy from the useful energy. For an heat pump, the efficiency accounts
         for the building temperature through Carnot.
        :param data_heating: A dataframe with the following columns: scenario, year, <technology 1>, <technology 2>,...
        :param temp_build: the temperature of the buildings in the form
               [[Percent building1, Percent building2,...], [T1, T2,...]] in Celsius.
        :return: a dataframe with the final energy
        """
        # temperature of the building
        if temp_building is not None:
            self.temp_building = temp_building
        self.temp_building = np.array(self.temp_building)

        # create the output dataframe
        final_energy = _create_empty_output(data_heating)

        # compute final energy
        for tech_name0 in data_heating.columns[2:]:
            # get correct name
            tech_name = find_string(tech_name0,
                                    self._data_efficiency.index,
                                    cutoff=self._cutoff)

            # get efficency
            eff = self._data_efficiency.loc[tech_name, "efficiency"]
            if 'heat' in tech_name and 'pump' in tech_name:
                carnot = (self.temp_building[:, 1] + self.zero_abs
                          ) / np.abs(self.temp_building[:, 1] - self._temp_ext)
                eff = eff * np.sum(carnot * self.temp_building[:, 0] / 100)

            # get final energy
            final_energy[tech_name] = data_heating[tech_name0] / eff

        return final_energy
예제 #6
0
    def get_reference(self, politic_type):
        """Obtain a reference for the political objective of interest.
        :param politic_type: string - the name of the political frame work
        """

        politic_found = find_string(politic_type, self.db_obj.index,
                                    self._cutoff)
        return self.db_obj.loc[politic_found, "reference"].iloc[0]
예제 #7
0
    def get_unit(self, met_param):
        """
        This funtion return the units of the meteorological parameter
        :param met_param: the type of meterological parameter
        """
        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)

        return self._unit_data[met_param].strip()
예제 #8
0
    def get_reference(self, met_param):
        """
        retrun the reference of the data for the meterological parameter of interest.
        :param met_param: the type of meteorological parameter of interest
        """

        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)
        return self.reference[met_param]
예제 #9
0
    def get_units(self, techno_choice):
        """
        This function returns the type of units for each technology. In other words, is the price given by m2, by kW or
        by m, etc.
        :param techno_choice: string - the name of the technology of interest
        :return: a string representing the unit
        """
        techno_correct = find_string(techno_choice, self._techno_list,
                                     self._cutoff)

        return self._units[techno_correct]
예제 #10
0
    def _get_techno_and_price(self, techno_choice, price_choice):
        """
        This function takes the string from the user with his/her choice of technology and price and return them in the
        correct form
        :param techno_choice: string - the name of the technology of interest
        :param price_choice: string - the type of price (CAPEX, OPEX, etc)
        :return:
        """

        techno_correct = find_string(techno_choice, self._techno_list,
                                     self._cutoff)
        if price_choice == 'OPEX':
            price_choice = conf.opex_name

        price_type = [
            c for c in self.db_price[techno_correct].columns
            if c not in self._column_not_print
        ]
        price_correct = find_string(price_choice, price_type, self._cutoff)

        return techno_correct, price_correct
예제 #11
0
파일: kbob.py 프로젝트: CREM-APP/OSEM
    def get_units(self, choice_col):
        """
        This function return the units of the different data type
        :return: the unit as string
        """
        name_found = find_string(choice_col, self.data.columns, self._cutoff)
        if not name_found:
            raise ValueError(
                "The requested data {} does not match any entry.".format(
                    choice_col))

        return self.unit[name_found].values[0]
예제 #12
0
    def get_type_of_price_available(self, techno_choice):
        """
        This function return the type of price (installation, CAPEX, maintenance, etc.) available for the technology
        :param techno_choice: string - the name of the technology of interest
        """
        techno_correct = find_string(techno_choice, self._techno_list,
                                     self._cutoff)
        price_type = [
            c for c in self.db_price[techno_correct].columns
            if c not in self._column_not_print
        ]

        return price_type
예제 #13
0
    def get_meteo_station(self, met_param, return_coord=False):
        """
        This function get the meteorological station available for a particular meteorological parameter
        :param met_param: the type of meteorological parameter of interest
        :param return_coord: If True, the coordinates (CH1903/LV95) are returned with the station
        :return: A Serie of string which are the station name (and maybe the coordinates)
        """
        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)

        if return_coord:
            return self._meteo_data[
                met_param].loc[:, ['station_name', 'coordinates_CH']]
        else:
            return self._meteo_data[met_param].loc[:, 'station_name']
예제 #14
0
    def get_closest_station(self,
                            met_param,
                            coordinates,
                            altitude=None,
                            max_alt_diff=None):
        """
        This function finds the station which is the closest to a point described by its coordinates. If an altitude
        and a maximum altitude difference is given, it finds the closest station within the altitude difference.
        :param met_param: the type of meteorological parameter of interest
        :param coordinates: The coordinates of the study area in the coordinate system CH1903/LV95
        :param altitude: the altitude at the coordinate at the point of interest (optional)
        :param max_alt_diff: the max altitude difference between the station and the point of interest (opt)
        :return: the characteristics of the station (name, altitude, distance, coordinate) in a Series
        """

        # get data
        met_param = find_string(met_param, self._meteo_data.keys(),
                                self._cutoff)
        datam = self._meteo_data[met_param]

        # add constraint on altitude
        if altitude is not None and max_alt_diff is not None:
            datam = datam.loc[abs(datam['elev_m'] - altitude) < max_alt_diff,
                              'elev_m']

        # get distance
        dist = np.sqrt((coordinates[0] - datam['coord_x'])**2 +
                       (coordinates[1] - datam['coord_y'])**2).values
        arg_min_dist = np.argmin(dist)
        dist_min = dist[arg_min_dist]

        # return data
        sta = datam.iloc[arg_min_dist, :]
        sta = pd.concat(
            (sta, pd.Series(data=[dist_min],
                            index=['distance_m'])))  # avoid warning
        return sta[['station_name', 'elev_m', 'coordinates_CH', 'distance_m']]