Example #1
0
    def __init__(self, dataset, dry_depth=0.0):
        """
        initilize a Mudflats object

        :param dataset: a dataset with a depth Variable
        :type dataset: gridded.Dataset

        :param dry_depth=0.0: depth below which a tidal flat is considered dry
        :type dry_depth: float
        """

        if isinstance(dataset, gridded.Dataset):
            self.dataset = dataset
        else:
            self.dataset = gridded.Dataset(dataset)

        self.dry_depth = dry_depth

        try:
            self.depth = self.dataset.variables['depth']
        except KeyError:
            raise ValueError('Dataset must have a "depth" variable')
    def __init__(self, dataset, dry_vel_u=-9999.0, grid_topology=None):
        """
        initilize a Mudflats object for Matroos Files

        :param dataset: a dataset with a VELU Variable
        :type dataset: gridded.Dataset

        :param dry_vel_u=-9999.0: vel_u == -9999.0 which is masked/undefined meaning a tidal flat is considered dry
        :type dry_vel_u: float
        """
        # check if given dataset is instance of gridded.Dataset
        if isinstance(dataset, gridded.Dataset):
            self.dataset = dataset
        # add grid_topology for rgrid
        else:
            self.dataset = gridded.Dataset(dataset,
                                           grid_topology=grid_topology)

        self.dry_vel_u = dry_vel_u

        try:
            self.vel_u = self.dataset.variables['VELU']
        except KeyError:
            raise ValueError('Dataset must have a "VELU" variable')
def test_no_depth():
    ds = gridded.Dataset()
    ds.variables = {}  # just so there is something
    with pytest.raises(ValueError):
        tf = Delft3D_Mudflats(ds)
def dataset():
    ds = gridded.Dataset(infile)

    return ds
Example #5
0
                                      units="meters",
                                      data=depth,
                                      data_file=nc,
                                      grid_file=nc,
                                      fill_value=0,
                                      location='nodes',
                                      attributes=None,
                                      )

# global attributes
attrs = {key: nc.getncattr(key) for key in nc.ncattrs()}

# now make a dataset out of it all:
ds = gridded.Dataset(ncfile=None,
                     grid=grid,
                     variables={'Depth': depth_var},
                     attributes=attrs
                     )

## now learn a bit about it:

# What is its grid type?
print("The dataset Grid is:", type(ds.grid))

print("It has these variables:", list(ds.variables.keys()))

print('You can access the variable with indexing: ds["Depth"]')
Depth = ds["Depth"]

print(Depth)
Example #6
0
"""checking a not-properly compliant dataset"""

from datetime import datetime
import gridded

filename = "../PACE_GNOME_01V2.nc"
# filename = "../PACE_GNOME_01V2_fixed.nc"

# grid_topology = {"node_lat": "latc",
#                  "node_lon": "lonc",
#                  "center_lon": "lon",
#                  "center_lat": "lat",
#                  }

ds = gridded.Dataset("../PACE_GNOME_01V2.nc",
                     # grid_topology=grid_topology
                     )

print ds

depth = ds.variables['depth']

print depth
print depth.grid

# see if we can interpolate

points = ((5.2, 53.3), (5.3, 53.3), (5.2, 53.25))

# should be middle of the timespan in the file
time = datetime(2009, 1, 15)
Example #7
0
    SELFE=
    'http://comt.sura.org/thredds/dodsC/data/comt_1_archive/inundation_tropical/VIMS_SELFE/Hurricane_Rita_2D_final_run_without_waves'
)

bbox = [-95, -85, 27, 32]  # Set the bounding box.
variable = 'sea_surface_height_above_geoid'  # CF standard_name (or long_name, if no standard_name).
contour_levels = np.arange(-1, 5.0, 0.2)  # Set the contour levels.
start_time = datetime(2005, 9, 24, 5, 0, 0)  # UTC time

# ## Read the data
#

# In[3]:

# load up a gridded.dataset of the ADCIRC model:
ds = gridded.Dataset(models['SELFE'])

# ### Get some information about this dataset

# In[4]:

# Information about the grid:
print(ds.grid.info)

# In[5]:

# what variables are there"
print("Variables available and their standard names:\n")
for name, var in ds.variables.items():
    try:
        print(name, ":", var.attributes['standard_name'])