本文整理匯總了Python中metars.workers.decoders.nz.MetarDecoderNZ類的典型用法代碼示例。如果您正苦於以下問題:Python MetarDecoderNZ類的具體用法?Python MetarDecoderNZ怎麽用?Python MetarDecoderNZ使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MetarDecoderNZ類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_decode_temp
def test_decode_temp(self):
val = "10"
decoder = MetarDecoderNZ()
decoder.decode_temp(val)
res = decoder.decoded_metar["temp"][self.DECODED_KEY]
degree_sign = u'\N{DEGREE SIGN}'
assert_equals(res, "10%sC" % degree_sign)
示例2: test_decode_dewpoint_negative
def test_decode_dewpoint_negative(self):
val = "M04"
decoder = MetarDecoderNZ()
decoder.decode_dewpoint(val)
res = decoder.decoded_metar["dewpoint"][self.DECODED_KEY]
degree_sign = u'\N{DEGREE SIGN}'
assert_equals(res, "minus 4%sC" % degree_sign)
示例3: test_decode_dewpoint_single_digit_degree_gets_leading_zero_stripped
def test_decode_dewpoint_single_digit_degree_gets_leading_zero_stripped(self):
val = "09"
decoder = MetarDecoderNZ()
decoder.decode_dewpoint(val)
res = decoder.decoded_metar["dewpoint"][self.DECODED_KEY]
degree_sign = u'\N{DEGREE SIGN}'
assert_equals(res, "9%sC" % degree_sign)
示例4: test_decode_nzch_metar
def test_decode_nzch_metar(self):
# Basic smoke test to make sure the code gets run through and parser
# works, without asserting any results.
with open('metars/workers/tests/data/nzch-encoded.json') as data:
nzch = json.load(data)
decoder = MetarDecoderNZ()
decoder.decode_metar(nzch["metar"])
示例5: test_decode_wx_phenomena_tornado_waterspout_special_case
def test_decode_wx_phenomena_tornado_waterspout_special_case(self):
# +FC is a special case for tornadoes and waterspouts - the
# modifier '+' should be ignored.
val = ["+FC"]
decoder = MetarDecoderNZ()
decoder.decode_wx_phenomena(val)
res = decoder.decoded_metar["wx_phenomena"][self.DECODED_KEY]
assert_equals(res, ["funnel cloud (tornado or waterspout)"])
示例6: test_decode_obs_datetime
def test_decode_obs_datetime(self):
val = "301900Z"
decoder = MetarDecoderNZ()
decoder.decode_obs_datetime(val)
res_date = decoder.decoded_metar["obs_datetime"][self.DECODED_KEY]["date"]
res_time = decoder.decoded_metar["obs_datetime"][self.DECODED_KEY]["time"]
assert_equals(res_date, "30")
assert_equals(res_time, "1900")
示例7: test_decoded_wind_variation_missing
def test_decoded_wind_variation_missing(self):
val = ""
decoder = MetarDecoderNZ()
decoder.decode_wind_dir_variation(val)
# The decoder should handle an empty wind variation, and the keys
# should exist in the decoded metar with empty values.
res = decoder.decoded_metar["wind_dir_variation"][self.DECODED_KEY]
assert_equals(res, "")
示例8: test_decode_sky_condition_multiple_layers
def test_decode_sky_condition_multiple_layers(self):
val = ["SCT016///", "BKN085///", "OVC100TCU"]
decoder = MetarDecoderNZ()
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["scattered clouds at 1,600 feet (no cloud type)",
"broken clouds at 8,500 feet (no cloud type)",
"overcast at 10,000 feet (towering cumulus)"])
示例9: test_decode_wx_phenomena_modifiers
def test_decode_wx_phenomena_modifiers(self):
decoder = MetarDecoderNZ()
# Light
val = ["-PY"]
decoder.decode_wx_phenomena(val)
res = decoder.decoded_metar["wx_phenomena"][self.DECODED_KEY]
assert_equals(res, ["light spray"])
# Moderate
val = ["PY"]
decoder.decode_wx_phenomena(val)
res = decoder.decoded_metar["wx_phenomena"][self.DECODED_KEY]
assert_equals(res, ["moderate spray"])
# Heavy
val = ["+PY"]
decoder.decode_wx_phenomena(val)
res = decoder.decoded_metar["wx_phenomena"][self.DECODED_KEY]
assert_equals(res, ["heavy spray"])
示例10: test_decode_sky_condition_no_cloud_detected_nzaa_nzwn_nzch
def test_decode_sky_condition_no_cloud_detected_nzaa_nzwn_nzch(self):
val = ["NCD"]
decoder = MetarDecoderNZ()
# NZAA
decoder.decoded_metar["icao_id"][self.DECODED_KEY] = "NZAA"
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["no cloud detected below 10,000 feet"])
# NZAA
decoder.decoded_metar["icao_id"][self.DECODED_KEY] = "NZWN"
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["no cloud detected below 10,000 feet"])
# NZAA
decoder.decoded_metar["icao_id"][self.DECODED_KEY] = "NZCH"
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["no cloud detected below 10,000 feet"])
示例11: test_decode_sky_condition_basic
def test_decode_sky_condition_basic(self):
val = ["FEW020"]
decoder = MetarDecoderNZ()
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["few clouds at 2,000 feet"])
示例12: test_decode_dewpoint_missing
def test_decode_dewpoint_missing(self):
val = ""
decoder = MetarDecoderNZ()
decoder.decode_dewpoint(val)
res = decoder.decoded_metar["dewpoint"][self.DECODED_KEY]
assert_equals(res, "(missing)")
示例13: test_decode_icao_id
def test_decode_icao_id(self):
val = "NZCH"
decoder = MetarDecoderNZ()
decoder.decode_icao_id(val)
res = decoder.decoded_metar["icao_id"][self.DECODED_KEY]
assert_equals(res, "NZCH")
示例14: test_decode_sky_condition_sky_clear
def test_decode_sky_condition_sky_clear(self):
val = ["SKC"]
decoder = MetarDecoderNZ()
decoder.decode_sky_condition(val)
res = decoder.decoded_metar["sky_condition"][self.DECODED_KEY]
assert_equals(res, ["sky clear"])
示例15: test_decode_is_not_special_report
def test_decode_is_not_special_report(self):
val = False
decoder = MetarDecoderNZ()
decoder.decode_is_special_report(val)
res = decoder.decoded_metar["is_special_report"][self.DECODED_KEY]
assert_equals(res, False)