Create a Wind Condition from a dictionary.

        Args:
            data = {
            "wind_speed": float,
            "wind_direction": float,
            "rain": bool,
            "snow_on_ground": bool}
349123
def from_json(cls, data):
        
        # Check required and optional keys
        optional_keys = {'wind_direction': 0, 'rain': False, 'snow_on_ground': False}
        assert 'wind_speed' in data, 'Required key "wind_speed" is missing!'
        for key, val in optional_keys.items():
            if key not in data:
                data[key] = val

        return cls(data['wind_speed'], data['wind_direction'], data['rain'],
                   data['snow_on_ground'])
209927
function (response) {
          document.getElementById("windmillWeather").innerHTML = "<div>Current conditions</div>" + '<img class="icon" src="https://openweathermap.org/img/w/' + response.weather[0].icon + '.png' + '"><span>' + response.weather[0].main + ", Temp: " + response.main.temp + "'c, Wind: " + response.wind.speed + " (m/s)</span>";
        }
281091
def _create_feed_dict(self, data):
        
        return {
            self.input_data: data,
            self.hrand: np.random.rand(data.shape[0], self.num_hidden),
            self.vrand: np.random.rand(data.shape[0], data.shape[1])
        }
601037
def items(cls):
        
        return [
            cls.PRECIPITATION,
            cls.WIND,
            cls.TEMPERATURE,
            cls.PRESSURE
        ]
1291492
def decode_wind(s)

      if s =~ /(\d{3})(\d{2})G?(\d{2})?(KT|MPS|KMH)/
        # different units
        wind = case $4
                 when "KT" then
                   $2.to_f * KNOTS_TO_METERS_PER_SECOND
                 when "MPS" then
                   $2.to_f
                 when "KMH" then
                   $2.to_f * KILOMETERS_PER_HOUR_TO_METERS_PER_SECOND
                 else
                   nil
               end

        wind_max = case $4
                     when "KT" then
                       $3.to_f * KNOTS_TO_METERS_PER_SECOND
                     when "MPS" then
                       $3.to_f
                     when "KMH" then
                       $3.to_f * KILOMETERS_PER_HOUR_TO_METERS_PER_SECOND
                     else
                       nil
                   end

        # wind_max is not less than normal wind
        if wind_max < wind or wind_max.nil?
          wind_max = wind
        end

        @winds << {
          :wind => wind,
          :wind_max => wind_max,
          :wind_direction => $1.to_i
        }
      end

      # variable/unknown direction
      if s =~ /VRB(\d{2})(KT|MPS|KMH)/
        wind = case $2
                 when "KT" then
                   $1.to_f * KNOTS_TO_METERS_PER_SECOND
                 when "MPS" then
                   $1.to_f
                 when "KMH" then
                   $1.to_f * KILOMETERS_PER_HOUR_TO_METERS_PER_SECOND
                 else
                   nil
               end

        @winds << {
          :wind => wind
        }

      end
    end
776367
def add_weatherdata(self, data):
        
        if not isinstance(data, WeatherData):
            raise ValueError('Weather data need to be of type WeatherData')
        self._data["WEATHER DATA"].append(data)
1241350
def get_weather(self):
        
        import predix.data.weather
        weather = predix.data.weather.WeatherForecast()
        return weather
409038
def create_from_dict(self, dictionary):
        
        # Defaults
        args = []
        kwargs = {}
        factory_method = None
        factory_args = []
        factory_kwargs = {}
        static = False
        calls = None

        # Check dictionary for arguments
        if 'args' in dictionary:
            args = dictionary['args']

        if 'kwargs' in dictionary:
            kwargs = dictionary['kwargs']

        if 'factory-method' in dictionary:
            factory_method = dictionary['factory-method']

        if 'factory-args' in dictionary:
            factory_args = dictionary['factory-args']

        if 'factory-kwargs' in dictionary:
            factory_kwargs = dictionary['factory-kwargs']

        if 'static' in dictionary:
            static = dictionary['static']

        if 'calls' in dictionary:
            calls = dictionary['calls']

        return self.create(
            dictionary['module'],
            dictionary['class'],
            args=args,
            kwargs=kwargs,
            factory_method=factory_method,
            factory_args=factory_args,
            factory_kwargs=factory_kwargs,
            static=static,
            calls=calls
        )
1347599
def from_dict(data, ctx):
        

        data = data.copy()

        if data.get('balance') is not None:
            data['balance'] = ctx.convert_decimal_number(
                data.get('balance')
            )

        if data.get('pl') is not None:
            data['pl'] = ctx.convert_decimal_number(
                data.get('pl')
            )

        if data.get('resettablePL') is not None:
            data['resettablePL'] = ctx.convert_decimal_number(
                data.get('resettablePL')
            )

        if data.get('financing') is not None:
            data['financing'] = ctx.convert_decimal_number(
                data.get('financing')
            )

        if data.get('commission') is not None:
            data['commission'] = ctx.convert_decimal_number(
                data.get('commission')
            )

        if data.get('guaranteedExecutionFees') is not None:
            data['guaranteedExecutionFees'] = ctx.convert_decimal_number(
                data.get('guaranteedExecutionFees')
            )

        if data.get('marginRate') is not None:
            data['marginRate'] = ctx.convert_decimal_number(
                data.get('marginRate')
            )

        if data.get('unrealizedPL') is not None:
            data['unrealizedPL'] = ctx.convert_decimal_number(
                data.get('unrealizedPL')
            )

        if data.get('NAV') is not None:
            data['NAV'] = ctx.convert_decimal_number(
                data.get('NAV')
            )

        if data.get('marginUsed') is not None:
            data['marginUsed'] = ctx.convert_decimal_number(
                data.get('marginUsed')
            )

        if data.get('marginAvailable') is not None:
            data['marginAvailable'] = ctx.convert_decimal_number(
                data.get('marginAvailable')
            )

        if data.get('positionValue') is not None:
            data['positionValue'] = ctx.convert_decimal_number(
                data.get('positionValue')
            )

        if data.get('marginCloseoutUnrealizedPL') is not None:
            data['marginCloseoutUnrealizedPL'] = ctx.convert_decimal_number(
                data.get('marginCloseoutUnrealizedPL')
            )

        if data.get('marginCloseoutNAV') is not None:
            data['marginCloseoutNAV'] = ctx.convert_decimal_number(
                data.get('marginCloseoutNAV')
            )

        if data.get('marginCloseoutMarginUsed') is not None:
            data['marginCloseoutMarginUsed'] = ctx.convert_decimal_number(
                data.get('marginCloseoutMarginUsed')
            )

        if data.get('marginCloseoutPercent') is not None:
            data['marginCloseoutPercent'] = ctx.convert_decimal_number(
                data.get('marginCloseoutPercent')
            )

        if data.get('marginCloseoutPositionValue') is not None:
            data['marginCloseoutPositionValue'] = ctx.convert_decimal_number(
                data.get('marginCloseoutPositionValue')
            )

        if data.get('withdrawalLimit') is not None:
            data['withdrawalLimit'] = ctx.convert_decimal_number(
                data.get('withdrawalLimit')
            )

        if data.get('marginCallMarginUsed') is not None:
            data['marginCallMarginUsed'] = ctx.convert_decimal_number(
                data.get('marginCallMarginUsed')
            )

        if data.get('marginCallPercent') is not None:
            data['marginCallPercent'] = ctx.convert_decimal_number(
                data.get('marginCallPercent')
            )

        if data.get('trades') is not None:
            data['trades'] = [
                ctx.trade.TradeSummary.from_dict(d, ctx)
                for d in data.get('trades')
            ]

        if data.get('positions') is not None:
            data['positions'] = [
                ctx.position.Position.from_dict(d, ctx)
                for d in data.get('positions')
            ]

        if data.get('orders') is not None:
            data['orders'] = [
                ctx.order.Order.from_dict(d, ctx)
                for d in data.get('orders')
            ]

        return Account(**data)
507306
def create_dicts(data):
    
    chars = set()
    for sample in data:
        chars.update(set(sample))
    char_indices = dict((c, i) for i, c in enumerate(chars))
    indices_char = dict((i, c) for i, c in enumerate(chars))
    return char_indices, indices_char
972089
def items(cls):
        
        return [
            cls.TEMPERATURE,
            cls.PRESSURE,
            cls.HUMIDITY,
            cls.WIND_SPEED,
            cls.WIND_DIRECTION,
            cls.CLOUDS
        ]
1164557
async def forecast(self, globalIdLocal):
        """"""

        data = await self.retrieve(API_FORECAST + "{globalIdLocal}.json".
                                   format(globalIdLocal=globalIdLocal))

        if not self.weather_type:
            await self.weather_type_classe()

        if not self.wind_type:
            await self.wind_type_classe()

        _forecasts = []
        for forecast in data['data']:
            Forecast = namedtuple('Forecast', list(forecast.keys())+['description'])
            _description = self.weather_type[forecast['idWeatherType']]
            if forecast['classWindSpeed'] != -99.0:
                _description += ", com vento "+ self.wind_type[forecast['classWindSpeed']] +\
                                " de " + WIND_DIRECTION[forecast['predWindDir']]
            vals = [self._to_number(v) for v in forecast.values()] + [_description]
            _forecasts.append(Forecast(*vals))
        return _forecasts
709469
def oneday_weather_forecast(
        location='Portland, OR',
        inputs=('Min Temperature', 'Mean Temperature', 'Max Temperature', 'Max Humidity', 'Mean Humidity', 'Min Humidity', 'Max Sea Level Pressure', 'Mean Sea Level Pressure', 'Min Sea Level Pressure', 'Wind Direction'),
        outputs=('Min Temperature', 'Mean Temperature', 'Max Temperature', 'Max Humidity'),
        date=None,
        epochs=200,
        delays=(1, 2, 3, 4),
        num_years=4,
        use_cache=False,
        verbosity=1,
        ):
    
    date = make_date(date or datetime.datetime.now().date())
    num_years = int(num_years or 10)
    years = range(date.year - num_years, date.year + 1)
    df = weather.daily(location, years=years, use_cache=use_cache, verbosity=verbosity).sort()
    # because up-to-date weather history was cached above, can use that cache, regardless of use_cache kwarg
    trainer, df = train_weather_predictor(
        location,
        years=years,
        delays=delays,
        inputs=inputs,
        outputs=outputs,
        epochs=epochs,
        verbosity=verbosity,
        use_cache=True,
        )
    nn = trainer.module
    forecast = {'trainer': trainer}

    yesterday = dict(zip(outputs, nn.activate(trainer.ds['input'][-2])))
    forecast['yesterday'] = update_dict(yesterday, {'date': df.index[-2].date()})

    today = dict(zip(outputs, nn.activate(trainer.ds['input'][-1])))
    forecast['today'] = update_dict(today, {'date': df.index[-1].date()})

    ds = util.input_dataset_from_dataframe(df[-max(delays):], delays=delays, inputs=inputs, normalize=False, verbosity=0)
    tomorrow = dict(zip(outputs, nn.activate(ds['input'][-1])))
    forecast['tomorrow'] = update_dict(tomorrow, {'date': (df.index[-1] + datetime.timedelta(1)).date()})

    return forecast
1262097
def is_condition_met(self, hand, *args):
        
        pon_sets = [x for x in hand if is_pon(x)]
        if len(pon_sets) != 4:
            return False

        count_wind_sets = 0
        winds = [EAST, SOUTH, WEST, NORTH]
        for item in pon_sets:
            if is_pon(item) and item[0] in winds:
                count_wind_sets += 1

        return count_wind_sets == 4
988791
def to_dict(self):
        
        return {'station_id': self.station_id,
                'timestamp': self.timestamp,
                'aggregated_on': self.aggregated_on,
                'temp': self.temp,
                'humidity': self.humidity,
                'wind': self.wind,
                'pressure': self.pressure,
                'precipitation': self.precipitation}
990500
def new_from_json_dict(cls, data):
        
        new_data = {utils.to_snake_case(key): value
                    for key, value in data.items()}

        return cls(**new_data)
1261639
def main(argv=sys.argv[1:]):
    """"""
    args = docopt(__doc__, argv=argv,
                  version=pkg_resources.require('buienradar')[0].version)

    level = logging.ERROR
    if args['-v']:
        level = logging.INFO
    if args['-v'] == 2:
        level = logging.DEBUG
    logging.basicConfig(level=level)

    log = logging.getLogger(__name__)
    log.info("Start...")

    latitude = float(args['--latitude'])
    longitude = float(args['--longitude'])
    timeframe = int(args['--timeframe'])

    usexml = False
    if args['--usexml']:
        usexml = True

    result = get_data(latitude, longitude, usexml)
    if result[SUCCESS]:
        log.debug("Retrieved data:\n%s", result)

        result = parse_data(result[CONTENT], result[RAINCONTENT],
                            latitude, longitude, timeframe, usexml)
        log.info("result: %s", result)
        print(result)
    else:
        log.error("Retrieving weather data was not successfull (%s)",
                  result[MESSAGE])