def main(): """ """ # parse the arguments parser = argparse.ArgumentParser( description='Entry to Pyrad processing framework') # keyword arguments parser.add_argument('--database', type=str, default='/store/msrad/radar/pyrad_products/', help='base path to the radar data') parser.add_argument( '--datadirs', type=str, default=( 'mals_sha_windmills_point_psr_filtered_WM1_20200304-20200311,' 'mals_sha_windmills_point_psr_filtered_WM1_20200312-20200315,' 'mals_sha_windmills_point_psr_filtered_WM1_20200316-20200320,' 'mals_sha_windmills_point_psr_filtered_WM1_20200321-20200325'), help='directories containing data') parser.add_argument( '--datatypes', type=str, default='dBuZ,dBuZv,rcs_h,rcs_v,ZDRu,RhoHVu,uPhiDPu,Vu,Wu', help='Data types. Coma separated') args = parser.parse_args() print("====== PYRAD windmill data processing started: %s" % datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")) atexit.register(_print_end_msg, "====== PYRAD windmill data processing finished: ") datadirs = args.datadirs.split(',') datatypes = args.datatypes.split(',') # Read periods of processing for datatype in datatypes: first_read = False for datadir in datadirs: # Read data time series files flist = glob.glob(args.database + datadir + '/' + datatype + '_TS/TS/ts_POINT_MEASUREMENT_hist_' + datatype + '.csv') if not flist: continue hist_aux, bin_edges_aux = read_histogram(flist[0]) if not first_read: hist = hist_aux bin_edges = bin_edges_aux first_read = True continue hist += hist_aux basepath = os.path.dirname(flist[0]) + '/' # Histogram plots field_name = get_fieldname_pyart(datatype) field_dict = get_metadata(field_name) fname = args.database + 'ts_POINT_MEASUREMENT_hist_' + datatype + '.png' bin_centers = bin_edges[:-1] + ((bin_edges[1] - bin_edges[0]) / 2.) fname = plot_histogram2(bin_centers, hist, [fname], labelx=get_colobar_label( field_dict, field_name), titl=datatype) print('Plotted ' + ' '.join(fname)) fname = args.database + 'ts_POINT_MEASUREMENT_hist_' + datatype + '.csv' fname = write_histogram(bin_edges, hist, fname) print('Written ' + fname)
def main(): """ """ # basepath = '/data/pyrad_products/rad4alp_hydro_PHA/' basepath = '/store/msrad/radar/pyrad_products/rad4alp_hydro_PHA/data_analysis_min10sources/' print("====== Lightning post-processing started: %s" % datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")) atexit.register(_print_end_msg, "====== Lightning post-processing finished: ") # prefix = ['All', 'no_CG', 'CGt'] # dir = ['all_data/', 'no_CG/', 'CGt/'] prefix = ['CGt', 'CGn', 'CGp'] dir = ['CGt/', 'CGn/', 'CGp/'] sources = ['allsources', 'firstsource'] titles = ['Value at VHF source location', 'Value at flash origin location'] datatypes = [ 'dBZc', 'entropy', 'hydro', 'hydro_prop', 'KDPc', 'nhydro', 'RhoHVc', 'TEMP', 'ZDRc' ] labels = [ 'horizontal reflectivity [dBZ]', 'entropy [-]', 'radar echo classification [-]', 'proportion of hydrometeors [%]', 'specific differential phase [deg/km]', 'Number of hydrometeor in radar gate', 'copolar correlation coefficient [-]', 'temperature [deg Celsius]', 'differential reflectivity [dB]' ] # sources = ['', '_first_source'] # titles = ['Value at VHF source location', 'Value at flash origin location'] # datatypes = ['alt', 'dBm'] # labels = [ # 'VHF source altitude [m MSL]', 'VHF source power [dBm]'] for source, titl in zip(sources, titles): for datatype, labelx in zip(datatypes, labels): hist1, bin_edges1 = read_histogram(basepath + dir[0] + prefix[0] + '_' + source + '_ts_trajlightning_' + datatype + '.csv') hist2, bin_edges2 = read_histogram(basepath + dir[1] + prefix[1] + '_' + source + '_ts_trajlightning_' + datatype + '.csv') hist3, bin_edges3 = read_histogram(basepath + dir[2] + prefix[2] + '_' + source + '_ts_trajlightning_' + datatype + '.csv') # hist1, bin_edges1 = read_histogram( # basepath+dir[0]+prefix[0]+'_Santis_hist_'+datatype+source+'.csv') # hist2, bin_edges2 = read_histogram( # basepath+dir[1]+prefix[1]+'_Santis_hist_'+datatype+source+'.csv') # hist3, bin_edges3 = read_histogram( # basepath+dir[2]+prefix[2]+'_Santis_hist_'+datatype+source+'.csv') if (not np.array_equal(bin_edges1, bin_edges2) or not np.array_equal(bin_edges1, bin_edges3)): warn('Bin edges should be identical to group histograms') continue if hist1 is None or hist2 is None or hist3 is None: warn('Dataset not available') continue invert_xaxis = False if datatype == 'TEMP': invert_xaxis = True bin_res = bin_edges1[1] - bin_edges1[0] bin_centers = bin_edges1[1:] - bin_res / 2. fname = basepath + 'group_Santis_CG_hist_' + source + '_' + datatype + '.png' fig, ax = plot_histogram2(bin_centers, hist1, [fname], labelx=labelx, titl=titl, alpha=0.25, save_fig=False, color='b', invert_xaxis=invert_xaxis) fig, ax = plot_histogram2(bin_centers, hist2, [fname], labelx=labelx, titl=titl, ax=ax, fig=fig, save_fig=False, color='g', alpha=0.25, invert_xaxis=invert_xaxis) fname_list = plot_histogram2(bin_centers, hist3, [fname], labelx=labelx, titl=titl, ax=ax, fig=fig, save_fig=True, color='r', alpha=0.25, invert_xaxis=invert_xaxis) # Total number of values n1 = np.ma.sum(hist1) n2 = np.ma.sum(hist2) n3 = np.ma.sum(hist3) print(n1) print(n2) print(n3) # Mode print(bin_centers[np.ma.argmax(hist1)]) print(bin_centers[np.ma.argmax(hist2)]) print(bin_centers[np.ma.argmax(hist3)]) # Median freq1 = np.ma.cumsum(hist1) / n1 freq2 = np.ma.cumsum(hist2) / n2 freq3 = np.ma.cumsum(hist3) / n3 ind1 = np.where(freq1 >= 0.5)[0][0] ind2 = np.where(freq2 >= 0.5)[0][0] ind3 = np.where(freq3 >= 0.5)[0][0] print(bin_centers[ind1]) print(bin_centers[ind2]) print(bin_centers[ind3]) if datatype == 'hydro': print(hist1 / n1 * 100.) print(hist2 / n2 * 100.) print(hist3 / n3 * 100.) print('plotted ' + ''.join(fname_list))
def main(): """ """ # parse the arguments parser = argparse.ArgumentParser( description='Entry to Pyrad processing framework') # keyword arguments parser.add_argument('--database', type=str, default='/store/msrad/radar/pyrad_products/', help='base path to the radar data') parser.add_argument( '--datadirs', type=str, default=( 'mals_sha_windmills_point_psr_filtered_WM1_20200304-20200311,' 'mals_sha_windmills_point_psr_filtered_WM1_20200312-20200315,' 'mals_sha_windmills_point_psr_filtered_WM1_20200316-20200320,' 'mals_sha_windmills_point_psr_filtered_WM1_20200321-20200325'), help='directories containing data') parser.add_argument( '--datatypes', type=str, default='dBuZ,dBuZv,rcs_h,rcs_v,uPhiDPu,RhoHVu,ZDRu,Vu,Wu', help='Data types. Coma separated') parser.add_argument( '--orientations', type=str, default= '0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350', help='Orientation respect to radar') parser.add_argument('--span', type=float, default=10., help='Span') parser.add_argument('--vel_limit', type=float, default=0., help='Velocity limit') args = parser.parse_args() print("====== PYRAD windmill data processing started: %s" % datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")) atexit.register(_print_end_msg, "====== PYRAD windmill data processing finished: ") datadirs = args.datadirs.split(',') datatypes = args.datatypes.split(',') orientations = np.asarray(args.orientations.split(','), dtype=float) speeds = [ 'speed_GT' + str(args.vel_limit), 'speed_LE' + str(args.vel_limit) ] scan_type = 'ppi' for ori in orientations: for speed in speeds: for datatype in datatypes: first_read = False for datadir in datadirs: # Read data time series files flist = glob.glob(args.database + datadir + '/' + datatype + '_TS/TS/' + datatype + '_span' + str(args.span) + '_ori' + str(ori) + '_' + speed + '_hist.csv') if not flist: continue hist_aux, bin_edges_aux = read_histogram(flist[0]) if not first_read: hist = hist_aux bin_edges = bin_edges_aux first_read = True continue hist += hist_aux if not first_read: warn('No files for orientation ' + str(ori) + ' and ' + speed) continue # Histogram plots field_name = get_fieldname_pyart(datatype) field_dict = get_metadata(field_name) fname = (args.database + datatype + '_span' + str(args.span) + '_ori' + str(ori) + '_' + speed + '_hist.png') titl = (datatype + ' span ' + str(args.span) + ' ori ' + str(ori) + ' ' + speed) bin_centers = bin_edges[:-1] + ( (bin_edges[1] - bin_edges[0]) / 2.) fname = plot_histogram2(bin_centers, hist, [fname], labelx=get_colobar_label( field_dict, field_name), titl=titl) print('Plotted ' + ' '.join(fname)) fname = (args.database + datatype + '_span' + str(args.span) + '_ori' + str(ori) + '_' + speed + '_hist.csv') fname = write_histogram(bin_edges, hist, fname) print('Written ' + fname)
def main(): """ """ # basepath = '/data/pyrad_products/rad4alp_hydro_PHA/' basepath = '/store/msrad/radar/pyrad_products/rad4alp_hydro_PHA/' day_vec = [ datetime.datetime(2017, 6, 29), datetime.datetime(2017, 6, 30), datetime.datetime(2017, 7, 10), datetime.datetime(2017, 7, 14), datetime.datetime(2017, 7, 18), datetime.datetime(2017, 7, 19), datetime.datetime(2017, 7, 30), datetime.datetime(2017, 8, 1) ] # day_vec = [ # datetime.datetime(2017, 7, 14)] basename = 'Santis_data_entropy_CGpn' filt_type = 'keep_all' nsources_min = 10 if 'entropy' in basename: pol_vals_labels = [ 'hydro', 'entropy', 'propAG', 'propCR', 'propIH', 'propLR', 'propMH', 'propRN', 'propRP', 'propVI', 'propWS' ] datatype_vec = [ 'hydro', 'entropy', 'propAG', 'propCR', 'propIH', 'propLR', 'propMH', 'propRN', 'propRP', 'propVI', 'propWS' ] step_list = [None, 0.1, 1., 1., 1., 1., 1., 1., 1., 1., 1.] else: pol_vals_labels = [ 'hydro [-]', 'KDPc [deg/Km]', 'dBZc [dBZ]', 'RhoHVc [-]', 'TEMP [deg C]', 'ZDRc [dB]' ] datatype_vec = ['hydro', 'KDPc', 'dBZc', 'RhoHVc', 'TEMP', 'ZDRc'] step_list = [None, 0.05, 0.5, 0.001, 1., 0.1] for label in pol_vals_labels: if 'hydro' in label: hydro_label = label break print("====== Lightning post-processing started: %s" % datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")) atexit.register(_print_end_msg, "====== Lightning post-processing finished: ") # read all the data to analyze flashnr, time_data, time_in_flash, lat, lon, alt, dBm, pol_vals_dict = ( read_data(basepath, day_vec, basename=basename, pol_vals_labels=pol_vals_labels)) # flashnr, time_data, time_in_flash, lat, lon, alt, dBm, pol_vals_dict = ( # read_data_two_sources( # basepath, day_vec, basename1='Santis_data_entropy', # basename2='Santis_data_entropy_CGt', basename_out='Santis_data_entropy_no_CG', # keep_common=False, # pol_vals_labels=pol_vals_labels)) # Get indices of data to keep if filt_type == 'keep_all': ind, data_ID, subtitl = get_indices_all_data(flashnr, nsources_min=nsources_min) elif filt_type == 'keep_solid': ind, data_ID, subtitl = get_indices_solid_phase( flashnr, pol_vals_dict[hydro_label], nsources_min=nsources_min) elif filt_type == 'keep_liquid': ind, data_ID, subtitl = get_indices_liquid_phase( flashnr, pol_vals_dict[hydro_label], nsources_min=nsources_min) elif filt_type == 'keep_liquid_origin': ind, data_ID, subtitl = get_indices_liquid_phase_origin( flashnr, pol_vals_dict[hydro_label], nsources_min=nsources_min) else: warn('Unknown filter type ' + filt_type) return flashnr_filt = flashnr[ind] time_data_filt = time_data[ind] time_in_flash_filt = time_in_flash[ind] lat_filt = lat[ind] lon_filt = lon[ind] alt_filt = alt[ind] dBm_filt = dBm[ind] pol_vals_dict_filt = deepcopy(pol_vals_dict) for key in pol_vals_dict.keys(): pol_vals_dict_filt[key] = pol_vals_dict[key][ind] # # write the filtered data in a file # vals_list = [] # for label in pol_vals_labels: # vals_list.append(pol_vals_dict_filt[label]) # # fname = basepath+basename'_'+data_ID+'.csv' # write_ts_lightning( # flashnr_filt, time_data_filt, time_in_flash_filt, lat_filt, lon_filt, # alt_filt, dBm_filt, vals_list, fname, pol_vals_labels) # print('written to '+fname) # get flashes origin of filtered data flashnr_first, ind_first = np.unique(flashnr_filt, return_index=True) time_data_first = time_data_filt[ind_first] time_in_flash_first = time_in_flash_filt[ind_first] lat_first = lat_filt[ind_first] lon_first = lon_filt[ind_first] alt_first = alt_filt[ind_first] dBm_first = dBm_filt[ind_first] pol_vals_dict_first = deepcopy(pol_vals_dict_filt) for key in pol_vals_dict_filt.keys(): pol_vals_dict_first[key] = pol_vals_dict_filt[key][ind_first] # get duration and area of flash duration_filt = np.ma.masked_all(flashnr_first.size) area_filt = np.ma.masked_all(flashnr_first.size) chy_filt, chx_filt, _ = wgs84_to_swissCH1903(lon_filt, lat_filt, alt_filt, no_altitude_transform=True) for i, flash_ID in enumerate(flashnr_first): time_data_flash = time_data_filt[flashnr_filt == flash_ID] duration_filt[i] = ( 1e3 * (time_data_flash[-1] - time_data_flash[0]).total_seconds()) chy_flash = chy_filt[flashnr_filt == flash_ID] chx_flash = chx_filt[flashnr_filt == flash_ID] points_flash = shapely.geometry.MultiPoint( list(zip(chy_flash, chx_flash))) area_filt[i] = points_flash.minimum_rotated_rectangle.area * 1e-6 print('N flashes: ' + str(flashnr_first.size)) print('N sources: ' + str(flashnr_filt.size)) # Analyse the data # create histograms of hydrometeor proportions if 'propAG' in pol_vals_dict_filt: bins_centers = np.arange(0, 10, 1) bins_edges = np.arange(-0.5, 10.5, 1) # Create histogram of number of differnt hydrometeors types in each # radar range gate. All sources nhydros_hist = hist_nhydros_gate(pol_vals_dict_filt, percent_min=10.) fname = (basepath + data_ID + '_allsources_ts_trajlightning_nhydro.png') plot_histogram2(bins_centers, nhydros_hist, [fname], labelx='Number of hydrometeors in radar range gate', labely='occurrence', titl='Trajectory Histogram All Sources' + subtitl) print("----- plot to '%s'" % fname) # store histogram fname = (basepath + data_ID + '_allsources_ts_trajlightning_nhydro.csv') write_histogram(bins_edges, nhydros_hist, fname) print('Written ' + fname) # Create histogram of number of different hydrometeors types in each # radar range gate. First source nhydros_hist = hist_nhydros_gate(pol_vals_dict_first, percent_min=10.) fname = (basepath + data_ID + '_firstsource_ts_trajlightning_nhydro.png') plot_histogram2(bins_centers, nhydros_hist, [fname], labelx='Number of hydrometeors in radar range gate', labely='occurrence', titl='Trajectory Histogram First Sources' + subtitl) print("----- plot to '%s'" % fname) # store histogram fname = (basepath + data_ID + '_firstsource_ts_trajlightning_nhydro.csv') write_histogram(bins_edges, nhydros_hist, fname) print('Written ' + fname) return # Create histograms of dominant hydrometeors all sources hydro_hist2 = hist_dominant_hydrometeors(pol_vals_dict_filt, percent_min=10.) fname_hist = basepath + data_ID + '_allsources_ts_trajlightning_hydro_dominant.png' fname_hist = _plot_time_range(bins_edges, bins_edges, hydro_hist2, None, [fname_hist], titl='Trajectory Histogram All Sources' + subtitl, xlabel='Dominant hydrometeor', ylabel='2nd most dominant hydrometeor', vmin=0, clabel='Occurrence', figsize=[10, 8], dpi=72) print('Plotted ' + ' '.join(fname_hist)) # Create histogram of dominant hydrometeors first sources hydro_hist2 = hist_dominant_hydrometeors(pol_vals_dict_first, percent_min=10.) fname_hist = basepath + data_ID + '_firstsource_ts_trajlightning_hydro_dominant.png' fname_hist = _plot_time_range( bins_edges, bins_edges, hydro_hist2, None, [fname_hist], titl='Trajectory Histogram First Sources' + subtitl, xlabel='Dominant hydrometeor', ylabel='2nd most dominant hydrometeor', vmin=0, clabel='Occurrence', figsize=[10, 8], dpi=72) print('Plotted ' + ' '.join(fname_hist)) # create histogram of percentage of dominant hydrometeor all sources hydro_hist = hist_hydrometeor_mixtures(pol_vals_dict_filt) fname = (basepath + data_ID + '_allsources_ts_trajlightning_hydro_prop.png') plot_histogram2(bins_centers, hydro_hist, [fname], labelx='radar echo classification (-)', labely='percentage', titl='Trajectory Histogram All Sources' + subtitl) print("----- plot to '%s'" % fname) # store histogram fname = (basepath + data_ID + '_allsources_ts_trajlightning_hydro_prop.csv') write_histogram(bins_edges, hydro_hist, fname) print('Written ' + fname) # create histogram of percentage of dominant hydrometeor first sources hydro_hist = hist_hydrometeor_mixtures(pol_vals_dict_first) fname = (basepath + data_ID + '_firstsource_ts_trajlightning_hydro_prop.png') plot_histogram2(bins_centers, hydro_hist, [fname], labelx='radar echo classification (-)', labely='percentage', titl='Trajectory Histogram First Sources' + subtitl) print("----- plot to '%s'" % fname) # store histogram fname = (basepath + data_ID + '_firstsource_ts_trajlightning_hydro_prop.csv') write_histogram(bins_edges, hydro_hist, fname) print('Written ' + fname) for i, key in enumerate(pol_vals_labels): step = step_list[i] datatype = datatype_vec[i] field_name = get_fieldname_pyart(datatype) field_dict = get_metadata(field_name) labelx = get_colobar_label(field_dict, field_name) vals = pol_vals_dict_filt[key] bins, values = compute_histogram(vals, field_name, step=step) print(datatype + ' min: ' + str(vals.min())) print(datatype + ' max: ' + str(vals.max())) # Plot all sources histogram fname_first_source = (basepath + data_ID + '_allsources_ts_trajlightning_' + datatype + '.png') plot_histogram(bins, values, [fname_first_source], labelx=labelx, titl='Trajectory Histogram All Sources' + subtitl) print("----- plot to '%s'" % fname_first_source) # store histogram fname_first_source = (basepath + data_ID + '_allsources_ts_trajlightning_' + datatype + '.csv') hist_values, _ = np.histogram(values, bins=bins) write_histogram(bins, hist_values, fname_first_source) print('Written ' + fname_first_source) # First sources vals = pol_vals_dict_first[key] bins, values = compute_histogram(vals, field_name, step=step) # Plot first source histogram fname_first_source = (basepath + data_ID + '_firstsource_ts_trajlightning_' + datatype + '.png') plot_histogram(bins, values, [fname_first_source], labelx=labelx, titl='Trajectory Histogram First Source' + subtitl) print("----- plot to '%s'" % fname_first_source) # store histogram fname_first_source = (basepath + data_ID + '_firstsource_ts_trajlightning_' + datatype + '.csv') hist_values_first, _ = np.histogram(values, bins=bins) write_histogram(bins, hist_values_first, fname_first_source) print('Written ' + fname_first_source) # Get histograms of sources altitude and power # define histogram bin edges bin_edges_alt = np.arange(-50., 14150., 100.) bin_edges_dBm = np.arange(-17., 47., 1.) bin_edges_time = np.arange(0, 25, 1) bin_edges_area = np.arange(0., 2100., 100.) bin_edges_duration = np.arange(0., 1100., 100.) # Plot histogram of LMA flash area _, area_filt_values = compute_histogram(area_filt, None, bin_edges=bin_edges_area) fname_hist = basepath + data_ID + '_Santis_hist_area.png' fname_hist = plot_histogram(bin_edges_area, area_filt_values, [fname_hist], labelx='Area [km2]', titl='Flash area' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_area.csv' hist_area, _ = np.histogram(area_filt_values, bins=bin_edges_area) fname_hist = write_histogram(bin_edges_area, hist_area, fname_hist) print('Written ' + fname_hist) # Plot histogram of LMA flash duration _, duration_filt_values = compute_histogram(duration_filt, None, bin_edges=bin_edges_duration) fname_hist = basepath + data_ID + '_Santis_hist_duration.png' fname_hist = plot_histogram(bin_edges_duration, duration_filt_values, [fname_hist], labelx='Duration [ms]', titl='Flash duration' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_duration.csv' hist_duration, _ = np.histogram(duration_filt_values, bins=bin_edges_duration) fname_hist = write_histogram(bin_edges_duration, hist_duration, fname_hist) print('Written ' + fname_hist) # Plot histogram time of occurrence time_hour_first = occurrence_time(time_data_first) fname_hist = basepath + data_ID + '_Santis_hist_time.png' fname_hist = plot_histogram(bin_edges_time, time_hour_first, [fname_hist], labelx='Hour [UTC]', titl='Flash occurrence time' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_time.csv' hist_time, _ = np.histogram(time_hour_first, bins=bin_edges_time) fname_hist = write_histogram(bin_edges_time, hist_time, fname_hist) print('Written ' + fname_hist) # Plot histogram altitude all sources _, alt_filt_values = compute_histogram(alt_filt, None, bin_edges=bin_edges_alt) fname_hist = basepath + data_ID + '_Santis_hist_alt.png' fname_hist = plot_histogram(bin_edges_alt, alt_filt_values, [fname_hist], labelx='Altitude [m MSL]', titl='Flash sources altitude' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_alt.csv' hist_alt, _ = np.histogram(alt_filt_values, bins=bin_edges_alt) fname_hist = write_histogram(bin_edges_alt, hist_alt, fname_hist) print('Written ' + fname_hist) # Plot histogram altitude first sources _, alt_first_values = compute_histogram(alt_first, None, bin_edges=bin_edges_alt) fname_hist = basepath + data_ID + '_Santis_hist_alt_first_source.png' fname_hist = plot_histogram(bin_edges_alt, alt_first_values, [fname_hist], labelx='Altitude [m MSL]', titl='Flash first source altitude' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_alt_first_source.csv' hist_alt_fist, _ = np.histogram(alt_first_values, bins=bin_edges_alt) fname_hist = write_histogram(bin_edges_alt, hist_alt_fist, fname_hist) print('Written ' + fname_hist) # Plot histogram power all sources _, dBm_filt_values = compute_histogram(dBm_filt, None, bin_edges=bin_edges_dBm) fname_hist = basepath + data_ID + '_Santis_hist_dBm.png' fname_hist = plot_histogram(bin_edges_dBm, dBm_filt_values, [fname_hist], labelx='Power [dBm]', titl='Flash sources power' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_dBm.csv' hist_dBm, _ = np.histogram(dBm_filt_values, bins=bin_edges_dBm) fname_hist = write_histogram(bin_edges_dBm, hist_dBm, fname_hist) print('Written ' + fname_hist) # Plot histogram power first sources _, dBm_first_values = compute_histogram(dBm_first, None, bin_edges=bin_edges_dBm) fname_hist = basepath + data_ID + '_Santis_hist_dBm_first_source.png' fname_hist = plot_histogram(bin_edges_dBm, dBm_first_values, [fname_hist], labelx='Power [dBm]', titl='Flash first source power' + subtitl) print('Plotted ' + ' '.join(fname_hist)) fname_hist = basepath + data_ID + '_Santis_hist_dBm_first_source.csv' hist_dBm_first, _ = np.histogram(dBm_first_values, bins=bin_edges_dBm) fname_hist = write_histogram(bin_edges_dBm, hist_dBm_first, fname_hist) print('Written ' + fname_hist) # Plot 2D histogram all sources H, _, _ = np.histogram2d(alt_filt_values, dBm_filt_values, bins=[bin_edges_alt, bin_edges_dBm]) # set 0 values to blank H = np.ma.asarray(H) H[H == 0] = np.ma.masked fname_hist = basepath + data_ID + '_Santis_2Dhist_alt_dBm.png' fname_hist = _plot_time_range(bin_edges_alt, bin_edges_dBm, H, None, [fname_hist], titl='LMA sources Altitude-Power histogram' + subtitl, xlabel='Altitude [m MSL]', ylabel='Power [dBm]', clabel='Occurrence', vmin=0, vmax=None, figsize=[10, 8], dpi=72) print('Plotted ' + ' '.join(fname_hist)) # Plot 2D histogram first sources H, _, _ = np.histogram2d(alt_first_values, dBm_first_values, bins=[bin_edges_alt, bin_edges_dBm]) # set 0 values to blank H = np.ma.asarray(H) H[H == 0] = np.ma.masked fname_hist = basepath + data_ID + '_Santis_2Dhist_alt_dBm_first_source.png' fname_hist = _plot_time_range( bin_edges_alt, bin_edges_dBm, H, None, [fname_hist], titl='LMA first sources Altitude-Power histogram' + subtitl, xlabel='Altitude [m MSL]', ylabel='Power [dBm]', clabel='Occurrence', vmin=0, vmax=None, figsize=[10, 8], dpi=72) print('Plotted ' + ' '.join(fname_hist)) # plot position all sources figfname = basepath + data_ID + '_Santis_LMA_sources_pos_max_height_on_top.png' figfname = plot_pos(lat_filt, lon_filt, alt_filt, [figfname], sort_altitude='Highest_on_top', cb_label='Source height [m MSL]', titl='Flash sources position. Highest on top' + subtitl) print('Plotted ' + ' '.join(figfname)) figfname = basepath + data_ID + '_Santis_LMA_sources_pos_min_height_on_top.png' figfname = plot_pos(lat_filt, lon_filt, alt_filt, [figfname], sort_altitude='Lowest_on_top', cb_label='Source height [m MSL]', titl='Flash sources position. Lowest on top' + subtitl) print('Plotted ' + ' '.join(figfname)) # plot position first source figfname = (basepath + data_ID + '_Santis_LMA_first_source_pos_max_height_on_top.png') figfname = plot_pos(lat_first, lon_first, alt_first, [figfname], sort_altitude='Highest_on_top', cb_label='Source height [m MSL]', titl='First flash source position. Highest on top' + subtitl) print('Plotted ' + ' '.join(figfname)) figfname = (basepath + data_ID + '_Santis_LMA_first_source_pos_min_height_on_top.png') figfname = plot_pos(lat_first, lon_first, alt_first, [figfname], sort_altitude='Lowest_on_top', cb_label='Source height [m MSL]', titl='First flash source position. Lowest on top' + subtitl) print('Plotted ' + ' '.join(figfname))