Exemplo n.º 1
0
def loadFile(filename, limits):
    """
    Load a subset of the data from the given file, with the extent
    of the subset specified in the `limits` tuple

    :param str filename: str full path to file to load.

    :param tuple limits: tuple of index limits of a tile.

    :returns: 2-D `numpy.ndarray` of wind speed values.

    """

    (xmin, xmax, ymin, ymax) = limits

    try:
        ncobj = nctools.ncLoadFile(filename)
        ncobj_vmax = nctools.ncGetVar(ncobj, 'vmax')
        data_subset = ncobj_vmax[ymin:ymax, xmin:xmax]
        ncobj.close()

        if xmax < xmin or ymax < ymin:
            log.debug("max tile limits are not smaller than min")

        return data_subset

    except IOError:
        log.debug('{0} file does not exist'.format(filename))
        raise
Exemplo n.º 2
0
def loadFile(filename, limits):
    """
    Load a subset of the data from the given file, with the extent
    of the subset specified in the `limits` tuple

    :param str filename: str full path to file to load.

    :param tuple limits: tuple of index limits of a tile.

    :returns: 2-D `numpy.ndarray` of wind speed values.

    """

    (xmin, xmax, ymin, ymax) = limits

    ncobj = nctools.ncLoadFile(filename)
    ncobj_vmax = nctools.ncGetVar(ncobj, 'vmax')
    data_subset = ncobj_vmax[ymin:ymax, xmin:xmax]
    ncobj.close()
    return data_subset
Exemplo n.º 3
0
def loadFile(filename, limits):
    """
    Load a subset of the data from the given file, with the extent
    of the subset specified in the `limits` tuple

    :param str filename: str full path to file to load.

    :param tuple limits: tuple of index limits of a tile.

    :returns: 2-D `numpy.ndarray` of wind speed values.

    """

    (xmin, xmax, ymin, ymax) = limits

    ncobj = nctools.ncLoadFile(filename)
    ncobj_vmax = nctools.ncGetVar(ncobj, 'vmax')
    data_subset = ncobj_vmax[ymin:ymax, xmin:xmax]
    ncobj.close()
    return data_subset
Exemplo n.º 4
0
def getData(ncobj, varname, ij):
    var = ncGetVar(ncobj, varname)[:]
    lvar = ncGetVar(ncobj, 'l' + varname)[:]
    data = var
    data[ij] = lvar[ij]
    return data
    os.makedirs(options.outDir)
except:
    pass

################################################## Parte principal del codigo ##################################################
## Leer data desde .nc
inputNC = nctools.ncLoadFile(args[0])

## importar datos de los lugares desde tu .csv
locations = readLocationsFromFile(options.inLoc)

## Informacion sobre la estructura del .nc y las variables que contiene
nctools.ncFileInfo(args[0])

##leer variables
lons = nctools.ncGetVar(inputNC, "lon")
lats = nctools.ncGetVar(inputNC, "lat")
locs = nctools.ncGetVar(inputNC, "loc")
scales = nctools.ncGetVar(inputNC, "scale")
shps = nctools.ncGetVar(inputNC, "shp")
#valores del viento dict[years,lat,lon]=valor
windvals = nctools.ncGetVar(inputNC, "wspd")
windvals_up = nctools.ncGetVar(inputNC, "wspdupper")
windvals_down = nctools.ncGetVar(inputNC, "wspdlower")
years = nctools.ncGetVar(inputNC, "years")

lat = 28.35
lon = 268.4
lon = lon - 360

print lat, lon, windvals[1, lat, lon]