예제 #1
0
def sigmet2cfrad(filepath,
                 outdir='cf',
                 dirlock=None,
                 verbose=False,
                 filter_raw=False):
    """Convert Sigmet raw radar data to cfradial format"""
    radar = io.read_sigmet(filepath)
    if is_bad(radar):
        if filter_raw:
            if verbose:
                eprint('rm {}'.format(filepath))
            remove(filepath)
        return
    time = radar_start_datetime(radar)
    if dirlock:
        dirlock.acquire()
    subdir = ensure_dir(path.join(outdir, time.strftime('%Y%m%d')))
    if dirlock:
        dirlock.release()
    out_filepath = path.join(subdir, cfrad_filename(radar))
    if verbose:
        print(out_filepath)
    io.write_cfradial(out_filepath, radar)
예제 #2
0
    # Search for the file(s)
    flist = glob(args.searchstring)
    
    # Create an output file if requested
    if args.make_file:
        OutTx = open(args.outFile,'w')   
    
    for file in flist:
        fLName, fileExt = os.path.splitext(file)
        fName = os.path.basename(file)
        
        # Get the file size
        fSize = os.path.getsize(file)

        # read in the file
        radar = fio.read_sigmet(file,file_field_names=True)

        # Create a latitude string        
        if radar.latitude['units'] == 'degrees_north':
            rlat = str(radar.latitude['data'])[1:-1]+'N'
        if radar.latitude['units'] == 'degrees_south':
            rlat = str(radar.latitude['data'])[1:-1]+'S'
        
        # Create a longitude string
        if radar.longitude['units'] == 'degrees_east':
            rlon = str(radar.longitude['data'])[1:-1]+'E'
        if radar.longitude['units'] == 'degrees_west':
            rlon = str(radar.longitude['data'])[1:-1]+'W'
            
        # Create field names, check for extended header
        if radar.metadata['sigmet_extended_header'] == 'true':
예제 #3
0
    # Search for the file(s)
    flist = glob(args.searchstring)

    # Create an output file if requested
    if args.make_file:
        OutTx = open(args.outFile, 'w')

    for file in flist:
        fLName, fileExt = os.path.splitext(file)
        fName = os.path.basename(file)

        # Get the file size
        fSize = os.path.getsize(file)

        # read in the file
        radar = fio.read_sigmet(file, file_field_names=True)

        # Create a latitude string
        if radar.latitude['units'] == 'degrees_north':
            rlat = str(radar.latitude['data'])[1:-1] + 'N'
        if radar.latitude['units'] == 'degrees_south':
            rlat = str(radar.latitude['data'])[1:-1] + 'S'

        # Create a longitude string
        if radar.longitude['units'] == 'degrees_east':
            rlon = str(radar.longitude['data'])[1:-1] + 'E'
        if radar.longitude['units'] == 'degrees_west':
            rlon = str(radar.longitude['data'])[1:-1] + 'W'

        # Create field names, check for extended header
        if radar.metadata['sigmet_extended_header'] == 'true':
예제 #4
0
def process_file(filename, outdir, verbose=False):
    """
    """

    if verbose:
        print 'Processing file: {}'.format(os.path.basename(filename))

    # Read radar data
    radar = read_sigmet(filename, exclude_fields=EXLUDE_FIELDS)

    # Radar significant detection
    # Includes Doppler velocity coherency, spectrum width coherency, and
    # minimum normalized coherent power
    gf = noise.velocity_coherency(
        radar, gatefilter=None, num_bins=VDOP_COHER_BINS,
        limits=VDOP_COHER_LIMITS, texture_window=TEXTURE_WINDOW,
        texture_sample=TEXTURE_SAMPLE, min_sigma=None, max_sigma=None,
        rays_wrap_around=False, remove_salt=False, fill_value=None,
        vdop_field=VDOP_FIELD, vdop_text_field=None, cohere_field=None,
        verbose=verbose)
    gf = noise.velocity_phasor_coherency(
        radar, gatefilter=gf, num_bins=PHASE_COHER_BINS,
        limits=PHASE_COHER_LIMITS, texture_window=TEXTURE_WINDOW,
        texture_sample=TEXTURE_SAMPLE, min_sigma=None, max_sigma=None,
        rays_wrap_around=False, remove_salt=False, fill_value=None,
        vdop_field=VDOP_FIELD, vdop_phase_field=None, phase_text_field=None,
        cohere_field=None, verbose=verbose)
    gf = noise.spectrum_width_coherency(
        radar, gatefilter=gf, num_bins=SW_COHER_BINS,
        limits=SW_COHER_LIMITS, texture_window=TEXTURE_WINDOW,
        texture_sample=TEXTURE_SAMPLE, min_sigma=None, max_sigma=None,
        rays_wrap_around=False, remove_salt=False, fill_value=None,
        width_field=SW_FIELD, width_text_field=None, cohere_field=None,
        verbose=verbose)
    gf = noise.significant_detection(
        radar, gatefilter=gf, remove_salt=True, salt_window=SALT_WINDOW,
        salt_sample=SALT_SAMPLE, fill_holes=False, dilate=DILATE,
        structure=None, min_ncp=MIN_NCP, ncp_field=NCP_FIELD,
        detect_field=None, verbose=verbose)

    # Compute radar texture fields
    texture_fields.add_textures(
        radar, fields=TEXTURE_FIELDS, gatefilter=None,
        texture_window=TEXTURE_WINDOW, texture_sample=TEXTURE_SAMPLE,
        min_sweep=None, max_sweep=None, min_range=None, max_range=None,
        min_ncp=None, rays_wrap_around=False, fill_value=None,
        ncp_field=NCP_FIELD)

    # Echo classification
    bayes.classify(
        radar, textures=TEXTURES, moments=MOMENTS, heights=HEIGHTS,
        nonprecip_map=None, gatefilter=gf, weights=1.0, class_prob='equal',
        min_inputs=3, zero=ZERO, ignore_inputs=IGNORE_INPUTS, use_insects=True,
        fill_value=None, cloud_field=CLOUD_FIELD, ground_field=GROUND_FIELD,
        insect_field=INSECT_FIELD, ncp_field=NCP_FIELD, verbose=verbose)

    # Filter ground clutter gates
    gf.exclude_equal(
        'radar_echo_classification', 1, exclude_masked=True, op='or')

    # Doppler velocity correction
    vdop_corr = dealias_region_based(
        radar, gatefilter=gf, interval_splits=3, interval_limits=None,
        skip_between_rays=2, skip_along_ray=2, centered=True, nyquist_vel=None,
        rays_wrap_around=True, keep_original=False, vel_field=VDOP_FIELD,
        corr_vel_field=CORR_VDOP_FIELD)
    radar.add_field(CORR_VDOP_FIELD, vdop_corr, replace_existing=False)

    # TODO: reflectivity correction

    # Parse metadata
    radar.metadata = _create_metadata(radar, filename)

    # ARM file name protocols
    date = datetime_from_radar(radar).strftime('%Y%m%d.%H%M%S')
    filename = 'sgpxsaprppicmac{}.{}.{}.cdf'.format(FN, DL, date)

    # Write CMAC NetCDF file
    write_cfradial(os.path.join(outdir, filename), radar, format=FORMAT,
                   arm_time_variables=True)

    return