-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathts2nc_autoread_d02.ncl
676 lines (520 loc) · 22.1 KB
/
ts2nc_autoread_d02.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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; NCL Libraries
;
; $NCARG_ROOT is /usr on gamow
;
load "/home/wcapehart/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "/home/wcapehart/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "/home/wcapehart/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "/home/wcapehart/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "/home/wcapehart/lib/ncarg/nclscripts/csm/contributed.ncl"
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
begin
setfileoption("nc","Format","NetCDF4") ; these are going to be big files
setfileoption("nc","CompressionLevel",5)
dir_local = "/home/wcapehart/WRFV381_TKE/"
wrf_home_dir = "/home/wcapehart/WRFV381_TKE/"
wrf_version = "WRFV381"
wrf_program_root_dir = wrf_home_dir + wrf_version+"/"
dir_for_wrf_output = wrf_program_root_dir+"WRFV3/test/em_real/"
run_date = systemfunc("cat " + dir_local + "current_day.txt")
domainstring = ".d02."
wrf_full_model_file = "nam02_d02_"+run_date+".nc"
print(wrf_full_model_file)
tke_on = True
soils_on = True
station_id = (/ "CRSV", \
"FYGB", \
"FYGF", \
"FYOO", \
"FYOW", \
"FYWH", \
"FYWB", \
"FYRU" /)
f_wrf = addfile(dir_for_wrf_output + wrf_full_model_file + ".nc", "r")
sigmas = f_wrf->ZNU(0,:)
wrf_elev = f_wrf->HGT(0,:,:)
soil_levels = f_wrf->ZS(0,:)
delete(soil_levels@stagger)
delete(soil_levels@FieldType)
delete(soil_levels@MemoryOrder)
soil_levels!0 = "soil_levels"
soil_levels&soil_levels = soil_levels
soil_levels@positive = "down"
soil_levels@standard_name = "depth"
soil_levels@long_name = "Depths of Center of the Soil Layers"
soil_levels@description = "Depths of Center of the Soil Layers"
soil_levels@units = "m"
wrf_time = wrf_times_c(f_wrf->Times, 0 )
wrf_utc_date = cd_calendar(wrf_time(0), -5)
ptop = (/ f_wrf->P_TOP(0) /) ; Pa.
ptop@long_name = "Pressure at Top of Model Space"
ptop@description = "Pressure at Top of Model Space"
ptop@standard_name = "air_pressure"
ptop@units = "Pa"
ptop!0 = "ptop"
ptop&ptop = ptop
nlevels = 15
sigma = (/ sigmas(0:nlevels-1) /)
sigma!0 = "sigma"
sigma&sigma = sigma
sigma@units = ""
sigma@long_name = "Sigma Coordinate from WRF"
sigma@description = "Sigma Coordinate from WRF"
sigma@standard_name = "atmosphere_sigma_coordinate"
sigma@comment1 = "pressure(n,k) = ptop + sigma(k)*(psfc(n,k)-ptop)"
sigma@formula_terms = "sigma: sigma ps: psfc ptop: ptop"
sigma@positive = "down"
; run date must be in this format "2015-02-08_12" "YYYY-MM-DD_HH"
run_date = "2015-01-23_12"
run_date = sprinti("%0.4i-", wrf_utc_date(0,0)) + \
sprinti("%0.2i-", wrf_utc_date(0,1)) + \
sprinti("%0.2i_", wrf_utc_date(0,2)) + \
sprinti("%0.2i", wrf_utc_date(0,3))
datestring = sprinti("%0.4i-", wrf_utc_date(0,0)) + \
sprinti("%0.2i-", wrf_utc_date(0,1)) + \
sprinti("%0.2i", wrf_utc_date(0,2))
hourstring = sprinti("%0.2i", wrf_utc_date(0,3))
; these match the time series file names
ncol = 19
do ss = 0, dimsizes(station_id)-1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
filename = station_id(ss) + domainstring +"TS"
data2 = asciiread(dir_for_wrf_output + filename, -1, "string" )
headerstring = data2(0)
;000000000011111111112222222222333333333344444444445555555555666666666677777777778888888888999999999911111111112
;012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
;Grootfontein 3 4 FYGF (-19.599, 18.116) ( 125, 126) (-19.600, 18.103) 1416.6 meters
station_name2 = str_get_cols(headerstring, 0,26)
station_name = str_left_strip(str_right_strip(station_name2(0)))
station_name!0 = "ncl_scalar"
station_name@long_name = "station name"
station_name@description = "station name"
station_name@cf_role = "timeseries_id"
latitude_wrf = stringtofloat(str_get_cols(headerstring, 70, 76))
longitude_wrf = stringtofloat(str_get_cols(headerstring, 78, 85))
latitude_wrf!0 = "ncl_scalar"
longitude_wrf!0 = "ncl_scalar"
latitude_wrf@long_name = "latitude"
latitude_wrf@description = "latitude"
latitude_wrf@standard_name = "latitude"
latitude_wrf@comment = "relative to wrf grid"
latitude_wrf@units = "degrees_north"
latitude_wrf@axis = "Y"
longitude_wrf@long_name = "longitude"
longitude_wrf@description = "longitude"
longitude_wrf@standard_name = "longitude"
latitude_wrf@comment = "relative to wrf grid"
longitude_wrf@units = "degrees_east"
longitude_wrf@axis = "X"
latitude_sta = stringtofloat(str_get_cols(headerstring, 39, 45))
longitude_sta = stringtofloat(str_get_cols(headerstring, 47, 54))
latitude_sta!0 = "ncl_scalar"
longitude_sta!0 = "ncl_scalar"
gettheparents = str_split(headerstring,")")
elev = stringtofloat(str_split(gettheparents(3)," meters"))
elev!0 = "ncl_scalar"
elev@description = "surface elevation"
elev@long_name = "surface elevation"
elev@standard_name = "height"
elev@comment = "relative to wrf grid"
elev@units = "m"
elev@positive = "up"
elev@axis = "Z"
data = readAsciiTable(dir_for_wrf_output + filename, ncol, "float", 1)
time = data(:,1)
time_min = round( time(0),0)
print(time_min)
time(:) = (/ time - time_min /)
time@long_name = "Time"
time@description = "Time"
time@standard_name = "time"
time@units = "hours since "+ datestring + " "+ hourstring + ":00:00"
time!0 = "time"
time&time = time
print("maxtime = "+max(time))
domain = data(0,0)
domain@long_name = "WRF Domain Nest"
domain@description = "WRF Domain Nest"
grid_x = data(0,3)
grid_x@long_name = "WRF X Coordinate"
grid_x@description = "WRF X Coordinate"
grid_y = data(0,4)
grid_y@long_name = "WRF Y Coordinate"
grid_y@description = "WRF Y Coordinate"
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
temperature = data(:,5)
temperature@long_name = "2-m Air Temperature"
temperature@description = "2-m Air Temperature"
temperature@standard_name = "air_temperature"
temperature@units = "K"
temperature@coordinates = "time lat lon alt" ;
q = data(:,6)
q@long_name = "2-m Vapor Mixing Ratio"
q@description = "2-m Vapor Mixing Ratio"
q@standard_name = "specific_humidity"
q@units = "kg kg-1"
q@coordinates = "time lat lon alt" ;
w = q / (1-q)
u = data(:,7)
u@long_name = "10-m Eastward Wind"
u@description = "10-m Eastward Wind"
u@standard_name = "eastward_wind"
u@units = "m s-1"
u@coordinates = "time lat lon alt" ;
v = data(:,8)
v@long_name = "10-m Northward Wind"
v@description = "10-m Northward Wind"
v@standard_name = "northward_wind"
v@units = "m s-1"
v@coordinates = "time lat lon alt" ;
psfc = data(:,9)
psfc@long_name = "Mean Sea Level Pressure"
psfc@description = "Mean Sea Level Pressure"
psfc@standard_name = "air_pressure_at_sea_level"
psfc@units = "Pa"
psfc@coordinates = "time lat lon alt" ;
rh=temperature
rh(:) = relhum(temperature, w, psfc)
rh@long_name = "2-m relative humidity"
rh@description = "2-m relative humidity"
rh@standard_name = "relative_humidity"
rh@units = "%"
rh@coordinates = "time lat lon alt" ;
rh = where(rh .lt. 0, 0, rh)
rh = where(rh .gt.100,100,rh)
rh!0 = "time"
printVarSummary(rh)
dewpoint=temperature
dewpoint(:) = dewtemp_trh(temperature, rh)
dewpoint@long_name = "2-m Dewpoint Temp"
dewpoint@description = "2-m Dewpoint Temp"
dewpoint@standard_name = "dew_point_temperature"
dewpoint@units = "K"
dewpoint!0 = "time"
dewpoint@coordinates = "time lat lon alt" ;
printVarSummary(dewpoint)
printVarSummary(temperature)
glw = data(:,10)
glw@long_name = "Surface Downward Longwave Radiation"
glw@description = "Surface Downward Longwave Radiation"
glw@standard_name = "surface_net_downward_longwave_flux"
glw@units = "W m-2"
glw@coordinates = "time lat lon alt" ;
gsw = data(:,11)
gsw@long_name = "Surface Downward Shortwave Radiation"
gsw@description = "Surface Downward Shortwave Radiation"
gsw@standard_name = "surface_net_downward_shortwave_flux"
gsw@units = "W m-2"
gsw@coordinates = "time lat lon alt" ;
hfx = data(:,12)
hfx@long_name = "Surface Sensible Heat Flux"
hfx@description = "Surface Sensible Heat Flux"
hfx@standard_name = "surface_upward_sensible_heat_flux"
hfx@units = "W m-2"
hfx@coordinates = "time lat lon alt" ;
lfx = data(:,13)
lfx@long_name = "Surface Latent Heat Flux"
lfx@description = "Surface Latent Heat Flux"
lfx@standard_name = "surface_upward_latent_heat_flux"
lfx@units = "W m-2"
lfx@coordinates = "time lat lon alt" ;
tskin = data(:,14)
tskin@long_name = "Surface Skin Temperature"
tskin@description = "Surface Skin Temperature"
tskin@standard_name = "surface_temperature"
tskin@units = "K"
tskin@coordinates = "time lat lon alt" ;
tsoil_top = data(:,15)
tsoil_top@long_name = "Topmost Soil Layer Temperature"
tsoil_top@description = "Topmost Soil Layer Temperature"
tsoil_top@standard_name = "soil_temperature"
tsoil_top@comment1 = "depth from surface to 10 cm below surface for NOAH land model"
tsoil_top@units = "K"
tsoil_top@coordinates = "time lat lon alt" ;
rainc = data(:,16)
rainc@long_name = "Cumulus Cumulative Precipitation"
rainc@description = "Cumulus Cumulative Precipitation"
rainc@standard_name = "convective_precipitation_amount"
rainc@units = "kg m-2"
rainc@coordinates = "time lat lon alt" ;
rainnc = data(:,17)
rainnc@long_name = "Grid-Scale Cumulative Precipitation"
rainnc@description = "Grid-Scale Cumulative Precipitation"
rainnc@standard_name = "stratiform_precipitation_amount"
rainnc@units = "kg m-2"
rainnc@coordinates = "time lat lon alt" ;
clw = data(:,18)
clw@long_name = "Columnar Water Vapor"
clw@description = "Columnar Water Vapor"
clw@standard_name = "atmosphere_mass_content_of_water_vapor"
clw@units = "kg m-2"
clw@coordinates = "time lat lon alt" ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(data)
filename = station_id(ss) + domainstring + "UU"
print(filename)
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time sigma lat lon" ;
u_profile = data(:,1:dimsizes(sigma))
u_profile!1 = "sigma"
u_profile&sigma = sigma
u_profile@long_name = "Eastward Wind Speed"
u_profile@description = "Eastward Wind Speed"
u_profile@standard_name = "eastward_wind"
u_profile@units = "m s-1"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(data)
filename = station_id(ss) + domainstring + "VV"
print(filename)
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time sigma lat lon" ;
v_profile = data(:,1:dimsizes(sigma))
v_profile!1 = "sigma"
v_profile&sigma = sigma
v_profile@long_name = "Northward Wind Speed"
v_profile@description = "Northward Wind Speed"
v_profile@standard_name = "northward_wind"
v_profile@units = "m s-1"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wind_speed_profile = v_profile
wind_speed_profile(:,:) = (/ v_profile*v_profile + u_profile*u_profile /)
wind_speed_profile@long_name = "Wind Speed"
wind_speed_profile@description = "Wind Speed"
wind_speed_profile@standard_name = "wind_speed"
wind_speed_profile@units = "m s-1"
wind_dir_profile = v_profile
wind_dir_profile(:,:) = (/ atan2(-u_profile, -v_profile) /)
wind_dir_profile@long_name = "Wind Direction"
wind_dir_profile@description = "Wind Direction"
wind_dir_profile@standard_name = "wind_from_direction"
wind_dir_profile@units = "degree"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(data)
filename = station_id(ss) + domainstring + "TH"
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@alt = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
potential_temperature_profile = data(:,1:dimsizes(sigma))
potential_temperature_profile!1 = "sigma"
potential_temperature_profile&sigma = sigma
potential_temperature_profile@long_name = "Potential Temperature"
potential_temperature_profile@description = "Potential Temperature"
potential_temperature_profile@standard_name = "air_potential_temperature"
potential_temperature_profile@units = "K"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(data)
filename = station_id(ss) + domainstring + "QV"
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time sigma lat lon" ;
specific_humidity_profile = data(:,1:dimsizes(sigma))
specific_humidity_profile!1 = "sigma"
specific_humidity_profile&sigma = sigma
specific_humidity_profile@long_name = "Specific Humidity"
specific_humidity_profile@description = "Specific Humidity"
specific_humidity_profile@standard_name = "specific_humidity"
specific_humidity_profile@units = "kg kg-1"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(data)
filename = station_id(ss) + domainstring + "PH"
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time sigma lat lon" ;
geopotential_height_profile = data(:,1:dimsizes(sigma))
geopotential_height_profile!1 = "sigma"
geopotential_height_profile&sigma = sigma
geopotential_height_profile@long_name = "Geopotential Height"
geopotential_height_profile@description = "Geopotential Height"
geopotential_height_profile@standard_name = "geopotential_height"
geopotential_height_profile@units = "m"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if (tke_on) then
delete(data)
filename = station_id(ss) + domainstring + "TE"
data = readAsciiTable(dir_for_wrf_output + filename, (1+nlevels), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time sigma lat lon" ;
turbulent_kinetic_energy_profile = data(:,1:dimsizes(sigma))
turbulent_kinetic_energy_profile!1 = "sigma"
turbulent_kinetic_energy_profile&sigma = sigma
turbulent_kinetic_energy_profile@long_name = "Turbulent Kinetic Energy"
turbulent_kinetic_energy_profile@description = "Turbulent Kinetic Energy"
turbulent_kinetic_energy_profile@standard_name = "specific_kinetic_energy_of_air_due_to_turbulence"
turbulent_kinetic_energy_profile@units = "m2 s-2"
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if (soils_on) then
delete(data)
filename = station_id(ss) + domainstring + "SM"
data = readAsciiTable(dir_for_wrf_output + filename, (1+dimsizes(soil_levels)), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time soil_levels lat lon" ;
soil_moisture_profile = data(:,1:dimsizes(soil_levels))
soil_moisture_profile!1 = "soil_levels"
soil_moisture_profile&soil_levels = soil_levels
soil_moisture_profile@long_name = "Soil Water Content"
soil_moisture_profile@description = "Soil Water Content"
soil_moisture_profile@standard_name = "liquid_water_content_of_soil_layer"
soil_moisture_profile@units = "kg m-2"
soil_levels_2d = conform(soil_moisture_profile,soil_levels,1)
soil_moisture_profile(:,:) = (/ soil_moisture_profile * soil_levels_2d /)
delete(data)
filename = station_id(ss) + domainstring + "ST"
data = readAsciiTable(dir_for_wrf_output + filename, (1+dimsizes(soil_levels)), "float", 1)
data!0 = "time"
data&time = time
data@lat = latitude_wrf
data@lon = longitude_wrf
data@lat_sta = latitude_sta
data@lon_sta = longitude_sta
data@elev = elev
data@domain = domain
data@grid_x = grid_x
data@grid_y = grid_y
data@coordinates = "time soil_levels lat lon" ;
soil_temperature_profile = data(:,1:dimsizes(soil_levels))
soil_temperature_profile!1 = "soil_levels"
soil_temperature_profile&soil_levels = soil_levels
soil_temperature_profile@long_name = "Soil Temperature"
soil_temperature_profile@description = "Soil Temperature"
soil_temperature_profile@standard_name = "soil_temperature"
soil_temperature_profile@units = "K"
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setfileoption("nc","Format","NetCDF4") ; these are going to be big files
setfileoption("nc","CompressionLevel",5)
wrf_file= "nam02_d" + sprinti("%0.2i", tointeger(domain)) + "_" + \
datestring + "_" + hourstring + "_" + station_id(ss) + ".nc"
system("rm -frv "+dir_for_wrf_output + wrf_file)
nc = addfile(dir_for_wrf_output + wrf_file, "c")
nc@station_id = station_id(ss)
nc@station_name = station_name
nc@featureType = "timeSeries"
nc@Conventions = "CF-1.6"
nc@lat = latitude_wrf
nc@lon = longitude_wrf
nc@lat_sta = latitude_sta
nc@lon_sta = longitude_sta
nc@elev = elev
nc@domain = domain
delete(time@_FillValue)
nc->time = time
nc->sigma = sigma
nc->soil_levels = soil_levels
nc->lat = latitude_wrf
nc->lon = longitude_wrf
nc->alt = elev
nc->station_name = station_name
nc->temperature = temperature
nc->rh = rh
nc->dewpoint = dewpoint
nc->q = q
nc->u = u
nc->v = v
nc->psfc = psfc
nc->glw = glw
nc->gsw = gsw
nc->hfx = hfx
nc->lfx = lfx
nc->tskin = tskin
nc->tsoil_top = tsoil_top
nc->rainc = rainc
nc->rainnc = rainnc
nc->clw = clw
nc->ptop = ptop
nc->u_wind_profile = u_profile
nc->v_wind_profile = v_profile
nc->wind_speed_profile = wind_speed_profile
nc->wind_direction_profile = wind_dir_profile
nc->potential_temperature_profile = potential_temperature_profile
nc->specific_humidity_profile = specific_humidity_profile
nc->geopotential_height_profile = geopotential_height_profile
if (tke_on) then
nc->turbulent_kinetic_energy_profile = turbulent_kinetic_energy_profile
end if
if (soils_on) then
nc->soil_temperature_profile = soil_temperature_profile
nc->soil_moisture_profile = soil_moisture_profile
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printVarSummary(time)
delete(data)
end do
end