解压缩一个 netCDF 文件

huangapple go评论54阅读模式
英文:

Decompressing a netCDF file

问题

我有一个名为in.nc的压缩 netCDF 文件(_DeflateLevel=4)。我想要解压这个文件。

我已经尝试使用以下命令,但没有改变:

nccopy -d 0 in.nc out.nc

以下是in.nc的规格:

time_counter = UNLIMITED ; // (12 currently)
	y = 552 ;
	x = 552 ;
variables:
	float Q16c(time_counter, y, x) ;
		Q16c:long_name = "深层沉积有机物" ;
		Q16c:units = "mg C/m2" ;
		Q16c:online_operation = "average" ;
		Q16c:interval_operation = "900 s" ;
		Q16c:interval_write = "1 month" ;
		Q16c:cell_methods = "time: mean (interval: 900 s)" ;
		Q16c:_FillValue = 1.e+20f ;
		Q16c:missing_value = 1.e+20f ;
		Q16c:coordinates = "time_centered nav_lat nav_lon" ;
		Q16c:_Storage = "chunked" ;
		Q16c:_ChunkSizes = 1, 552, 552 ;
		Q16c:_DeflateLevel = 4 ;
		Q16c:_Endianness = "little" ;
英文:

I have a compressed netCDF file called in.nc with a (_DeflateLevel=4). I want to decompress the file.

I've already tried using the following command but it doesn't change anything:

nccopy -d 0 in.nc out.nc

Here are the in.nc specifications:

time_counter = UNLIMITED ; // (12 currently)
	y = 552 ;
	x = 552 ;
variables:
	float Q16c(time_counter, y, x) ;
		Q16c:long_name = "Deep Sediment Particulate organic Matter" ;
		Q16c:units = "mg C/m2" ;
		Q16c:online_operation = "average" ;
		Q16c:interval_operation = "900 s" ;
		Q16c:interval_write = "1 month" ;
		Q16c:cell_methods = "time: mean (interval: 900 s)" ;
		Q16c:_FillValue = 1.e+20f ;
		Q16c:missing_value = 1.e+20f ;
		Q16c:coordinates = "time_centered nav_lat nav_lon" ;
		Q16c:_Storage = "chunked" ;
		Q16c:_ChunkSizes = 1, 552, 552 ;
		Q16c:_DeflateLevel = 4 ;
		Q16c:_Endianness = "little" ;

答案1

得分: 2

解压缩使用NCO的压缩文件的方法很简单:

ncks -L 0 in.nc out.nc

附注:这种方法应该适用于大多数常见的编解码器,包括DEFLATE、Zstandard和Bzip2。

英文:

The way to decompress a compressed file with NCO is straightforward:

ncks -L 0 in.nc out.nc

p.s.: this method should work for the most common codecs, including DEFLATE, Zstandard, and Bzip2.

答案2

得分: 1

我认为在cdo中解压文件的方法是

cdo -z zip_0 copy in.nc out.nc

如果它们是使用2字节的shorts以及add_offsetscale_factor(例如ERA5等)进行压缩,那么可以通过以下方式将其解压缩为浮点数:

cdo unpack in.nc out.nc

或者

cdo -b f32 copy in.nc out.nc
英文:

I think the way to decompress files in cdo is

cdo -z zip_0 copy in.nc out.nc 

If they are compressed using 2 byte shorts with an add_offset and scale_factor (e.g. ERA5 etc) then you can decompress those by converting to float like this

cdo unpack in.nc out.nc 

or alternatively

cdo -b f32 copy in.nc out.nc 

huangapple
  • 本文由 发表于 2023年2月20日 00:46:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75501734.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定