Reading Tar Files In Matlab

24 ビュー (過去 30 日間)
Joe Sheckles
Joe Sheckles 2020 年 2 月 20 日
回答済み: Harsh 2024 年 10 月 12 日
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

回答 (1 件)

Harsh
Harsh 2024 年 10 月 12 日
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.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by