18 in_grib=os.environ.get(
'BIG_GRIB')
19 out_grib=os.environ.get(
'LITTLE_GRIB')
21 single_lev_vars = [
'APCP',
'ACPCP',
'PWAT']
22 multi_lev_vars = [
'UGRD',
'VGRD',
'RH',
'TMP']
23 levels =
"'1000 mb|850 mb|700 mb|600 mb|500 mb|400 mb|300 mb|10 m|2 m'"
26 if not os.path.isdir(os.path.dirname(out_grib)):
27 os.makedirs(os.path.dirname(out_grib))
30 wg_args =
' '.join([
'-match',
''.join([
"'",
'|'.join(single_lev_vars),
"'"])])
31 newgrib_args =
' '.join([
'-grib', out_grib])
32 cmd =
' '.join([
'wgrib2', in_grib, wg_args, newgrib_args])
39 wg_args =
' '.join([
'-match',
''.join([
"'",
'|'.join(multi_lev_vars),
"'"])])
41 grep_arg =
' '.join([
'|',
'grep',
'-Ew', levels,
'|'])
42 tempgrid_args=
' '.join([
'wgrib2',
'-i', in_grib,
'-grib tmp.grib2'])
43 cat_args =
' '.join([
'cat tmp.grib2 >>', out_grib])
44 cmd =
' '.join([
'wgrib2', in_grib, wg_args, grep_arg, tempgrid_args])
52 os.system(
'rm tmp.grid2')