Example #1
0
def test_bad_grid(tmpdir):
    grid = RectilinearField((np.arange(12),))
    var_0_data = np.arange(grid.get_point_count())
    grid.add_field("var_0", var_0_data, centering="point")

    with tmpdir.as_cwd():
        with pytest.raises(TypeError):
            tofile("test-1d", grid)
Example #2
0
def test_bad_grid():
    grid = RectilinearField((np.arange(12), ))
    var_0_data = np.arange(grid.get_point_count())
    grid.add_field('var_0', var_0_data, centering='point')

    with cd_temp() as _:
        with assert_raises(TypeError):
            tofile('test-1d', grid)
def rectilinear_3d_field():
    field = RectilinearField(
        [-1, 0, 1],
        [2, 4, 6],
        [10, 20, 30],
        coordinate_names=("elevation", "latitude", "longitude"),
        units=("m", "degrees_north", "degrees_east"),
    )
    data = np.arange(field.get_point_count(), dtype=float)
    field.add_field("air__temperature", data, centering="point", units="F")
    return field
Example #4
0
def rectilinear_3d_field():
    field = RectilinearField(
        [-1, 0, 1],
        [2, 4, 6],
        [10, 20, 30],
        coordinate_names=("elevation", "latitude", "longitude"),
        units=("m", "degrees_north", "degrees_east"),
    )
    data = np.arange(field.get_point_count(), dtype=float)
    field.add_field("air__temperature", data, centering="point", units="F")
    return field
Example #5
0
def test_rectilinear(tmpdir, ndims):
    coords = [np.arange(dim) for dim in np.random.randint(1, 101, ndims)]
    field = RectilinearField(*coords, units=["m"] * ndims)

    data = np.arange(field.get_point_count())
    field.add_field("Elevation", data, centering="point")

    attrs = dict(description="Example {0}D nc file".format(ndims),
                 author="pytest")

    with tmpdir.as_cwd():
        field_tofile(field, "rectilinear.nc", attrs=attrs, append=True)

        assert os.path.isfile("rectilinear.nc")
def rectilinear_2d_field():
    field = RectilinearField([-1, 0, 1], [2, 4, 6])
    data = np.arange(field.get_point_count())
    field.add_field("air__temperature", data, centering="point", units="F")
    return field
Example #7
0
def rectilinear_2d_field():
    field = RectilinearField([-1, 0, 1], [2, 4, 6])
    data = np.arange(field.get_point_count())
    field.add_field("air__temperature", data, centering="point", units="F")
    return field