예제 #1
0
print("\n**Tutorial**\n")

print("\n**Sample datasets**\n")

print("\n**Import**\n")

import cf

cf.CF()

print("\n**Field construct**\n")

print("\n**Reading field constructs from datasets**\n")

x = cf.read('file.nc')
type(x)
len(x)
y = cf.read('*.nc')
len(y)
z = cf.read(['file.nc', 'precipitation_flux.nc'])
len(z)
try:
    y = cf.read('$PWD')
except:
    pass
else:
    raise Exception("This should have failed!")
y = cf.read('$PWD', ignore_read_error=True)
len(y)

print("\n**Inspection**\n")
예제 #2
0
import datetime
import faulthandler
import os
import unittest

import numpy

faulthandler.enable()  # to debug seg faults and timeouts

import netCDF4

import cf

VN = cf.CF()


def _make_contiguous_file(filename):
    n = netCDF4.Dataset(filename, "w", format="NETCDF3_CLASSIC")

    n.Conventions = "CF-" + VN
    n.featureType = "timeSeries"

    n.createDimension("station", 4)
    n.createDimension("obs", 24)
    n.createDimension("name_strlen", 8)
    n.createDimension("bounds", 2)

    lon = n.createVariable("lon", "f8", ("station", ))
    lon.standard_name = "longitude"
    lon.long_name = "station longitude"
    lon.units = "degrees_east"