예제 #1
0
def eg_simple_grouped():
    """Produce a grouped version of the simple containers example."""
    d_time = od('time', u=True)
    c_time = ov('time', dd=[d_time], aa=[oa('units', 'seconds')])

    d_ilat = od('lat', 10)
    d_ilon = od('lon', 5)
    idims = [d_ilat, d_ilon, d_time]
    d_mlat = od('lat', 24)
    d_mlon = od('lon', 16)
    mdims = [d_mlat, d_mlon, d_time]

    c_ilat = ov('lat', dd=[d_ilat], aa=[oa('units', 'degrees_north')])
    c_ilon = ov('lon', dd=[d_ilon], aa=[oa('units', 'degrees_east')])
    c_mlat = ov('lat', dd=[d_mlat], aa=[oa('units', 'degrees_north')])
    c_mlon = ov('lon', dd=[d_mlon], aa=[oa('units', 'degrees_east')])

    g = og('foo',
           dd=[d_time], vv=[c_time],
           gg=[og('instrument',
                  dd=[d_ilat, d_ilon],
                  vv=([c_ilat, c_ilon,
                       ov('rh', dd=idims, aa=[oa('_FillValue', -1)])]),
                  aa=[oa('container_type', 'simple'),
                      oa('measurement_platform', 'aircraft')]),
               og('model',
                  dd=[d_mlat, d_mlon],
                  vv=([c_mlat, c_mlon,
                       ov('rh', dd=mdims, aa=[oa('_FillValue', -1)])]),
                  aa=[oa('container_type', 'simple'),
                      oa('measurement_platform',
                         'global circulation model')])])
    _fake_complete(g)
    return g
예제 #2
0
def eg_simple_flat():
    """Produce a flat version of the simple containers example."""
    d_time = od('time', u=True)

    d_mlat = od('model___lat', 24)
    d_mlon = od('model___lon', 16)
    mdims = [d_mlat, d_mlon, d_time]
    d_ilat = od('instrument___lat', 10)
    d_ilon = od('instrument___lon', 5)
    idims = [d_ilat, d_ilon, d_time]

    collection_vars = [
        ov('instrument', data=np.array(0),
           aa=[oa('container_type', 'simple'),
               oa('container_dims', 'instrument___lat instrument___lon'),
               oa('container_vars',
                  'instrument___lat instrument___lon instrument___rh'),
               oa('measurement_platform', 'aircraft')]),
        ov('model', data=np.array(0),
           aa=[oa('container_type', 'simple'),
               oa('container_dims', 'model___lat model___lon'),
               oa('container_vars',
                  'model___lat model___lon model___rh'),
               oa('measurement_platform', 'global circulation model')])]

    data_vars = [
        ov('time', dd=[d_time], aa=[oa('units', 'seconds')]),
        ov('instrument___lat', dd=[d_ilat], aa=[oa('units', 'degrees_north')]),
        ov('instrument___lon', dd=[d_ilon], aa=[oa('units', 'degrees_east')]),
        ov('instrument___rh', dd=idims, aa=[oa('_FillValue', -1)]),
        ov('model___lat', dd=[d_mlat], aa=[oa('units', 'degrees_north')]),
        ov('model___lon', dd=[d_mlon], aa=[oa('units', 'degrees_east')]),
        ov('model___rh', dd=mdims, aa=[oa('_FillValue', -1)])]

    g = og('foo',
           dd=[d_mlat, d_mlon, d_ilat, d_ilon, d_time],
           vv=collection_vars + data_vars)
    _fake_complete(g)
    return g