forked from jbzambon/wrf_tc_azimuthal_mean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrf_plevs.ncl
2419 lines (2413 loc) · 94.4 KB
/
wrf_plevs.ncl
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; wrfout_to_cf.ncl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; -NCL script to read an ARW wrfout NetCDF file on staggered model
; grid and to output unstaggered values in NetCDF CF compliant format.
; -Extensive help in maintaining and adding to the script was provide by
; Matt Higgins.
;
; command syntax:
; ncl 'file_in="wrfout.nc"' 'file_out="wrfpost.nc"' wrfout_to_cf.ncl
;
; -The NCL script is executed by the above command syntax. Alternatively,
; the file_out and file_in can be set in the script and there is then no
; need to specify it at the command prompt.
; -The values that are to be included in the output are determined by
; setting several attribute variables to True (include) or False (skip).
; These attribute variables are set at around line 160 in this script.
; -Setting the overall variable of a group of variables to false will exclude
; all of the variables in that group from the output file. For example,
; setting the variable out2dMet to False means that all 2dMet variables will
; not be included. If out2dMet is set to true, all of the individual variable
; attributes (i.e. out2dMet@T_sfc, out2dMet@T_2m, etc.) that are also set to
; true will be included in the output file.
;
; Support information:
; This script is semi-supported on a time available basis. If
; you come across an error, or have an idea for an improvement, please send
; an email. I will update the script on a time when I have time. Send all
; inquiries or questions to: Mark Seefeldt - [email protected]
;
; Release Notes: v2.0.0
; -release notes for all versions can be found at:
; http://foehn.colorado.edu/wrfout_to_cf/
; -v2.0.0
; NOTE: A significant change was made to re-name all mixing ratio
; variables to 'r_' from 'q'. Examples:
; Before: q_2m Now: r_v_2m
; q_e r_v_e
; q_p r_v_p
; q_cloud r_cloud
; q_rain_p r_rain_p
; This change was made with the addition of specific humidty as a
; moisture output option. The decision was made to go with the more
; community accepted variable of 'r' to represent mixing ratio.
; The previous values of q_2m, q_e, and q_p now represent specific
; humidity.
;
; -Added specific humidity as an output at 2m, eta levels, and pressure levels.
; -All measures of moisture (Td, RH, r_v, q) are available at 2m, eta levels,
; and pressure levels.
; -Added winds rotated to true earth coord. at 2m, eta, and pressure levels.
; -Added wind direction (Earth) and wind speed at 2m, eta, and pressure levels.
; -Added potential vorticity and absolute vorticity at eta and pressure levels.
; -Changed several variable names to more simples forms.
; ex: SHFlx and LHFlx to SH and LH.
; -Added a CLWRF section of a selection of CLWRF variables.
; -Reorganized the code for a simpler and easy to follow layout.
;
; TODO: In an upcoming release there will be an option to use CMIP variable
; names in the output file. There are placeholders for this option
; that are included below, but this is not an active feature at this
; point.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
system("echo 'Starting NCL CF routine ' `date -u`")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; load in the libraries
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; procedure to process the attributes in creating CF compliant WRF output
procedure assignVarAttCoord(x:numeric, time[*]:numeric, vert[*]:numeric, \
fl_vert:numeric)
; x:numeric -variable to process the attributes
; time[*]:numeric -array with time values for adding coordinates
; vert[*]:numeric -array with vertical values for adding coordinates
; Note: set to 0 if no vertical coordinate
; fl_vert:numeric -flag indicating vertical coordinate type
; 0 = no vertical coordinate (x,y only)
; 1 = pressure
; 2 = eta
; 3 = soil
; MissingValue -assigned missing value attribute
begin
; assign the default missing value
MissingValue = 1e20
; set time for all variables
x!0 = "time"
x&time = time
; set the vertical coordinate depending on fl_vert
if (fl_vert .eq. 1) then ;pressure as vertical coordinate
x!1 = "pressure"
x&pressure = vert
;x@missing_value = MissingValue
x@_FillValue = MissingValue
end if
if (fl_vert .eq. 2) then ;eta as vertical coordinate
x!1 = "eta"
x&eta = vert
x@_FillValue = MissingValue
end if
if (fl_vert .eq. 3) then ;soil as vertical coordinate
x!1 = "soil"
x&soil = vert
x@_FillValue = MissingValue
end if
; set the horizontal coordinates
if (fl_vert .eq. 0) then ;no vertical coordinate
x!1 = "south_north"
x!2 = "west_east"
;x@missing_value = MissingValue
x@_FillValue = MissingValue
else ;with vertical coordinate
x!2 = "south_north"
x!3 = "west_east"
;x@missing_value = MissingValue
x@_FillValue = MissingValue
end if
; set the mapping coordinates
x@coordinates = "lon lat"
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; start the primary wrfout_to_cf.ncl program
begin
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; configuration settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set the units for time
TimeUnits = "hours since 2001-01-01 00:00:00"
; set the values for pressure to be interpolated
pressure = (/1000., 980., 960., 940., 920., 900., \
880., 860., 840., 820., 800., \
780., 760., 740., 720., 700., \
680., 660., 640., 620., 600., \
580., 560., 540., 520., 500., \
480., 460., 440., 420., 400., \
380., 360., 340., 320., 300., \
280., 260., 240., 220., 200., \
180., 160., 140., 120., 100./)
; set the limits for the output range
; 0 = beginning of dataset
; 9999 = end of dataset
; Note: remember that the array is zero-based
limTime = (/0,9999/)
limS_N = (/0,9999/)
limW_E = (/0,9999/)
limPres = (/0,9999/)
limEta = (/0,9999/)
limSoil = (/0,9999/)
; set default values for file_in, dir_in, and file_out, if not specified
if (.not.isvar("file_in")) then
;file_in = "wrfout_d01_YYYY-MM-DD_00:00:00"
end if
if (.not.isvar("dir_in")) then
;dir_in = "DIRIN"
dir_in = ""
end if
if (.not.isvar("file_out")) then
;file_out = "YYYYMMDD_z.nc"
end if
if (.not.isvar("dir_out")) then
;dir_out = "DIROUT"
dir_out = ""
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; set the flags for selecting variables to be included ;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Note: Not all of the indicated values below can be extracted /
; converted from a given wrfout file. Some of the fields are
; included with only specific WRF physics options.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; output settings
axis = True ;one-dimensional coordinate fields
projection = False ;CF projection info with fields
outPtop = False ;include Ptop in the output file
;outCMIP = False ;use CMIP variable names in output
;MissingValue = -999999 ;missing value
; Note: MissingValue is currently assigned in the procedure assignVarAttCoord
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set the netcdf file global attributes
fileAtt = True
fileAtt@creation_date = systemfunc("date")
fileAtt@institution = "North Carolina State University - MEAS"
fileAtt@created_by = "Joseph B. Zambon: [email protected]"
fileAtt@notes = "Created with NCL script: ncl_cf.ncl"
fileAtt@source = file_in
fileAtt@Conventions = "CF 1.6, Standard Name Table v19"
fileAtt@title = file_out
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; time / date variables
outDateTime = True ;include a yyyymmddhh field
outUTCDate = True ;include yr,mo,dy,hr,mn fields
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional near-surface / surface met variables
out2dMet = False
out2dMet@SST = True ;sea-surface temperature
out2dMet@mdbz = True ;simulated radar reflectivity
out2dMet@T_sfc = True ;temperature at the surface
out2dMet@p_sfc = True ;pressure at the surface
out2dMet@slp = True ;sea-level pressure - using WRF-NCL
out2dMet@slp_b = False ;sea-level pressure - lowest eta level
out2dMet@T_2m = True ;temperature at 2m
out2dMet@theta_2m = True ;potential temperature at 2m
out2dMet@Td_2m = True ;dewpoint temperature at 2m
out2dMet@r_v_2m = True ;mixing ratio at 2m
out2dMet@q_2m = True ;specific humidity at 2m
out2dMet@rh_2m = True ;relative humidity at 2m
out2dMet@u_10m_gr = False ;u wind - grid - at 10m
out2dMet@v_10m_gr = False ;v wind - grid - at 10m
out2dMet@u_10m_tr = True ;u wind - rotated to earth - at 10m
out2dMet@v_10m_tr = True ;v wind - rotated to earth - at 10m
out2dMet@ws_10m = True ;wind speed - at 10m
out2dMet@wd_10m = True ;wind direction - earth - at 10m
;Warning: When using u_10m_tr / v_10m_tr / wd_10m / wd_10m there appears
; to be a warning error stating that the input field was not
; unstaggered. This appears to be an error in wrf_user_getvar
; as it appears to be a bug in hadling the fact that the 10m winds
; are already unstaggered. This is uncomfirmed. There appears to
; be no ill effects of the warning.
out2dMet@precip_g = True ;total grid scale precipitation
out2dMet@precip_c = True ;total cumulus precipitation
out2dMet@precip_fr = True ;fraction of frozen nonconv. precip
out2dMet@dryairmass = True ;total dry air mass in column
out2dMet@pblh = True ;PBL height
out2dMet@rho = False ;density at lowest eta level
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; three-dimensional upper-level (eta levels) meteorology variables
outEta = False
outEta@p_e = False ;pressure - eta
outEta@Z_e = False ;geopotential height - eta
outEta@T_e = False ;temperature - eta
outEta@theta_e = False ;potential temperature - eta
outEta@Td_e = False ;dewpoint temperature - eta
outEta@r_v_e = False ;mixing ratio - eta
outEta@q_e = False ;specific humidity - eta
outEta@rh_e = False ;relative humidity - eta
outEta@u_gr_e = False ;u wind - grid - eta
outEta@v_gr_e = False ;v wind - grid - eta
outEta@u_tr_e = False ;u wind - rotated to earth - eta
outEta@v_tr_e = False ;v wind - rotated to earth - eta
outEta@ws_e = False ;wind speed - eta
outEta@wd_e = False ;wind direction - earth - eta
outEta@w_e = False ;w wind - eta
outEta@pp_e = False ;pressure pert. - eta
outEta@r_cloud = False ;cloud mixing ratio - eta
outEta@r_rain = False ;rain mixing ratio - eta
outEta@r_ice = False ;ice mixing ratio - eta
outEta@r_snow = False ;snow mixing ratio - eta
outEta@r_graup = False ;graupel mixing ratio - eta
outEta@pvo_e = False ;potential vorticity - eta
outEta@avo_e = False ;absolute vorticity - eta
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; three-dimensional upper-level (pressure levels) meteorology variables
outPressure = True
outPressure@Z_p = True ;geopotential height - pressure
outPressure@T_p = True ;temperature - pressure
outPressure@theta_p = True ;potential temperature - pressure
outPressure@Td_p = True ;dewpoint temperature - pressure
outPressure@r_v_p = True ;mixing ratio - pressure
outPressure@q_p = True ;specific humidity - pressure
outPressure@rh_p = True ;relative humidity - pressure
outPressure@u_gr_p = False ;u wind - grid - pressure
outPressure@v_gr_p = False ;v wind - grid - pressure
outPressure@u_tr_p = True ;u wind - rotated to earth - pressure
outPressure@v_tr_p = True ;v wind - rotated to earth - pressure
outPressure@ws_p = True ;wind speed - pressure
outPressure@wd_p = True ;wind direction - earth - pressure
outPressure@w_p = True ;w wind - pressure
outPressure@pp_p = False ;pressure pert. - pressure
outPressure@r_cloud_p = True ;cloud mixing ratio - pressure
outPressure@r_rain_p = True ;rain mixing ratio - pressure
outPressure@r_ice_p = True ;ice mixing ratio - pressure
outPressure@r_snow_p = True ;snow mixing ratio - pressure
outPressure@r_graup_p = True ;graupel mixing ratio - pressure
outPressure@pvo_p = True ;potential vorticity - pressure
outPressure@avo_p = True ;absolute vorticity - pressure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional surface energy budget / radiation variables
out2dRadFlx = False
out2dRadFlx@SW_d = False ;SW flux - downward - sfc - instant
out2dRadFlx@LW_d = False ;LW flux - downward - sfc - instant
out2dRadFlx@SW_u = False ;SW flux - upward - sfc - instant
out2dRadFlx@LW_u = False ;LW flux - upward - sfc - instant
out2dRadFlx@LW_u_toa = False ;LW flux - upward - TOA - instant
out2dRadFlx@SW_d_acc = True ;SW flux - downward - sfc - accum.
out2dRadFlx@LW_d_acc = True ;LW flux - downward - sfc - accum.
out2dRadFlx@SW_u_acc = True ;SW flux - upward - sfc - accum.
out2dRadFlx@LW_u_acc = True ;LW flux - upward - sfc - accum.
out2dRadFlx@SW_d_toa_acc = True ;SW flux - downward - TOA - accum.
out2dRadFlx@LW_d_toa_acc = True ;LW flux - downward - TOA - accum.
out2dRadFlx@SW_u_toa_acc = True ;SW flux - upward - TOA - accum.
out2dRadFlx@LW_u_toa_acc = True ;LW flux - upward - TOA - accum.
out2dRadFlx@albedo = True ;surface albedo
out2dRadFlx@emiss_sfc = True ;surface emissivity
out2dRadFlx@SH = False ;SH flux - upward - sfc - instant
out2dRadFlx@LH = False ;LH flux - upward - sfc - instant
out2dRadFlx@SH_acc = True ;SH flux - upward - sfc - accum.
out2dRadFlx@LH_acc = True ;LH flux - upward - sfc - accum.
out2dRadFlx@MH = True ;moisture heat flux - upward - sfc.
out2dRadFlx@u_star = True ;friction velocity (u*)
out2dRadFlx@LWP = False ;liquid water path
out2dRadFlx@IWP = False ;ice water path
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional surface/soil variables
out2dLandSoil = False
out2dLandSoil@LandMask = True ;land mask (1 - land, 0 - water)
out2dLandSoil@LandUse = False ;land use category
out2dLandSoil@SoilT_L = False ;soil temperature at lower boundary
out2dLandSoil@SoilT_B = False ;bottom soil temperature
out2dLandSoil@GroundFlx = False ;ground heat flux
out2dLandSoil@SnowHgt = True ;snow depth
out2dLandSoil@SnowWater = True ;snow water equivalent
out2dLandSoil@SnowDens = True ;snow density
out2dLandSoil@SnowFlx = False ;snow phase change heat flux
out2dLandSoil@SnowMelt = False ;melted snow; accumulated
out2dLandSoil@SeaIce = False ;sea ice flag
out2dLandSoil@WaterFlx = False ;surface evaporation
out2dLandSoil@SfcRunoff = False ;surface runoff flux
out2dLandSoil@SubRunoff = False ;subsurface runoff flux
out2dLandSoil@SoilMoist = False ;total soil moisture content
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; three-dimensional soil variables
outSoil = False
outSoil@SoilTemp = False ;temperature - soil
outSoil@SoilMoist = False ;moisture - soil
outSoil@SoilWater = False ;water - soil
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional CLimate WRF (CLWRF) variables
; (http://www.meteo.unican.es/en/software/clwrf)
; -The CLWRF variables are activated by compiler flags within configiure.wrf.
; -The variables are outputted to auxiliary history output file(s).
outCLWRF = False
outCLWRF@T_sfc_min = False ;temperature at sfc - min.
outCLWRF@T_sfc_max = False ;temperature at sfc - max.
outCLWRF@T_sfc_mean = False ;temperature at sfc - mean
outCLWRF@T_sfc_std = False ;temperature at sfc - std. dev.
outCLWRF@T_2m_min = False ;temperature at 2 m - min.
outCLWRF@T_2m_max = False ;temperature at 2 m - max.
outCLWRF@T_2m_mean = False ;temperature at 2 m - mean
outCLWRF@T_2m_std = False ;temperature at 2 m - std. dev.
outCLWRF@r_v_2m_min = False ;mixing ratio at 2 m - min.
outCLWRF@r_v_2m_max = False ;mixing ratio at 2 m - max.
outCLWRF@r_v_2m_mean = False ;mixing ratio at 2 m - mean
outCLWRF@r_v_2m_std = False ;mixing ratio at 2 m - std. dev.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; open the input netcdf file (wrfout file)
wrfout = addfile(dir_in+file_in+".nc","r")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; time coordinate
; -the time in wrfout is in an odd character format
TimeChar = wrfout->Times
; -determine the number of dimensions for time
DimTimeChar = dimsizes(TimeChar)
nTime = DimTimeChar(0)
; -convert the wrfout time to a CF compliant time
; "hours since 1901-01-01 00:00:00"
time_in = wrf_times_c(TimeChar, 1)
; -create an array indicating the year, month, day, hour, minute, second
utc_date = floattoint(ut_calendar(time_in, 0))
; -create the final variable for time with the units selected
time = (/ut_inv_calendar(utc_date(:,0), utc_date(:,1), utc_date(:,2), \
utc_date(:,3), utc_date(:,4), utc_date(:,5), \
TimeUnits, 0)/) ;time
time@long_name = "Time"
time@standard_name = "time"
time@units = TimeUnits
time@calendar = "standard"
time!0 = "time"
time&time = time
utc_date!0 = "time" ;utc_date
utc_date&time = time
year = utc_date(:,0)
year@long_name = "Year"
year!0 = "time"
year&time = time
month = utc_date(:,1)
month@long_name = "Month"
month!0 = "time"
month&time = time
day = utc_date(:,2)
day@long_name = "Day"
day!0 = "time"
day&time = time
hour = utc_date(:,3)
hour@long_name = "Hour"
hour!0 = "time"
hour&time = time
minute = utc_date(:,4)
minute@long_name = "Minutes"
minute!0 = "time"
minute&time = time
; -convert the wrfout time to a DateTime integer for easy reading
if (outDateTime) then
DateTime = (/wrf_times_c(TimeChar, 3)/) ;time
DateTime@long_name = "Date and Time"
DateTime!0 = "time"
DateTime&time = time
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; vertical variables / coordinates
; Note: pressure levels are assigned in the beginning section
if (outPressure) then
nPressure = dimsizes(pressure) ;pressure vertical coordinate
pressure@long_name = "Pressure Levels"
pressure@standard_name = "air_pressure"
pressure@units = "hPa"
pressure@positive = "down"
pressure!0 = "pressure"
pressure&pressure = pressure
end if
if (outEta .or. outPressure)
eta = (/wrfout->ZNU(0,:)/) ;eta values on half-levels (mass)
nEta = dimsizes(eta)
eta@long_name = "Eta Levels (mass points)"
eta@standard_name = "atmosphere_sigma_coordinate"
eta@units = "1"
eta@positive = "down"
eta@formula_terms = "sigma: eta ps: p_sfc ptop: p_top"
eta!0 = "eta"
eta&eta = eta
end if
if (outSoil) then
soil = (/wrfout->ZS(0,:)/) ;depths of center of soil layers
nSoil = dimsizes(soil)
soil@long_name = "Soil Levels (depth)"
soil@standard_name = "depth"
soil@units = "m"
soil@positive = "down"
soil!0 = "soil"
soil&soil = soil
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; one-dimensional general model variables
if (outPtop .or. outEta) then
p_top_in = (/wrfout->P_TOP/)/100. ;pressure at top of model
;in some files P_TOP has two dimensions, in some it has one dimension
if ((dimsizes(dimsizes(p_top_in))) .eq. 2) then
p_top = p_top_in(0,0)
else
p_top = p_top_in(0)
end if
p_top@long_name = "Pressure at Top of the Model"
p_top@standard_name = "air_pressure"
p_top@units = "hPa"
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional mapping variables
lat = (/wrfout->XLAT(0,:,:)/) ;lat (mass)
DimLat = dimsizes(lat)
nS_N = DimLat(0) ;S_N dimension
nW_E = DimLat(1) ;W_E dimension
lat@long_name = "Latitude"
lat@standard_name = "latitude"
lat@units = "degrees_north"
lat!0 = "south_north"
lat!1 = "west_east"
lon = (/wrfout->XLONG(0,:,:)/) ;lon (mass)
lon@long_name = "Longitude"
lon@standard_name = "longitude"
lon@units = "degrees_east"
lon!0 = "south_north"
lon!1 = "west_east"
Z_sfc = (/wrfout->HGT(0,:,:)/) ;Z_sfc
Z_sfc@long_name = "Terrain Height"
Z_sfc@standard_name = "height"
Z_sfc@units = "m"
Z_sfc@coordinates = "lon lat"
Z_sfc!0 = "south_north"
Z_sfc!1 = "west_east"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; one-dimensional coordinate system
if (axis) then
south_north = ispan(0,nS_N-1,1) ;south_north
south_north@long_name = "y-coordinate in Cartesian system"
south_north@axis = "Y"
south_north@units = "m"
south_north!0 = "south_north"
west_east = ispan(0,nW_E-1,1) ;west_east
west_east@long_name = "x-coordinate in Cartesian system"
west_east@axis = "X"
west_east@units = "m"
west_east!0 = "west_east"
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional near-surface / surface met variables
; -retrieved directly from the wrfout file - or
; -derived/diagnostic fields using wrf_user_getvar
if (out2dMet) then
if (out2dMet@SST) then
SST = (/wrfout->SST/) ;SST
SST@long_name = "Sea-Surface Temperature"
SST@standard_name = "sea_surface_temperature"
SST@units = "K"
assignVarAttCoord(SST,time,0,0)
system("echo 'Done with SST ' `date -u`")
end if
if (out2dMet@T_sfc) then
T_sfc = (/wrfout->TSK/) ;T_sfc
T_sfc@long_name = "Temperature at the Surface"
T_sfc@standard_name = "surface_temperature"
T_sfc@units = "K"
assignVarAttCoord(T_sfc,time,0,0)
system("echo 'Done with T_sfc ' `date -u`")
end if
if (out2dMet@p_sfc) then
p_sfc = (/wrfout->PSFC/)/100. ;p_sfc
p_sfc@long_name = "Pressure at the Surface"
p_sfc@standard_name = "surface_air_pressure"
p_sfc@units = "hPa"
assignVarAttCoord(p_sfc,time,0,0)
system("echo 'Done with p_sfc ' `date -u`")
end if
if (out2dMet@slp) then ;slp
slp = (/wrf_user_getvar(wrfout,"slp",-1)/)
slp@long_name = "Sea-Level Pressure"
slp@standard_name = "air_pressure_at_sea_level"
slp@units = "hPa"
assignVarAttCoord(slp,time,0,0)
system("echo 'Done with slp ' `date -u`")
end if
if (out2dMet@mdbz) then ;slp
mdbz = (/wrf_user_getvar(wrfout,"mdbz",-1)/)
mdbz@long_name = "Maximum reflectivity"
mdbz@standard_name = "simulated_radar_reflectivity"
mdbz@units = "dBZ"
assignVarAttCoord(mdbz,time,0,0)
system("echo 'Done with mdbz ' `date -u`")
end if
if (out2dMet@T_2m) then
T_2m = (/wrfout->T2/) - 273.15 ;T_2m
T_2m@long_name = "Temperature at 2 m"
T_2m@standard_name = "air_temperature"
T_2m@units = "degC"
assignVarAttCoord(T_2m,time,0,0)
system("echo 'Done with T_2m ' `date -u`")
end if
if (out2dMet@theta_2m) then
theta_2m = (/wrfout->TH2/) ;theta_2m
theta_2m@long_name = "Potential Temperature at 2 m"
theta_2m@standard_name = "air_potential_temperature"
theta_2m@units = "K"
assignVarAttCoord(theta_2m,time,0,0)
system("echo 'Done with theta_2m ' `date -u`")
end if
if (out2dMet@Td_2m) then ;Td_2m
Td_2m = (/wrf_user_getvar(wrfout,"td2",-1)/)
Td_2m@long_name = "Dewpoint Temperature at 2 m"
Td_2m@standard_name = "dew_point_temperature"
Td_2m@units = "degC"
assignVarAttCoord(Td_2m,time,0,0)
system("echo 'Done with Td_2m ' `date -u`")
end if
if (out2dMet@r_v_2m .or. out2dMet@q_2m) then
r_v_2m = (/wrfout->Q2/) ;r_v_2m
r_v_2m@long_name = "Water Vapor Mixing Ratio at 2 m"
r_v_2m@standard_name = "humidity_mixing_ratio"
r_v_2m@units = "kg kg-1"
assignVarAttCoord(r_v_2m,time,0,0)
system("echo 'Done with r_v_2m ' `date -u`")
if (out2dMet@q_2m)
q_2m = r_v_2m / (1 + r_v_2m) ; q_2m
q_2m@long_name = "Specific Humidity at 2 m"
q_2m@standard_name = "specific_humidity"
q_2m@units = "kg kg-1"
assignVarAttCoord(q_2m,time,0,0)
system("echo 'Done with q_2m ' `date -u`")
end if
end if
if (out2dMet@rh_2m) then ;rh_2m
rh_2m = (/wrf_user_getvar(wrfout,"rh2",-1)/)
rh_2m@long_name = "Relative Humidity at 2 m"
rh_2m@standard_name = "relative_humidity"
rh_2m@units = "percent"
assignVarAttCoord(rh_2m,time,0,0)
system("echo 'Done with rh_2m ' `date -u`")
end if
if (out2dMet@u_10m_gr) then
u_10m_gr = (/wrfout->U10/) ;u_10m_gr
u_10m_gr@long_name = "u-Component of Wind at 10 m (grid)"
u_10m_gr@standard_name = "eastward_wind"
u_10m_gr@units = "m s-1"
assignVarAttCoord(u_10m_gr,time,0,0)
system("echo 'Done with u_10m_gr ' `date -u`")
end if
if (out2dMet@v_10m_gr) then
v_10m_gr = (/wrfout->V10/) ;v_10m_gr
v_10m_gr@long_name = "v-Component of Wind at 10 m (grid)"
v_10m_gr@standard_name = "northward_wind"
v_10m_gr@units = "m s-1"
assignVarAttCoord(v_10m_gr,time,0,0)
system("echo 'Done with v_10m_gr ' `date -u`")
end if
; - values for u_10m_tr, v_10m_tr, ws_10m, and/or wd_10m
if (out2dMet@u_10m_tr .or. out2dMet@v_10m_tr .or. \
out2dMet@ws_10m .or. out2dMet@wd_10m) then
uv_10m_tr = (/wrf_user_getvar(wrfout,"uvmet10",-1)/)
u_10m_tr = (/uv_10m_tr(0,:,:,:)/) ;u_10m_tr
u_10m_tr@long_name = "u-Component of wind at 10 m (Earth)"
u_10m_tr@standard_name = "eastward_wind"
u_10m_tr@units = "m s-1"
assignVarAttCoord(u_10m_tr,time,0,0)
system("echo 'Done with u_10m_tr ' `date -u`")
v_10m_tr = (/uv_10m_tr(1,:,:,:)/) ;v_10m_tr
v_10m_tr@long_name = "v-Component of wind at 10 m (Earth)"
v_10m_tr@standard_name = "northward_wind"
v_10m_tr@units = "m s-1"
assignVarAttCoord(v_10m_tr,time,0,0)
system("echo 'Done with v_10m_tr ' `date -u`")
if (out2dMet@ws_10m)
ws_10m = sqrt(u_10m_tr^2 + v_10m_tr^2) ;ws_10m
ws_10m@long_name = "Wind Speed at 10 m"
ws_10m@standard_name = "wind_speed"
ws_10m@units = "m s-1"
assignVarAttCoord(ws_10m,time,0,0)
system("echo 'Done with ws_10m ' `date -u`")
end if
if (out2dMet@wd_10m) ;wd_10m
r2d = 45.0/atan(1.0)
wd_10m = atan2(u_10m_tr, v_10m_tr) * r2d + 180.
wd_10m@long_name = "Wind Direction at 10 m"
wd_10m@standard_name = "wind_from_direction"
wd_10m@units = "degree"
assignVarAttCoord(wd_10m,time,0,0)
system("echo 'Done with wd_10m ' `date -u`")
end if
end if
if (out2dMet@precip_g) then
precip_g = (/wrfout->RAINNC/) ;precip_g
precip_g@long_name = "Accumulated Total Grid Scale Precipitation"
precip_g@standard_name = "large_scale_precipitation_amount"
precip_g@units = "mm"
assignVarAttCoord(precip_g,time,0,0)
system("echo 'Done with precip_g ' `date -u`")
end if
if (out2dMet@precip_c) then
precip_c = (/wrfout->RAINC/) ;precip_c
precip_c@long_name = "Accumulated Total Cumulus Precipitation"
precip_c@standard_name = "convective_precipitation_amount"
precip_c@units = "mm"
assignVarAttCoord(precip_c,time,0,0)
system("echo 'Done with precip_c ' `date -u`")
end if
if (out2dMet@precip_fr) then
precip_fr = (/wrfout->SR/) ;precip_fr
precip_fr@long_name = "Fraction of Frozen Non-convective Precipitation"
precip_fr@standard_name = ""
precip_fr@units = "1"
assignVarAttCoord(precip_fr,time,0,0)
system("echo 'Done with precip_fr ' `date -u`")
end if
if (out2dMet@dryairmass) then
dryairmass = ((/wrfout->MU/)+(/wrfout->MUB/))/100. ;dryairmass
dryairmass@long_name = "Total Dry Air Mass in Column"
dryairmass@standard_name = ""
dryairmass@units = "hPa"
assignVarAttCoord(dryairmass,time,0,0)
system("echo 'Done with dryairmass ' `date -u`")
end if
if (out2dMet@pblh) then
pblh = (/wrfout->PBLH/) ;pblh
pblh@long_name = "PBL Height"
pblh@standard_name = "atmosphere_boundary_layer_thickness"
pblh@units = "m"
assignVarAttCoord(pblh,time,0,0)
system("echo 'Done with pblh ' `date -u`")
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; two-dimensional near-surface / surface met variables (calculated)
if (out2dMet@slp_b .or. out2dMet@rho) then
; Note: This is an alternative method to calculate slp based on
; the temperature, moisture, and height of the lowest model level.
; There is no certainty that this is any better, and possibly
; worse than what is used in slp.
; -create the variable
slp_b = new((/nTime,nS_N,nW_E/), double, "No_FillValue") ;slp
rho = new((/nTime,nS_N,nW_E/), double, "No_FillValue") ;rho
; -loop through the nTimes
do n = 0, nTime-1
; -create new variables for what is needed to calculate slp
T_eta = new((/nEta,nS_N,nW_E/), double, "No_FillValue")
r_v_eta = new((/nEta,nS_N,nW_E/), double, "No_FillValue")
p_eta = new((/nEta,nS_N,nW_E/), double, "No_FillValue")
Z_eta = new((/nEta,nS_N,nW_E/), double, "No_FillValue")
temp_v = new((/nS_N,nW_E/), double, "No_FillValue")
; -read in the values needed for calculations
T_eta = (/wrf_user_getvar(wrfout,"tk",n)/)
p_eta = (/wrf_user_getvar(wrfout,"pressure",n)/)
Z_eta = (/wrf_user_getvar(wrfout,"z",n)/)
r_v_eta = (/wrfout->QVAPOR(n,:,:,:)/)
; -calculate the virtual temperature
temp_v = (1.+(0.622*r_v_eta(0,:,:)))*T_eta(0,:,:)
; -calculate the sea-level pressure using the virtual temperature of
; the lowest model level
slp_b(n,:,:) = p_eta(0,:,:)*exp((9.81*Z_eta(0,:,:))/(287.*temp_v))
rho(n,:,:) = p_eta(0,:,:)*100. / (287.*temp_v)
; -multiply p_eta by 100 as p_eta is in hPa
end do
; -set the attributes
slp_b@long_name = "Sea-Level Pressure"
slp_b@standard_name = "air_pressure_at_sea_level"
slp_b@units = "hPa"
assignVarAttCoord(slp_b,time,0,0) ;slp
system("echo 'Done with slp_b ' `date -u`")
rho@long_name = "Air Density at Lowest Model Level"
rho@standard_name = "air_density"
rho@units = "kg m-3"
assignVarAttCoord(rho,time,0,0) ;slp
system("echo 'Done with rho ' `date -u`")
end if
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; three-dimensional upper-level (eta) metorology variables
; -retrieved directly from the wrfout file - or
; -derived/diagnostic fields using wrf_user_getvar
if (outEta .or. outPressure)
if (outEta@p_e .or. outPressure) then
p_e = (/wrf_user_getvar(wrfout,"pressure",-1)/) ;p_e
p_e@long_name = "Pressure"
p_e@standard_name = "air_pressure"
p_e@units = "hPa"
assignVarAttCoord(p_e,time,eta,2)
system("echo 'Done with p_e ' `date -u`")
end if
if (outEta@Z_e .or. outPressure@Z_p) then
Z_e = (/wrf_user_getvar(wrfout,"z",-1)/) ;Z_e
Z_e@long_name = "Geopotential Height"
Z_e@standard_name = "geopotential_height"
Z_e@units = "m"
assignVarAttCoord(Z_e,time,eta,2)
system("echo 'Done with Z_e ' `date -u`")
end if
if (outEta@T_e .or. outPressure@T_p) then
T_e = (/wrf_user_getvar(wrfout,"tk",-1)/) ;T_e
T_e@long_name = "Temperature"
T_e@standard_name = "air_temperature"
T_e@units = "K"
assignVarAttCoord(T_e,time,eta,2)
system("echo 'Done with T_e ' `date -u`")
end if
if (outEta@theta_e .or. outPressure@theta_p) then
theta_e = (/wrf_user_getvar(wrfout,"th",-1)/) ;theta_e
theta_e@long_name = "Potential Temperature"
theta_e@standard_name = "air_potential_temperature"
theta_e@units = "K"
assignVarAttCoord(theta_e,time,eta,2)
system("echo 'Done with theta_e ' `date -u`")
end if
if (outEta@Td_e .or. outPressure@Td_p) then
Td_e = (/wrf_user_getvar(wrfout,"td",-1)/) ;Td_e
Td_e@long_name = "Dewpoint Temperature"
Td_e@standard_name = "dew_point_temperature"
Td_e@units = "degC"
assignVarAttCoord(Td_e,time,eta,2)
system("echo 'Done with Td_e ' `date -u`")
end if
; mixing ratio and specific humidity both come from mixing ratio
if (outEta@r_v_e .or. outPressure@r_v_p .or. \
outEta@q_e .or. outPressure@q_p) then
r_v_e = (/wrfout->QVAPOR/) ;r_v_e
r_v_e@long_name = "Mixing Ratio - Water Vapor"
r_v_e@standard_name = "humidity_mixing_ratio"
r_v_e@units = "kg kg-1"
assignVarAttCoord(r_v_e,time,eta,2)
system("echo 'Done with r_v_e ' `date -u`")
if (outEta@q_e .or. outPressure@q_p) then
q_e = r_v_e / (1 + r_v_e) ;q_e
q_e@long_name = "Specific Humidity"
q_e@standard_name = "specific_humidity"
q_e@units = "kg kg-1"
assignVarAttCoord(q_e,time,eta,2)
system("echo 'Done with q_e ' `date -u`")
end if
end if
if (outEta@rh_e .or. outPressure@rh_p) then
rh_e = (/wrf_user_getvar(wrfout,"rh",-1)/) ;rh_e
rh_e@long_name = "Relative Humidity"
rh_e@standard_name = "relative_humidity"
rh_e@units = "percent"
assignVarAttCoord(rh_e,time,eta,2)
system("echo 'Done with rh_e ' `date -u`")
end if
if (outEta@u_gr_e .or. outPressure@u_gr_p) then
u_gr_e = (/wrf_user_getvar(wrfout,"ua",-1)/) ;u_gr_e
u_gr_e@long_name = "u-Component of Wind (grid)"
u_gr_e@standard_name = "eastward_wind"
u_gr_e@units = "m s-1"
assignVarAttCoord(u_gr_e,time,eta,2)
system("echo 'Done with u_gr_e ' `date -u`")
end if
if (outEta@v_gr_e .or. outPressure@v_gr_p) then
v_gr_e = (/wrf_user_getvar(wrfout,"va",-1)/) ;v_gr_e
v_gr_e@long_name = "v-Component of Wind (grid)"
v_gr_e@standard_name = "northward_wind"
v_gr_e@units = "m s-1"
assignVarAttCoord(v_gr_e,time,eta,2)
system("echo 'Done with v_gr_e ' `date -u`")
end if
; the wind is handled as a single variable for u and v, read for all
if (outEta@u_tr_e .or. outPressure@u_tr_p .or. \
outEta@v_tr_e .or. outPressure@v_tr_p .or. \
outEta@ws_e .or. outPressure@ws_p .or. \
outEta@wd_e .or. outPressure@wd_p) then
uv_tr_e = (/wrf_user_getvar(wrfout,"uvmet",-1)/) ;u_tr and v_tr
u_tr_e = uv_tr_e(0,:,:,:,:) ;u_tr_e
u_tr_e@long_name = "u-Component of Wind (Earth)"
u_tr_e@standard_name = "eastward_wind"
u_tr_e@units = "m s-1"
assignVarAttCoord(u_tr_e,time,eta,2)
system("echo 'Done with u_tr_e ' `date -u`")
v_tr_e = uv_tr_e(1,:,:,:,:) ;v_tr_e
v_tr_e@long_name = "v-Component of Wind (Earth)"
v_tr_e@standard_name = "northward_wind"
v_tr_e@units = "m s-1"
assignVarAttCoord(v_tr_e,time,eta,2)
system("echo 'Done with v_tr_e ' `date -u`")
if (outEta@ws_e)
ws_e = sqrt(u_tr_e^2 + v_tr_e^2) ;ws_e
ws_e@long_name = "Wind Speed"
ws_e@standard_name = "wind_speed"
ws_e@units = "m s-1"
assignVarAttCoord(ws_e,time,0,0)
system("echo 'Done with ws_e ' `date -u`")
end if
if (outEta@wd_e)
r2d = 45.0/atan(1.0) ;wd_e
wd_e = atan2(u_tr_e, v_tr_e) * r2d + 180.
wd_e@long_name = "Wind Direction"
wd_e@standard_name = "wind_from_direction"
wd_e@units = "degree"
assignVarAttCoord(wd_e,time,0,0)
system("echo 'Done with wd_e ' `date -u`")
end if
end if
if (outEta@w_e .or. outPressure@w_p) then
w_e =(/wrf_user_getvar(wrfout,"wa",-1)/) ;w_e
w_e@long_name = "w-Component of Wind"
w_e@standard_name = "upward_wind"
w_e@units = "m s-1"
assignVarAttCoord(w_e,time,eta,2)
system("echo 'Done with w_e ' `date -u`")
end if
if (outEta@pp_e .or. outPressure@pp_p) then
pp_e = (/wrfout->P/)/100. ;pp_e
pp_e@long_name = "Pressure Perturbation"
pp_e@standard_name = ""
pp_e@units = "hPa"
assignVarAttCoord(pp_e,time,eta,2)
system("echo 'Done with pp_e ' `date -u`")
end if
if (outEta@r_cloud .or. outPressure@r_cloud_p) then
r_cloud = (/wrfout->QCLOUD/) ;r_cloud
r_cloud@long_name = "Mixing Ratio - Cloud"
r_cloud@standard_name = "mass_fraction_of_cloud_condensed_water_in_air"
r_cloud@units = "kg kg-1"
assignVarAttCoord(r_cloud,time,eta,2)
system("echo 'Done with r_cloud ' `date -u`")
end if
if (outEta@r_rain .or. outPressure@r_rain_p) then
r_rain = (/wrfout->QRAIN/) ;r_rain
r_rain@long_name = "Mixing Ratio - Rain"
r_rain@standard_name = "mass_fraction_of_rain_in_air"
r_rain@units = "kg kg-1"
assignVarAttCoord(r_rain,time,eta,2)
system("echo 'Done with r_rain ' `date -u`")
end if
if ((outEta@r_ice .or. outPressure@r_ice_p) .and. \
isfilevar(wrfout, "QICE")) then
r_ice = (/wrfout->QICE/) ;r_ice
r_ice@long_name = "Mixing Ratio - Ice"
r_ice@standard_name = "mass_fraction_of_ice_in_air"
r_ice@units = "kg kg-1"
assignVarAttCoord(r_ice,time,eta,2)
system("echo 'Done with r_ice ' `date -u`")
end if
if ((outEta@r_snow .or. outPressure@r_snow_p) .and. \
isfilevar(wrfout, "QSNOW")) then
r_snow = (/wrfout->QSNOW/) ;r_snow
r_snow@long_name = "Mixing Ratio - Snow"
r_snow@standard_name = "mass_fraction_of_snow_in_air"
r_snow@units = "kg kg-1"
assignVarAttCoord(r_snow,time,eta,2)
system("echo 'Done with r_snow ' `date -u`")
end if
if ((outEta@r_graup .or. outPressure@r_graup_p) .and. \
isfilevar(wrfout, "QGRAUP")) then
r_graup = (/wrfout->QGRAUP/) ;r_graupel
r_graup@long_name = "Mixing Ratio - Graupel"
r_graup@standard_name = "mass_fraction_of_graupel_in_air"
r_graup@units = "kg kg-1"
assignVarAttCoord(r_graup,time,eta,2)
system("echo 'Done with r_graup ' `date -u`")
end if
if (outEta@pvo_e .or. outPressure@pvo_p) then
pvo_e = (/wrf_user_getvar(wrfout,"pvo",-1)/) ;pvo_e
pvo_e@long_name = "Potential Vorticity"
pvo_e@standard_name = "potential_vorticity_of_atmosphere_layer"
pvo_e@units = "PVU"
assignVarAttCoord(pvo_e,time,eta,2)
system("echo 'Done with pvo_e ' `date -u`")
end if
if (outEta@avo_e .or. outPressure@avo_p) then
avo_e = (/wrf_user_getvar(wrfout,"avo",-1)/) ;avo_e
avo_e@long_name = "Absolute Vorticity"
avo_e@standard_name = "atmosphere_absolute_vorticity"
avo_e@units = "s-1"
assignVarAttCoord(avo_e,time,eta,2)
system("echo 'Done with avo_e ' `date -u`")
end if
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; three-dimensional upper-level (pressure) metorology variables
; (variables on selected pressure levels)
; -derived/diagnostic fields using wrf_user_getvar
; -create the variables
if (outPressure) then
if (outPressure@Z_p) then
Z_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;Z_p
end if
if (outPressure@T_p) then
T_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;T_p
end if
if (outPressure@theta_p) then
theta_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue");th_p
end if
if (outPressure@Td_p) then
Td_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;Td_p
end if
if (outPressure@r_v_p) then
r_v_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;r_v_p
end if
if (outPressure@q_p) then
q_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;q_p
end if
if (outPressure@rh_p) then
rh_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;rh_p
end if
if (outPressure@u_gr_p) then
u_gr_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;u_gr_p
end if
if (outPressure@v_gr_p) then
v_gr_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;v_gr_p
end if
if (outPressure@u_tr_p) then
u_tr_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;u_tr_p
end if
if (outPressure@v_tr_p) then
v_tr_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;v_tr_p
end if
if (outPressure@ws_p) then
ws_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;ws_p
end if
if (outPressure@wd_p) then
wd_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;wd_p
end if
if (outPressure@w_p) then
w_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;w_p
end if
if (outPressure@pp_p) then
pp_p = new((/nTime,nPressure,nS_N,nW_E/), "float", "No_FillValue") ;pp_p
end if
if ((outPressure@r_cloud_p) .and. (isfilevar(wrfout, "QCLOUD"))) then ;r_cl
r_cloud_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue")
end if
if ((outPressure@r_rain_p) .and. (isfilevar(wrfout, "QRAIN"))) then ;r_rain
r_rain_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue")
end if
if ((outPressure@r_ice_p) .and. (isfilevar(wrfout, "QICE"))) then ;r_ice
r_ice_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue")
end if
if ((outPressure@r_snow_p) .and. (isfilevar(wrfout, "QSNOW"))) then ;r_snow
r_snow_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue")
end if
if ((outPressure@r_graup_p) .and. (isfilevar(wrfout, "QGRAUP"))) then ;r_grp
r_graup_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue")
end if
if (outPressure@pvo_p) then
pvo_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;pvo_p
end if
if (outPressure@avo_p) then
avo_p = new((/nTime,nPressure,nS_N,nW_E/),"float","No_FillValue") ;avo_p
end if
; use wrf_user_intrp3d to interpolate the model levels to a pressure level
system("echo Starting 3D variables over " + tostring(nTime) + " levels @ `date -u`")
do n = 0, nTime-1 ; loop through the times in the wrfout file
do p = 0, nPressure-1 ; loop through the selected pressure levels
if (outPressure@Z_p) then ;Z_p
Z_p(n,p,:,:) = (/wrf_user_intrp3d(Z_e(n,:,:,:),p_e(n,:,:,:), \
"h",pressure(p),0,False)/)
end if
if (outPressure@T_p) then ;T_p
T_p(n,p,:,:) = (/wrf_user_intrp3d(T_e(n,:,:,:),p_e(n,:,:,:), \
"h",pressure(p),0,False)/)