Пример #1
0
def test_msg15():
    """Check proper decoding of message type 15."""
    f = Level2File(
        get_test_data('KTLX20130520_201643_V06.gz', as_file_obj=False))
    data = f.clutter_filter_map['data']
    assert isinstance(data[0][0], list)
    assert f.clutter_filter_map['datetime'] == datetime(
        2013, 5, 19, 0, 0, 0, 315000)
Пример #2
0
 def __init__(self, filepath):
     from metpy.io.nexrad import Level2File
     self.f = Level2File(filepath)
     self.dtime = self.f.dt
     self.timestr = self.dtime.strftime('%Y%m%d%H%M%S')
     self.name = self.f.stid.decode()
     self.el = np.array([ray[0][0].el_angle for ray in self.f.sweeps])
     self.stationlon = self.f.sweeps[0][0][1].lon
     self.stationlat = self.f.sweeps[0][0][1].lat
Пример #3
0
def read_nexrad(fn, f):
    nex = f
    if fn.endswith('.gz'):
        nex = zlib.decompress(nex, 15 + 32)
    try:
        nex = Level2File(BytesIO(nex))
    except:
        nex = 0
    return nex
Пример #4
0
 def __init__(self, filepath):
     self.f = Level2File(filepath)
     dtime = self.f.dt
     self.timestr = dtime.strftime('%Y%m%d%H%M%S')
     self.name = self.f.stid.decode()
     self.el = np.array([ray[0][0].el_angle for ray in self.f.sweeps])
     self.stationlon = self.f.sweeps[0][0][1].lon
     self.stationlat = self.f.sweeps[0][0][1].lat
     self.level = None
     self.drange = None
     self.dtype = None
     self.reso = None
Пример #5
0
 def __init__(self, file: Any):
     r'''
     Parameters
     ----------
     file: str
         path directed to the file to read
     '''
     from metpy.io.nexrad import Level2File
     self.f = Level2File(file)
     self.scantime = self.f.dt
     self.name = self.f.stid.decode()
     self.el = np.array([ray[0][0].el_angle for ray in self.f.sweeps])
     self.stationlon = self.f.sweeps[0][0][1].lon
     self.stationlat = self.f.sweeps[0][0][1].lat
def data_extraction(user_site, curr_date):
    s3 = boto3.resource('s3',
                        config=Config(signature_version=botocore.UNSIGNED,
                                      user_agent_extra='Resource'))
    bucket = s3.Bucket('noaa-nexrad-level2')
    # making list of dates [ yyyy , mm , dd ]
    curr_date = str(curr_date).split('-')
    # making the date of correct format( yyyy/mm/dd )
    if (len(curr_date[2]) == 1):
        curr_date[2] = "0" + curr_date[2]
    # iterating through all the elements in the list
    # temporary variable
    temp2 = ''
    for obj in bucket.objects.filter(Prefix= ( curr_date[ 0 ] + '/' + curr_date[ 1 ] + '/' + curr_date[ 2 ] + '/' + user_site + '/' \
                        + user_site + curr_date[ 0 ] + curr_date[ 1 ] + curr_date[ 2 ] + '_' ) ):#'2017/01/01/KTLX/KTLX20170101_'):
        #f = Level2File(obj.get()[ 'Body' ])
        # temporary variable for location
        temp1 = temp2
        # to access the second most recent time
        temp2 = obj
    # after finding the latest element in the NEXRAD AWS directory
    # as per the current time.
    # Downloading that file
    f = Level2File(temp1.get()['Body'])
    # extracting mathemtical data from the weather data's class
    # to be passed upon in the future.
    sweep = 0
    # First item in ray is header, which has azimuth angle
    az = np.array([ray[0].az_angle for ray in f.sweeps[sweep]])
    # 5th item is a dict mapping a var name (byte string) to a tuple
    # of (header, data array)
    ref_hdr = f.sweeps[sweep][0][4][b'REF'][0]
    ref_range = np.arange(
        ref_hdr.num_gates) * ref_hdr.gate_width + ref_hdr.first_gate
    ref = np.array([ray[4][b'REF'][1] for ray in f.sweeps[sweep]])
    rho_hdr = f.sweeps[sweep][0][4][b'RHO'][0]
    rho_range = (np.arange(rho_hdr.num_gates + 1) -
                 0.5) * rho_hdr.gate_width + rho_hdr.first_gate
    rho = np.array([ray[4][b'RHO'][1] for ray in f.sweeps[sweep]])
    # converting all numpy arrays to list to be passed on as JSON objects
    plot_details = {
        "site": user_site,
        "date": curr_date,
        "ref_range": ref_range.tolist(),
        "ref": ref.tolist(),
        "rho_range": rho_range.tolist(),
        "rho": rho.tolist(),
        "az": az.tolist()
    }
    return plot_details
Пример #7
0
 def test_msg15(self):
     f = Level2File(
         get_test_data('KTLX20130520_201643_V06.gz', as_file_obj=False))
     data = f.clutter_filter_map['data']
     assert isinstance(data[0][0], list)
Пример #8
0
 def test_fobj(self):
     Level2File(get_test_data('Level2_KFTG_20150430_1419.ar2v'))
Пример #9
0
def read_level2_file(fname):
    Level2File(fname)
Пример #10
0
def test_level2_fobj():
    'Test reading NEXRAD level2 data from a file object'
    Level2File(get_test_data('Level2_KFTG_20150430_1419.ar2v'))
Пример #11
0
def test_level2(fname):
    'Test reading NEXRAD level 2 files from the filename'
    Level2File(get_test_data(fname, as_file_obj=False))
Пример #12
0
def test_msg15():
    'Check proper decoding of message type 15'
    f = Level2File(
        get_test_data('KTLX20130520_201643_V06.gz', as_file_obj=False))
    data = f.clutter_filter_map['data']
    assert isinstance(data[0][0], list)
Пример #13
0
def test_level2(fname, voltime):
    """Test reading NEXRAD level 2 files from the filename."""
    f = Level2File(get_test_data(fname, as_file_obj=False))
    assert f.dt == voltime