#code='METAR COR VABB 310040Z 08008KT 3000 HZ NSC 25/18 Q1011 NOSIG='
#code='METAR LEMD 222200Z 35007KT 310V020 CAVOK 27/10 Q1015 NOSIG='
#code='METAR UMMM 151230Z 08004MPS 9999 FEW025 OVC100 07/00 Q1041 R12/CLRD60 NOSIG RMK QFE760'
#code='METAR UMMS 151230Z 01002MPS 010V070 CAVOK 09/00 Q1042 R13/CLRD// NOSIG'
# code='METAR EYKA 151250Z 10007KT 060V130 CAVOK 09/00 Q1042 R08/090095'
#code='METAR UMMS 151230Z 01002MPS 010V070 CAVOK 09/00 Q1042 R88CLRD95 NOSIG'
#code='METAR UMMS 151230Z 01002MPS 010V070 CAVOK 09/00 Q1042 R24CLRD93 NOSIG'
#code='METAR UMMS 151230Z 01002MPS 010V070 CAVOK 09/00 Q1042 R99/421594 NOSIG'
#code='METAR UMMS 151230Z 01002MPS 010V070 CAVOK 09/00 Q1042 R99/SNOCLO NOSIG'
#code='METAR LTAJ 151220Z 24012KT 9999 SCT040 BKN100 14/04 Q1017 TEMPO Q1019 TEMPO 27015G25KT -TSRA'
code='SPECI KBTV 151208Z 36007KT 1SM R15/P6000FT -SN BR BKN006 OVC019 M01/M03 A2965'

print "-----------------------------------------------------------------------"
print "METAR: ",code
print "-----------------------------------------------------------------------"

# Initialize a Metar object with the coded report
obs = Metar(code)

print obs.string()
print obs.json()
#print obs.string().split('\n')

metar_header = {}
metar_header['ICAO_code'] = obs.station_id
metar_header['origin_time'] = obs.time.isoformat(' ')
metar_header['origin_date'] = obs.time.day
metar_header['origin_hours'] = obs.time.isoformat()[11:13]
metar_header['origin_minutes'] = obs.time.isoformat()[14:16]
print metar_header