Hello.
This time, previous article :: "Introduction of drawing code for figures with" degree of perfection "of meteorological data" I would like to introduce you.
The meteorological data obtained from the Meteorological Business Support Center follows the format specified by the International Meteorological Organization (GRIB2 format).
These data are named at different times for each time resolution.
This time we will share a useful list creation when the data is named at regular time intervals.
time_list.py
def preparating_data(self, yyyy, mm, dd, hh):
time_list = []
num_time_list = len(time_list)
month_thirtyone = [ 1, 3, 5, 7, 8, 10, 12 ]
month_thirty = [ 4, 6, 9, 11 ]
month_twntynine = [ 2 ]
while num_time_list < 13:
time_list.append(str(yyyy) + str('%02d' % mm) + str('%02d' % dd) + str('%02d' % hh) + '00')
#Action to add 0 to 1 digit number
hh = hh - 6
if hh < 0 and dd == 1:
mm, hh = mm - 1, 18
if mm in month_thirty:
dd = 30
elif mm in month_thirtyone:
dd = 31
elif mm in month_twntynine:
#Leap year consideration
if yyyy % 4 == 0:
dd = 28
else:
dd =29
elif hh < 0:
dd, hh = dd - 1, 18
num_time_list += 1
return time_list
that's all.
Thank you for watching until the end.
・ Read GRIB2 (weather binary data) by yourself without using a library in PHP https://qiita.com/miyawa-tarou/items/e4eff81dfcac527572e5
・ Meteorology x Python ~ National Synthetic Radar ~ https://qiita.com/OSAKO/items/ef042f80ec63dd288225
Recommended Posts