Showing posts with label pygrib. Show all posts
Showing posts with label pygrib. Show all posts

Monday, June 29, 2020

parse GRIB check, Sydney



20200501 [54.69749573 57.41155823 59.21858948] ok
20200502 [51.97318848 55.55209473 58.46303223] ok
20200503 [45.92867554 55.01656616 61.02828491] ok
20200504 [53.28748291 59.00037354 62.53709229] OK
20200505 [49.20707825 58.18246887 63.52621887]
20200506 [48.28738525 58.630354   64.508479  ]
20200507 [55.30841797 61.85802734 65.63380859]
20200508 [55.65253723 63.57324036 67.99941223]
20200509 [54.88275269 58.41947144 61.34798706]
20200510 [43.80663879 52.25820129 57.86913879]
20200511 [41.37396362 53.92122925 61.8032605 ]
20200512 [46.40064819 56.35689819 62.25611694]
20200513 [47.98355835 55.6546521  59.9155896 ]
20200514 [52.05619019 58.86947144 63.04954956]
20200515 [53.11944702 59.86944702 64.0284314 ]
20200516 [48.51894958 59.31894958 65.34473083]
20200517 [51.78133972 60.68993347 66.1778241 ]
20200518 [57.4385022  63.5416272  67.14514282]
20200519 [52.88447693 60.42197693 64.67588318]
20200520 [59.27906921 62.66813171 64.37320984]
20200521 [49.63461121 53.89203308 57.45336121]
20200522 [54.28715637 56.16450012 57.89770325]
20200523 [57.77273376 60.04031189 62.00906189]
20200524 [55.38757446 58.36882446 60.66804321]
20200525 [57.18021362 60.2563855  63.88802612]
20200526 [55.2185498  60.95956543 64.7951123 ]
20200527 [49.87902954 57.68371704 62.98879517]
20200528 [51.84025391 58.08751953 61.27619141]
20200529 [48.95472229 57.70862854 63.04886292]
20200530 [51.02179993 58.99875305 63.68156555]
20200531 [51.02971008 59.03127258 63.85119446]
20200601 [47.43827942 50.97851379 53.57304504]
20200602 [47.39716309 53.06083496 57.11083496]
20200603 [49.32493408 55.74094971 60.27962158]
20200604 [40.34075439 52.13567627 59.25481689]


20200201 [85.42057007 84.02838257 80.69557007] ok
20200202 [72.65275391 74.10119141 75.01876953] ok
20200203 [66.27101563 67.364375   68.3909375 ] accu lowester =69??
20200204 [64.36796387 68.53046387 70.94218262] ok
20200205 [69.50239685 71.9422406  73.8125531 ] ok
20200206 [69.03860901 69.81907776 70.87728088]
20200207 [68.51425903 69.89941528 71.14394653]
20200208 [69.94009216 71.33227966 72.20415466] ok
20200209 [70.44238708 72.49902771 73.83848083] accu highest =73
20200210 [71.02411316 73.51669128 75.13036316] ok
20200211 [72.52267578 73.35236328 73.94298828] ok
20200212 [71.87231262 73.134422   74.0484845 ] ok
20200213 [69.81970947 71.18025635 72.62869385] ok
20200214 [63.35604065 68.16893127 70.93221252] ok
20200215 [69.59542358 71.13878296 72.50987671] ok
20200216 [69.77345703 70.77189453 72.17111328]
20200217 [68.70638245 69.96146057 71.84583557]
20200218 [71.55090759 74.46536072 76.39543884]
20200219 [62.24837158 66.23509033 69.00540283]
20200220 [65.95809753 68.62645691 70.29637878]
20200221 [65.9602124  67.86216553 69.57779053]
20200222 [67.26851929 69.59586304 71.26930054]
20200223 [66.54913452 70.53233765 73.58390015]
20200224 [69.20247009 72.15559509 74.51106384]
20200225 [70.63610352 72.92125977 74.07790039]
20200226 [66.98534668 68.2685498  69.8435498 ]
20200227 [62.1200238  67.84697693 71.67900818]
20200228 [64.9325238  69.38330505 72.13955505]


20200101 [68.14981506 68.90215881 69.64395569]
20200102 [72.22313354 71.87860229 72.21610229]
20200103 [70.79559753 71.67450378 72.45497253]
20200104 [72.45434082 71.35043457 71.24848145]
20200105 [65.98767822 68.07244385 69.59119385]
20200106 [70.49959839 71.12537964 71.67381714]
20200107 [72.76250732 71.9152417  71.83438232]
20200108 [70.55233276 70.13748901 70.43631714]
20200109 [70.05380066 71.14716003 72.31434753]
20200110 [74.5925     74.42375    73.42179688]
20200111 [66.07452515 66.83390015 68.14522827]
20200112 [63.734245   67.48190125 69.97096375]
20200113 [66.29985474 69.44633911 71.40805786]
20200114 [66.34646423 69.18357361 70.84294861]
20200115 [70.94797791 72.02024353 72.50539978]
20200116 [69.4866864  70.1757489  71.26910828]
20200117 [69.43158997 69.36830872 69.95541809]
20200118 [67.21663635 69.42796448 71.11546448]
20200119 [68.61338318 70.3747113  71.90049255]
20200120 [66.7152478  70.40313843 72.92032593]
20200121 [68.89751709 71.85064209 74.31157959]
20200122 [69.36053589 73.77264526 75.85741089]
20200123 [82.19737366 81.41690491 80.64698303] hottest day in day! YES!
20200124 [74.66792114 74.88588989 75.74018677]
20200125 [75.09248779 75.24365967 76.31240967]
20200126 [74.91036194 75.53262756 76.08106506]
20200127 [74.40147522 74.87960022 75.69874084]
20200128 [74.32577942 74.36093567 75.09218567]
20200129 [68.65175293 71.80175293 73.67206543]











GRIB paring check, Beijing, passed

code: parse_grib.ipynb

20200501 [76.24124573 77.13069885]. OK
20200502 [72.6345166  74.09350098]. OK
20200503 [66.69898804 68.96656616] OK
20200504 [54.08201416 53.69529541] OK
20200505 [61.49418762 61.181297  ] OK
20200506 [64.57176025 65.886604  ] OK
20200507 [61.92833984 61.68576172] OK
20200508 [54.80175598 56.51738098] OK
20200509 [58.18392456 59.06986206] OK
20200510 [61.55351379 64.23945129] OK
20200511 [64.92865112 64.3063855 ] OK
20200512 [57.41510132 61.64439819] OK
20200513 [69.78394897 73.4155896 ] OK
20200514 [65.61595581 67.13822144] OK
20200515 [64.39757202 64.8581189 ] OK
20200516 [57.69824646 60.99238708] OK
20200517 [59.46649597 61.04852722] OK
20200518 [59.9135022  63.11623657] OK
20200519 [63.12549255 65.50557068] OK
20200520 [69.51305359 70.70836609] OK
20200521 [62.20648621 63.47914246] OK
20200522 [72.32934387 73.32778137] OK
20200523 [65.23289001 67.20867126] OK
20200524 [64.14851196 67.15437134] OK
20200525 [60.65716675 63.04779175] OK
20200526 [64.33808105 68.1419873 ] OK
20200527 [61.88840454 63.31223267] OK
20200528 [69.24611328 71.53478516] OK
20200529 [70.45276917 72.82933167] OK
20200530 [68.43469055 71.78508118] OK
20200531 [56.83400696 59.86447571] OK
20200601 [63.65937317 64.65781067] OK
20200602 [72.12255371 77.76864746] OK
20200603 [73.47376221 74.66204346] OK
20200604 [71.11302002 70.94778564] OK



Tuesday, June 9, 2020

How to extract specific information from GRIB files?



https://gis.stackexchange.com/questions/173775/how-to-extract-specific-information-from-grib-files



https://github.com/jswhit/pygrib/issues/27

Coordinates, spatial grids
https://confluence.ecmwf.int/display/CKB/ERA5%3A+data+documentation#ERA5:datadocumentation-Spatialgrid

To find specific coordinates within this 720 x 360 array i just extrapolate the coordinates to the array. Ex: If I want to find data for New York New York coordinates ~40.5N 74 W I'll map those coordinates to the array to by doing 2x(90-40.5) and 2x (180-74) to find the following result:
grbs_old = pygrib.open('nomads.ncep.noaa.gov/cgi-bin/'+str(grib_filename))
data=grbs_old[6].values
data[99][212]
Grid box
https://confluence.ecmwf.int/display/CKB/Model+grid+box+and+time+step
Horizontal
In the horizontal the discrete points are arranged in a two dimensional grid and hence are referred to as grid points. The grid can be regular or irregular. An example of a regular latitude/longitude grid would be where the grid points are located every 1 degree of longitude in the east-west direction and every 1 degree of latitude in the north-south direction. Each grid point is associated with an area that either surrounds the grid point or lies between the grid points. This area is referred to as the "grid box".
Grid point values cannot properly represent variability on spatial scales smaller than the grid box.
(In addition to using grid points, the ECMWF Integrated Forecasting System (IFS) also uses an additional mathematical concept, spectral space, to represent horizontal space. This concept uses a set of wavy basis functions, spherical harmonics, to describe variations in the horizontal. The IFS switches between spectral space and grid point space, in order to perform specific computations.)


For Hong's Pygrib file,
grbs = pygrib.open('2019-2020June10.grib')
valuesTmp = grbs[1].values
valuesTmp.shape #return (721, 1440)

so, 720/180 = 4

1440/360 = 4

It turns out that GRIB use 0-360 longitude and many software use -180W, 180E longitude. 

Hong tried ( - 180W mod 360), and temperature results from DC matches AccuWeather results,





Sunday, June 7, 2020

ecCodes install; pygrib

Ref:
https://github.com/ecmwf/eccodes-python#system-dependencies

==== ecCodes
On large macpro laptop

#homebrew works
brew install eccodes

(base) CS313BQin:build hqin$  python -m eccodes selfcheck
Found: ecCodes v2.17.0.
Your system is ready.

pip, pip3, and conda did not work

=====pygrib

#conda install -c conda-forge pygrib

download github sources

Copy setup.cfg.template to setup.cfg #did not make anychanges
(base) CS313BQin:pygrib-master hqin$ python setup.py build

  • Run 'python setup.py build' #passed
  • Run 'sudo python setup.py install' #passed
  • Run 'python test.py' to test your pygrib installation. #passed