-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnam_grid.txt
1418 lines (1141 loc) · 48.6 KB
/
nam_grid.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
NAM/NARR Grids
==============
Steven K. Baum
v0.5, 2013-02-18
:doctype: book
:toc:
:icons:
:numbered!:
[preface]
Overview
--------
This is documentation about the NAM and NARR datasets downloaded from
2000-2013 for use as forcing fields for the TGLO/TABS Gulf of Mexico
circulation model.
They are being processed year by year so as to allow other users to
extract the fields contained therein. For example, the 2013 fields can
be found at:
http://barataria.tamu.edu:6060/thredds/ncss/grib/NCEP/NAM/CONUS_12km/2013/best/dataset.html[+http://barataria.tamu.edu:6060/thredds/ncss/grib/NCEP/NAM/CONUS_12km/2013/best/dataset.html+]
wherein temporal and spatial subsets of any of the dozens of fields
can be extracted.
Herein we will document the problems encountered in processing the
various years, and how those problems were solved.
Problems With Dataset
---------------------
Change of Grid in Oct. 2011
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The dataset resides at:
-----
barataria.tamu.edu:/raid/howie
-----
and the directory structure is:
-----
2009_NAM12
2010_NAM12
2011_NAM12
2012_NAM12
2013_NAM12
-----
The year 2011 is different since the NAM grid used changed
on Oct. 19, thus leaving the following subdirectory structure
for +2011_NAM12+:
-----
NAM201101
NAM201102
NAM201103
NAM201104
NAM201105
NAM201106
NAM201107
NAM201108
NAM201109
NAM201110a
NAM201110b
NAM201111b
NAM201112b
-----
The directory for +NAM201110a+ is:
-----
A111001
A111002
A111003
A111004
A111005
A111006
A111007
A111008
A111009
A111010
A111011
A111012
A111013
A111014
A111015
A111016
A111017
A111018
-----
and for +NAM201110b+ is:
-----
B111001
B111002
B111003
B111004
B111005
B111006
B111007
B111008
B111009
B111010
B111011
B111012
B111013
B111014
B111015
B111016
B111017
B111018
B111019
B111020
B111021
B111022
B111023
B111024
B111025
B111026
B111027
B111028
B111029
B111030
B111031
-----
Thus, model output for both the old and new grids are available from
Oct. 1 through Oct. 18, and only data for the new grid from Oct. 19
onward.
THREDDS Unable to Handle Pre-Oct. 19, 2011 Model Output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While THREDDS can recognize the grid presently used by NAM, it
is not now capable of handling the grid used before Oct. 18, 2011.
Old vs. New Grid
~~~~~~~~~~~~~~~~
If we use +wgrib2+ to extract grid information from the old and new
grids, we find the following.
The old grid info can be found via, e.g.
-----
wgrib2 -grid /raid/howie/2011_NAM12/NAM201101/A110101/1100100.F00.grb
-----
and is:
-----
Rotated Lat/Lon (Arakawa Staggered E-grid)(669 x 1165) units 1e-06 input WE:SN output WE:SN res 56
lat0 -7.446000 lat-center 54.000000 dlat 0.077000
lon0 215.861000 lon-center 254.000000 dlon 0.090000 #points=779385
-----
The new grid info can be found via:
-----
wgrib2 -grid /raid/howie/2013_NAM12/NAM201301/B130101/1300100.F00.grb
-----
and is:
-----
Lambert Conformal: (614 x 428) input WE:SN output WE:SN res 8
Lat1 12.190000 Lon1 226.541000 LoV 265.000000
LatD 25.000000 Latin1 25.000000 Latin2 25.000000
LatSP 0.000000 LonSP 0.000000
North Pole (614 x 428) Dx 12191.000000 m Dy 12191.000000 m mode 8
-----
THREDDS Use
-----------
XML Code for THREDDS Catalog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An example of THREDDS output on a NAM grid can be found at:
http://barataria.tamu.edu:6060/thredds/ncss/grib/NCEP/NAM/CONUS_12km/conduit/best/dataset.html[+http://barataria.tamu.edu:6060/thredds/ncss/grib/NCEP/NAM/CONUS_12km/conduit/best/dataset.html+]
The XML code used to create this is:
-----
<dataset name="North American Model (NAM)">
<metadata inherited="true">
<documentation type="summary">NCEP Nonhydrostatic Mesoscale Model (NMM) and Gridpoint Statistical Interpolation
(GSI) analysis, running in the Weather Research and Forecasting (WRF) infrastructure.
</documentation>
<documentation xlink:href="http://meted.ucar.edu/nwp/pcu2/NAMWRFjun2006.htm"
xlink:title="COMET MetEd (Meteorology Education and Training) documentation"/>
<documentation xlink:href="http://www.nco.ncep.noaa.gov/pmb/products/nam/"
xlink:title="NCEP NAM product inventory"/>
</metadata>
<featureCollection name="2013-NAM-CONUS_12km-conduit" featureType="GRIB" harvest="true" path="grib/NCEP/NAM/CONUS_12km/conduit">
<metadata inherited="true">
<documentation type="summary">NCEP North American Model : AWIPS 218 (B) grid over the continental United States.
Model runs are made at 06Z, 12Z, 18Z and 00Z, with analysis and forecasts every 3 hours out to 84 hours (3.5 days).
Horizontal = 614 by 428 points, resolution 12.19 km, LambertConformal projection.
Vertical = small number of mandatory pressure levels, lots of surface fields.
</documentation>
</metadata>
<collection spec="/raid/howie/2013_NAM12/YEAR/#yyDDDHH#.*grb$"
olderThan="5 min"/>
<update startup="never" trigger="allow"/>
<tdm rewrite="test" rescan="0 6,21,36,51 * * * ? *" trigger="allow"/>
<gribConfig>
<intvFilter excludeZero="true"/>
<intvFilter intvLength="3">
<variable id="0-1-8"/>
<variable id="0-1-10"/>
</intvFilter>
</gribConfig>
</featureCollection>
</dataset>
-----
Changes in Directory Structure Needed for Data/Time Extraction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The original directory structure was (under +barataria.tamu.edu/raid/howie/+):
-----
2009_NAM12
2010_NAM12
2011_NAM12
2012_NAM12
2013_NAM12
NAM201301
B130101
1300100.F00.grb
1300100.F03.grb
1300106.F00.grb
1300106.F03.grb
1300112.F00.grb
1300112.F03.grb
1300118.F00.grb
1300118.F03.grb
B130102
B130103
...
B130131
NAM201302
NAM201303
NAM201304
NAM201305
NAM201306
NAM201307
NAM201308
NAM201309
NAM201310
NAM201311
NAM201312
-----
The lowest subdirectory filenames needed to be rewritten in
the following way in order for the THREDDS crawler to establish
the proper order of the files.
-----
1300100.F00.grb -> 1300100.grb
1300100.F03.grb -> 1300103.grb
1300106.F00.grb -> 1300106.grb
1300106.F03.grb -> 1300109.grb
1300112.F00.grb -> 1300112.grb
1300112.F03.grb -> 1300115.grb
1300118.F00.grb -> 1300118.grb
1300118.F03.grb -> 1300121.grb
-----
These rewrites are performed via soft links so an entire year can
be softlinked into a single subdirectory called +YEAR+. Note also
how the day number within each month needs to be converted into a
Julian day for the year so the following regular expression can be used
to establish the date and time of each file:
+/raid/howie/2013_NAM12/YEAR/#yyDDDHH#.*grb$+
-----
1300100.grb -> /raid/howie/2013_NAM12/NAM201301/B130101/1300100.F00.grb
1300103.grb -> /raid/howie/2013_NAM12/NAM201301/B130101/1300100.F03.grb
...
1300121.grb -> /raid/howie/2013_NAM12/NAM201301/B130101/1300118.F03.grb
1300200.grb -> /raid/howie/2013_NAM12/NAM201301/B130102/1300200.F00.grb
1300203.grb -> /raid/howie/2013_NAM12/NAM201301/B130102/1300200.F03.grb
...
1300221.grb -> /raid/howie/2013_NAM12/NAM201301/B130102/1300218.F03.grb
...
1303121.grb -> /raid/howie/2013_NAM12/NAM201301/B130131/1303118.F03.grb
1303200.grb -> /raid/howie/2013_NAM12/NAM201302/B130201/1303200.F00.grb
1303203.grb -> /raid/howie/2013_NAM12/NAM201302/B130201/1303200.F03.grb
...
-----
Python Program to Make Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A Python program to create a file containing all the required
symbolic linking commands is listed below. It is typically run
via something like:
+python2.7 namconv.py >& ch2013.sh+
from within the +YEAR+ subdirectory created in each
+20**_NAM12+ directory.
[source,python]
-----
#!/usr/bin/python2.7
#
# This is the non-subroutine version of convert.py
#
# Usage: convert.py ff [yyyymmdd]
#
# where: ff = 00,06,12,18
# yyyymmdd = an optional year month and day if you want to process files from days other than today
import os, sys, fnmatch
import numpy as np
import numpy.ma as ma
import netCDF4
import octant
import time,datetime
from octant import csa
from mpl_toolkits.basemap import Basemap
from octant.tools import rot2d
from time import strftime
from netCDF4 import Dataset
import math, glob
from netCDF4 import num2date,date2num,datetime
import glob
topdir = "/raid/howie/"
os.chdir(topdir)
years = sorted(glob.glob("*NAM*"))
years = ['2013_NAM12']
julian_day = 0
for year in years:
yeardir = topdir + year
os.chdir(yeardir)
months = sorted(glob.glob("*NAM*"))
# months = ['NAM201301','NAM201302']
for month in months:
monthdir = yeardir + "/" + month
os.chdir(monthdir)
days = sorted(glob.glob("B*"))
# days = ['B130101']
for day in days:
julian_day = julian_day + 1
daydir = monthdir + "/" + day
os.chdir(daydir)
# Clean up previous trash.
# os.system("rm *.grb_* line* *grbuv.txt")
dayfiles = sorted(glob.glob("*.grb"))
for dayfile in dayfiles:
fpart = dayfile.split('.')
# ['1300118', 'F03', 'grb']
yr = fpart[0][0:2]
# 13
hr = int(fpart[0][5:7])
# 18
sbhr = int(fpart[1][1:3])
# 03
tothr = hr + sbhr
# 21
hr_str = str(tothr).zfill(2)
# '21'
jd_str = str(julian_day).zfill(3)
newfile = yr + jd_str + hr_str + ".grb"
oldpath = daydir + "/" + dayfile
com = "ln -s " + oldpath + " " + newfile
print com
-----
Summary
-------
If we use +wgrib2 -grid+ to find the grid definition we find via:
+wgrib2 -grid 1000100.F00.grb+
the following:
-----
grid_template=32768:winds(grid):
Rotated Lat/Lon (Arakawa Staggered E-grid)(669 x 1165) units 1e-06 input WE:SN output WE:SN res 56
lat0 -7.446000 lat-center 54.000000 dlat 0.077000
lon0 215.861000 lon-center 254.000000 dlon 0.090000 #points=779385
-----
And if we search for the string +Arakawa Staggered E-grid)(669 x 1165)+
we find a hit at:
http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html[+http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html+]
where we find at table entry 99:
-----
779385-point (669x1165) Arakawa staggered E-grid on rotated latitude/longitude grid (Used by the 12km NAM Model - expanded domain).
-----
This links to a grid description table at:
http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID99[+http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID99+]
Links
-----
GRIB2 - Grid Definition Template 3.32768
http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp3-32768.shtml[+http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp3-32768.shtml+]
Wgrib2 Tricks for NCEP Users
http://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/tricks.ncep[+http://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/tricks.ncep+]
The Old Way
-----------
The programs and data files used by Matt to extract U and V from the old GRIB
files are:
. +doeta**.csh+ - Extracts text files containing +UGRD:10+ and +VGRD:10+ from
the GRIB files using +wgrib2+.
. +get12buv.f+ - Extracts a GOM geographical subset from the larger GRIB
fields using a text file containing the lon/lat values of the points within
the GOM region, and also rotates the components from the curvilinear grid
to a lon/lat regular grid.
. +MESA_ETA12B_UV.GRID+ - A text file containing all the lon/lat values within
the larger GRIB file that are in the GOM geographical subset.
The +doeta00.csh+ file:
-----
#!/bin/csh -f
cd /abyss/ETA32CODE
# Convert from GRIB to ascii and extract GOM subregion
rm get_roms.log >& /dev/null
set a=`date -u +%y%m%d`
#set a = "100405";
#/d2/abyss/ETA32CODE/ftp00.csh
cd /abyss/ETA32CODE
foreach f (A$a/*00.F*.grb)
echo $f > eta32infile.txt
# grib2:
set upick = `/usr/local/bin/wgrib2 -verf $f | grep "UGRD:10" | awk '{print substr($1,0,4)}'` >& /dev/null
set vpick = `/usr/local/bin/wgrib2 -verf $f | grep "VGRD:10" | awk '{print substr($1,0,4)}'` >& /dev/null
/usr/local/bin/wgrib2 $f -text $f'_u' -d $upick >& /dev/null
/usr/local/bin/wgrib2 $f -text $f'_v' -d $vpick >& /dev/null
/abyss/ETA32CODE/get12buv
rm A$a/*_* >& /dev/null
end
# Put Gulf of Mexico Eta Winds in pickup place for Baum
cp /abyss/ETA32CODE/A$a/*00.F*.txt /bosco/gulfweather/
chmod 777 /bosco/gulfweather/*.txt
# Make plots - which get converted to pdf and posted
#foreach f (A$a/*00.F*.grbuv.txt)
#/abyss/ETA32CODE/makeplot9.gmt $f
#nd
cd /abyss/ETA32CODE/A$a/
/d2/abyss/ETA32CODE/gftp.csh
/d2/abyss/ETA32CODE/gftp2.csh
-----
The +get12buv.f+ file:
-----
program get12uvb
c program to read ascii versions of grib ETA-12 data
c only outputs u and v
character*132 ufile,vfile,tfile,pfile,gfile
character*132 infile,outfile,linefile
character*5 ST
character*80 com(2)
real*4 alat,alon
real*8 u,v,t,p
integer snagthese(4369),ic
integer*8 linecount
linecount= 779385
maxline = 4369
maxlinep = maxline+1
pi = 4.0*atan(1.)
rad2deg = 360./(2.*pi)
open(unit=88,file='eta32infile.txt',status='old')
do while(.true.)
read(88,'(a132)',end=9123)infile
do i = 132,1,-1
if(infile(i:i) .ne. ' ')goto 123
enddo
write(*,*)'Input filename string too long'
stop
123 continue
linefile = 'linefileb.save'
outfile = infile(1:i)//'uv.txt'
ufile = infile(1:i)//'_u'
vfile = infile(1:i)//'_v'
c write(*,*)'Input file = ',infile(1:i)
c write(*,*)'output file = ',outfile
luinu = 20
luinv = 21
luing = 24
luout = 25
luline = 26
open(luout,file=outfile,status='unknown')
c open(luline,file=linefile,status='old')
open(luline,file=linefile,status='unknown')
open(luinu,file=ufile,status='old')
open(luinv,file=vfile,status='old')
c do i = 1,4369
c read(luline,*) snagthese(i)
c end do
read(luinu,'(a80)') com(1)
c read(luinu,*) id,iparam,iht,ilevel,iyr,imth,iday,ihr,imt
c write(*,'("luinu iparam ufile ",i2,1x,i3,1x,a20)')
c $luinu,iparam,ufile
read(luinv,'(a80)') com(1)
c read(luinv,*) id,iparam,iht,ilevel,iyr,imth,iday,ihr,imt
c write(*,'("luinv iparam vfile ",i2,1x,i3,1x,a20)')
c $luinv,iparam,vfile
id = 99
if(id .eq. 99) then
c write(*,*)'ETA-12b'
gfile = 'MESO_ETA12B_UV.GRID'
TP = 54.0 ! Central latitude of the eta32 grid.
TL = 106.0 ! Central longitude of the eta32 grid.
ST = 'ETA12B'
else
write(*,*)'Program get12uv'
write(*,*)'Grid ',id,' Unrecognized '
write(*,*)'Program Stop'
endif
open(luing,file=gfile,status='old')
write(luout,'(a5)')ST
write(luout,99)
99 format(' Long Lat Dir Spd U@10 V(m/s)')
ic = 1
c Read u, v, and the associated lat-longs
do 10 j=1,linecount
read(luinu,* ,end=200) u
read(luinv,* ,end=200) v
read(luing,80,end=200) alon,alat
80 format(F10.3,F10.3)
c if(j .eq. snagthese(ic)) then
c ic = ic + 1
if((alon.ge.-100.).and.(alon.le.-80.).and. ! Gulf of Mexico
& (alat.ge. 18.).and.(alat.le. 32.))then ! Gulf of Mexico
write(luline,*)j
fu = u
fv = v
call rotate(fu,fv,TP,TL,alat,abs(alon),ue,ve)
c write(*,*)alat,alon,fu,fv,ue,ve
dir = rad2deg*atan2(ve,ue)
spd = sqrt(ue*ue+ve*ve)
dir = 90. - dir
if(dir .lt. 0.) dir = dir+360.
write(luout,100) alon,alat,
$ dir,spd,ue,ve !Scaled speed & Pressure
100 format(2(f8.3,1x),4(f7.2,1x)) !u&v unscaled cartesian
endif
c if(ic .eq. maxlinep) goto 2001
c endif
10 continue
200 continue
2001 continue
close(luinu)
close(luinv)
close(luing)
close(luout)
close(luline)
end do
9123 continue
close(unit=88)
stop
end
SUBROUTINE ROTATE(UGRID,VGRID,TPH0D,TLM0D,GRLATD,GRLOND,
& UEARTH,VEARTH)
C
C ROTATE WINDS
C
C THIS ROUTINE WILL ROTATE GRID RELATIVE WINDS TO EARTH RELATIVE
C
C INPUT:
C UGRID (REAL) - U COMPONENT W.R.T. ETA GRID
C VGRID (REAL) - V COMPONENT W.R.T. ETA GRID
C TPH0D (REAL) - CENTRAL LATITUDE (DEG N) OF ETA GRID ROTATION
C TLM0D (REAL) - CENTRAL LONGITUDE (DEG W) OF ETA GRID ROTATION
C GRLATD(REAL) - LATITUDE (DEG N) OF ETA GRID POINT
C GRLOND(REAL) - LONGITUDE (DEG W) OF ETA GRID POINT
C
C OUTPUT:
C UEARTH(REAL) - U COMPONENT W.R.T. EARTH
C VEARTH(REAL) - V COMPONENT W.R.T. EARTH
C
C NOTE: SIMILAR CODE CAN BE USED TO ROTATE FROM EARTH RELATIVE
C TO GRID RELATIVE, USING THE FOLLOWING...
C
C UGRID=COSALP*UEARTH-SINALP*VEARTH
C VGRID=SINALP*UEARTH+COSALP*VEARTH
C
C WIND ROTATION SINES AND COSINES
C
PARAMETER(DTR=1.74532925E-2)
C
SINPH0 = SIN(TPH0D*DTR)
COSPH0 = COS(TPH0D*DTR)
RGRLON = GRLOND*DTR
RGRLAT = GRLATD*DTR
DLM = RGRLON-TLM0D*DTR
XX = COSPH0*COS(RGRLAT)*COS(DLM)
1 +SINPH0*SIN(RGRLAT)
YY = -COS(RGRLAT)*SIN(DLM)
TLON = ATAN(YY/XX)
ALPHA = ASIN(SINPH0*SIN(TLON)/COS(RGRLAT))
SINALP = SIN(ALPHA)
COSALP = COS(ALPHA)
UEARTH = UGRID*COSALP+VGRID*SINALP
VEARTH = VGRID*COSALP-UGRID*SINALP
RETURN
END
-----
A part of the +MESO_ETA12B_UV.GRID+ file:
-----
-144.140 -7.446
-144.049 -7.357
-143.958 -7.267
-143.867 -7.178
-143.776 -7.089
-143.684 -7.000
-143.593 -6.911
-143.501 -6.822
-143.409 -6.734
-143.317 -6.646
-143.225 -6.558
-143.133 -6.470
...
14.555 45.310
14.586 45.185
14.617 45.060
14.649 44.935
14.680 44.810
14.712 44.685
14.745 44.560
-----
A sample output text file is +1129106.F00.grbuv.txt+:
-----
ETA12
Long Lat Dir Spd U@10 V(m/s)
-99.939 18.052 160.98 1.03 0.33 -0.97
-99.786 18.036 107.80 1.21 1.15 -0.37
-99.634 18.021 111.13 0.71 0.66 -0.26
-99.481 18.004 19.68 0.26 0.09 0.25
-99.854 18.121 146.75 1.77 0.97 -1.48
-99.701 18.105 119.99 1.23 1.06 -0.61
-99.549 18.089 186.62 0.68 -0.08 -0.68
-99.396 18.073 342.65 0.62 -0.19 0.59
...
-80.372 31.860 355.04 3.78 -0.33 3.77
-80.185 31.797 355.19 3.92 -0.33 3.91
-80.432 31.963 358.34 3.81 -0.11 3.81
-80.245 31.900 355.99 3.75 -0.26 3.74
-80.058 31.837 356.88 4.01 -0.22 4.00
-80.118 31.940 358.21 3.76 -0.12 3.76
-----
Grid Changes
------------
Presently, the GRIB files contain fields on a Lambert Conformal grid.
The details can be found via:
-----
wgrib -grid testfile.grb
-----
which will produce:
-----
grid_template=30:winds(grid):
Lambert Conformal: (614 x 428) input WE:SN output WE:SN res 8
Lat1 12.190000 Lon1 226.541000 LoV 265.000000
LatD 25.000000 Latin1 25.000000 Latin2 25.000000
LatSP 0.000000 LonSP 0.000000
North Pole (614 x 428) Dx 12191.000000 m Dy 12191.000000 m mode 8
-----
This became the default grid on Oct. 18, 2011. Prior to that, the grid was:
-----
grid_template=32768:winds(grid):
Rotated Lat/Lon (Arakawa Staggered E-grid)(669 x 1165) units 1e-06 input WE:SN output WE:SN res 56
lat0 -7.446000 lat-center 54.000000 dlat 0.077000
lon0 215.861000 lon-center 254.000000 dlon 0.090000 #points=779385
-----
The last fields on the Arakawa grid were on Oct. 18, 2011 at 0600, and
the first ones on the Lambert Conformal grid were on Oct. 18, 2011 at
1200. There was an overlap period where fields were available on both
grids from 11-10-18-06 to 11-10-31-18. Thus there are fields for
Oct. 2011 in two subdirectories:
-----
/raid/howie/2011_NAM12/NAM201110a
/raid/howie/2011_NAM12/NAM201110b
-----
The details about the files on the overlap period are below:
-----
2011_NAM12/NAM201110a/A111001 to A111018
A111018
1129100.F00.grb
1129100.F03.grb
1129106.F00.grb
1129106.F03.grb
1129106.F06.grb
2011_NAM12/NAM201110b/B111001 to B111031
B111018
1129100.F00.grb
1129100.F03.grb
1129106.F00.grb
1129106.F03.grb
1129112.F00.grb
1129112.F03.grb
1129118.F00.grb
1129118.F03.grb
-----
Converting from GRIB to NetCDF Using NetCDF-Java
------------------------------------------------
At the website:
http://stackoverflow.com/questions/17403928/convert-grib-to-netcdf-file[+http://stackoverflow.com/questions/17403928/convert-grib-to-netcdf-file+]
we learn how to use +toolsUI+ to convert GRIB files into NetCDF files.
Here we convert both the old and new grid files for 11-10-18-06 from GRIB to NetCDF format:
-----
java -Xmx512m -classpath toolsUI-4.3.jar ucar.nc2.dataset.NetcdfDataset -in /raid/howie/2011_NAM12/NAM201110b/B111018/1129106.F03.grb -out 1129106.F03a.nc
java -Xmx512m -classpath toolsUI-4.3.jar ucar.nc2.dataset.NetcdfDataset -in /raid/howie/2011_NAM12/NAM201110a/A111018/1129106.F03.grb -out 1129106.F03b.nc
-----
Extracting Subsets from Converted Files
---------------------------------------
The following table shows the correlation between GRIB file variable names and
converted NetCDF file variable names:
-----
UGRD - u-component_of_wind_height_above_ground
VGRD - v-component_of_wind_height_above_ground
TMP - Temperature_surface
PRES - Pressure_surface
RH - Relative_humidity_height_above_ground
TCDC - Total_cloud_cover_entire_atmosphere
PRATE - Precipitation_rate_surface
DSWRF - Downward_Short-Wave_Radiation_Flux_surface
-----
The extraction of all of these into a single, reduced file can be done via:
-----
ncks -v u-component_of_wind_height_above_ground,v-component_of_wind_height_above_ground,Temperature_surface,Pressure_surface,Relative_humidity_height_above_ground,Total_cloud_cover_entire_atmosphere,Precipitation_rate_surface,Downward_Short-Wave_Radiation_Flux_surface 1129106.F03b.nc SFC.1129106.F03b.nc
-----
The metadata for each variable is:
-----
dimensions:
time = 1 ;
lat = 1165 ;
lon = 669 ;
height_above_ground = 1 ;
height_above_ground1 = 1 ;
variables:
float lat(lat) ;
lat:units = "degrees_north" ;
float lon(lon) ;
lon:units = "degrees_east" ;
int time(time) ;
time:units = "Hour since 2011-10-18T06:00:00Z" ;
time:standard_name = "time" ;
float height_above_ground(height_above_ground) ;
height_above_ground:units = "m" ;
height_above_ground:long_name = "Specified height level above ground" ;
height_above_ground:positive = "up" ;
height_above_ground:Grib2_level_type = 103 ;
height_above_ground:datum = "ground" ;
float height_above_ground1(height_above_ground1) ;
height_above_ground1:units = "m" ;
height_above_ground1:long_name = "Specified height level above ground" ;
height_above_ground1:positive = "up" ;
height_above_ground1:Grib2_level_type = 103 ;
height_above_ground1:datum = "ground" ;
float u-component_of_wind_height_above_ground(time, height_above_ground1, lat, lon) ;
u-component_of_wind_height_above_ground:long_name = "u-component of wind @ Specified height level above ground" ;
u-component_of_wind_height_above_ground:units = "m/s" ;
u-component_of_wind_height_above_ground:missing_value = NaNf ;
u-component_of_wind_height_above_ground:abbreviation = "UGRD" ;
u-component_of_wind_height_above_ground:Grib_Variable_Id = "VAR_0-2-2_L103" ;
u-component_of_wind_height_above_ground:Grib2_Parameter = 0, 2, 2 ;
u-component_of_wind_height_above_ground:Grib2_Parameter_Discipline = "Meteorological products" ;
u-component_of_wind_height_above_ground:Grib2_Parameter_Category = "Momentum" ;
u-component_of_wind_height_above_ground:Grib2_Parameter_Name = "u-component of wind" ;
u-component_of_wind_height_above_ground:Grib2_Level_Type = 103 ;
u-component_of_wind_height_above_ground:Grib2_Generating_Process_Type = "Forecast" ;
float v-component_of_wind_height_above_ground(time, height_above_ground1, lat, lon) ;
v-component_of_wind_height_above_ground:long_name = "v-component of wind @ Specified height level above ground" ;
v-component_of_wind_height_above_ground:units = "m/s" ;
v-component_of_wind_height_above_ground:missing_value = NaNf ;
v-component_of_wind_height_above_ground:abbreviation = "VGRD" ;
v-component_of_wind_height_above_ground:Grib_Variable_Id = "VAR_0-2-3_L103" ;
v-component_of_wind_height_above_ground:Grib2_Parameter = 0, 2, 3 ;
v-component_of_wind_height_above_ground:Grib2_Parameter_Discipline = "Meteorological products" ;
v-component_of_wind_height_above_ground:Grib2_Parameter_Category = "Momentum" ;
v-component_of_wind_height_above_ground:Grib2_Parameter_Name = "v-component of wind" ;
v-component_of_wind_height_above_ground:Grib2_Level_Type = 103 ;
v-component_of_wind_height_above_ground:Grib2_Generating_Process_Type = "Forecast" ;
float Temperature_surface(time, lat, lon) ;
Temperature_surface:long_name = "Temperature @ Ground or water surface" ;
Temperature_surface:units = "K" ;
Temperature_surface:missing_value = NaNf ;
Temperature_surface:abbreviation = "TMP" ;
Temperature_surface:Grib_Variable_Id = "VAR_0-0-0_L1" ;
Temperature_surface:Grib2_Parameter = 0, 0, 0 ;
Temperature_surface:Grib2_Parameter_Discipline = "Meteorological products" ;
Temperature_surface:Grib2_Parameter_Category = "Temperature" ;
Temperature_surface:Grib2_Parameter_Name = "Temperature" ;
Temperature_surface:Grib2_Level_Type = 1 ;
Temperature_surface:Grib2_Generating_Process_Type = "Forecast" ;
float Pressure_surface(time, lat, lon) ;
Pressure_surface:long_name = "Pressure @ Ground or water surface" ;
Pressure_surface:units = "Pa" ;
Pressure_surface:missing_value = NaNf ;
Pressure_surface:abbreviation = "PRES" ;
Pressure_surface:Grib_Variable_Id = "VAR_0-3-0_L1" ;
Pressure_surface:Grib2_Parameter = 0, 3, 0 ;
Pressure_surface:Grib2_Parameter_Discipline = "Meteorological products" ;
Pressure_surface:Grib2_Parameter_Category = "Mass" ;
Pressure_surface:Grib2_Parameter_Name = "Pressure" ;
Pressure_surface:Grib2_Level_Type = 1 ;
Pressure_surface:Grib2_Generating_Process_Type = "Forecast" ;
float Relative_humidity_height_above_ground(time, height_above_ground, lat, lon) ;
Relative_humidity_height_above_ground:long_name = "Relative humidity @ Specified height level above ground" ;
Relative_humidity_height_above_ground:units = "%" ;
Relative_humidity_height_above_ground:missing_value = NaNf ;
Relative_humidity_height_above_ground:abbreviation = "RH" ;
Relative_humidity_height_above_ground:Grib_Variable_Id = "VAR_0-1-1_L103" ;
Relative_humidity_height_above_ground:Grib2_Parameter = 0, 1, 1 ;
Relative_humidity_height_above_ground:Grib2_Parameter_Discipline = "Meteorological products" ;
Relative_humidity_height_above_ground:Grib2_Parameter_Category = "Moisture" ;
Relative_humidity_height_above_ground:Grib2_Parameter_Name = "Relative humidity" ;
Relative_humidity_height_above_ground:Grib2_Level_Type = 103 ;
Relative_humidity_height_above_ground:Grib2_Generating_Process_Type = "Forecast" ;
float Total_cloud_cover_entire_atmosphere(time, lat, lon) ;
Total_cloud_cover_entire_atmosphere:long_name = "Total cloud cover @ Entire atmosphere layer" ;
Total_cloud_cover_entire_atmosphere:units = "%" ;
Total_cloud_cover_entire_atmosphere:missing_value = NaNf ;
Total_cloud_cover_entire_atmosphere:abbreviation = "TCDC" ;
Total_cloud_cover_entire_atmosphere:Grib_Variable_Id = "VAR_0-6-1_L200" ;
Total_cloud_cover_entire_atmosphere:Grib2_Parameter = 0, 6, 1 ;
Total_cloud_cover_entire_atmosphere:Grib2_Parameter_Discipline = "Meteorological products" ;
Total_cloud_cover_entire_atmosphere:Grib2_Parameter_Category = "Cloud" ;
Total_cloud_cover_entire_atmosphere:Grib2_Parameter_Name = "Total cloud cover" ;
Total_cloud_cover_entire_atmosphere:Grib2_Level_Type = 200 ;
Total_cloud_cover_entire_atmosphere:Grib2_Generating_Process_Type = "Forecast" ;
float Precipitation_rate_surface(time, lat, lon) ;
Precipitation_rate_surface:long_name = "Precipitation rate @ Ground or water surface" ;
Precipitation_rate_surface:units = "kg.m-2.s-1" ;
Precipitation_rate_surface:missing_value = NaNf ;
Precipitation_rate_surface:abbreviation = "PRATE" ;
Precipitation_rate_surface:Grib_Variable_Id = "VAR_0-1-7_L1" ;
Precipitation_rate_surface:Grib2_Parameter = 0, 1, 7 ;
Precipitation_rate_surface:Grib2_Parameter_Discipline = "Meteorological products" ;
Precipitation_rate_surface:Grib2_Parameter_Category = "Moisture" ;
Precipitation_rate_surface:Grib2_Parameter_Name = "Precipitation rate" ;
Precipitation_rate_surface:Grib2_Level_Type = 1 ;
Precipitation_rate_surface:Grib2_Generating_Process_Type = "Forecast" ;
float Downward_Short-Wave_Radiation_Flux_surface(time, lat, lon) ;
Downward_Short-Wave_Radiation_Flux_surface:long_name = "Downward Short-Wave Radiation Flux @ Ground or water surface" ;
Downward_Short-Wave_Radiation_Flux_surface:units = "W.m-2" ;
Downward_Short-Wave_Radiation_Flux_surface:missing_value = NaNf ;
Downward_Short-Wave_Radiation_Flux_surface:abbreviation = "DSWRF" ;
Downward_Short-Wave_Radiation_Flux_surface:Grib_Variable_Id = "VAR_0-4-192_L1" ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Parameter = 0, 4, 192 ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Parameter_Discipline = "Meteorological products" ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Parameter_Category = "Short wave radiation" ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Parameter_Name = "Downward Short-Wave Radiation Flux" ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Level_Type = 1 ;
Downward_Short-Wave_Radiation_Flux_surface:Grib2_Generating_Process_Type = "Forecast" ;
// global attributes:
:Originating_or_generating_Center = "US National Weather Service, National Centres for Environmental Prediction (NCEP)" ;
:Originating_or_generating_Subcenter = "0" ;
:GRIB_table_version = "2,1" ;
:Type_of_generating_process = "Forecast" ;
:Analysis_or_forecast_generating_process_identifier_defined_by_originating_centre = "Non-hydrostatic Meso Model (NMM) (Currently 8 km)" ;
:Conventions = "CF-1.6" ;
:history = "Thu May 15 16:15:55 2014: ncks -v u-component_of_wind_height_above_ground,v-component_of_wind_height_above_ground,Temperature
_surface,Pressure_surface,Relative_humidity_height_above_ground,Total_cloud_cover_entire_atmosphere,Precipitation_rate_surface,Downward_Short-Wave_Radiat
ion_Flux_surface 1129106.F03b.nc SFC.1129106.F03b.nc\n",
"Read using CDM IOSP Grib2Collection" ;
:featureType = "GRID" ;
:file_format = "GRIB-2" ;