-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_modis_hist_daily_monthly_means.pro
1184 lines (1106 loc) · 51.6 KB
/
plot_modis_hist_daily_monthly_means.pro
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
;***************************************
; This program reads in the month files of histograms and
; calculates monthly and daily means and sdev
; Makes the plot of the daily means
;***************************************
pro plot_modis_hist_daily_monthly_means
; imac or chpc
path_prefix='/Volumes/'
;path_prefix='/uufs/chpc.utah.edu/common/home/'
; increased box
ulat=-40 & llat=-70
llon=50 & rlon=170
; Choose aqua or terra
eos='MYD'
;eos='MOD'
;eos='MOYD' ;both
; Time range to analyze=List of months
julian_day_1m=timegen(start=julday(11,1,2014,0,0,0),final=julday(2,28,2019,23,59,59),units='months',step_size=1)
;julian_day_1m=timegen(start=julday(11,1,2016,0,0,0),final=julday(2,28,2019,23,59,59),units='months',step_size=1)
; SEASON Nov 2018-Feb 2019
; SEASON Nov 2017-Feb 2018
; SEASON Nov 2016-Feb 2017
; SEASON Nov 2015-Feb 2016
; SEASON Nov 2014-Feb 2015
; number and date strings of monthly time array
numtimes_1m=n_elements(julian_day_1m)
caldat,julian_day_1m,mm_1m,dd_1m,yy_1m,hh_1m,mi_1m,ss_1m
; String of the time range
time_range_str=string(yy_1m[0],format='(I4)')+string(mm_1m[0],format='(I02)')+'-'+$
string(yy_1m[-1],format='(I4)')+string(mm_1m[-1],format='(I02)')
; String of search box limits
box_str=string(llat,format='(I03)')+'_'+string(ulat,format='(I03)')+'lat.'+$
string(llon,format='(I03)')+'_'+string(rlon,format='(I03)')+'lon'
; Name of output file for the time range
output_file=eos+'.histograms_mean.'+time_range_str+'.'+box_str+'.tau.cmonth2.cdf'
print,output_file
; Arrays of variables to loop through
months=[11,12,1,2] ;composite plot for these months
num_months=n_elements(months)
month_name=['nov','dec','jan','feb']
region=['box','n60','s60','ln60','hn60','ls60','hs60']
var_mod=['julian_day','count_1km','count_5km','center_latitude','center_longitude',$
'mean_nd','mean_re','mean_lwp','mean_tau','mean_solar_zenith']
varname_mod=['nd','re','lwp','tau','solar_zenith']
varmin_mod=[ 2.0, 4.2, 1.0, 0.1, 0.0] ;bin center
varmax_mod=[300.0,30.0, 300.0,35.0, 90.0]
vardbin_mod=[1.0, 0.1, 1.5, 0.2, 0.5] ;1/2 bin width
var_cer=['mean_sw_up','mean_sw_toa','mean_sw_alb','mean_sw_nalb']
varname_cer=['sw_up','sw_toa','sw_alb','sw_nalb']
varmin_cer=[0.0, 500.0, 0.0, 0.0] ;bin center
varmax_cer=[900.0, 1500.0, 1.0, 1.0]
vardbin_cer=[5.0, 5.0, 0.005, 0.005] ;1/2 bin width
varname=[varname_mod,varname_cer]
var=[var_mod,var_cer]
; If the output file does not exist, then create it
;if file_test(output_file) eq 0 then begin
if file_test(output_file) eq 1 or file_test(output_file) eq 0 then begin
print,'making output file'
all_julian_day=!NULL
; Loop through the months
for i=0,numtimes_1m-1 do begin
; Get the monthly histogram file
if eos eq 'MOYD' then begin
file_str='*.histograms.'+string(yy_1m[i],format='(I4)')+string(mm_1m[i],format='(I02)')+'*cdf'
endif else begin
file_str=eos+'.histograms.'+string(yy_1m[i],format='(I4)')+string(mm_1m[i],format='(I02)')+'*cdf'
endelse
files=file_search(file_str,count=num_files)
if num_files gt 0 then print,num_files,files
; If there is a monthly histogram file
if num_files gt 0 then begin
; Loop through the monthly histogram files and put the data in one array
for j=0,num_files-1 do begin
print,files[j]
fid=ncdf_open(files[j])
for k=0,n_elements(var)-1 do begin
xstr='vid=ncdf_varid(fid,"'+var[k]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,'+var[k]+'1'
result=execute(xstr)
endfor
ncdf_close,fid
if j eq 0 then begin
print,j,'j ',i,'i ','new array'
for k=0,n_elements(var)-1 do begin
xstr=var[k]+'='+var[k]+'1'
result=execute(xstr)
endfor
endif else begin
print,j,'j ',i,'i ','append'
for k=0,n_elements(var)-1 do begin
xstr=var[k]+'=['+var[k]+','+var[k]+'1]'
result=execute(xstr)
endfor
endelse
endfor ;end of loop through monthly files
; Now calculate daily means
julian_day_1d=timegen(start=min(julian_day),final=max(julian_day),units='days',step_size=1)
caldat,julian_day_1d,mm_1d,dd_1d,yy_1d,hh_1d,mi_1d,ss_1d
num_1d=n_elements(julian_day_1d)
; Create arrays to hold daily means
print,'create arrays'
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname)-1 do begin
xstr='daily_mean_'+varname[v]+'_'+region[r]+'=make_array(num_1d,/float,value=-9999)'
result=execute(xstr)
xstr='daily_sdev_'+varname[v]+'_'+region[r]+'=make_array(num_1d,/float,value=-9999)'
result=execute(xstr)
endfor
xstr='daily_count_'+region[r]+'=make_array(num_1d,/float,value=-9999)'
result=execute(xstr)
xstr='daily_count_cer_'+region[r]+'=make_array(num_1d,/float,value=-9999)'
result=execute(xstr)
endfor
; Loop through the days to get the mean value for each day
;region=['box','n60','s60','ln60','hn60','ls60','hs60']
for k=0,num_1d-1 do begin
;*** MODIS Variables ***
r_1d=where(julian_day ge julday(mm_1d[k],dd_1d[k],yy_1d[k],0,0,0) and $
julian_day le julday(mm_1d[k],dd_1d[k],yy_1d[k],23,59,59) and $
center_latitude ge llat and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon,c_1d)
if c_1d gt 0 then begin
; Values for the day
sub_mean_nd=mean_nd[r_1d]
sub_mean_re=mean_re[r_1d]
sub_mean_lwp=mean_lwp[r_1d]
sub_mean_tau=mean_tau[r_1d]
sub_mean_solar_zenith=mean_solar_zenith[r_1d]
sub_center_lat=center_latitude[r_1d]
sub_center_lon=center_longitude[r_1d]
; box
r_box=where(sub_center_lat ge llat and sub_center_lat le ulat,c_box)
; north,south of -60S
r_n60=where(sub_center_lat gt -60 and sub_center_lat le ulat,c_n60) ;lo north of -60S
r_s60=where(sub_center_lat ge llat and sub_center_lat le -60,c_s60) ;hi north of -60S
; Hi,Lo north,south of -60S
r_ln60=where(sub_center_lat gt -60 and sub_center_lat le ulat and sub_mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(sub_center_lat gt -60 and sub_center_lat le ulat and sub_mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(sub_center_lat ge llat and sub_center_lat le -60 and sub_mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(sub_center_lat ge llat and sub_center_lat le -60 and sub_mean_nd ge 100,c_hs60) ;hi south of -60S
; Daily means
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname_mod)-1 do begin
xstr='daily_mean_'+varname_mod[v]+'_'+region[r]+'[k]=mean(sub_mean_'+varname_mod[v]+'[r_'+region[r]+'])'
result=execute(xstr)
xstr='daily_sdev_'+varname_mod[v]+'_'+region[r]+'[k]=stddev(sub_mean_'+varname_mod[v]+'[r_'+region[r]+'])'
result=execute(xstr)
endfor
xstr='daily_count_'+region[r]+'[k]=c_'+region[r]
result=execute(xstr)
endfor
endif ;end of modis variables
;*** CERES Variables ***
r_1d=where(julian_day ge julday(mm_1d[k],dd_1d[k],yy_1d[k],0,0,0) and $
julian_day le julday(mm_1d[k],dd_1d[k],yy_1d[k],23,59,59) and $
center_latitude ge llat and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_1d)
if c_1d gt 0 then begin
; Values for the day
sub_mean_sw_up=mean_sw_up[r_1d]
sub_mean_sw_toa=mean_sw_toa[r_1d]
sub_mean_sw_alb=mean_sw_alb[r_1d]
sub_mean_sw_nalb=mean_sw_nalb[r_1d]
sub_center_lat=center_latitude[r_1d]
sub_mean_nd=mean_nd[r_1d]
; box
r_box=where(sub_center_lat ge llat and sub_center_lat le ulat,c_box)
; north,south of -60S
r_n60=where(sub_center_lat gt -60 and sub_center_lat le ulat,c_n60) ;lo north of -60S
r_s60=where(sub_center_lat ge llat and sub_center_lat le -60,c_s60) ;hi north of -60S
; Hi,Lo north,south of -60S
r_ln60=where(sub_center_lat gt -60 and sub_center_lat le ulat and sub_mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(sub_center_lat gt -60 and sub_center_lat le ulat and sub_mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(sub_center_lat ge llat and sub_center_lat le -60 and sub_mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(sub_center_lat ge llat and sub_center_lat le -60 and sub_mean_nd ge 100,c_hs60) ;hi south of -60S
; Daily means
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname_cer)-1 do begin
xstr='daily_mean_'+varname_cer[v]+'_'+region[r]+'[k]=mean(sub_mean_'+varname_cer[v]+'[r_'+region[r]+'])'
result=execute(xstr)
xstr='daily_sdev_'+varname_cer[v]+'_'+region[r]+'[k]=stddev(sub_mean_'+varname_cer[v]+'[r_'+region[r]+'])'
result=execute(xstr)
endfor
xstr='daily_count_cer_'+region[r]+'[k]=c_'+region[r]
result=execute(xstr)
endfor
endif ;end of ceres variables
endfor ;end of loop through days
;***************
; Now calculate the monthly means
;*** MODIS Variables ***
r_box=where(center_latitude ge llat and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon,c_box)
; north,south of -60S
r_n60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon,c_n60) ;north of -60S
r_s60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon,c_s60) ;south of -60S
; Hi,Lo north,south of -60S
r_ln60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hs60) ;hi south of -60S
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname_mod)-1 do begin
xstr='month_mean_'+varname_mod[v]+'_'+region[r]+'=mean(mean_'+varname_mod[v]+'[r_'+region[r]+'])'
result=execute(xstr)
xstr='month_sdev_'+varname_mod[v]+'_'+region[r]+'=stddev(mean_'+varname_mod[v]+'[r_'+region[r]+'])'
result=execute(xstr)
endfor
xstr='month_count_'+region[r]+'=c_'+region[r]
result=execute(xstr)
xstr='sub_mean_nd=mean_nd[r_'+region[r]+']'
result=execute(xstr)
nd_median=median(sub_mean_nd)
xstr='month_nd_median_'+region[r]+'=nd_median'
result=execute(xstr)
xstr='month_nd_lo_median_'+region[r]+'=median(sub_mean_nd[where(sub_mean_nd le nd_median)])'
result=execute(xstr)
xstr='month_nd_hi_median_'+region[r]+'=median(sub_mean_nd[where(sub_mean_nd gt nd_median)])'
result=execute(xstr)
endfor
;*** CERES Variables ***
r_box=where(center_latitude ge llat and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_box)
; north,south of -60S
r_n60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_n60) ;north of -60S
r_s60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_s60) ;south of -60S
; Hi,Lo north,south of -60S
r_ln60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hs60) ;hi south of -60S
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname_cer)-1 do begin
xstr='month_mean_'+varname_cer[v]+'_'+region[r]+'=mean(mean_'+varname_cer[v]+'[r_'+region[r]+'])'
result=execute(xstr)
xstr='month_sdev_'+varname_cer[v]+'_'+region[r]+'=stddev(mean_'+varname_cer[v]+'[r_'+region[r]+'])'
result=execute(xstr)
endfor
xstr='month_count_cer_'+region[r]+'=c_'+region[r]
result=execute(xstr)
endfor
;******************************
; Save everything in one big array
if all_julian_day eq !NULL then begin
all_julian_day=julian_day_1m[i]
all_julian_day_1d=julian_day_1d
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname)-1 do begin
xstr='all_month_mean_'+varname[v]+'_'+region[r]+'=month_mean_'+varname[v]+'_'+region[r]
result=execute(xstr)
xstr='all_month_sdev_'+varname[v]+'_'+region[r]+'=month_sdev_'+varname[v]+'_'+region[r]
result=execute(xstr)
xstr='all_daily_mean_'+varname[v]+'_'+region[r]+'=daily_mean_'+varname[v]+'_'+region[r]
result=execute(xstr)
xstr='all_daily_sdev_'+varname[v]+'_'+region[r]+'=daily_sdev_'+varname[v]+'_'+region[r]
result=execute(xstr)
endfor
xstr='all_month_count_'+region[r]+'=month_count_'+region[r]
result=execute(xstr)
xstr='all_month_count_cer_'+region[r]+'=month_count_cer_'+region[r]
result=execute(xstr)
xstr='all_month_nd_median_'+region[r]+'=month_nd_median_'+region[r]
result=execute(xstr)
xstr='all_month_nd_lo_median_'+region[r]+'=month_nd_lo_median_'+region[r]
result=execute(xstr)
xstr='all_month_nd_hi_median_'+region[r]+'=month_nd_hi_median_'+region[r]
result=execute(xstr)
xstr='all_daily_count_'+region[r]+'=daily_count_'+region[r]
result=execute(xstr)
xstr='all_daily_count_cer_'+region[r]+'=daily_count_cer_'+region[r]
result=execute(xstr)
endfor
endif else begin
all_julian_day=[all_julian_day,julian_day_1m[i]]
all_julian_day_1d=[all_julian_day_1d,julian_day_1d]
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname)-1 do begin
xstr='all_month_mean_'+varname[v]+'_'+region[r]+'=[all_month_mean_'+varname[v]+'_'+region[r]+',month_mean_'+varname[v]+'_'+region[r]+']'
result=execute(xstr)
xstr='all_month_sdev_'+varname[v]+'_'+region[r]+'=[all_month_sdev_'+varname[v]+'_'+region[r]+',month_sdev_'+varname[v]+'_'+region[r]+']'
result=execute(xstr)
xstr='all_daily_mean_'+varname[v]+'_'+region[r]+'=[all_daily_mean_'+varname[v]+'_'+region[r]+',daily_mean_'+varname[v]+'_'+region[r]+']'
result=execute(xstr)
xstr='all_daily_sdev_'+varname[v]+'_'+region[r]+'=[all_daily_sdev_'+varname[v]+'_'+region[r]+',daily_sdev_'+varname[v]+'_'+region[r]+']'
result=execute(xstr)
endfor
xstr='all_month_count_'+region[r]+'=[all_month_count_'+region[r]+',month_count_'+region[r]+']'
result=execute(xstr)
xstr='all_month_count_cer_'+region[r]+'=[all_month_count_cer_'+region[r]+',month_count_cer_'+region[r]+']'
result=execute(xstr)
xstr='all_month_nd_median_'+region[r]+'=[all_month_nd_median_'+region[r]+',month_nd_median_'+region[r]+']'
result=execute(xstr)
xstr='all_month_nd_lo_median_'+region[r]+'=[all_month_nd_lo_median_'+region[r]+',month_nd_lo_median_'+region[r]+']'
result=execute(xstr)
xstr='all_month_nd_hi_median_'+region[r]+'=[all_month_nd_hi_median_'+region[r]+',month_nd_hi_median_'+region[r]+']'
result=execute(xstr)
xstr='all_daily_count_'+region[r]+'=[all_daily_count_'+region[r]+',daily_count_'+region[r]+']'
result=execute(xstr)
xstr='all_daily_count_cer_'+region[r]+'=[all_daily_count_cer_'+region[r]+',daily_count_cer_'+region[r]+']'
result=execute(xstr)
endfor
endelse
endif ;if there are histogram files
endfor ;loop through list of dates
;*****************************
; Create a composite seasonal plot
;*****************************
; ; Arrays of variables to loop through
; months=[11,12,1,2] ;composite plot for these months
; num_months=n_elements(months)
; varname=['nd','re','lwp','tau']
; varmin=[2.0,4.2,1.0,0.1] ;bin center
; varmax=[300.0,30.0,300.0,35.0]
; vardbin=[1.0,0.1,1.5,0.2] ;1/2 bin width
; region=['box','n60','s60','ln60','hn60','ls60','hs60']
; var=['julian_day','count_1km','count_5km','center_latitude','center_longitude',$
; 'mean_nd','mean_re','mean_lwp','mean_tau']
; Create arrays to hold composite monthly means
print,'create arrays'
for r=0,n_elements(region)-1 do begin
for v=0,n_elements(varname)-1 do begin
xstr='cmonth_mean_'+varname[v]+'_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
xstr='cmonth_sdev_'+varname[v]+'_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
endfor
xstr='cmonth_count_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
xstr='cmonth_count_cer'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
xstr='cmonth_nd_median_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
xstr='cmonth_nd_lo_median_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
xstr='cmonth_nd_hi_median_'+region[r]+'=make_array(num_months,/float,value=-9999)'
result=execute(xstr)
endfor
; Loop through the months
for i=0,num_months-1 do begin
month=months[i]
month_str=string(month,format='(I02)')
; Get the monthly histogram file names
if eos eq 'MOYD' then begin
file_str='*.histograms.*'+month_str+'01-*'+'*cdf'
endif else begin
file_str=eos+'.histograms.*'+month_str+'01-*'+'*cdf'
endelse
files=file_search(file_str,count=num_files)
if num_files gt 0 then print,num_files,files
if num_files gt 0 then begin
; Loop through the monthly histogram files and put the data in one array
for j=0,num_files-1 do begin
print,files[j]
fid=ncdf_open(files[j])
for k=0,n_elements(var)-1 do begin
xstr='vid=ncdf_varid(fid,"'+var[k]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,'+var[k]+'1'
result=execute(xstr)
endfor
ncdf_close,fid
if j eq 0 then begin
for k=0,n_elements(var)-1 do begin
xstr=var[k]+'='+var[k]+'1'
result=execute(xstr)
endfor
endif else begin
for k=0,n_elements(var)-1 do begin
xstr=var[k]+'=['+var[k]+','+var[k]+'1]'
result=execute(xstr)
endfor
endelse
endfor ;end of loop through files
;*** MODIS VALUES ***
; Now calculate the monthly means
r_box=where(center_latitude ge llat and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon,c_box)
; north,south of -60S
r_n60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon,c_n60) ;north of -60S
r_s60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon,c_s60) ;south of -60S
; Hi,Lo north,south of -60S
r_ln60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(center_latitude gt -60 and center_latitude le ulat and $
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(center_latitude ge llat and center_latitude le -60 and $
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hs60) ;hi south of -60S
for r=0,n_elements(region)-1 do begin
;cmonth_mean_nd=mean(mean_nd[ridx])
;cmonth_sdev_nd=stddev(mean_nd[ridx])
;cmonth_nd_median=nd_median
;cmonth_nd_lo_median=median(sub_mean_nd[where(sub_mean_nd le nd_median)])
;cmonth_nd_hi_median=median(sub_mean_nd[where(sub_mean_nd gt nd_median)])
for k=0,n_elements(varname_mod)-1 do begin
xstr='cmonth_mean_'+varname_mod[k]+'_'+region[r]+'[i]=mean(mean_'+varname_mod[k]+'[r_'+region[r]+'])'
result=execute(xstr)
xstr='cmonth_sdev_'+varname_mod[k]+'_'+region[r]+'[i]=stddev(mean_'+varname_mod[k]+'[r_'+region[r]+'])'
result=execute(xstr)
; Make a histogram
xstr='data_var=mean_'+varname_mod[k]+'[r_'+region[r]+']'
result=execute(xstr)
start_bin=varmin_mod[k]
end_bin=varmax_mod[k]
dbin=vardbin_mod[k]
hist_generic,data_var,start_bin,end_bin,dbin,bins,data_freq,data_counts
;xstr='cmonth_bins_'+month_name[i]+'_'+varname[k]+'_'+region[r]+'=bins'
xstr='cmonth_bins_'+varname_mod[k]+'=bins'
;print,xstr
result=execute(xstr)
xstr='cmonth_count_'+month_name[i]+'_'+varname_mod[k]+'_'+region[r]+'=data_counts'
;print,xstr
result=execute(xstr)
endfor ;end of loop through variables
xstr='sub_mean_nd=mean_nd[r_'+region[r]+']'
result=execute(xstr)
nd_median=median(sub_mean_nd)
xstr='cmonth_nd_median_'+region[r]+'[i]=nd_median'
result=execute(xstr)
xstr='cmonth_nd_lo_median_'+region[r]+'[i]=median(sub_mean_nd[where(sub_mean_nd le nd_median)])'
result=execute(xstr)
xstr='cmonth_nd_hi_median_'+region[r]+'[i]=median(sub_mean_nd[where(sub_mean_nd gt nd_median)])'
result=execute(xstr)
xstr='cmonth_count_'+region[r]+'[i]=c_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
;*** CERES Variables
; Now calculate the monthly means
r_box=where(center_latitude ge llat and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_box)
; north,south of -60S
r_n60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_n60) ;north of -60S
r_s60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon,c_s60) ;south of -60S
; Hi,Lo north,south of -60S
r_ln60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ln60) ;lo north of -60S
r_hn60=where(center_latitude gt -60 and center_latitude le ulat and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hn60) ;hi north of -60S
r_ls60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd le 50,c_ls60) ;lo south of -60S
r_hs60=where(center_latitude ge llat and center_latitude le -60 and $
mean_sw_toa ne -9999 and $ ;don't average in these values
center_longitude ge llon and center_longitude le rlon and mean_nd ge 100,c_hs60) ;hi south of -60S
for r=0,n_elements(region)-1 do begin
;cmonth_mean_nd=mean(mean_nd[ridx])
;cmonth_sdev_nd=stddev(mean_nd[ridx])
;cmonth_nd_median=nd_median
;cmonth_nd_lo_median=median(sub_mean_nd[where(sub_mean_nd le nd_median)])
;cmonth_nd_hi_median=median(sub_mean_nd[where(sub_mean_nd gt nd_median)])
for k=0,n_elements(varname_cer)-1 do begin
xstr='cmonth_mean_'+varname_cer[k]+'_'+region[r]+'[i]=mean(mean_'+varname_cer[k]+'[r_'+region[r]+'])'
;print,xstr
result=execute(xstr)
xstr='cmonth_sdev_'+varname_cer[k]+'_'+region[r]+'[i]=stddev(mean_'+varname_cer[k]+'[r_'+region[r]+'])'
;print,xstr
result=execute(xstr)
; Make a histogram
xstr='data_var=mean_'+varname_cer[k]+'[r_'+region[r]+']'
;print,xstr
result=execute(xstr)
print, min(data_var),max(data_var),' ',varname_cer[k],' month',month,' region ',region[r]
start_bin=varmin_cer[k]
end_bin=varmax_cer[k]
;dbin=(end_bin-start_bin)/300.0
dbin=vardbin_cer[k]
hist_generic,data_var,start_bin,end_bin,dbin,bins,data_freq,data_counts
;xstr='cmonth_bins_'+month_name[i]+'_'+varname[k]+'_'+region[r]+'=bins'
xstr='cmonth_bins_'+varname_cer[k]+'=bins'
;print,xstr
result=execute(xstr)
xstr='cmonth_count_'+month_name[i]+'_'+varname_cer[k]+'_'+region[r]+'=data_counts'
;print,xstr
result=execute(xstr)
endfor ;end of loop through variables
xstr='sub_mean_nd=mean_nd[r_'+region[r]+']'
result=execute(xstr)
nd_median=median(sub_mean_nd)
xstr='cmonth_nd_median_'+region[r]+'[i]=nd_median'
;print,xstr
result=execute(xstr)
xstr='cmonth_nd_lo_median_'+region[r]+'[i]=median(sub_mean_nd[where(sub_mean_nd le nd_median)])'
;print,xstr
result=execute(xstr)
xstr='cmonth_nd_hi_median_'+region[r]+'[i]=median(sub_mean_nd[where(sub_mean_nd gt nd_median)])'
;print,xstr
result=execute(xstr)
xstr='cmonth_count_cer_'+region[r]+'[i]=c_'+region[r]
;print,xstr
result=execute(xstr)
endfor ;end of loop through region
endif ;end of found month histogram files
endfor ;end of loop through months
;*****************************
; write the data into a file
;*****************************
do_write='yes'
if do_write eq 'yes' then begin
num=n_elements(all_julian_day)
num_1d=n_elements(all_julian_day_1d)
fid=ncdf_create(output_file,/clobber)
num_1m_did=ncdf_dimdef(fid,'num_1m',num)
num_1d_did=ncdf_dimdef(fid,'num_1d',num_1d)
num_cmonth_did=ncdf_dimdef(fid,'num_cmonth',num_months)
julian_day_1m_id=ncdf_vardef(fid,'julian_day_monthly',num_1m_did,/double)
julian_day_1d_id=ncdf_vardef(fid,'julian_day_daily',num_1d_did,/double)
; Create monthly variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='monthly_mean_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"monthly_mean_'+$
varname[k]+'_'+region[r]+'",num_1m_did)'
result=execute(xstr)
xstr='monthly_sdev_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"monthly_sdev_'+$
varname[k]+'_'+region[r]+'",num_1m_did)'
result=execute(xstr)
endfor ;end of loop through variables
xstr='monthly_nd_median_'+region[r]+'_id=ncdf_vardef(fid,"monthly_nd_median_'+region[r]+'",num_1m_did)'
result=execute(xstr)
xstr='monthly_nd_lo_median_'+region[r]+'_id=ncdf_vardef(fid,"monthly_nd_lo_median_'+region[r]+'",num_1m_did)'
result=execute(xstr)
xstr='monthly_nd_hi_median_'+region[r]+'_id=ncdf_vardef(fid,"monthly_nd_hi_median_'+region[r]+'",num_1m_did)'
result=execute(xstr)
xstr='monthly_count_'+region[r]+'_id=ncdf_vardef(fid,"monthly_count_'+region[r]+'",num_1m_did)'
result=execute(xstr)
xstr='monthly_count_cer_'+region[r]+'_id=ncdf_vardef(fid,"monthly_count_cer_'+region[r]+'",num_1m_did)'
result=execute(xstr)
endfor ;end of loop through region
; Create daily variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='daily_mean_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"daily_mean_'+$
varname[k]+'_'+region[r]+'",num_1d_did)'
result=execute(xstr)
xstr='daily_sdev_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"daily_sdev_'+$
varname[k]+'_'+region[r]+'",num_1d_did)'
result=execute(xstr)
endfor ;end of loop through variables
xstr='daily_count_'+region[r]+'_id=ncdf_vardef(fid,"daily_count_'+region[r]+'",num_1d_did)'
result=execute(xstr)
xstr='daily_count_cer_'+region[r]+'_id=ncdf_vardef(fid,"daily_count_cer_'+region[r]+'",num_1d_did)'
result=execute(xstr)
endfor ;end of loop through region
; Create composite month variables
; Create dimensions and bins for histograms
for k=0,n_elements(varname)-1 do begin
xstr='num_bins_'+varname[k]+'_did=ncdf_dimdef(fid,"num_bins_'+varname[k]+'",'+$
'n_elements(cmonth_bins_'+varname[k]+'))'
result=execute(xstr)
xstr='cmonth_bins_'+varname[k]+'_id=ncdf_vardef(fid,"cmonth_bins_'+$
varname[k]+'",num_bins_'+varname[k]+'_did)'
result=execute(xstr)
endfor
; Create variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='cmonth_mean_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_mean_'+$
varname[k]+'_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
xstr='cmonth_sdev_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_sdev_'+$
varname[k]+'_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
for m=0,num_months-1 do begin
xstr='cmonth_count_'+month_name[m]+'_'+varname[k]+'_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_count_'+$
month_name[m]+'_'+varname[k]+'_'+region[r]+'",num_bins_'+varname[k]+'_did)'
result=execute(xstr)
endfor ;end of loop through months
endfor ;end of loop through variables
xstr='cmonth_nd_median_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_nd_median_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
xstr='cmonth_nd_lo_median_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_nd_lo_median_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
xstr='cmonth_nd_hi_median_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_nd_hi_median_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
xstr='cmonth_count_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_count_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
xstr='cmonth_count_cer_'+region[r]+'_id=ncdf_vardef(fid,"cmonth_count_cer_'+region[r]+'",num_cmonth_did)'
result=execute(xstr)
endfor ;end of loop through region
ncdf_control,fid,/endef
ncdf_varput,fid,julian_day_1m_id,all_julian_day
ncdf_varput,fid,julian_day_1d_id,all_julian_day_1d
; Write monthly variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='ncdf_varput,fid,monthly_mean_'+varname[k]+'_'+region[r]+'_id,all_month_mean_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,monthly_sdev_'+varname[k]+'_'+region[r]+'_id,all_month_sdev_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
endfor ;end of loop through variables
xstr='ncdf_varput,fid,monthly_nd_median_'+region[r]+'_id,all_month_nd_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,monthly_nd_lo_median_'+region[r]+'_id,all_month_nd_lo_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,monthly_nd_hi_median_'+region[r]+'_id,all_month_nd_hi_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,monthly_count_'+region[r]+'_id,all_month_count_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,monthly_count_cer_'+region[r]+'_id,all_month_count_cer_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
; Write daily variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='ncdf_varput,fid,daily_mean_'+varname[k]+'_'+region[r]+'_id,all_daily_mean_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,daily_sdev_'+varname[k]+'_'+region[r]+'_id,all_daily_sdev_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
endfor ;end of loop through variables
xstr='ncdf_varput,fid,daily_count_'+region[r]+'_id,all_daily_count_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,daily_count_cer_'+region[r]+'_id,all_daily_count_cer_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
; Write composite month variables
for k=0,n_elements(varname)-1 do begin
xstr='ncdf_varput,fid,cmonth_bins_'+varname[k]+'_id,cmonth_bins_'+varname[k]
result=execute(xstr)
endfor
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='ncdf_varput,fid,cmonth_mean_'+varname[k]+'_'+region[r]+'_id,cmonth_mean_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,cmonth_sdev_'+varname[k]+'_'+region[r]+'_id,cmonth_sdev_'+$
varname[k]+'_'+region[r]
result=execute(xstr)
for m=0,num_months-1 do begin
xstr='ncdf_varput,fid,cmonth_count_'+month_name[m]+'_'+varname[k]+'_'+region[r]+'_id,cmonth_count_'+$
month_name[m]+'_'+varname[k]+'_'+region[r]
result=execute(xstr)
endfor ;end of loop through months
endfor ;end of loop through variables
xstr='ncdf_varput,fid,cmonth_nd_median_'+region[r]+'_id,cmonth_nd_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,cmonth_nd_lo_median_'+region[r]+'_id,cmonth_nd_lo_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,cmonth_nd_hi_median_'+region[r]+'_id,cmonth_nd_hi_median_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,cmonth_count_'+region[r]+'_id,cmonth_count_'+region[r]
result=execute(xstr)
xstr='ncdf_varput,fid,cmonth_count_cer_'+region[r]+'_id,cmonth_count_cer_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
ncdf_close,fid
endif ;end of do_write eq 'yes'
endif else begin ;need to make the output file
;*************************************
; Read previously created output file
print,'found output file'
fid=ncdf_open(output_file)
vid=ncdf_varid(fid,'julian_day_monthly') & ncdf_varget,fid,vid,all_julian_day
vid=ncdf_varid(fid,'julian_day_daily') & ncdf_varget,fid,vid,all_julian_day_1d
; Monthly variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='vid=ncdf_varid(fid,"monthly_mean_'+varname[k]+'_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_mean_'+varname[k]+'_'+region[r]
result=execute(xstr)
xstr='vid=ncdf_varid(fid,"monthly_sdev_'+varname[k]+'_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_sdev_'+varname[k]+'_'+region[r]
result=execute(xstr)
endfor ;end of loop through variables
xstr='vid=ncdf_varid(fid,"monthly_nd_median_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_nd_median_'+region[r]
result=execute(xstr)
xstr='vid=ncdf_varid(fid,"monthly_nd_lo_median_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_nd_lo_median_'+region[r]
result=execute(xstr)
xstr='vid=ncdf_varid(fid,"monthly_nd_hi_median_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_nd_hi_median_'+region[r]
result=execute(xstr)
xstr='vid=ncdf_varid(fid,"monthly_count_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,monthly_count_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
; Create daily variables
for r=0,n_elements(region)-1 do begin
for k=0,n_elements(varname)-1 do begin
xstr='vid=ncdf_varid(fid,"daily_mean_'+varname[k]+'_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,all_daily_mean_'+varname[k]+'_'+region[r]
result=execute(xstr)
xstr='vid=ncdf_varid(fid,"daily_sdev_'+varname[k]+'_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,all_daily_sdev_'+varname[k]+'_'+region[r]
result=execute(xstr)
endfor ;end of loop through variables
xstr='vid=ncdf_varid(fid,"daily_count_'+region[r]+'")'
result=execute(xstr)
xstr='ncdf_varget,fid,vid,all_daily_count_'+region[r]
result=execute(xstr)
endfor ;end of loop through region
ncdf_close,fid
endelse
;********************************************
; Daily means plot
;********************************************
; Creating monthly tick marks for the daily data
numtimes=n_elements(all_julian_day_1d)
caldat,all_julian_day_1d,mm,dd,yy,hh,mi,ss
mname=strarr(numtimes)
r=where(mm eq 11,c)
mname[r]='Nov'
r=where(mm eq 12,c)
mname[r]='Dec'
r=where(mm eq 1,c)
mname[r]='Jan'
r=where(mm eq 2,c)
mname[r]='Feb'
;xticknames=mname+' '+string(yy,format='(I4)')
idx=make_array(25,/int,value=-1)
idx_year=make_array(25,/string)
idx_month=make_array(25,/string)
for i=0,n_elements(all_julian_day)-1 do begin
r=where(all_julian_day_1d ge all_julian_day[i],c)
idx[i]=r[0]
idx_year[i]=string(yy[r[0]],format='(I4)')
idx_month[i]=mname[r[0]]
endfor
idx=idx[0:i-1]
idx_year=idx_year[0:i-1]
idx_month=idx_month[0:i-1]
xticknames=idx_month+' '+idx_year
blanks=make_array(n_elements(xticknames),/string)
;*****************
; Colortable
;******************
; Top is the last color to scale 256 colors, 0-255
top_color=252
; Colortable 0-252 253=white
;mytable=colortable(39,ncolors=254)
mytable=colortable(33,ncolors=253)
;254=hot pink ;gray=255
mytable=[mytable,transpose([255,255,255]),transpose([238,18,137]),transpose([230,230,230])]
mycbtable=mytable[0:top_color,*]
;*************************
; Daily time series
;*************************
pxdim=900 & pydim=900
xl=0.09 & xr=0.95
yb=0.10 & yt=0.95
sx=0.08
sy=0.01
numplots_x=1
numplots_y=9
position_plots,xl,xr,yb,yt,sx,sy,numplots_x,numplots_y,pos
; Colorbar position
cbpos=pos
cbpos[*,0]=pos[*,2]-0.02
cbpos[*,2]=cbpos[*,0]+0.009
dx=0.01 & dy=0.01
pnum=0
p0=plot([0,1],[0,1],position=pos[pnum,*],/buffer,dimensions=[pxdim,pydim],axis_style=4,/nodata)
d=p0.convertcoord([pos[pnum,0],pos[pnum,2]],[pos[pnum,1],pos[pnum,3]],/normal,/to_device)
isx=(d[0,1,0]-d[0,0,0])
isy=(d[1,1,0]-d[1,0,0])
; Date format for plotting
dummy=label_date(date_format=['%M/%D!C%Y'])
fs1=10 ;font_size
pnum=0
r=where(all_daily_count_box ne -9999,c)
dmin=min(all_daily_count_box[r])
dmax=max(all_daily_count_box[r])
xarray=findgen(numtimes)
p0=plot(xarray,all_daily_count_box,/current,position=pos[pnum,*],$
/xstyle,ytitle='# boxes!Cper day',font_size=fs1,yrange=[dmin,dmax],$
;xtickformat='label_date',xtickunits='Months',xtickinterval=1,$
xtickname=xticknames,xtext_orientation=90,xtickvalues=idx,$
sym_size=0.3,symbol='o',/sym_filled)
r=where(mm eq 11,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_count_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='red',linestyle=6)
endif
r=where(mm eq 12,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_count_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='green',linestyle=6)
endif
r=where(mm eq 1,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_count_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='blue',linestyle=6)
endif
r=where(mm eq 2,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_count_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='purple',linestyle=6)
endif
pnum=1
r=where(all_daily_mean_nd_box ne -9999,c)
dmin=min(all_daily_mean_nd_box[r])
dmax=max(all_daily_mean_nd_box[r])
xarray=findgen(numtimes)
p0=plot(xarray,all_daily_mean_nd_box,/current,position=pos[pnum,*],$
/xstyle,ytitle='Nd',font_size=fs1,yrange=[dmin,dmax],$
;xtickformat='label_date',xtickunits='Months',xtickinterval=1,$
xtickname=blanks,xtext_orientation=90,xtickvalues=idx,$
sym_size=0.3,symbol='o',/sym_filled)
r=where(mm eq 11,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_nd_box[r],$
;p1=errorplot(xarray[r],all_daily_mean_nd[r],all_daily_sdev_nd[r],$
/overplot,sym_size=0.3,symbol='o',/sym_filled,color='red',linestyle=6)
endif
r=where(mm eq 12,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_nd_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='green',linestyle=6)
endif
r=where(mm eq 1,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_nd_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='blue',linestyle=6)
endif
r=where(mm eq 2,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_nd_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='purple',linestyle=6)
endif
pnum=2
r=where(all_daily_mean_re_box ne -9999,c)
dmin=min(all_daily_mean_re_box[r])
dmax=max(all_daily_mean_re_box[r])
xarray=findgen(numtimes)
p0=plot(xarray,all_daily_mean_re_box,/current,position=pos[pnum,*],$
/xstyle,ytitle='Re',font_size=fs1,yrange=[dmin,dmax],$
;xtickformat='label_date',xtickunits='Months',xtickinterval=1,$
xtickname=blanks,xtext_orientation=90,xtickvalues=idx,$
sym_size=0.3,symbol='o',/sym_filled)
r=where(mm eq 11,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_re_box[r],$
;p1=errorplot(xarray[r],all_daily_mean_nd[r],all_daily_sdev_nd[r],$
/overplot,sym_size=0.3,symbol='o',/sym_filled,color='red',linestyle=6)
endif
r=where(mm eq 12,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_re_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='green',linestyle=6)
endif
r=where(mm eq 1,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_re_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='blue',linestyle=6)
endif
r=where(mm eq 2,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_re_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='purple',linestyle=6)
endif
pnum=3
r=where(all_daily_mean_lwp_box ne -9999,c)
dmin=min(all_daily_mean_lwp_box[r])
dmax=max(all_daily_mean_lwp_box[r])
xarray=findgen(numtimes)
p0=plot(xarray,all_daily_mean_lwp_box,/current,position=pos[pnum,*],$
/xstyle,ytitle='LWP',font_size=fs1,yrange=[dmin,dmax],$
;xtickformat='label_date',xtickunits='Months',xtickinterval=1,$
xtickname=blanks,xtext_orientation=90,xtickvalues=idx,$
sym_size=0.3,symbol='o',/sym_filled)
r=where(mm eq 11,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_lwp_box[r],$
;p1=errorplot(xarray[r],all_daily_mean_nd[r],all_daily_sdev_nd[r],$
/overplot,sym_size=0.3,symbol='o',/sym_filled,color='red',linestyle=6)
endif
r=where(mm eq 12,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_lwp_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='green',linestyle=6)
endif
r=where(mm eq 1,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_lwp_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='blue',linestyle=6)
endif
r=where(mm eq 2,c)
if c gt 0 then begin
p1=plot(xarray[r],all_daily_mean_lwp_box[r],/overplot,sym_size=0.3,symbol='o',$
/sym_filled,color='purple',linestyle=6)
endif
pnum=4
r=where(all_daily_mean_tau_box ne -9999,c)
dmin=min(all_daily_mean_tau_box[r])
dmax=max(all_daily_mean_tau_box[r])
xarray=findgen(numtimes)
p0=plot(xarray,all_daily_mean_tau_box,/current,position=pos[pnum,*],$
/xstyle,ytitle='TAU',font_size=fs1,yrange=[dmin,dmax],$
;xtickformat='label_date',xtickunits='Months',xtickinterval=1,$
xtickname=blanks,xtext_orientation=90,xtickvalues=idx,$