Exemple #1
0
def show_met(display_defaults, rs, usetimes, figs):

    if display_defaults.enabled('sfcmet_rain_rate'):
        if hasattr(rs,'rain_intensity_mean_wx1')\
              and hasattr(rs,'rain_intensity_mean_wx2'):
            print 'rendering rain rate from wx files'
            gt.plot_vs_time(
                'sfcmet_rain_rate',
                'rain gauge',
                rs.times,
                [rs.rain_intensity_mean_wx1, rs.rain_intensity_mean_wx2],
                ['g', 'b'],
                [2, 2],
                ['wx1', 'wx2'],
                'upper left',
                'Rain intensity',
                'mm/hr',
                'Rain rate vs time',
                False  #FIXME
                ,
                display_defaults,
                figs)
        else:
            print 'no rain intensity plot----rs.rain_intensity_wx1 or wx2 not found'
    if display_defaults.enabled('sfcmet_rain_accumulated'):
        if hasattr(rs,'rain_accumulated_wx1')\
            and hasattr(rs,'rain_accumulated_wx2'):
            print 'rendering accumulated rain from wx files'
            gt.plot_vs_time(
                'sfcmet_rain_accumulated',
                'rain gauge',
                rs.times,
                [rs.rain_accumulated_wx1, rs.rain_accumulated_wx2],
                ['g', 'b'],
                [2, 2],
                ['wx1', 'wx2'],
                'upper left',
                'Rain Accumulated',
                'mm',
                'Rain Accumulated',
                False  #FIXME
                ,
                display_defaults,
                figs)
        else:
            print 'no accumulated rain plot--rs.rain_accumulated_wx1 or wx2 missing'
    return
Exemple #2
0
def show_rain(instrument, display_defaults, rs, usetimes, usealts, figs):
    if hasattr(rs, 'precip_rate'):
        gt.plot_vs_time(
            'rainguage_precip_rate',
            instrument,
            usetimes,
            [rs.precip_rate],
            ['b'],
            [2],
            [],
            '',
            'raingauge precip rate (mm/hr)',
            [],
            'raingauge precip rate vs time',
            False  #FIXME
            ,
            display_defaults,
            figs)
        print 'rendering rainguage precip rate'
Exemple #3
0
def show_raman(instrument,display_defaults,rs,usetimes,usealts,figs,consts=None,qc_mask=None):
    """
        show_raman(instrument,display_defaults,rs,usetimes,usealts,figs)
        Display variables produced by raman_inversion
    """
    
            #toplevel
    if usealts is None and hasattr(rs,'altitudes'):
                usealts=rs.altitudes
    if usetimes is None and hasattr(rs,'times'):
                usetimes=rs.times
     
    plot_alt_index = rs.plot_alt_index if hasattr(rs,'plot_alt_index') else 0
    plot_altitude = usealts[plot_alt_index]
    layer_indices = rs.layer_indices if hasattr(rs,'layer_indices') else np.arange(len(usealts))
    
         
    if display_defaults.enabled('rl_backscatter_image') and (hasattr(rs,'beta_a_backscat') or hasattr(rs,'beta') or hasattr(rs,'particulate_backscatter_be')):

                title_str = instrument+' backscatter cross section '
                print 'rendering ',title_str
                try:
                    gt.rti_fig('rl_backscatter_image'
                    , instrument
                    , rs.beta_a_backscat if hasattr(rs,'beta_a_backscat') else (rs.beta if hasattr(rs,'beta') else rs.particulate_backscatter_be)
                    , usetimes
                    , usealts
                    , title_str
                    , '1/(m sr)'
                    , None                 
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data for raman backscatter plot"
            
    if display_defaults.enabled('rl_extinction_image') and (hasattr(rs,'extinction_aerosol') or hasattr(rs,'extinction_n2') or hasattr(rs,'extinction_be')):

                title_str = instrument+' Extinction '
                print 'rendering ',title_str     
                try:
                    gt.rti_fig('rl_extinction_image'
                    , instrument
                    , rs.extinction_aerosol if hasattr(rs,'extinction_aerosol') else (rs.extinction_n2 if hasattr(rs,'extinction_n2') else rs.extinction_be)
                    , usetimes
                    , usealts
                    , title_str
                    , '1/m'
                    , None                             
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data for raman extinction plot"

    
    if display_defaults.enabled('rl_h2o_to_n2_count_ratio_image') and hasattr(rs,'water_counts'):

                title_str = instrument+' h20_to_n2_counts_ratio '
                print 'rendering ',title_str
                try:
                    gt.rti_fig('rl_h2o_to_n2_count_ratio_image'
                    , instrument
                    , rs.water_counts / rs.nitrogen_counts
                    , usetimes
                    , usealts
                    , title_str
                    , ' '
                    , None
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data for raman h20_to_n2_count_ratio  plot"  
   

    if display_defaults.enabled('rl_depol_image') and (hasattr(rs,'linear_depol') or hasattr(rs,'depolarization_ratio')):

                title_str = instrument+' Linear Depolarization '
                print 'rendering ',title_str     
                try:
                    gt.rti_fig('rl_depol_image'
                    , instrument
                    , rs.linear_depol if hasattr(rs,'linear_depol') else rs.depolarization_ratio
                    , usetimes
                    , usealts
                    , title_str
                    , '%'
                    , None                             
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data for linear depolarization plot"
            
    if display_defaults.enabled('rl_aerosol_scattering_ratio_image') and (hasattr(rs,'aerosol_backscatter_ratio') or hasattr(rs,'scattering_ratio_e_n2')):

                if hasattr(rs,'aerosol_backscatter_ratio'):
                    title_str = instrument+' Aerosol Scattering Ratio '
                else:
                    title_str = instrument+' Scattering Ratio '
                print 'rendering ',title_str     
                try:
                    gt.rti_fig('rl_aerosol_scattering_ratio_image'
                    , instrument
                    , rs.aerosol_backscatter_ratio if hasattr(rs,'aerosol_backscatter_ratio') else rs.scattering_ratio_e_n2
                    , usetimes
                    , usealts
                    , title_str
                    , '%'
                    , None                             
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data aerosol scattering ratio plot"
    
    if display_defaults.enabled('rl_raw_scattering_ratio_image') and hasattr(rs,'raw_scattering_ratio'):

                title_str = instrument+' Raw Scattering Ratio '
                print 'rendering ',title_str     
                try:
                    gt.rti_fig('rl_raw_scattering_ratio_image'
                    , instrument
                    , rs.raw_scattering_ratio
                    , usetimes
                    , usealts
                    , title_str
                    , '%'
                    , None                             
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data aerosol scattering ratio plot"

    if display_defaults.enabled('rl_od_vs_time') and hasattr(rs,'optical_depth_aerosol'):
        """
        alt_res = shared_dz
        alt1=float(display_defaults.get_value('od_vs_time','altitude1'))
        alt2=float(display_defaults.get_value('od_vs_time','altitude2'))
       
        alt1_index = int(alt1* 1000.0 / alt_res)
        alt2_index = int(alt2* 1000.0 / alt_res)
        nalts = rs.rs_inv.optical_depth_aerosol.shape[1]
        if alt1_index >= nalts:
            alt1_index = nalts - 1
        if alt2_index >= nalts:
            alt2_index = nalts - 1
        """    
        lines = []
        legend = []
        if display_defaults.get_value('rl_od_vs_time','use_plot_layer_alts'):
            alt1_index = layer_indices[0]
            alt2_index = layer_indices[-1]
        else:
             alt_res = rs.altitudes[1]-rs.altitudes[0]
             alt1=float(display_defaults.get_value('rl_od_vs_time','altitude1'))
             alt2=float(display_defaults.get_value('rl_od_vs_time','altitude2'))
       
             alt1_index = int(alt1* 1000.0 / alt_res)
             alt2_index = int(alt2* 1000.0 / alt_res)
             nalts = rs.optical_depth_aerosol.shape[1]
             if alt1_index >= nalts:
                alt1_index = nalts - 1
             if alt2_index >= nalts:
                alt2_index = nalts - 1
            
        if display_defaults.get_value('rl_od_vs_time','show_od_1_and_2'):
            if display_defaults.get_value('rl_od_vs_time','show_od_1_and_2')==1:
                lines.append(rs.optical_depth_aerosol[:, alt1_index])
                legend.append('Z= %4.2f' %(rs.altitudes[alt1_index]))
            else: 
                lines.append(rs.rs_inv.optical_depth_aerosol[:, alt2_index])
                legend.append('Z= %4.2f' %(rs.altitudes[alt2_index])) 
        if display_defaults.get_value('rl_od_vs_time','show_od_difference'):
            od = rs.optical_depth_aerosol[:, alt2_index]\
                          - rs.optical_depth_aerosol[:, alt1_index]
            if qc_mask is not None:
              od[qc_mask[:,alt1_index]==0] =np.NaN
            lines.append(od)
            legend.append('d_OD')
        print figs
        gt.plot_vs_time('rl_od_vs_time'
                 ,instrument
                 ,rs.times
                 ,lines
                 ,['g','b','r']
                 ,[2,2,2]
                 ,legend
                 ,'upper left'    
                 ,'Aerosol optical depth'
                 ,None
                 ,'Aerosol optical depth vs time'   
                 ,False
                 ,display_defaults
                 ,figs)        
               
    return figs
Exemple #4
0
def show_ramanmerge(instrument,display_defaults,rs,usetimes,usealts,figs,consts=None):
    """
      show_ramanmerge(instrument,display_defaults,rs,usetimes,usealts,figs)
      show plots from rlprofmerge data stream
    """
   

    plot_alt_index = rs.plot_alt_index if hasattr(rs,'plot_alt_index') else 0
    plot_altitude = usealts[plot_alt_index]
    layer_indices = rs.layer_indices if hasattr(rs,'layer_indices') else np.arange(len(usealts))

 

    if display_defaults.enabled('rl_h2o_to_n2_count_ratio_image') and hasattr(rs,'water_counts'):

                title_str = instrument+' h20_to_n2_counts_ratio '
                print 'rendering ',title_str
                try:
                    gt.rti_fig('rl_h2o_to_n2_count_ratio_image'
                    , instrument
                    , rs.water_counts / rs.nitrogen_counts
                    , usetimes
                    , usealts
                    , title_str
                    , ' '
                    , None
                    , display_defaults
                    ,figs)
                except AttributeError:
                    raise RuntimeError, "show_images - no data for raman h20_to_n2_count_ratio  plot"

    if display_defaults.enabled('rl_hi_to_lo_channel_ratios') and \
        hasattr(rs,'nitrogen_counts_high'):

        print 'Rendering rl_hi_to_lo_channel ratios'
        title ='rl nfov to wfov vs time Z = %4.2f km' %(rs.altitudes[plot_alt_index]/1000.0)
        legend = ['n2 %3.1f' %( np.nanmean(rs.nitrogen_counts_high[:,plot_alt_index] \
                          / rs.nitrogen_counts_low[:,plot_alt_index]))]
        legend.append('elastic %3.1f' %(np.nanmean(rs.elastic_counts_high[:,plot_alt_index] \
                          / rs.elastic_counts_low[:,plot_alt_index])))
                                
        legend.append('h2o %3.1f' %(np.nanmean(rs.water_counts_high[:,plot_alt_index] \
                          / rs.water_counts_low[:,plot_alt_index])))                                
        gt.plot_vs_time('rl_hi_to_lo_channel_ratios'
                 ,instrument
                 ,usetimes
                 ,[rs.nitrogen_counts_high[:,plot_alt_index] \
                          / rs.nitrogen_counts_low[:,plot_alt_index]
                     ,rs.elastic_counts_high[:,plot_alt_index] \
                          / rs.elastic_counts_low[:,plot_alt_index]
                     ,rs.water_counts_high[:,plot_alt_index] \
                          / rs.water_counts_low[:,plot_alt_index]]
                 ,['b','r','g']
                 ,[2,2,2]
                 ,legend
                 ,'upper left'    
                 ,'narrow to wfov count ratios'
                 ,''
                 ,title  
                 ,False
                 ,display_defaults
                 ,figs)
        
    if display_defaults.enabled('rl_filter_mode') and \
        hasattr(rs,'filter_mode'):

        print 'Rendering Raman filter_mode'
        try:  
            title ='Raman filter mode'  
            gt.plot_vs_time('rl_filter_mode'
                 ,instrument
                 ,usetimes
                 ,[rs.filter_mode]
                 ,['b']
                 ,[2]
                 ,None
                 ,'upper left'    
                 ,'filter mode'
                 ,''
                 ,title  
                 ,False
                 ,display_defaults
                 ,figs)             
        except AttributeError:
             raise RuntimeError, "show_images - Raman filter mode plot"

    if display_defaults.enabled('rl_count_rates_vs_time') and \
        hasattr(rs,'nitrogen_counts'):

        print 'Rendering Raman count rates vs time'

        try:
            title ='Raman counting rates,Z=%4.2f km' %(rs.altitudes[plot_alt_index]/1000.0) 
            gt.plot_vs_time('rl_counts_vs_time'
                 ,instrument
                 ,usetimes
                 ,[rs.nitrogen_counts[:,plot_alt_index]
                       ,rs.elastic_counts[:,plot_alt_index]
                       ,rs.water_counts[:,plot_alt_index]]
                 ,['b','r','g']
                 ,[2,2,2]
                 ,['n2','elastic','h2o']
                 ,'upper left'    
                 ,'Count rate'
                 ,'Hz'
                 ,title  
                 ,False
                 ,display_defaults
                 ,figs)         
        except AttributeError:
             raise RuntimeError, "show_images - Raman counting rates plot"
         
    if display_defaults.enabled('rl_dark_counts_vs_time') and \
        hasattr(rs,'nitrogen_counts'):

        print 'Rendering Raman dark counts vs time'

        if 1: #try:
            #low channel is wfov, high is narrow fov
            title ='Raman dark count rates'
            temp_n2_low = rs.nitrogen_low_dark_counts.copy()
            temp_n2_low[temp_n2_low <= 0] = np.NaN
            temp_elastic_low = rs.elastic_low_dark_counts.copy()
            temp_elastic_low[temp_elastic_low <= 0] = np.NaN
            temp_water_low = rs.water_low_dark_counts.copy()
            temp_water_low[temp_water_low<=0] = np.NaN
            temp_n2_high = rs.nitrogen_high_dark_counts.copy()
            temp_n2_high[temp_n2_high <= 0] = np.NaN
            temp_elastic_high = rs.elastic_high_dark_counts.copy()
            temp_elastic_high[temp_elastic_high <= 0] = np.NaN
            temp_water_high = rs.water_high_dark_counts.copy()
            temp_water_high[temp_water_high<=0] = np.NaN
            gt.plot_vs_time('rl_dark_counts_vs_time'
                 ,instrument
                 ,usetimes
                 ,[temp_elastic_low, temp_n2_low, temp_water_low
                   ,temp_elastic_high,temp_n2_high,temp_water_high]
                 ,['r','b','g','r','b','g']
                 ,[1,1,1,3,3,3]
                 ,['elastic_low','N2_low','H2O_low'
                     ,'elastic_high','N2_high','H2O_high']
                 ,'upper left'    
                 ,'Count rate'
                 ,'Hz'
                 ,title  
                 ,False
                 ,display_defaults
                 ,figs)         
        if 0: #except AttributeError:
             raise RuntimeError, "show_images - Raman counting rates plot"
Exemple #5
0
def show_pars(instrument,display_defaults,rs,usetimes,usealts,figs):
            #toplevel
            if usealts==None and hasattr(rs,'heights'):
                usealts=rs.heights
            if usetimes==None and hasattr(rs,'times'):
                usetimes=rs.times
            #delta_t=np.zeros(rs.times.shape)
            #make vector of time differences between data points
            delta_t = hau.T_Array(np.array([(rs.times[x+1]-rs.times[x]).total_seconds() for x in range(rs.times.size-1)]+[0.0]))
            if delta_t.size>1:
                delta_t[-1]=nanmean(delta_t[:-2])
    
            if figs==None:
                figs=gt.figurelist()
          
                
            #start here
           
            if instrument.find('pars2S1') >= 0:
                color ='r'
                instrment = 'Pars2S1'
            else:
                color = 'b'
                instrument = 'Pars2S2'

            if display_defaults.enabled('parsivel_precip_rate'):                
                if hasattr(rs,'precip_rate'):
                    gt.plot_vs_time('parsivel_precip_rate'
                       ,instrument
                       ,usetimes
                       ,[rs.precip_rate]  
                       ,[color]
                       ,[2]
                       ,[]
                       ,''    
                       ,'Parsivel precip rate (mm/hr)'
                       ,[]
                       ,'Parsivel precip rate vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel precip rate'               
                else:
                    print
                    print 'No Parsivel precip rate image--precip rate field not found'
                    
            if display_defaults.enabled('parsivel_accumulated_precip'):
                if hasattr(rs,'precip_rate'):
                    #precip rate in units of mm/hr--convert seconds to hours
                    temp = (rs.precip_rate * delta_t/3600.0).copy()
                    temp[np.isnan(temp)]=0.0
                    accumulated_precip = np.cumsum(temp,0)   
                    gt.plot_vs_time('parsivel_accumulated_precip'
                       ,instrument
                       ,usetimes
                       ,[accumulated_precip]  
                       ,[color]
                       ,[2]
                       ,[]
                       ,''    
                       ,'Parsivel precip (mm)'
                       ,[]
                       ,'Parsivel precip vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel precip'               
                else:
                    print
                    print 'No Parsivel precip image--precip_rate field not found'

            if display_defaults.enabled('parsivel_median_volume_diameter'):
                if hasattr(rs,'median_volume_diameter'):
                    temp = rs.median_volume_diameter.copy()
                    temp[temp <0] = np.NaN
                    gt.plot_vs_time('parsivel_median_volume_diameter'
                       ,instrument
                       ,usetimes
                       ,[temp]  
                       ,[color]
                       ,[2]
                       ,None
                       ,''    
                       ,'median volume diameter'
                       ,'mm'
                       ,'parsivel median vol. dia. vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel median volume diameter'               
                else:
                    print
                    print 'No Parsivel median volume diameter plot--field not found'
                    
            if display_defaults.enabled('parsivel_liquid_water_content'):
                if hasattr(rs,'liquid_water_content'):
            
                    gt.plot_vs_time('parsivel_liquid_water_content'
                       ,instrument
                       ,usetimes
                       ,[rs.liquid_water_content * 1e-3]  #convert from mm^3/m^3 to gr/m^3  
                       ,[color]
                       ,[2]
                       ,None
                       ,''    
                       ,'Liquid water content'
                       ,'mm'
                       ,'Parsivel LWC vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel liquid water content'               
                else:
                    print
                    print 'No Parsivel liquid water content plot--field not found'
                    
            if display_defaults.enabled('parsivel_radar_reflectivity'):
                if hasattr(rs,'equivalent_radar_reflectivity'):
                    temp = rs.equivalent_radar_reflectivity.copy()
                    temp[temp<-50] = np.NaN
                    gt.plot_vs_time('parsivel_radar_reflectiviy'
                       ,instrument
                       ,usetimes
                       ,[temp]   
                       ,[color]
                       ,[2]
                       ,None
                       ,''    
                       ,'Radar reflectivity'
                       ,'dBZ'
                       ,'Parsivel radar reflectivity vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel radar reflectivity'               
                else:
                    print
                    print 'No Parsivel equivalent radar reflectivity--field not found'
            if 0:
              print 'particle size'
              print rs.particle_size.shape
              print rs.particle_size
              print 'particle width'
              print rs.class_size_width.shape
              print rs.class_size_width
              print 'fall velocity'
              print rs.raw_fall_velocity.shape
              print rs.raw_fall_velocity
            
            if 0: #display_defaults.enabled('parsivel_fall_velocity'):
                if hasattr(rs,'raw_fall_velocity'):
            
                    gt.plot_vs_time('parsivel_fall_velocity'
                       ,instrument
                       ,usetimes
                       ,[rs.raw_fall_velocity]   
                       ,[color]
                       ,[2]
                       ,None
                       ,''    
                       ,'Raw fall velocity'
                       ,'m/s'
                       ,'Parsivel fall velocity vs time'   
                       ,False #FIXME
                       ,display_defaults
                       ,figs)
                    print 'rendering Parsivel raw fall velocity'               
                else:
                    print
                    print 'No Parsivel raw fall velocity plot--field not found'
                    
            if 0: # display_defaults.enabled('parsivelfall_velocity_vs_time'):
                if hasattr(rs,'raw_spectrum'):

                    fall_velocity = rs.raw_spectrum.copy()
                    
                    fall_velocity[fall_velocity < -9000.0] = 0.0
                    #sum over particle size
                    fall_velocity = np.sum
                
                    gt.plot_vs_time('parsivel_fall_velocity_vs_time'
                        ,instrument
                        ,usetimes
                        ,[fall_velocity]  
                        ,[color]
                        ,[2]
                        ,[]
                        ,''    
                        ,'Parsivel fall velocity (m/s)'
                        ,[]
                        ,'Parsivel fall velocity vs time'   
                        ,False #FIXME
                        ,display_defaults
                        ,figs)
                    print 'rendering Parsivel raw fall velocity'               
                else:
                     print
                     print 'No Parsivel raw fall velocity plot--field not found'








            if display_defaults.enabled('parsivel_size_spectrum'):
                if hasattr(rs,'raw_spectrum'):
                    raw_spectrum = rs.raw_spectrum.copy()
                    raw_spectrum[raw_spectrum < -9000] = 0.0
                    #sum over time
                    raw_spectrum = np.sum(raw_spectrum,0)
                    #sum over velocities
                    raw_spectrum = np.sum(raw_spectrum,1)
                   
                    np.set_printoptions(threshold=np.NaN)

                   

                    gt.plot_xy('parsivel_size_spectrum'  #plot name
                        ,'Parsivel'
                        ,rs.times
                        ,[rs.particle_size[:19]]
                        ,[raw_spectrum[:19]]
                        ,[color]
                        ,[]
                        ,[]
                        ,['-']
                        ,[2]
                        ,[]
                        ,'upper right'
                        ,'particle size '
                        ,'mm'
                        ,'number'
                        ,None
                        ,'Raw spectrum'
                        ,'' #text_str
                        ,None #'text_position_x
                        ,None #text_position_y
                        ,None #text_angle
                        ,display_defaults
                        ,figs)
                else:
                    print
                    print 'Parsivel raw spectum plot not plotted--variable not found'

            if display_defaults.enabled('parsivel_fall_velocity_spectrum'):
                if hasattr(rs,'raw_spectrum'):
                    raw_spectrum = rs.raw_spectrum.copy()
                    raw_spectrum[raw_spectrum < -9000] = 0.0
                    #sum over time
                    raw_spectrum = np.sum(raw_spectrum,0)
                    #sum over sizes
                    raw_spectrum = np.sum(raw_spectrum,1)
                    
                    np.set_printoptions(threshold=np.NaN)

                    gt.plot_xy('parsivel_fall_velocity_spectrum'  #plot name
                        ,'Parsivel'
                        ,rs.times
                        ,[rs.raw_fall_velocity]
                        ,[raw_spectrum]
                        ,[color]
                        ,[]
                        ,[]
                        ,['-']
                        ,[2]
                        ,[]
                        ,'upper right'
                        ,'fall velocity'
                        ,'m/s'
                        ,'number'
                        ,None
                        ,'fall spectrum'
                        ,'' #text_str
                        ,None #'text_position_x
                        ,None #text_position_y
                        ,None #text_angle
                        ,display_defaults
                        ,figs)
                else:
                    print
                    print 'Parsivel fall velocity spectum  not plotted--variable not found'

            if display_defaults.enabled('parsivel_number_detected_particles_vs_time'):
                if hasattr(rs,'number_detected_particles'):
                    print 'rendering parsivel number_detected_particles_vs_time'
                    gt.plot_vs_time('parsivel_number_detected_particles_vs_time'
                        ,instrument
                        ,usetimes
                        ,[rs.number_detected_particles]  
                        ,[color]
                        ,[2]
                        ,[]
                        ,''    
                        ,'Number of particles'
                        ,None
                        ,'Parsivel number of detected particles vs time'   
                        ,False #FIXME
                        ,display_defaults
                        ,figs)
                            
                else:
                   print
                   print 'Pareivel number_detected_particles not plotted--variable not found'
                   
            if display_defaults.enabled('parsivel_number_density'):
                if hasattr(rs,'number_density_drops'):
                    number_density = rs.number_density_drops.copy()
                    number_density[number_density < -9000] = 0.0
                    #sum over time
                    number_density = np.mean(number_density,0)
                        
                    #np.set_printoptions(threshold=np.NaN)
            
                    gt.plot_xy('parsivel_number_density'
                        ,instrument
                        ,rs.times
                        ,[rs.particle_size[:19]]
                        ,[number_density[:19]]
                        ,[color]
                        ,[]
                        ,[]
                        ,['-']
                        ,[2]
                        ,[]
                        ,'upper right'
                        ,'particle size '
                        ,'mm'
                        ,'number density'
                        ,'1/(m^3 *mm)'
                        ,'Number density'
                        ,'' #text_str
                        ,None #'text_position_x
                        ,None #text_position_y
                        ,None #text_angle
                        ,display_defaults
                        ,figs)
                else:
                    print
                    print 'Parsivel number density not plotted--variable not found'
Exemple #6
0
def compare_hsrl_aeronet(rti, aeronet_file, cmp_alt=None, plot_limit=None):
    """compare_hsrl_aeronet(rti,aeronet_file,cmp_alt=None,plot_limit=None):
       plot aeronet optical depth on existing od_vs_time plot
       aeronet_file = name of file downloaded from aeronet web site for requested time
       cmp_alt = plot hsrl vs aeronet using hsrl data from this altitude 
       plot_limit  = limit hsrl vs aeronet plot to this OD 
    """

    if cmp_alt == None or plot_limit == None:
        print "INPUT ERROR--usage cmp_aeronet(rti, 'aeronet_file_name',comparison_alt(km),od_plot_upper_limit)"
        return
    times = rti.rs.rs_inv.times
    print 'read aeronet file = ' + aeronet_file
    [AOT500, AOT532, AOT667, AOT370,
     aeronet_times] = read_aeronet(aeronet_file, times)
    AOT532_trimed = AOT532[aeronet_times <= rti.rs.rs_inv.times[-1]]
    AOT370_trimed = AOT370[aeronet_times <= rti.rs.rs_inv.times[-1]]
    aeronet_times_trimed = aeronet_times[
        aeronet_times <= rti.rs.rs_inv.times[-1]]
    """ 
    #estimate hsrl unmeasured aerosol optical depth below molecular normalization altitude
    #by extrapolating optical depth slope measured at ref_alt to ground level
    norm_index = rti.rs.rs_inv.mol_norm_index
    #calculate the number bins between ground and ref altitude--allow fractional bins
    bin_range_to_ref_alt = (rti.rs.rs_inv.msl_altitudes[norm_index] - rti.rs.rs_mean.lidar_altitude)\
                           /(rti.rs.rs_inv.msl_altitudes[1]-rti.rs.rs_inv.msl_altitudes[0])
    print 'bin_range_to_ref_alt ',bin_range_to_ref_alt
    print rti.rs.rs_inv.msl_altitudes[norm_index]
    print rti.rs.rs_mean.lidar_altitude
    print norm_index
    #overlap_aod = #_bins_grd_to_ref_alt * OD_of_one_bin_at_ref_alt
    overlap_aod = bin_range_to_ref_alt\
           * (rti.rs.rs_inv.optical_depth_aerosol[:,norm_index+1] \
             -rti.rs.rs_inv.optical_depth_aerosol[:,norm_index])
    """
    norm_index = rti.rs.rs_inv.mol_norm_index
    overlap_aod = rti.rs.rs_inv.mol_ref_aod
    #interpolate overlap_aod computed at hsrl times to aeronet times
    overlap_aod_at_aeronet_times = np.zeros(len(aeronet_times_trimed))
    for i in range(len(aeronet_times_trimed)):
        #index into times less <= aeronet_times
        index = len(times[times <= aeronet_times_trimed[i]])
        if index == 0 or index == len(
                times) or times[index] == aeronet_times_trimed[i]:
            overlap_aod_at_aeronet_times[i] = overlap_aod[index]
        else:
            overlap_aod_at_aeronet_times[i] = (overlap_aod[index - 1] +
                                               overlap_aod[index]) / 2.0

    print 'aeronet start, end times = ', aeronet_times[0], aeronet_times[-1]
    print 'overlap_aods'
    print overlap_aod_at_aeronet_times
    #plot on existing od vs time plot
    gt.plot_vs_time(
        'od_vs_time',
        'ahsrl',
        aeronet_times_trimed,
        [AOT532_trimed - overlap_aod_at_aeronet_times],
        ['r'],
        [0],
        None,
        'upper left',
        'Optical depth above ' +
        str(int(rti.rs.rs_inv.msl_altitudes[norm_index]) / 1000.0) + '(km)',
        None,
        'Optical depth vs time',
        None,
        rti.
        display_defaults  #grabs the display defaults stored from the artist
        ,
        rti.figs)

    #plot hsrl od vis aeronet od
    bs_threshold = 1e-4
    i = 0
    #    alt_index = len(rti.rs.rs_inv.msl_altitudes[self.rs.rs_inv.msl_altitudes<= cmp_alt*1000.0])
    #    altitude = rti.rs.rs_inv.msl_altitudes[alt_index]

    j = 0
    alt_index = len(
        rti.rs.rs_inv.msl_altitudes[rti.rs.rs_inv.msl_altitudes <= cmp_alt *
                                    1000.0])
    altitude = rti.rs.rs_inv.msl_altitudes[alt_index]

    hsrl_ods = np.NaN * np.ones(aeronet_times_trimed.shape)
    aeronet_ods = np.NaN * np.ones(aeronet_times_trimed.shape)
    hsrl_ods_cloud = np.NaN * np.ones(aeronet_times_trimed.shape)
    aeronet_ods_cloud = np.NaN * np.ones(aeronet_times_trimed.shape)
    for a_time in aeronet_times_trimed:
        time_index = len(times[times <= a_time])
        h_od = rti.rs.rs_inv.optical_depth_aerosol[time_index, alt_index]
        a_od = AOT532_trimed[i]
        if h_od < plot_limit and a_od < plot_limit \
              and rti.rs.rs_inv.qc_mask[time_index,alt_index]:
            hsrl_ods[i] = h_od
            aeronet_ods[i] = a_od
            print i, h_od, a_od
            i = i + 1
            #find clouds in hsrl data
            if any(rti.rs.rs_inv.beta_a_backscat[time_index,
                                                 2:] > bs_threshold):
                hsrl_ods_cloud[j] = h_od
                aeronet_ods_cloud[j] = a_od
                j = j + 1
    one_to_one_line = np.array([0, plot_limit])
    colors = ['k', 'c', 'r', 'g']
    linetype = ['*', '-', '*', '*']
    linewidth = [2, 4, 4, 4]

    gt.plot_xy(
        'od_hsrl_vs_aeronet_raw'  #plot name
        ,
        ' ',
        times,
        [one_to_one_line, aeronet_ods, aeronet_ods_cloud],
        [one_to_one_line, hsrl_ods, hsrl_ods_cloud],
        ['k', 'r', 'c'],
        ['*', 'o', 'o'],
        [4, 4, 4, 4],
        ['-', 'o', 'o', 'o'],
        linewidth,
        None,
        'upper right',
        'Aeronet Optical depth',
        None,
        'HSRL 532 OD ' + str(int(altitude)) + '(m)',
        None,
        'HSRL vs aeronet OD',
        ['no near range dead zone correction'],
        [plot_limit * 0.5],
        [plot_limit * 0.95],
        [0],
        rti.display_defaults,
        rti.figs)

    gt.plot_xy(
        'od_hsrl_vs_aeronet_corrected'  #plot name
        ,
        ' ',
        times,
        [one_to_one_line, aeronet_ods, aeronet_ods_cloud],
        [
            one_to_one_line, overlap_aod_at_aeronet_times + hsrl_ods,
            hsrl_ods_cloud
        ],
        colors,
        ['*', 'o', 'o'],
        [4, 4, 4, 4],
        ['-', 'o', 'o', 'o'],
        linewidth,
        None,
        'upper right',
        'Aeronet Optical depth',
        None,
        'HSRL 532 OD 0-->' + str(int(altitude) / 1000.0) + '(km)',
        None,
        'HSRL vs AERONET optical depth',
        ['includes near range dead zone correction'],
        [plot_limit * 0.5],
        [plot_limit * 0.95],
        [0],
        rti.display_defaults,
        rti.figs)
    #compute standard deviation of aeronet and hsrl ods less than plot limit
    temp_x = aeronet_ods[aeronet_ods <= plot_limit]
    temp_y = overlap_aod_at_aeronet_times[
        aeronet_ods <= plot_limit] + hsrl_ods[aeronet_ods <= plot_limit]
    temp_x = temp_x[temp_y <= plot_limit]
    temp_y = temp_y[temp_y <= plot_limit]
    std = np.nanmean(np.sqrt((temp_x - temp_y)**2))
    print
    print 'std deviation ODs = ', std
    print

    temp_x = aeronet_ods[np.isnan(overlap_aod_at_aeronet_times +
                                  hsrl_ods) == 0]
    temp_y = overlap_aod_at_aeronet_times[np.isnan(overlap_aod_at_aeronet_times+hsrl_ods)==0]\
               + hsrl_ods[np.isnan(overlap_aod_at_aeronet_times+hsrl_ods) == 0]
    temp_y = temp_y[np.isnan(temp_x) == 0]

    pc = np.polyfit(temp_x, temp_y, 1)
    x_od = np.array([0, plot_limit])
    fit_od = np.polyval(pc, x_od)
    gt.plot_xy(
        'od_hsrl_vs_aeronet_with_fit'  #plot name
        ,
        ' ',
        times,
        [one_to_one_line, aeronet_ods, x_od],
        [one_to_one_line, overlap_aod_at_aeronet_times + hsrl_ods, fit_od],
        colors,
        ['*', 'o', 'o'],
        [4, 4, 4, 4],
        ['-', 'o', '-'],
        linewidth,
        None,
        'upper right',
        'Aeronet Optical depth',
        None,
        'HSRL 532 OD 0-->' + str(int(altitude) / 1000.0) + '(km)',
        None,
        'HSRL vs AERONET optical depth',
        ['std = ' + str(std)]  #text_str
        ,
        [plot_limit * 0.5]  #text_position_x
        ,
        [plot_limit * 0.95]  #text_position_y
        ,
        [0]  #text_angle
        ,
        rti.display_defaults,
        rti.figs)

    #create a new od vs time plot with hsrl values at comparison altitudes
    alt_index = len(
        rti.rs.rs_inv.msl_altitudes[rti.rs.rs_inv.msl_altitudes <= cmp_alt *
                                    1000.0])
    gt.plot_vs_time(
        'hsrl_and_aeronet_od_vs_time',
        'ahsrl',
        times,
        [rti.rs.rs_inv.optical_depth_aerosol[:, alt_index] + overlap_aod],
        ['b'],
        [2],
        None,
        'upper left',
        'Optical depth',
        None,
        'Optical depth vs time',
        None,
        rti.
        display_defaults  #grabs the display defaults stored from the artist
        ,
        rti.figs)
    #overplot with aeronet values
    gt.plot_vs_time(
        'hsrl_and_aeronet_od_vs_time',
        'ahsrl',
        aeronet_times_trimed,
        [AOT532_trimed],
        ['r'],
        [0],
        None,
        'upper left',
        'Optical depth',
        None,
        'Optical depth vs time',
        None,
        rti.
        display_defaults  #grabs the display defaults stored from the artist
        ,
        rti.figs)

    if 'rl_od_vs_time' in rti.figs:
        #don't bother with this plot if no raman optical depth plot
        try:
            gt.plot_vs_time(
                'rl_od_vs_time',
                'raman',
                aeronet_times_trimed,
                [AOT370_trimed],
                ['m'],
                [0],
                ['370nm'],
                'upper left',
                'Optical depth',
                None,
                'Optical depth vs time',
                None,
                rti.
                display_defaults  #grabs the display defaults stored from the artist
                ,
                rti.figs)
        except:
            print 'no raman optical depth vs time plot'

    rti.figs.showall()
    """