当前位置: 首页>>代码示例>>Python>>正文


Python LOGGER.warn方法代码示例

本文整理汇总了Python中pyiso.LOGGER.warn方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.warn方法的具体用法?Python LOGGER.warn怎么用?Python LOGGER.warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyiso.LOGGER的用法示例。


在下文中一共展示了LOGGER.warn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_trade

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_trade(self, latest=False,
                  start_at=False, end_at=False, **kwargs):
        # set args
        self.handle_options(data='trade', latest=latest,
                            start_at=start_at, end_at=end_at, **kwargs)

        # set up storage
        parsed_data = []

        # collect data
        for this_date in self.dates():
            # fetch
            try:
                df, mode = self.fetch_df(this_date)
            except (HTTPError, ValueError):
                LOGGER.warn('No data available in NVEnergy at %s' % this_date)
                continue

            # store
            try:
                parsed_data += self.parse_trade(df, this_date, mode)
            except KeyError:
                LOGGER.warn('Unparseable data available in NVEnergy at %s: %s' % (this_date, df))
                continue

        # return
        return self.time_subset(parsed_data)
开发者ID:WattTime,项目名称:pyiso,代码行数:29,代码来源:nvenergy.py

示例2: get_load

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_load(self, latest=False, start_at=False, end_at=False,
                 forecast=False, **kwargs):
        # set args
        self.handle_options(data='load', latest=latest, forecast=forecast,
                            start_at=start_at, end_at=end_at, **kwargs)

        # set up storage
        raw_data = []

        # collect raw data
        for endpoint in self.request_endpoints():
            # carry out request
            data = self.fetch_data(endpoint, self.auth)

            # pull out data
            try:
                raw_data += self.parse_json_load_data(data)
            except ValueError as e:
                LOGGER.warn(e)
                continue

        # parse data
        try:
            df = self._parse_json(raw_data)
        except ValueError:
            return []
        df = self.slice_times(df)

        # return
        return self.serialize_faster(df, drop_index=True)
开发者ID:cnblevins,项目名称:pyiso,代码行数:32,代码来源:isone.py

示例3: get_lmp

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_lmp(self, node_id='INTERNALHUB', latest=True, start_at=False, end_at=False, **kwargs):
        # set args
        self.handle_options(data='lmp', latest=latest,
                            start_at=start_at, end_at=end_at, node_id=node_id, **kwargs)
        # get location id
        try:
            locationid = self.locations[node_id.upper()]
        except KeyError:
            raise ValueError('No LMP data available for location %s' % node_id)

        # set up storage
        raw_data = []
        # collect raw data
        for endpoint in self.request_endpoints(locationid):
            # carry out request
            data = self.fetch_data(endpoint, self.auth)

            # pull out data
            try:
                raw_data += self.parse_json_lmp_data(data)
            except ValueError as e:
                LOGGER.warn(e)
                continue

        # parse and slice
        df = self._parse_json(raw_data)
        df = self.slice_times(df)

        # return
        return df.to_dict(orient='record')
开发者ID:cnblevins,项目名称:pyiso,代码行数:32,代码来源:isone.py

示例4: _dst_active_hours_for_transition_day

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def _dst_active_hours_for_transition_day(self, local_dt_index):
        """
        When attempting to localize a timezone-naive list of dates, the daylight savings status may be ambigous. This
        method is meant as a fallback when the ambiguous='infer' datetime handling in pandas fails. It assumes
        that the datetime index is a daylight saving transition day.

        :param pandas.DatetimeIndex local_dt_index: A list of timezone-naive DatetimeIndex values.
        :return: A list of bool values indicating whether daylight savings time is active for the list provided.
            This returned list of boolean value is useful for passing to pandas 'ambiguous' kwarg.
        :rtype: list
        """
        dst_active_list = []
        hour_idx = local_dt_index.hour
        if len(hour_idx) > 3:
            starting_timestamp = local_dt_index[0]
            starting_month = starting_timestamp.month
            starting_hour = starting_timestamp.hour

            if starting_month == 3 and starting_hour == 0:
                dst_active_list = [h > 1 for h in hour_idx]
            elif starting_month == 11 and starting_hour == 0:
                dst_active_list = [h < 2 for h in hour_idx]
            elif 3 < starting_month < 11:
                dst_active_list = [True for h in hour_idx]
            elif starting_month < 3 or starting_month > 11:
                dst_active_list = [False for h in hour_idx]
            else:
                LOGGER.warn("Uanble to infer fallback DST status for ambiguous DatetimeIndex values.")
        return dst_active_list
开发者ID:WattTime,项目名称:pyiso,代码行数:31,代码来源:base.py

示例5: request

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def request(self, *args, **kwargs):
        response = super(PJMClient, self).request(*args, **kwargs)
        if response and response.status_code == 400:
            LOGGER.warn('PJM request returned Bad Request %s' % response)
            return None

        return response
开发者ID:cnblevins,项目名称:pyiso,代码行数:9,代码来源:pjm.py

示例6: fetch_todays_outlook_renewables

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
 def fetch_todays_outlook_renewables(self):
     # get renewables data
     response = self.request(self.base_url_outlook+'renewables.html')
     try:
         return BeautifulSoup(response.content)
     except AttributeError:
         LOGGER.warn('No response for CAISO today outlook renewables')
         return None
开发者ID:avances123,项目名称:pyiso,代码行数:10,代码来源:caiso.py

示例7: get_load

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_load(self, latest=False, start_at=None, end_at=None, forecast=False, **kwargs):
        # set args
        self.handle_options(data='load', latest=latest,
                            start_at=start_at, end_at=end_at, forecast=forecast,
                            **kwargs)

        if self.options['forecast']:
            # fetch from eData
            df = self.fetch_edata_series('ForecastedLoadHistory', {'name': 'PJM RTO Total'})
            sliced = self.slice_times(df)
            sliced.columns = ['load_MW']

            # format
            extras = {
                'freq': self.FREQUENCY_CHOICES.hourly,
                'market': self.MARKET_CHOICES.dam,
                'ba_name': self.NAME,
            }
            data = self.serialize_faster(sliced, extras=extras)

            # return
            return data

        elif self.options['end_at'] and self.options['end_at'] < datetime.now(pytz.utc) - timedelta(hours=1):
            df = self.fetch_historical_load(self.options['start_at'].year)
            sliced = self.slice_times(df)

            # format
            extras = {
                'freq': self.FREQUENCY_CHOICES.hourly,
                'market': self.MARKET_CHOICES.dam,
                'ba_name': self.NAME,
            }
            data = self.serialize_faster(sliced, extras=extras)

            # return
            return data

        else:
            # handle real-time
            load_ts, load_val = self.fetch_edata_point('InstantaneousLoad', 'PJM RTO Total', 'MW')

            # fall back to OASIS
            if not (load_ts and load_val):
                load_ts, load_val = self.fetch_oasis_data()
            if not (load_ts and load_val):
                LOGGER.warn('No PJM latest load data')
                return []

            # format and return
            return [{
                'timestamp': load_ts,
                'freq': self.FREQUENCY_CHOICES.fivemin,
                'market': self.MARKET_CHOICES.fivemin,
                'load_MW': load_val,
                'ba_name': self.NAME,
            }]
开发者ID:cnblevins,项目名称:pyiso,代码行数:59,代码来源:pjm.py

示例8: utcify_index

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def utcify_index(self, local_index, tz_name=None, tz_col=None):
        """
        Convert a DateTimeIndex to UTC.

        :param DateTimeIndex local_index: The local DateTimeIndex to be converted.
        :param string tz_name: If local_ts is naive, it is assumed to be in timezone tz.
            If tz is not provided, the client's default timezone is used.
        :return: DatetimeIndex in UTC.
        :rtype: DatetimeIndex
        """
        # set up tz
        if tz_name is None:
            tz_name = self.TZ_NAME

        # use tz col if given
        if tz_col is not None:
            # it seems like we shouldn't have to iterate, but all the smart ways aren't working
            aware_utc_list = []
            for i in range(len(local_index)):
                try:
                    aware_local_ts = pytz.timezone(tz_col[i]).localize(local_index[i])
                except pytz.UnknownTimeZoneError:
                    # fall back to local ts
                    aware_local_ts = pytz.timezone(tz_name).localize(local_index[i])

                # utcify
                aware_utc_ts = self.utcify(aware_local_ts)
                aware_utc_list.append(aware_utc_ts)

            # indexify
            aware_utc_index = pd.DatetimeIndex(aware_utc_list)

        else:
            # localize
            try:
                aware_local_index = local_index.tz_localize(tz_name)
            except AmbiguousTimeError as e:
                LOGGER.debug(e)
                try:
                    aware_local_index = local_index.tz_localize(tz_name, ambiguous='infer')
                except AmbiguousTimeError:
                    LOGGER.warn('Second DatetimeIndex localization fallback, assuming DST transition day.')
                    dst_active_list = self._dst_active_hours_for_transition_day(local_dt_index=local_index)
                    aware_local_index = local_index.tz_localize(tz_name, ambiguous=dst_active_list)
            except TypeError as e:
                # already aware
                LOGGER.debug(e)
                aware_local_index = local_index

            # convert to utc
            aware_utc_index = aware_local_index.tz_convert('UTC')

        # return
        return aware_utc_index
开发者ID:WattTime,项目名称:pyiso,代码行数:56,代码来源:base.py

示例9: request

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def request(self, url, mode='get', retry_sec=5, **kwargs):
        """
        Get or post to a URL with the provided kwargs.
        Returns the response, or None if an error was encountered.
        If the mode is not 'get' or 'post', raises ValueError.
        """
        # check args
        allowed_modes = ['get', 'post']
        if mode not in allowed_modes:
            raise ValueError('Invalid request mode %s' % mode)

        # check for session
        try:
            session = getattr(self, 'session')
        except AttributeError:
            self.session = requests.Session()
            session = self.session

        # carry out request
        try:
            response = getattr(session, mode)(url, verify=False,
                                              timeout=self.TIMEOUT_SECONDS,
                                              **kwargs)
        # except requests.exceptions.ChunkedEncodingError as e:
        #     # JSON incomplete or not found
        #     msg = '%s: chunked encoding error for %s, %s:\n%s' % (self.NAME, url, kwargs, e)
        #     LOGGER.error(msg)
        #     return None
        except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as e:
            # eg max retries exceeded
            msg = '%s: connection error for %s, %s:\n%s' % (self.NAME, url, kwargs, e)
            LOGGER.error(msg)
            return None
        # except requests.exceptions.RequestException:
        #     msg = '%s: request exception for %s, %s:\n%s' % (self.NAME, url, kwargs, e)
        #     LOGGER.error(msg)
        #     return None

        if response.status_code == 200:
            # success
            LOGGER.debug('%s: request success for %s, %s with cache hit %s' % (self.NAME, url, kwargs, getattr(response, 'from_cache', None)))

        elif response.status_code == 429:
            # retry on throttle
            LOGGER.warn('%s: retrying in %d seconds, throttled for %s, %s' % (self.NAME, retry_sec, url, kwargs))
            sleep(retry_sec)
            return self.request(url, mode=mode, retry_sec=retry_sec, **kwargs)

        else:
            # non-throttle error
            LOGGER.error('%s: request failure with code %s for %s, %s' % (self.NAME, response.status_code, url, kwargs))

        return response
开发者ID:simon71717,项目名称:pyiso,代码行数:55,代码来源:base.py

示例10: get_load

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_load(self, latest=False, yesterday=False, start_at=False, end_at=False, **kwargs):
        super(AESOClient, self).handle_options(latest=latest, yesterday=yesterday, start_at=start_at, end_at=end_at,
                                               **kwargs)

        if latest:
            return self._get_latest_report(request_type=ParserFormat.load)
        elif self.options.get('start_at', None) and self.options.get('end_at', None):
            earliest_load_dt = self.mtn_tz.localize(datetime(year=2000, month=1, day=1, hour=0, minute=0, second=0))
            latest_load_dt = self.local_now().replace(hour=23, minute=59, second=59, microsecond=999999)
            start_at = max(self.options['start_at'], earliest_load_dt).astimezone(self.mtn_tz)
            end_at = min(self.options['end_at'], latest_load_dt).astimezone(self.mtn_tz)
            return self._get_load_for_date_range(start_at=start_at, end_at=end_at)
        else:
            LOGGER.warn('No valid options were supplied.')
开发者ID:WattTime,项目名称:pyiso,代码行数:16,代码来源:aeso.py

示例11: get_lmp

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_lmp(self, node_id, latest=True, start_at=False, end_at=False, **kwargs):
        # set args
        self.handle_options(data='lmp', latest=latest,
                            start_at=start_at, end_at=end_at, **kwargs)

        # get location id
        try:
            locationid = self.locations[node_id.upper()]
        except KeyError:
            raise ValueError('No LMP data available for location %s' % node_id)

        # set up storage
        raw_data = []
        parsed_data = []

        # collect raw data
        for endpoint in self.request_endpoints(locationid):
            # carry out request
            data = self.fetch_data(endpoint, self.auth)

            # pull out data
            try:
                raw_data += self.parse_json_lmp_data(data)
            except ValueError as e:
                LOGGER.warn(e)
                continue

        # parse data
        for raw_dp in raw_data:
            # set up storage
            parsed_dp = {}

            # add values
            parsed_dp['timestamp'] = self.utcify(raw_dp['BeginDate'])
            parsed_dp['lmp'] = raw_dp['LmpTotal']
            parsed_dp['ba_name'] = self.NAME
            parsed_dp['market'] = self.options['market']
            parsed_dp['freq'] = self.options['frequency']
            parsed_dp['node_id'] = node_id
            parsed_dp['lmp_type'] = 'energy'

            # add to full storage
            to_store = True
            if self.options['sliceable']:
                if self.options['start_at'] > parsed_dp['timestamp'] or self.options['end_at'] < parsed_dp['timestamp']:
                    to_store = False
            if to_store:
                parsed_data.append(parsed_dp)

        return parsed_data
开发者ID:ecalifornica,项目名称:pyiso,代码行数:52,代码来源:isone.py

示例12: get_load

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
 def get_load(self, latest=False, yesterday=False, start_at=False, end_at=False, **kwargs):
     self.handle_options(latest=latest, yesterday=yesterday, start_at=start_at, end_at=end_at, data='load')
     loads = []
     if latest:
         self._load_latest(loads)
     elif self._is_valid_date_range():
         self._hourly_range(loads)
     else:
         if self.options.get('forecast', False):
             LOGGER.warn(self.NAME + ': Load forecasts are not supported.')
         else:
             msg = '%s: Requested date range %s to %s is outside range of available data from %s to %s.' % \
                   (self.NAME, self.options.get('start_at', None), self.options.get('end_at', None),
                    self.options.get('earliest_data_at', None), self.options.get('latest_data_at', None))
             LOGGER.warn(msg)
     return loads
开发者ID:WattTime,项目名称:pyiso,代码行数:18,代码来源:yukon.py

示例13: fetch_entsoe

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def fetch_entsoe(self, url, payload, count=0):
        if not getattr(self, 'session', None):
            self.auth()

        r = self.request(url, params=payload)
        # TODO error checking
        if len(r.text) == 0:
            if count > 3:  # try 3 times to get response
                LOGGER.warn('Request failed, no response found after %i attempts' % count)
                return False
            # throttled
            sleep(5)
            return self.fetch_entsoe(url, payload, count + 1)
        if 'UNKNOWN_EXCEPTION' in r.text:
            LOGGER.warn('UNKNOWN EXCEPTION')
            return False
        return r.text
开发者ID:cnblevins,项目名称:pyiso,代码行数:19,代码来源:eu.py

示例14: get_trade

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
 def get_trade(self, latest=False, yesterday=False, start_at=False, end_at=False, **kwargs):
     self.handle_options(latest=latest, yesterday=yesterday, start_at=start_at, end_at=end_at, data='trade')
     # http://yukonenergy.ca/energy-in-yukon/electricity-101/electricity-library/whats-an-isolated-grid-and-what-does-that-mean-for-me
     LOGGER.warn('Yukon Energy is an isolated grid. Trade will always be zero.')
     trades = []
     hourly_rounded_dt = self.options.get('start_at').replace(minute=0, second=0, microsecond=0)
     while hourly_rounded_dt <= self.options.get('end_at'):
         if self.options['start_at'] <= hourly_rounded_dt <= self.options['end_at']:
             trades.append({
                 'ba_name': self.NAME,
                 'timestamp': Timestamp(hourly_rounded_dt),
                 'freq': self.FREQUENCY_CHOICES.hourly,
                 'market': self.MARKET_CHOICES.hourly,
                 'net_exp_MW': 0
             })
         hourly_rounded_dt = hourly_rounded_dt + timedelta(hours=1)
     return trades
开发者ID:WattTime,项目名称:pyiso,代码行数:19,代码来源:yukon.py

示例15: get_load

# 需要导入模块: from pyiso import LOGGER [as 别名]
# 或者: from pyiso.LOGGER import warn [as 别名]
    def get_load(self, latest=False, start_at=False, end_at=False,
                 forecast=False, **kwargs):
        # set args
        self.handle_options(data='load', latest=latest, forecast=forecast,
                            start_at=start_at, end_at=end_at, **kwargs)

        # set up storage
        raw_data = []
        parsed_data = []

        # collect raw data
        for endpoint in self.request_endpoints():
            # carry out request
            data = self.fetch_data(endpoint, self.auth)

            # pull out data
            try:
                raw_data += self.parse_json_load_data(data)
            except ValueError as e:
                LOGGER.warn(e)
                continue

        # parse data
        now = pytz.utc.localize(datetime.utcnow())
        for raw_dp in raw_data:
            # set up storage
            parsed_dp = {}

            # add values
            parsed_dp['timestamp'] = self.utcify(raw_dp['BeginDate'])
            parsed_dp['load_MW'] = raw_dp['LoadMw']
            parsed_dp['ba_name'] = self.NAME
            parsed_dp['market'] = self.options['market']
            parsed_dp['freq'] = self.options['frequency']

            # add to full storage
            if self.options['forecast'] and parsed_dp['timestamp'] < now:
                # don't include past forecast data
                pass
            else:
                parsed_data.append(parsed_dp)

        return parsed_data
开发者ID:ecalifornica,项目名称:pyiso,代码行数:45,代码来源:isone.py


注:本文中的pyiso.LOGGER.warn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。