예제 #1
0
    def _validate_inputs(self):
        weekday_schedule = self.weekday_chart.get_schedule()
        weekend_schedule = self.weekend_chart.get_schedule()

        # Get period/rates from table.
        tou_rates_dict = self.tou_period_table.get_rates()
        periods = set([int(period) for period in tou_rates_dict.keys()])

        # Determine if any values in schedule are not in period list.
        weekday_periods = set(np.unique(weekday_schedule))
        weekend_periods = set(np.unique(weekend_schedule))

        if not weekday_periods.issubset(periods):
            set_diff = ', '.join([
                '{:d}'.format(int(x))
                for x in sorted(weekday_periods.difference(periods))
            ])

            raise (InputError(
                'Impermissible entries ({0}) in the Weekday Rate Schedule found.'
                .format(set_diff)))

        if not weekend_periods.issubset(periods):
            set_diff = ', '.join([
                '{:d}'.format(int(x))
                for x in sorted(weekend_periods.difference(periods))
            ])

            raise (InputError(
                'Impermissible entries ({0}) in the Weekend Rate Schedule found.'
                .format(set_diff)))

        flat_rates_dict = self.flat_period_table.get_rates()

        return weekday_schedule, weekend_schedule, tou_rates_dict, flat_rates_dict
예제 #2
0
    def _validate_inputs(self):
        """Validates the search parameters."""
        # Check if an API key has been provided.
        api_key = self.api_key_input.text

        if not api_key:
            raise (InputError('Please enter an OpenEI API key.'))

        pv_params = self.param_widget.get_inputs()

        # Check module and array type spinners.
        module_types = self.module_type_select.values
        array_types = self.array_type_select.values

        try:
            module_ix = module_types.index(self.module_type_select.text)
            pv_params['module_type'] = str(module_ix)
        except ValueError:
            raise (InputError('Please specify a valid module type.'))

        try:
            array_ix = array_types.index(self.array_type_select.text)
            pv_params['array_type'] = str(array_ix)
        except ValueError:
            raise (InputError('Please specify a valid array type.'))

        return api_key, pv_params
예제 #3
0
    def _validate_inputs(self):
        if not self.peak_kw_min_field.text:
            raise (InputError(
                'The peak demand minimum must be specified. If there is no minimum, please set it to 0.'
            ))
        else:
            peak_kw_min = int(self.peak_kw_min_field.text)

        if self.peak_kw_max_field.text:
            if peak_kw_min > int(self.peak_kw_max_field.text):
                raise (InputError(
                    'The peak demand minimum must be less than the maximum.'))
            else:
                peak_kw_max = int(self.peak_kw_max_field.text)
        else:
            peak_kw_max = np.inf

        if not any([
                self.net_metering_1_toggle.state == 'down',
                self.net_metering_2_toggle.state == 'down'
        ]):
            raise (InputError('Please specify a net energy metering type.'))
        else:
            net_metering_type = self.net_metering_2_toggle.state == 'down'

        if self.net_metering_1_toggle.state == 'down' and not self.net_metering_sell_price_field.text:
            raise (InputError(
                'Please specify an energy sell price when selecting "Net metering 1.0."'
            ))
        else:
            sell_price = float(
                self.net_metering_sell_price_field.text
            ) if self.net_metering_1_toggle.state == 'down' else None

        return peak_kw_min, peak_kw_max, net_metering_type, sell_price
예제 #4
0
    def _validate_inputs(self):
        """Validates the search parameters."""
        # Check if an API key has been provided.
        api_key = self.api_key_input.text

        if not api_key:
            raise (InputError('Please enter an OpenEI API key.'))

        # Check if a search string has been provided.
        search_query = self.search_text_input.text

        if not search_query:
            raise (InputError('Please enter a search query.'))

        # Check if a search type has been specified.
        if self.by_name_toggle.state == 'down':
            search_type = 'utility_name'
        elif self.by_zip_toggle.state == 'down':
            search_type = 'zip'
        elif self.by_state_toggle.state == 'down':
            search_type = 'state'
        else:
            raise (InputError(
                'Please select a search type. (by name, by zip, or by state)'))

        return api_key, search_query, search_type
예제 #5
0
    def get_selections(self):
        """Retrieves UI selections."""
        if not self.utility_selected:
            raise (InputError('Please select a utility before proceeding.'))

        if not self.rate_structure_selected:
            raise (InputError(
                'Please select a rate structure before proceeding.'))

        return self.utility_selected, self.rate_structure_selected
예제 #6
0
    def _validate_inputs(self):
        if self.iso_select.text == 'Select market area':
            raise (InputError('No market area selected.'))

        if self.revstreams_select.text == 'Select revenue streams':
            raise (InputError('No revenue streams selected.'))

        if not self.node:
            raise (InputError('No pricing node selected.'))

        rv_selected = [self.month_rv.data[selected_ix] for selected_ix in self.month_rv.layout_manager.selected_nodes]

        if not rv_selected:
            raise (InputError('No data selected.'))
예제 #7
0
    def _validate_inputs(self):
        try:
            rate_dict = {
                rate.desc['period']: float(rate.text_input.text)
                for rate in self.period_rows
            }
        except ValueError:
            # An empty input.
            raise (
                InputError('All rates in the rate table must be specified.'))

        return rate_dict
예제 #8
0
    def _validate_inputs(self):
        iso_selected = self.iso_select.text

        data_manager = App.get_running_app().data_manager

        try:
            self.iso_select.values.index(iso_selected)
        except ValueError:
            raise InputError('Select a market area in "Select Data."')

        try:
            node_selected = self.node['nodeid']
            market_models_available = data_manager.get_valuation_revstreams(
                iso_selected, node_selected)
        except KeyError:
            raise InputError('Select a pricing node in "Select Data."')

        if node_selected not in data_manager.get_nodes(iso_selected).keys():
            raise InputError('Select a pricing node in "Select Data."')

        rev_streams = self.type_select.text

        if rev_streams not in market_models_available.keys():
            raise InputError('Select revenue streams in "Select Data."')

        try:
            year_selected = int(self.year_select.text)
        except ValueError:
            raise InputError('Select a year in "Select Data."')

        try:
            month_selected = list(calendar.month_name).index(
                self.month_select.text)
        except ValueError:
            raise InputError('Select a month in "Select Data."')
예제 #9
0
    def _validate_inputs(self):
        schedule_array = np.empty((12, 24), dtype=int)

        try:
            for ix, month_row in enumerate(self.schedule_rows, start=0):
                for iy, text_input in enumerate(month_row.text_inputs,
                                                start=0):
                    schedule_array[ix, iy] = int(text_input.text)
        except ValueError:
            # A TextInput is empty.
            raise (InputError('All schedule hours must be populated.'))

        return schedule_array
예제 #10
0
    def get_inputs(self):
        """Retrieves the search inputs and validates them."""
        api_key, search_query, search_type = self._validate_inputs()

        if search_type == 'zip':
            try:
                search_query = int(search_query)
            except ValueError:
                raise (InputError(
                    'When searching by zip, please provide a five digit numeric search query. (got "{0}")'
                    .format(search_query)))
        else:
            search_query = search_query.lower()

        return api_key, search_query, search_type
예제 #11
0
    def _validate_inputs(self):
        param_dict = self.param_widget.get_inputs(use_hint_text=True)

        # If a parameter sweep is specified, check all input fields.
        param_sweep_name = self.param_sweep_spinner.text

        if self.param_to_attr.get(param_sweep_name, False):
            param_sweep_attr_name = self.param_to_attr[param_sweep_name]

            try:
                param_min = float(self.param_min_input.text)
                param_max = float(self.param_max_input.text)
                param_step = int(self.param_step_input.text)
            except ValueError:
                raise InputError('All range input fields must be populated when specifying a parameter sweep.')
            else:
                if param_max < param_min:
                    raise InputError('Parameter sweep minimum must be less than or equal to the maximum.')
            
            # Values cannot be negative.
            if any([param_min < 0, param_max < 0]):
                raise InputError('"{0}" cannot be negative.'.format(param_sweep_name))

            # Percentages cannot exceed 100%.
            if param_sweep_attr_name in {'Self_discharge_efficiency', 'Round_trip_efficiency', 'State_of_charge_init', 'State_of_charge_min', 'State_of_charge_max', 'Reserve_reg_min', 'Reserve_reg_max',} and any([param_min > 100, param_max > 100]):
                raise InputError('"{0}" cannot exceed 100%.'.format(param_sweep_name))
            
            # State of charge initial, min, and max sweeps must comply with inequalities.
            if param_sweep_attr_name == 'State_of_charge_min':
                if not all([param_min < param_dict['State_of_charge_init'], param_max <= param_dict['State_of_charge_init']]):
                    raise InputError('The parameter sweep range for "{0}" must be entirely less than the initial state of charge.'.format(param_sweep_name))
            elif param_sweep_attr_name == 'State_of_charge_max':
                if not all([param_min >= param_dict['State_of_charge_init'], param_max > param_dict['State_of_charge_init']]):
                    raise InputError('The parameter sweep range for "{0}" must be entirely greater than the initial state of charge.'.format(param_sweep_name))
            elif param_sweep_attr_name == 'State_of_charge_init':
                if not all([
                    param_dict['State_of_charge_max'] > param_min,
                    param_dict['State_of_charge_max'] >= param_max,
                    param_dict['State_of_charge_min'] <= param_min,
                    param_dict['State_of_charge_min'] < param_max,
                    ]):
                    raise InputError('The parameter sweep range for "{0}" must be entirely between the minimum and maximum state of charge values.'.format(param_sweep_name))
        else:
            if any([self.param_min_input.text, self.param_max_input.text, self.param_step_input.text]):
                raise InputError('Did you forget to provide a parameter for the parameter sweep? Numbers for the sweep range were provided but no parameter was given.')