Reading Tar Files In Matlab

28 views (last 30 days)
Joe Sheckles
Joe Sheckles on 20 Feb 2020
Answered: Harsh Sharma on 12 Oct 2024
There are a list of tar files
In the tar files, there should be hourly precipitation amounts and they should be designated by location (longitude or latitude or pixels).
I am told that it is possible for Matlab to import this data and organize (tabulate or analyze) the precipitation amounts according to location for each file.
I started with
filenames = untar('C:\Users\Joseph\Documents\NWS_NEXRAD_NXL2SR_KOKX_20100203140000_20100203145959.tar')
Then a few gz files would appear in the Current Folder window.
I would then write something lke
files = gunzip('KOKX20100203_145516_V03.gz')
This will produce a file with a name KOKX20100203_145516_V03
When I click table, it shows up in unicode.
So currently, I am even unable to get a legible table, let alone tabulate results according to location.
If anyone is able to help in any way, at any level (not necessarily even organizing by location, but just even reading or opening), that would be great.
Thanks,
J

Answers (1)

Harsh Sharma
Harsh Sharma on 12 Oct 2024
Hi Joe,
The link you have provided doesn’t seem to be working but I can provide you with general workflow to extract relevant data from tar file and use it to create a table in MATLAB.
You can use the “untar” and “gunzip” files to handle the “.tz” and “.gz” files respectively but after that the decompressed files may not be directly readable as text due to their binary or specific data format. You must read the extracted file based on its format.
For example, if you have NetCDF” file, you can read the file using “ncread” function and specify the variable name as below:
ncFile = 'KOKX20100203_145516_V03'; % Example file name
data = ncread(ncFile, 'precipitation'); % Replace 'precipitation' with the actual variable name
Check the following page to find more info regarding the scientific data formats supported in MATLAB - https://www.mathworks.com/help/matlab/scientific-data.html?s_tid=CRUX_lftnav
I hope this resolves your query.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!