/
ORACLES_Explore_cld_retrieval.py
1508 lines (898 loc) · 39.6 KB
/
ORACLES_Explore_cld_retrieval.py
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
# coding: utf-8
# # Intro
# Name:
#
# Explore_cld_retrieval
#
# Purpose:
#
# Run throught the retrieved cloud properties and either flag or assure retrieval quality
#
# Input:
#
# none at command line
#
# Output:
#
# figures and save files...
#
# Keywords:
#
# none
#
# Dependencies:
#
# - Sp_parameters.py : for Sp class definition, and for defining the functions used to build parameters
# - matplotlib
# - mpltools
# - numpy
# - scipy : for saving and reading
# - plotting_utils (user defined plotting routines)
# - hdf5storage
#
# Needed Files:
#
# - file.rc : for consistent creation of look of matplotlib figures
# - 4STAR_cloud retrieval .mat files
#
# Modification History:
#
# Written: by Samuel LeBlanc, NASA Ames, Moffett Field, CA, 2016-10-26
# # Import of modules
# In[2]:
get_ipython().magic(u'config InlineBackend.rc = {}')
import matplotlib
#matplotlib.rc_file('C:\\Users\\sleblan2\\Research\\python_codes\\file.rc')
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from mpltools import color
get_ipython().magic(u'matplotlib notebook')
import numpy as np
import scipy.io as sio
import hdf5storage as hs
import Sp_parameters as Sp
# In[3]:
from path_utils import getpath
# In[5]:
fo = getpath('ORACLES')
# In[8]:
fp = fo+'starzen/'
fp_plot = fo+'plot/'
# In[9]:
fp, fp_plot
# In[2]:
# set the basic directory path
fp = 'C:/Users/sleblan2/Research/ORACLES/starzen/'
fp_plot = 'C:/Users/sleblan2/Research/ORACLES/plot/'
# In[10]:
vr = 'R1'
# # Load the files
# In[4]:
dds = ['20160827','20160830','20160831','20160902','20160904','20160906','20160908',
'20160910','20160912','20160914','20160918','20160920','20160924','20160925','20160927']
# In[5]:
rts = []
sps = []
# In[6]:
for daystr in dds:
print daystr
rt = hs.loadmat(fp+'{}_zen_cld_retrieved.mat'.format(daystr))
s = sio.loadmat(fp+'4STAR_{}starzen.mat'.format(daystr))
sp = Sp.Sp(s)
rts.append(rt)
sps.append(sp)
# ## Load the cloud probe incloud flag
# In[7]:
from load_utils import mat2py_time,toutc
# In[8]:
p = sio.netcdf_file(fp+'..//data_other//oracles.cloud.timings.nc','r')
# In[9]:
p.variables
# In[10]:
p.variables['timevec_20160914'].data
# In[11]:
t_0914 = mat2py_time(p.variables['timevec_20160914'].data)
# In[28]:
plt.figure()
plt.plot(t_0914,p.variables['cloud_time_20160914'].data,'x')
# # Start plotting the results
# In[11]:
rt.keys()
# In[13]:
plt.figure()
plt.plot(rt['utc'],rt['tau'])
# In[14]:
rt = rts[9]
# In[15]:
plt.figure()
plt.plot(rts[9]['utc'],rts[9]['tau'],'.')
plt.plot(rts[9]['utc'],rts[9]['utc'],'r+')
# In[16]:
plt.figure()
plt.plot(rts[9]['tau'],rts[9]['ref'],'.')
# In[12]:
igood = rts[9]['tau']>0
# In[13]:
igood[0:10]
# In[14]:
sp = sps[9]
# In[15]:
i=68
i_vis = [1061,1062,1064]
i_nir = [1060,1063]
plt.figure()
plt.plot(sp.wvl,sp.norm[i,:])
#plt.xlim(970,1030)
plt.plot(sp.wvl[i_vis],sp.norm[i,i_vis],'rx')
plt.plot(sp.wvl[i_nir],sp.norm[i,i_nir],'g+')
# In[16]:
np.nanmean(sp.norm[i,iw])
# In[17]:
np.nanmean(sp.norm[i,ii])
# ## Plot some of the sza for each day to ensure good fitting of lut
# In[70]:
plt.figure()
plt.plot(sps[7].utc,sps[7].sza,'x-')
# # Now setup filters to weed out bad data
# ## Filter out data points where nir and vis spectrometers don't match
# In[12]:
i_vis = [1061,1062,1064]
i_nir = [1060,1063]
# In[13]:
for i,daystr in enumerate(dds):
nvis = np.nanmean(sps[i].norm[:,i_vis],axis=1)
nnir = np.nanmean(sps[i].norm[:,i_nir],axis=1)
rts[i]['delta'] = abs(nvis-nnir)
rts[i]['fl_match'] = rts[i]['delta']<0.06
print daystr,rts[i]['delta'].shape,rts[i]['delta'][rts[i]['fl_match']].shape, float(rts[i]['delta'][rts[i]['fl_match']].shape[0])/ float(rts[i]['delta'].shape[0])*100.0
# ## Now filter out the times which were at too high altitude
# In[14]:
fl_alt = rt['alt']<1000.0
# In[15]:
for i,daystr in enumerate(dds):
rts[i]['fl_alt'] = rts[i]['alt'][:,0]<1000.0
print daystr,rts[i]['utc'].shape,rts[i]['utc'][rts[i]['fl_alt']].shape, float(rts[i]['utc'][rts[i]['fl_alt']].shape[0])/ float(rts[i]['utc'].shape[0])*100.0
# ## Filter for in cloud
# In[16]:
from write_utils import nearest_neighbor
# In[17]:
for i,daystr in enumerate(dds):
try:
p_time = mat2py_time(p.variables['timevec_{}'.format(daystr)].data)
except KeyError: # no in cloud data, so choose all of them
rts[i]['fl_incld'] = rts[i]['utc']>0.0
continue
putc = toutc(p_time)
rts[i]['incld'] = nearest_neighbor(putc,p.variables['cloud_time_{}'.format(daystr)].data,rts[i]['utc'],dist=1.0/3600)
rts[i]['fl_incld'] = rts[i]['incld']==0
print daystr,rts[i]['utc'].shape,rts[i]['utc'][rts[i]['fl_incld']].shape, float(rts[i]['utc'][rts[i]['fl_incld']].shape[0])/ float(rts[i]['utc'].shape[0])*100.0
# ## Filter for high ki squared residuas
# In[18]:
for i,daystr in enumerate(dds):
rts[i]['fl_ki'] = rts[i]['ki']<0.6
print daystr,rts[i]['utc'].shape,rts[i]['utc'][rts[i]['fl_ki']].shape, float(rts[i]['utc'][rts[i]['fl_ki']].shape[0])/ float(rts[i]['utc'].shape[0])*100.0
# ## Combine the filters
# In[19]:
tot=0
tot_fl=0
for i,daystr in enumerate(dds):
rts[i]['fl'] = rts[i]['fl_match'] & rts[i]['fl_alt'] & rts[i]['fl_incld'] & rts[i]['fl_ki']
print daystr,rts[i]['utc'].shape,rts[i]['utc'][rts[i]['fl']].shape, float(rts[i]['utc'][rts[i]['fl']].shape[0])/ float(rts[i]['utc'].shape[0])*100.0
tot = tot+len(rts[i]['utc'])
tot_fl = tot_fl+len(rts[i]['utc'][rts[i]['fl']])
# In[20]:
print tot, tot_fl, float(tot_fl)/float(tot)*100.0
# # Now plot each retrieved product, filtered
# In[21]:
from Sp_parameters import smooth
# In[98]:
for i,daystr in enumerate(dds):
plt.figure()
ax1 = plt.subplot(211)
ax2 = plt.subplot(212,sharex=ax1)
ax1.plot(rts[i]['utc'],rts[i]['tau'],'b.')
ax1.plot(rts[i]['utc'][rts[i]['fl']],rts[i]['tau'][rts[i]['fl']],'g+')
try:
ax1.plot(rts[i]['utc'][rts[i]['fl']],smooth(rts[i]['tau'][rts[i]['fl']],6),'kx')
except:
pass
ax1.set_ylabel('tau')
ax2.plot(rts[i]['utc'],rts[i]['ref'],'b.')
ax2.plot(rts[i]['utc'][rts[i]['fl']],rts[i]['ref'][rts[i]['fl']],'g+')
try:
ax2.plot(rts[i]['utc'][rts[i]['fl']],smooth(rts[i]['ref'][rts[i]['fl']],6),'kx')
except:
pass
ax2.set_ylabel('ref')
ax2.set_xlabel('UTC')
ax1.set_title(daystr)
# In[22]:
for i,daystr in enumerate(dds):
try:
rts[i]['tau_fl'] = smooth(rts[i]['tau'][rts[i]['fl']],6)
rts[i]['ref_fl'] = smooth(rts[i]['ref'][rts[i]['fl']],6)
except:
print 'except',i
rts[i]['tau_fl'] = rts[i]['tau'][rts[i]['fl']]
rts[i]['ref_fl'] = rts[i]['ref'][rts[i]['fl']]
rts[i]['lat_fl'] = rts[i]['lat'][rts[i]['fl']]
rts[i]['lon_fl'] = rts[i]['lon'][rts[i]['fl']]
rts[i]['alt_fl'] = rts[i]['alt'][rts[i]['fl']]
rts[i]['utc_fl'] = rts[i]['utc'][rts[i]['fl']]
# In[23]:
rt.keys()
# # Now write these values to ict file
# In[24]:
import write_utils as wu
# In[46]:
hdict = {'PI':'Jens Redemann',
'Institution':'NASA Ames Research Center',
'Instrument':'Spectrometers for Sky-Scanning, Sun-Tracking Atmospheric Research (4STAR)',
'campaign':'ORACLES 2016',
'special_comments':'Retrieved cloud properties',
'PI_contact':'Jens.Redemann-1@nasa.gov',
'platform':'NASA P3',
'location':'based out of Walvis Bay, Namibia, actual location of measurement included in file',
'instrument_info':'Derived product from 4STAR zenith measurements',
'data_info':'Using the cloud property retrieval method based on spectral transmitted light measurements described by LeBlanc, Pileskie, Schmidt, and Coddington (2015), AMT, modified to include impact of overlying aerosol layer.',
'uncertainty':'Uncertainty of retrieved properties will be defined in future archival.',
'DM_contact':'Samuel LeBlanc, samuel.leblanc@nasa.gov',
'project_info':'ORACLES 2016 deployment; August-September 2016; Walvis Bay, Namibia',
'stipulations':'This is the initial public release of the ORACLES-2016 data set. We strongly recommend that you consult the PI, both for updates to the data set, and for the proper and most recent interpretation of the data for specific science use.',
'rev_comments':"""R1: Archival for first public release of retrieved cloud properties. Future releases is expected to contain uncertainty estimates.
Same filtering and notes on data quality as previous release. Retrieved cloud properties includes the assumption of the presence of an overlying aerosol layer having AOD=0.36, SSA=0.87, and ASY=0.64 at 500 nm.
R0: Preliminary archival of cloud properties retrieved from 4STAR sky radiance measurements. Final radiance calibration not yet applied. Filtered out in-cloud data, bad measurements, and high clouds.
Data is subject to uncertainties linked to detector stability, transfer efficiency of light through fiber optic cable, and deposition on the instrument window."""
}
order = ['LAT','LON','COD','REF']
# In[47]:
for i,daystr in enumerate(dds):
d_dict = {'Start_UTC':{'data':rts[i]['utc'][rts[i]['fl']]*3600.0,'unit':'seconds from midnight UTC','long_description':'time keeping'},
'utc':{'data':rts[i]['utc'][rts[i]['fl']],'unit':'seconds from midnight UTC','long_description':'time keeping'},
'COD':{'data':rts[i]['tau_fl'],'unit':'None','long_description':'Cloud Optical Depth of overlying cloud'},
'REF':{'data':rts[i]['ref_fl'],'unit':'micrometer','long_description':'Cloud drop effective radius for liquid clouds'},
'LAT':{'data':rts[i]['lat'][rts[i]['fl']],'unit':'Degrees','long_description':'Latitude of measurement, negative for Southern hemisphere'},
'LON':{'data':rts[i]['lon'][rts[i]['fl']],'unit':'Degrees','long_description':'Longitude of measurement, East is positive, from -180 to 180'}
}
d_dict_out = wu.prep_data_for_ict(d_dict,in_var_name='utc',out_var_name='Start_UTC', in_input=True,time_interval=1.0)
wu.write_ict(hdict,d_dict_out,filepath=fp+'..//zen_ict/v3/',
data_id='4STAR_CLD',loc_id='P3',date=daystr,rev='R1',order=order)
# ## For use of this python, save values to mat files
# In[48]:
rtss = {str(i):rr for i,rr in enumerate(rts)}
# In[49]:
def dict_keys_to_unicode(d):
out = dict()
for k, v in d.items():
out[k.decode()] = v
return out
for n in rtss.keys():
if type(rtss[n]) is list:
print n
for i,t in enumerate(rtss[n]):
rtss[n][i] = dict_keys_to_unicode(t)
else:
print 'no',n
rtss[n] = dict_keys_to_unicode(rtss[n])
# In[50]:
hs.savemat(fp+'..//zen_ict/v3/{}_all_retrieved.mat'.format(vr),rtss)
# ## Optionally load the saved mat files
# In[23]:
rtss = hs.loadmat(fp+'..//zen_ict/v3/{}_all_retrieved.mat'.format(vr))
# In[34]:
if not 'rts' in locals():
rts = []
for n in sorted([int(u) for u in rtss.keys()]):
rts.append(rtss[str(n)])
elif not rts:
for n in sorted([int(u) for u in rtss.keys()]):
rts.append(rtss[str(n)])
# # Make plots
# ## Read the files as a verification
# In[51]:
vv = 'R1'
# In[52]:
from load_utils import load_ict
# In[53]:
out_RA = []
out_head_RA = []
for d in dds:
fname_aod = fp+'..//zen_ict/v3/4STAR-CLD_P3_{}_{vr}.ict'.format(d,vr=vr)
tt,th = load_ict(fname_aod,return_header=True)
out_RA.append(tt)
out_head_RA.append(th)
# In[54]:
out_head_RA[0]
# In[55]:
nm = out_RA[0].dtype.names
# In[56]:
nm
# In[87]:
for i,d in enumerate(dds):
fig,ax = plt.subplots(2,sharex=True,figsize=(9,5))
ax = ax.ravel()
ax[0].set_title('Cloud variables {} saved file for flight {}'.format(vv,d),y=1.25)
#ax[0].set_color_cycle([plt.cm.gist_ncar(k) for k in np.linspace(0, 1, len(wl))])
ax[0].plot(out_RA[i][nm[0]],out_RA[i]['COD'],'.')
ax[0].set_ylabel('COD')
ax[0].set_ylim(0,60)
ax[0].axhline(0,color='k')
ax[0].grid()
axy0 = ax[0].twiny()
axy0.set_xlim(ax[0].get_xlim())
xt = ax[0].get_xticks()
xl = []
for x in xt:
ii = np.argmin(abs(out_RA[i][nm[0]]-x))
if np.isfinite(out_RA[i]['LAT'][ii]):
xl.append('{:2.2f}'.format(out_RA[i]['LAT'][ii]))
else:
ia = np.isfinite(out_RA[i]['LAT'][ii-1200:ii+1200])
if any(ia):
laa = np.interp([1200],np.arange(2400)[ia],out_RA[i]['LAT'][ii-1200:ii+1200][ia])
if not np.isfinite(laa[0]):
xl.append(' ')
else:
xl.append('{:2.2f}'.format(laa[0]))
else: xl.append(' ')
axy0.set_xticks(xt)
axy0.set_xticklabels(xl)
axy0.set_xlabel('Latitude [$^\\circ$]')
box = ax[0].get_position()
ax[0].set_position([box.x0, box.y0, box.width, box.height*0.88])
axy0.set_position([box.x0, box.y0, box.width, box.height*0.88])
ax[1].plot(out_RA[i][nm[0]],out_RA[i]['REF'],'g.')
ax[1].set_ylabel('r$_{{eff}}$ [$\\mu$m]')
ax[1].set_xlabel('UTC [h]')
ax[1].grid()
axy1 = ax[1].twiny()
axy1.set_xlim(ax[1].get_xlim())
x1t = ax[1].get_xticks()
x1l = []
for x in x1t:
ii = np.argmin(abs(out_RA[i][nm[0]]-x))
if np.isfinite(out_RA[i]['LON'][ii]):
x1l.append('{:2.2f}'.format(out_RA[i]['LON'][ii]))
else:
iio = np.isfinite(out_RA[i]['LON'][ii-1200:ii+1200])
if any(iio):
loo = np.interp([1200],np.arange(2400)[iio],out_RA[i]['LON'][ii-1200:ii+1200][iio])
if not np.isfinite(loo[0]):
x1l.append(' ')
else:
x1l.append('{:2.2f}'.format(loo[0]))
else: x1l.append(' ')
axy1.set_xticks(x1t)
axy1.set_xticklabels(x1l)
axy1.set_xlabel('Longitude [$^\\circ$]')
box = ax[1].get_position()
ax[1].set_position([box.x0, box.y0, box.width, box.height*0.88])
axy1.set_position([box.x0, box.y0, box.width, box.height*0.88])
plt.savefig(fp+'..//zen_ict/v3/{vv}_{}.png'.format(d,vv=vv),dpi=600,transparent=True)
# ## Combine the data into a single array
# In[88]:
ar = {}
for n in rts[0].keys():
ar[n] = np.array([])
# In[89]:
ar['days'] = np.array([])
# In[90]:
for i,d in enumerate(dds):
ar['days'] = np.append(ar['days'],np.zeros_like(rts[i]['utc'])+i)
for n in rts[0].keys():
ar[n] = np.append(ar[n],rts[i][n])
# ## Save the combined array
# In[91]:
import hdf5storage as hs
# In[92]:
hs.savemat(fp+'..//zen_ict/v3/{}_all_cld_ict.mat'.format(vr),ar)
# ## Optionally load the all ict file
# In[7]:
if not 'ar' in locals():
ar = hs.loadmat(fp+'..//zen_ict/v3/{}_all_cld_ict.mat'.format(vr))
# ## plot the data on a map
# In[93]:
import plotting_utils as pu
# In[94]:
from map_interactive import build_basemap
# In[95]:
rts[i]['tau_fl']
# In[96]:
for i,daystr in enumerate(dds):
print rts[i]['lat'][rts[i]['fl']][:,0].shape,rts[i]['lon'][rts[i]['fl']][:,0].shape,rts[i]['tau_fl'].shape
# In[97]:
fig = plt.figure()
ax = plt.subplot(111)
m = build_basemap(lower_left=[-2,-25],upper_right=[15,-8],ax=ax,larger=False)
sa = []
for i,daystr in enumerate(dds):
x,y = m(rts[i]['lon'][rts[i]['fl']][:,0]+i*0.03,rts[i]['lat'][rts[i]['fl']][:,0])
sca = ax.scatter(x,y,c=rts[i]['tau_fl'],
s=10,alpha=0.7,vmin=0.0,vmax=60.0,edgecolor='None')
sa.append(sca)
#pu.prelim()
cb = plt.colorbar(sa[0])
cb.set_label('COD')
plt.savefig(fp+'..//zen_ict/v3/{}_COD_map.png'.format(vr),transparent=True,dpi=600)
# In[98]:
fig = plt.figure()
ax = plt.subplot(111)
m = build_basemap(lower_left=[-2,-25],upper_right=[15,-8],ax=ax,larger=False)
sa = []
for i,daystr in enumerate(dds):
x,y = m(rts[i]['lon'][rts[i]['fl']][:,0]+i*0.03,rts[i]['lat'][rts[i]['fl']][:,0])
sca = ax.scatter(x,y,c=rts[i]['ref_fl'],
s=10,alpha=0.7,vmin=0.0,vmax=30.0,edgecolor='None',cmap=plt.cm.gist_earth)
sa.append(sca)
#pu.prelim()
cb = plt.colorbar(sa[0])
cb.set_label('r$_{{eff}}$ [$\\mu$m]')
plt.savefig(fp+'..//zen_ict/v3/{}_REF_map.png'.format(vr),transparent=True,dpi=600)
# ## Plot out some statistics of all retrievals
# In[99]:
plt.figure()
plt.plot(ar['lat_fl'],ar['tau_fl'],'.',color='grey',alpha=0.1)
plt.hist2d(ar['lat_fl'],ar['tau_fl'],bins=40,normed=True)
plt.xlabel('Latitude [$^\\circ$]')
plt.ylabel('COD')
cb = plt.colorbar()
cb.set_label('Normalized counts')
plt.title('4STAR Cloud optical depth for all ORACLES flights')
plt.savefig(fp+'..//zen_ict/v3/{}_COD_hist_lat.png'.format(vr),transparent=True,dpi=600)
# In[8]:
plt.figure()
plt.plot(ar['lon_fl'],ar['tau_fl'],'.',color='grey',alpha=0.1)
plt.hist2d(ar['lon_fl'],ar['tau_fl'],bins=40,normed=True)
plt.xlabel('Longitude [$^\\circ$]')
plt.ylabel('COD')
cb = plt.colorbar()
cb.set_label('Normalized counts')
plt.title('4STAR Cloud optical depth for all ORACLES flights')
plt.savefig(fp+'..//zen_ict/v3/COD_hist_lon.png',transparent=True,dpi=600)
# In[57]:
plt.figure()
plt.plot(ar['lon_fl'],ar['ref_fl'],'.',color='grey',alpha=0.1)
plt.hist2d(ar['lon_fl'],ar['ref_fl'],bins=40,normed=True,cmap=plt.cm.gist_earth)
plt.xlabel('Longitude [$^\\circ$]')
plt.ylabel('r$_{{eff}}$ [$\\mu$m]')
plt.ylim(2,10)
cb = plt.colorbar()
cb.set_label('Normalized counts')
plt.title('4STAR Effective Radius for all ORACLES flights')
plt.savefig(fp+'..//zen_ict/v3/ref_hist_lon.png',transparent=True,dpi=600)
# In[58]:
plt.figure()
plt.plot(ar['lat_fl'],ar['ref_fl'],'.',color='grey',alpha=0.1)
plt.hist2d(ar['lat_fl'],ar['ref_fl'],bins=40,normed=True,cmap=plt.cm.gist_earth)
plt.ylim(2,10)
plt.xlabel('Latitude [$^\\circ$]')
plt.ylabel('r$_{{eff}}$ [$\\mu$m]')
cb = plt.colorbar()
cb.set_label('Normalized counts')
plt.title('4STAR Effective Radius for all ORACLES flights')
plt.savefig(fp+'..//zen_ict/v3/ref_hist_lat.png',transparent=True,dpi=600)
# In[9]:
fig = plt.figure()
plt.hist(ar['tau_fl'],bins=30,edgecolor='None',color='g',alpha=0.7,normed=True,label='filtered')
plt.hist(ar['tau'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=True,range=(0,70),label='All points')
plt.ylabel('Normed counts')
plt.xlabel('COD')
plt.grid()
pu.prelim()
plt.legend(frameon=False)
plt.savefig(fp+'..//zen_ict/v3/cod_hist.png',transparent=True,dpi=600)
# In[10]:
ar.keys()
# In[11]:
aam = ar['utc_fl']<12.0
apm = ar['utc_fl']>12.0
# In[12]:
fig = plt.figure()
plt.hist(ar['tau_fl'],bins=30,edgecolor='None',color='g',alpha=0.3,normed=True,label='filtered')
plt.hist(ar['tau'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=True,range=(0,70),label='All points')
plt.hist(ar['tau_fl'][aam],bins=30,edgecolor='None',color='b',alpha=0.7,normed=True,label='AM')
plt.hist(ar['tau_fl'][apm],bins=30,edgecolor='None',color='r',alpha=0.7,normed=True,label='PM')
plt.ylabel('Normed counts')
plt.xlabel('COD')
plt.grid()
pu.prelim()
plt.legend(frameon=False)
plt.savefig(fp+'..//zen_ict/v3/cod_hist_pm_am.png',transparent=True,dpi=600)
# In[94]:
fig = plt.figure()
plt.hist(ar['tau_fl'],bins=30,edgecolor='None',color='g',alpha=0.7,normed=False,label='filtered')
plt.hist(ar['tau'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=False,range=(0,70),label='All points')
plt.ylabel('Counts')
plt.xlabel('COD')
plt.legend(frameon=False)
plt.savefig(fp+'..//zen_ict/v3/cod_hist_all.png',transparent=True,dpi=600)
# In[103]:
np.nanmean(ar['tau_fl'])
# In[104]:
np.nanmean(ar['ref_fl'])
# In[102]:
fig = plt.figure()
plt.hist(ar['ref_fl'],bins=30,edgecolor='None',color='grey',alpha=0.7,normed=True,label='filtered')
plt.hist(ar['ref'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=True,range=(0,30),label='all points')
plt.ylabel('Normed counts')
plt.xlabel('r$_{{eff}}$ [$\\mu$m]')
plt.grid()
#pu.prelim()
plt.legend(frameon=False)
plt.savefig(fp+'..//zen_ict/v3/{}_ref_hist.png'.format(vr),transparent=True,dpi=600)
# In[101]:
fig = plt.figure()
plt.hist(ar['ref_fl'],bins=30,edgecolor='None',color='grey',alpha=0.7,normed=False,label='filtered')
plt.hist(ar['ref'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=False,range=(0,30),label='all points')
plt.ylabel('Counts')
plt.xlabel('r$_{{eff}}$ [$\\mu$m]')
plt.legend(frameon=False)
plt.savefig(fp+'..//zen_ict/v3/{}_ref_hist_all.png'.format(vr),transparent=True,dpi=600)
# In[132]:
reload(pu)
# In[100]:
fig,ax = plt.subplots(2,1)
ax = ax.ravel()
ax[0].hist(ar['tau_fl'],bins=30,edgecolor='None',color='g',alpha=0.7,normed=True,label='filtered')
ax[0].hist(ar['tau'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=True,range=(0,70),label='all points')
ax[0].set_ylabel('Normed counts')
ax[0].set_xlabel('COD')
ax[0].grid()
#pu.prelim(ax=ax[0])
ax[0].legend(frameon=False)
ax[1].hist(ar['ref_fl'],bins=30,edgecolor='None',color='grey',alpha=0.7,normed=True,label='filtered')
ax[1].hist(ar['ref'],bins=30,edgecolor='None',color='b',alpha=0.1,normed=True,range=(0,30),label='all points')
ax[1].set_ylabel('Normed counts')
ax[1].set_xlabel('r$_{{eff}}$ [$\\mu$m]')
plt.grid()
#pu.prelim(ax=ax[1])
plt.legend(frameon=False)
plt.tight_layout()
plt.savefig(fp+'..//zen_ict/v3/{}_ref_cod_hist.png'.format(vr),transparent=True,dpi=600)
# # Evaluate the Cloud Radiative Effect (CRE) from calculated retrieved values
# Based on the calculations of CRE found in Link to [ORACLES_cld_CRE](ORACLES_cld_CRE.ipynb)
#
# After running calculations on Pleaides, results are read in and operated
# ## Load results
# In[11]:
fp
# In[12]:
c = hs.loadmat(fp+'../rtm/ORACLES_CRE_{}.mat'.format('v2'))
# In[13]:
c.keys()
# In[14]:
c['star_aero_C']
# In[16]:
c['star_aero_CRE'].keys()
# In[21]:
CRE_aero = c['star_aero_CRE']['up'][:,2] -c['star_aero_CRE_clear']['up'][:,2]
CRE_noaero = c['star_noaero_CRE']['up'][:,2] -c['star_noaero_CRE_clear']['up'][:,2]
# ## Start plotting results of CRE
# In[15]:
import plotting_utils as pu
# In[47]:
plt.figure()
plt.hist(c['star_aero_C'][:,0],alpha=0.5,label='With Aerosol',edgecolor='None',normed=True,orientation='horizontal')
plt.hist(c['star_noaero_C'][:,0],alpha=0.5,label='No Aerosol',edgecolor='None',normed=True,orientation='horizontal')
plt.axhline(np.nanmean(c['star_aero_C'][:,0]))
plt.axhline(np.nanmedian(c['star_aero_C'][:,0]),linestyle='--')
plt.axhline(np.nanmean(c['star_noaero_C'][:,0]),color='g')
plt.axhline(np.nanmedian(c['star_noaero_C'][:,0]),color='g',linestyle='--')
plt.xlim(0,0.0035)
plt.legend(frameon=False,loc=1)
plt.ylabel('CRE [W/m$^2$]')
plt.title('SUR CRE')
plt.xlabel('Normalized counts')
plt.savefig(fp_plot+'ORACLES_SUR_CRE_4STAR.png',transparent=True,dpi=600)
# In[48]:
plt.figure()
plt.hist(CRE_aero,alpha=0.5,label='With Aerosol',edgecolor='None',normed=True,orientation='horizontal')
plt.hist(CRE_noaero,alpha=0.5,label='No Aerosol',edgecolor='None',normed=True,orientation='horizontal')
plt.axhline(np.nanmean(CRE_aero),label='Mean')
plt.axhline(np.nanmedian(CRE_aero),linestyle='--',label='Median')
plt.axhline(np.nanmean(CRE_noaero),color='g')
plt.axhline(np.nanmedian(CRE_noaero),color='g',linestyle='--')
plt.xlim(0,0.0035)
plt.legend(frameon=False,loc=4)