Reading NEXRAD Level III data obtained from NOAA got "Unknown or unsupported file format"

474 views
Skip to first unread message

Andy Zhang

unread,
Dec 16, 2020, 12:54:42 AM12/16/20
to Py-ART Users
Hello everyone, 

I have downloaded NEXRAD Level III data from NOAA (1). The downloaded file is attached here (2). However, when I trying to open them using pyart, I got the following errors with these scripts:

1.
> radar = pyart.io.read(filename='C:/Users/zhang/Documents/NEXRAD/A1/NWS_NEXRAD_NXL3_KPBZ_20150101000000_20150101235959.tar.gz')
TypeError: Unknown or unsupported file format: UNKNOWN

2. 
> radar = pyart.io.read(filename='C:/Users/zhang/Documents/NEXRAD/A1/NWS_NEXRAD_NXL3_KPBZ_20150101000000_20150101235959.tar')
>TypeError: Unknown or unsupported file format: UNKNOWN

3. 
> radar = pyart.io.read(filename='C:/Users/zhang/Documents/NEXRAD/A1/NWS_NEXRAD_NXL3_KPBZ_20150101000000_20150101235959/KPBZ_NXUS61_GSMPBZ_201501010004')
>TypeError: Unknown or unsupported file format: UNKNOWN 
 
 
Am I wrong in somewhere? I am a new student to PyART and radar data, looking forward to your suggestions! 






Scott Collis

unread,
Dec 16, 2020, 6:37:36 AM12/16/20
to Andy Zhang, Py-ART Users
You need to ungzip or pipe through python gzip library 

-sent from a mobile device-

On Dec 15, 2020, at 11:54 PM, Andy Zhang <andyz...@gmail.com> wrote:

Hello everyone, 
--
You received this message because you are subscribed to the Google Groups "Py-ART Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyart-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyart-users/52f34418-d9cd-4280-bed2-30cc20da9bfen%40googlegroups.com.

Andy Zhang

unread,
Dec 16, 2020, 11:24:22 AM12/16/20
to Py-ART Users
Thank you Scott! I implemented the ungzip function in my code, but the new problem is that there is an error "ValueError: embedded null byte". Could you please share me some insights on this error? Many thanks!

> Code:
import matplotlib.pyplot as plt
import pyart
import gzip 
import tarfile

# open the file
filename = './Data/NEXRAD/A1/NWS_NEXRAD_NXL3_KPBZ_20150101000000_20150101235959.tar.gz'

if filename.endswith("tar.gz"):
    tar = tarfile.open(filename, "r:gz")
    for member in tar.getmembers():
        f = tar.extractfile(member)
        if f is not None:
            content = f.read()
            radar = pyart.io.read(content, file_field_names=True)
            print(radar.info('compact'))

> Error message:
Traceback (most recent call last):
  File "/media/andy/b4a51c70-19cd-420f-91e4-c7adf2274c39/Proposal/scripts/nexrad_data_pyart.py", line 31, in <module>
    radar = pyart.io.read(content, file_field_names=True)
  File "/home/andy/miniconda3/envs/pyart_env/lib/python3.7/site-packages/pyart/io/auto_read.py", line 74, in read
    filetype = determine_filetype(filename)
  File "/home/andy/miniconda3/envs/pyart_env/lib/python3.7/site-packages/pyart/io/auto_read.py", line 182, in determine_filetype
    f = open(filename, 'rb')
ValueError: embedded null byte


Thanks,
Zhuoran

Collis, Scott M.

unread,
Dec 16, 2020, 11:26:52 AM12/16/20
to Andy Zhang, Py-ART Users

Are those level 3 files?

Andy Zhang

unread,
Dec 16, 2020, 11:28:08 AM12/16/20
to Py-ART Users
Yes, they are level 3 files.

Collis, Scott M.

unread,
Dec 16, 2020, 11:31:10 AM12/16/20
to Andy Zhang, Py-ART Users

Yeah.. my experience with Level 3 is limited.. if you are more interested in raw fields use level2

 

Have you tried taking one file and manually un-tar-gzipping and reading the files?

 

Zach, others, what is the state of a our level3 reading? Is it an Aux-io function?

Jason Webster

unread,
Dec 16, 2020, 11:39:57 AM12/16/20
to pyart...@googlegroups.com, scolli...@gmail.com, andyz...@gmail.com
After unzipping the level 3, the individual files can be read with the following

pyart.io.read_nexrad_level3(‘KPBZ_SDUS51_N0QPBZ_201501010006')


Collis, Scott M.

unread,
Dec 16, 2020, 11:44:32 AM12/16/20
to Jason Webster, pyart...@googlegroups.com, andyz...@gmail.com

So problem is not with Py-ART 😊

Maybe pipe from pythons gunzip -> tar

 

I have some code I did with level2 I will see if I can find…

Jason Webster

unread,
Dec 16, 2020, 11:51:12 AM12/16/20
to Collis, Scott M., pyart...@googlegroups.com, andyz...@gmail.com
I suggest using the following

    from sh import gunzip
    import tarfile

Use gunzip to expand and tarfile to extract out the level 3 files. 
If you want to be efficient, you can use tarfile to extract only the level 3 files you want

I’ll try to put together a complete example later.

Collis, Scott M.

unread,
Dec 16, 2020, 11:51:41 AM12/16/20
to Jason Webster, pyart...@googlegroups.com, andyz...@gmail.com

Here is my (very very old) code

https://github.com/scollis/houston/blob/master/scripts/stage_has.py

 

I use a tempfile.. This also manages ftping from NCEI

 

Note: I don’t use this anymore.. All my data comes from S3 now 😃

 

 

From: Jason Webster <jrwe...@atmosci.com>


Date: Wednesday, December 16, 2020 at 10:39 AM
To: <pyart...@googlegroups.com>
Cc: <scolli...@gmail.com>, <andyz...@gmail.com>

Collis, Scott M.

unread,
Dec 16, 2020, 11:51:58 AM12/16/20
to Jason Webster, pyart...@googlegroups.com, andyz...@gmail.com

Thanks Jason!

Reply all
Reply to author
Forward
0 new messages