创建NetCDF文件的DSL
项目描述
创建NetCDF文件的DSL。以下是一个简单示例
from pup import *
class Test(NetCDF):
# NC_GLOBAL attributes go here
history = 'Created for a test'
# dimensions need to be set explicitly only when they
# have no variable associated with them
dim0 = Dimension(2)
# variables that don't specify dimensions are assumed to
# be their own dimension
time = Variable(range(10), record=True, units='days since 2008-01-01')
# now a variable with dimensions (time,)
temperature = Variable(range(10), (time,), units='deg C')
Test.save('simple.nc')
这将生成以下NetCDF文件
netcdf simple { dimensions: dim0 = 2 ; time = UNLIMITED ; // (10 currently) variables: int time(time) ; time:units = "days since 2008-01-01" ; int temperature(time) ; temperature:units = "deg C" ; // global attributes: :history = "Created for a test" ; data: time = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; temperature = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; }
与使用常用NetCDF库执行相同操作的代码进行比较
f = netcdf_file("simple.nc", "w")
f.history = "Created for a test"
f.createDimension("dim0", 2)
f.createDimension("time", None)
time = f.createVariable("time", "i", ("time",))
time.units = "days since 2008-01-01"
time[:] = range(10)
temperature = f.createVariable("temperature", "i", ("time",))
temperature.units = "deg C"
temperature[:] = range(10)
默认情况下,它使用pupynere来创建文件,但可以覆盖;例如,我们可以使用netCDF4模块,这允许我们指定组
from netCDF4 import Dataset
class Test(NetCDF):
loader = Dataset
...
foo = Group(
dim = Dimension(10),
var = Variable(range(10)),
...
)
Test.save('simple.nc', format='NETCDF4')
变更日志
- 0.1.8:
确保首先创建记录维度。
- 0.1.7:
将字符串转换为字符数组。
- 0.1.6:
修复维度名称中的错误。
- 0.1.5:
添加了对使用netcdf4时组的支持。
- 0.1.4:
添加了对掩码数组的支持。
- 0.1.3:
在save()中将关键字参数传递给加载器。
- 0.1.2:
改进了可选加载器的检测。
- 0.1.1:
添加了pupynere依赖。
- 0.1:
初始发布。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
Puppy-0.1.8.tar.gz (3.6 kB 查看哈希值)
构建版本
Puppy-0.1.8-py2.7.egg (5.3 kB 查看哈希值)
关闭
Puppy-0.1.8.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 19ea7908bc997ab956f8ec79b23d9fcad134d5d72762d2bec97be79043192963 |
|
MD5 | 2302d7c0654dcfc11764f75ed87c521e |
|
BLAKE2b-256 | e6227275af67f649b89a9dd9ea0ca7bbb7155160251b93d616eaa474ad3247e2 |
关闭
Puppy-0.1.8-py2.7.egg 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | aee1c9f6c2e1d3e7617c2f1b60748bc03ad2b3d48987a457f9a465793f068eaa |
|
MD5 | 583d9853d46d6c371906cf62a0bda1da |
|
BLAKE2b-256 | d2d316fb5a7d3419266ef1e26e39bc6ef12b1f4357672605699e6d2e4980586c |