Translate the results of taf.parse

    Keys: Forecast, Min-Temp, Max-Temp

    Forecast keys: Wind, Visibility, Clouds, Altimeter, Wind-Shear, Turbulance, Icing, Other
190650
def taf(wxdata: TafData, units: Units) -> TafTrans:
    
    translations = {'forecast': []}  # type: ignore
    for line in wxdata.forecast:
        trans = shared(line, units)  # type: ignore
        trans['wind'] = wind(line.wind_direction, line.wind_speed,
                             line.wind_gust, unit=units.wind_speed)
        trans['wind_shear'] = wind_shear(line.wind_shear, units.altitude, units.wind_speed)
        trans['turbulance'] = turb_ice(line.turbulance, units.altitude)
        trans['icing'] = turb_ice(line.icing, units.altitude)
        # Remove false 'Sky Clear' if line type is 'BECMG'
        if line.type == 'BECMG' and trans['clouds'] == 'Sky clear':
            trans['clouds'] = None  # type: ignore
        translations['forecast'].append(TafLineTrans(**trans))  # type: ignore
    translations['min_temp'] = min_max_temp(wxdata.min_temp, units.temperature)  # type: ignore
    translations['max_temp'] = min_max_temp(wxdata.max_temp, units.temperature)  # type: ignore
    translations['remarks'] = remarks.translate(wxdata.remarks)
    return TafTrans(**translations)
547777
def load_forecasts(self):
        
        forecast_path = self.forecast_json_path + "/{0}/{1}/".format(self.run_date.strftime("%Y%m%d"),
                                                                     self.ensemble_member)
        forecast_files = sorted(glob(forecast_path + "*.json"))
        for forecast_file in forecast_files:
            file_obj = open(forecast_file)
            json_obj = json.load(file_obj)
            file_obj.close()
            track_id = json_obj['properties']["id"]
            obs_track_id = json_obj['properties']["obs_track_id"]
            forecast_hours = json_obj['properties']['times']
            duration = json_obj['properties']['duration']
            for f, feature in enumerate(json_obj['features']):
                area = np.sum(feature["properties"]["masks"])
                step_id = track_id + "_{0:02d}".format(f)
                for model_type in self.model_types:
                    for model_name in self.model_names[model_type]:
                        prediction = feature['properties'][model_type + "_" + model_name.replace(" ", "-")]
                        if model_type == "condition":
                            prediction = [prediction]
                        row = [track_id, obs_track_id, self.ensemble_name, self.ensemble_member, forecast_hours[f],
                               f + 1, duration, area] + prediction
                        self.forecasts[model_type][model_name].loc[step_id] = row
972089
def items(cls):
        
        return [
            cls.TEMPERATURE,
            cls.PRESSURE,
            cls.HUMIDITY,
            cls.WIND_SPEED,
            cls.WIND_DIRECTION,
            cls.CLOUDS
        ]
600693
def parse(station: str, txt: str) -> TafData:
    
    core.valid_station(station)
    while len(txt) > 3 and txt[:4] in ('TAF ', 'AMD ', 'COR '):
        txt = txt[4:]
    _, station, time = core.get_station_and_time(txt[:20].split(' '))
    retwx = {
        'end_time': None,
        'raw': txt,
        'remarks': None,
        'start_time': None,
        'station': station,
        'time': core.make_timestamp(time)
    }
    txt = txt.replace(station, '')
    txt = txt.replace(time, '').strip()
    if core.uses_na_format(station):
        use_na = True
        units = Units(**NA_UNITS)  # type: ignore
    else:
        use_na = False
        units = Units(**IN_UNITS)  # type: ignore
    # Find and remove remarks
    txt, retwx['remarks'] = core.get_taf_remarks(txt)
    # Split and parse each line
    lines = core.split_taf(txt)
    parsed_lines = parse_lines(lines, units, use_na)
    # Perform additional info extract and corrections
    if parsed_lines:
        parsed_lines[-1]['other'], retwx['max_temp'], retwx['min_temp'] \
            = core.get_temp_min_and_max(parsed_lines[-1]['other'])
        if not (retwx['max_temp'] or retwx['min_temp']):
            parsed_lines[0]['other'], retwx['max_temp'], retwx['min_temp'] \
                = core.get_temp_min_and_max(parsed_lines[0]['other'])
        # Set start and end times based on the first line
        start, end = parsed_lines[0]['start_time'], parsed_lines[0]['end_time']
        parsed_lines[0]['end_time'] = None
        retwx['start_time'], retwx['end_time'] = start, end
        parsed_lines = core.find_missing_taf_times(parsed_lines, start, end)
        parsed_lines = core.get_taf_flight_rules(parsed_lines)
    # Extract Oceania-specific data
    if retwx['station'][0] == 'A':  # type: ignore
        parsed_lines[-1]['other'], retwx['alts'], retwx['temps'] \
            = core.get_oceania_temp_and_alt(parsed_lines[-1]['other'])
    # Convert to dataclass
    retwx['forecast'] = [TafLineData(**line) for line in parsed_lines]  # type: ignore
    return TafData(**retwx), units
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'])
935868
def parseSingleAttr(self, attrValue):
        

        results = self.parseAttributes(temp=attrValue)
        if 'temp' in results[1]:
            return results[1]['temp']
        else:
            return results[0]['temp']
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }
891287
def get_wind(wxdata: [str], units: Units) -> ([str], Number, Number, Number, [Number]):  # type: ignore  # noqa
    
    direction, speed, gust = '', '', ''
    variable = []  # type: ignore
    if wxdata:
        item = copy(wxdata[0])
        for rep in ['(E)']:
            item = item.replace(rep, '')
        item = item.replace('O', '0')
        # 09010KT, 09010G15KT
        if item.endswith('KT') \
                or item.endswith('KTS') \
                or item.endswith('MPS') \
                or item.endswith('KMH') \
                or ((len(item) == 5 or (len(item) >= 8 and item.find('G') != -1) and item.find('/') == -1)
                    and (item[:5].isdigit() or (item.startswith('VRB') and item[3:5].isdigit()))):  # noqa
            # In order of frequency
            if item.endswith('KT'):
                item = item.replace('KT', '')
            elif item.endswith('KTS'):
                item = item.replace('KTS', '')
            elif item.endswith('MPS'):
                units.wind_speed = 'm/s'
                item = item.replace('MPS', '')
            elif item.endswith('KMH'):
                units.wind_speed = 'km/h'
                item = item.replace('KMH', '')
            direction = item[:3]
            if 'G' in item:
                g_index = item.find('G')
                gust = item[g_index + 1:]
                speed = item[3:g_index]
            else:
                speed = item[3:]
            wxdata.pop(0)
    # Separated Gust
    if wxdata and 1 < len(wxdata[0]) < 4 and wxdata[0][0] == 'G' and wxdata[0][1:].isdigit():
        gust = wxdata.pop(0)[1:]
    # Variable Wind Direction
    if wxdata and len(wxdata[0]) == 7 and wxdata[0][:3].isdigit() \
            and wxdata[0][3] == 'V' and wxdata[0][4:].isdigit():
        variable = [make_number(i, speak=i) for i in wxdata.pop(0).split('V')]
    # Convert to Number
    direction = make_number(direction, speak=direction)  # type: ignore
    speed = make_number(speed)  # type: ignore
    gust = make_number(gust)  # type: ignore
    return wxdata, direction, speed, gust, variable
1196040
def _parse_met(content):
        
        col_names = ['year', 'month', 'day', 'hour', 'minute',
                     'wind_direction', 'wind_speed', 'wind_gust',
                     'wave_height', 'dominant_wave_period', 'average_wave_period',
                     'dominant_wave_direction', 'pressure',
                     'air_temperature', 'water_temperature', 'dewpoint',
                     'visibility', '3hr_pressure_tendency', 'water_level_above_mean']

        col_units = {'wind_direction': 'degrees',
                     'wind_speed': 'meters/second',
                     'wind_gust': 'meters/second',
                     'wave_height': 'meters',
                     'dominant_wave_period': 'seconds',
                     'average_wave_period': 'seconds',
                     'dominant_wave_direction': 'degrees',
                     'pressure': 'hPa',
                     'air_temperature': 'degC',
                     'water_temperature': 'degC',
                     'dewpoint': 'degC',
                     'visibility': 'nautical_mile',
                     '3hr_pressure_tendency': 'hPa',
                     'water_level_above_mean': 'feet',
                     'time': None}

        df = pd.read_table(StringIO(content), comment='#', na_values='MM',
                           names=col_names, sep=r'\s+')
        df['time'] = pd.to_datetime(df[['year', 'month', 'day', 'hour', 'minute']], utc=True)
        df = df.drop(columns=['year', 'month', 'day', 'hour', 'minute'])
        df.units = col_units
        return df
506219
def minimum(station_code):
    
    temp = None
    fin = None
    try:
        fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                              _basename(station_code, 'ddy')))
    except IOError:
        logger.info("File not found")
        download_extract(_eere_url(station_code))
        fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                              _basename(station_code, 'ddy')))
    for line in fin:
        value = re.search('Max Drybulb=(-?\\d+\\.\\d*)', line)
        if value:
            temp = float(value.groups()[0])
    if not temp:
        try:
            fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                                  _basename(station_code, 'stat')))
            for line in fin:
                if line.find('Minimum Dry Bulb') is not -1:
                    return float(line[37:-1].split('\xb0')[0])
        except IOError:
            pass
    if temp:
        return temp
    else:
        raise Exception("Error: Minimum Temperature not found")
658668
def get_weather(test=False):
    
    if _Constants._TEST or test:
        rows = _Constants._DATABASE.execute("SELECT data FROM weather LIMIT {hardware}".format(
            hardware=_Constants._HARDWARE))
        data = [r[0] for r in rows]
        data = [_Auxiliary._byteify(_json.loads(r)) for r in data]
        
        return _Auxiliary._byteify(data)
        
    else:
        rows = _Constants._DATABASE.execute("SELECT data FROM weather".format(
            hardware=_Constants._HARDWARE))
        data = [r[0] for r in rows]
        data = [_Auxiliary._byteify(_json.loads(r)) for r in data]
        
        return _Auxiliary._byteify(data)
709463
def _parse_data(self):
        
        data = self._cache

        res = dict()
        res[MI_HUMIDITY] = float(data[9:13])
        res[MI_TEMPERATURE] = float(data[2:6])
        return res
909038
def parse_complex_forecast(response)
      ret = {}

      response['forecast']['simpleforecast']['forecastday'].each do |f|
        date = f['date']
        ret[f['period'] - 1] = {
          date: DateTime.new(date['year'], date['month'], date['day'], date['hour'], date['min'].to_i, date['sec'], date['tz_short']),
          weekday_name: date['weekday'],
          high_f: f['high']['fahrenheit'].to_i,
          high_c: f['high']['celsius'].to_i,
          low_f: f['low']['fahrenheit'].to_i,
          low_c: f['low']['celsius'].to_i,
          conditions: f['conditions'].to_i,
          image_url: f['icon_url'],
          snow: {
            snow_total_in: f['snow_allday']['in'],
            snow_total_cm: f['snow_allday']['cm'],
            snow_night_in: f['snow_night']['in'],
            snow_night_cm: f['snow_night']['cm'],
            snow_day_in: f['snow_day']['in'],
            snow_day_cm: f['snow_day']['cm']
          },
          quantative_precipitation: {
            qpf_total_in: f['qpf_allday']['in'],
            qpf_total_cm: f['qpf_allday']['cm'],
            qpf_night_in: f['qpf_night']['in'],
            qpf_night_cm: f['qpf_night']['cm'],
            qpf_day_in: f['qpf_day']['in'],
            qpf_day_cm: f['qpf_day']['cm']
          },
          wind: {
            average_mph: f['avewind']['mph'],
            average_kph: f['avewind']['kph'],
            average_dir: f['avewind']['dir'],
            average_temp: f['avewind']['degrees'],
            max_mph: f['maxwind']['mph'],
            max_kph: f['maxwind']['kph'],
            max_dir: f['maxwind']['dir'],
            max_temp: f['maxwind']['degrees']
          }
        }
      end

      ret
    end
551659
def titles2marc(self, key, values):
    
    first, rest = values[0], values[1:]

    self.setdefault('245', []).append({
        'a': first.get('title'),
        'b': first.get('subtitle'),
        '9': first.get('source'),
    })

    return [
        {
            'a': value.get('title'),
            'b': value.get('subtitle'),
            '9': value.get('source'),
        } for value in rest
    ]
1334087
def get_taf_flight_rules(lines: [dict]) -> [dict]:  # type: ignore
    
    for i, line in enumerate(lines):
        temp_vis, temp_cloud = line['visibility'], line['clouds']
        for report in reversed(lines[:i]):
            if not _is_tempo_or_prob(report['type']):
                if temp_vis == '':
                    temp_vis = report['visibility']
                if 'SKC' in report['other'] or 'CLR' in report['other']:
                    temp_cloud = 'temp-clear'
                elif temp_cloud == []:
                    temp_cloud = report['clouds']
                if temp_vis != '' and temp_cloud != []:
                    break
        if temp_cloud == 'temp-clear':
            temp_cloud = []
        line['flight_rules'] = FLIGHT_RULES[get_flight_rules(temp_vis, get_ceiling(temp_cloud))]
    return lines
1009700
def _calc_keys(self, config, name, timestamp):
    '''
    
    '''
    i_bucket = config['i_calc'].to_bucket( timestamp )
    r_bucket = config['r_calc'].to_bucket( timestamp )

    i_key = '%s%s:%s:%s'%(self._prefix, name, config['interval'], i_bucket)
    r_key = '%s:%s'%(i_key, r_bucket)

    return i_bucket, r_bucket, i_key, r_key
808493
function (_tahta_id, _kurum_id, _durum_id) {
                return TEMP + ":" + TAHTA + ":" + _tahta_id + ":" + KURUM + ":" + _kurum_id + ":" + ONAY_DURUMU + ":" + _durum_id + ":" + TEKLIF;
            }