def generateCoordsAndData(nj, ni, delta_lat, delta_lon, latMin, latMax, lonMin, lonMax): """ Generate coordinate and point/cell data @param nj number of latitudes @param ni number of longitudes @param delta_lat rotated pole shift in latitude @param delta_lon rotated pole shift in longitude @return CubeList object containing point and cell data """ # generate the axes latsPrime = numpy.linspace(latMin, latMax, nj) lonsPrime = numpy.linspace(lonMin, lonMax, ni) # set the curvilinear coords and field lats, lons = grid_mapper.createCoords(latsPrime, lonsPrime, delta_lat=delta_lat, delta_lon=delta_lon) print('min/max lats: {} {}'.format(lats.min(), lats.max())) print('min/max lons: {} {}'.format(lons.min(), lons.max())) pointData = grid_mapper.createPointData(lats, lons) latCells, lonCells, cellData = grid_mapper.createCellData(lats, lons) pointCube = iris.cube.Cube(pointData, var_name='pointData', standard_name='air_temperature', cell_methods=None) latCoord = iris.coords.AuxCoord(lats, var_name='lat', standard_name='latitude', units='degrees_north') lonCoord = iris.coords.AuxCoord(lons, var_name='lon', standard_name='longitude', units='degrees_east') pointCube.add_aux_coord(latCoord, data_dims=(0, 1)) pointCube.add_aux_coord(lonCoord, data_dims=(0, 1)) cellCube = iris.cube.Cube(cellData, var_name='cellData', standard_name='air_temperature') latBounds, latMid = createBoundsArray(lats) lonBounds, lonMid = createBoundsArray(lons) cellAuxLat = iris.coords.AuxCoord(latMid, var_name='latMid', standard_name='latitude', units='degrees_north', bounds=latBounds) cellAuxLon = iris.coords.AuxCoord(lonMid, var_name='lonMid', standard_name='longitude', units='degrees_east', bounds=lonBounds) cellCube.add_aux_coord(cellAuxLat, data_dims=(0, 1)) cellCube.add_aux_coord(cellAuxLon, data_dims=(0, 1)) return iris.cube.CubeList([pointCube, cellCube])
def generateCoordsAndData(nj, ni, rhoMin=0.0, rhoMax=1.0, theMin=0.0, theMax=2 * math.pi): """ Generate coordinate and point/cell data @param nj number of y @param ni number of x @param rhoMin min radius @param rhoMax max radius @param theMin min angle @param theMax max angle @return CubeList object containing point and cell data """ # generate the axes rho = numpy.linspace(rhoMin, rhoMax, nj) the = numpy.linspace(theMin, theMax, ni) # set the curvilinear coords and field yy, xx = grid_mapper.createCoords( rho, the, radius=rhoMax, ) print('min/max x: {} {}'.format(xx.min(), xx.max())) print('min/max y: {} {}'.format(yy.min(), yy.max())) pointData = grid_mapper.createPointData(yy, xx) yyCells, xxCells, cellData = grid_mapper.createCellData(yy, xx) pointCube = iris.cube.Cube(pointData, var_name='pointData', standard_name='air_temperature', cell_methods=None) yyCoord = iris.coords.AuxCoord(yy, var_name='yy') xxCoord = iris.coords.AuxCoord(xx, var_name='xx') pointCube.add_aux_coord(yyCoord, data_dims=(0, 1)) pointCube.add_aux_coord(xxCoord, data_dims=(0, 1)) cellCube = iris.cube.Cube(cellData, var_name='cellData', standard_name='air_temperature') yyBounds, yyMid = createBoundsArray(yy) xxBounds, xxMid = createBoundsArray(xx) cellAuxYY = iris.coords.AuxCoord(yyMid, var_name='yyMid', bounds=yyBounds) cellAuxXX = iris.coords.AuxCoord(xxMid, var_name='xxMid', bounds=xxBounds) cellCube.add_aux_coord(cellAuxYY, data_dims=(0, 1)) cellCube.add_aux_coord(cellAuxXX, data_dims=(0, 1)) return iris.cube.CubeList([pointCube, cellCube])
def generateCoordsAndDataRectilinear(nj, ni, ymin, ymax, xmin, xmax): """ Generate coordinate and point/cell data @param nj number of y @param ni number of x @param ymin min y @param ymax max y @param xmin min x @param xmax max x @return CubeList object containing point and cell data """ # generate the axes y = numpy.linspace(ymin, ymax, nj) x = numpy.linspace(xmin, xmax, ni) # set the curvilinear coords and field yy = numpy.outer(y, numpy.ones((ni, ), numpy.float64)) xx = numpy.outer(numpy.ones((nj, ), numpy.float64), x) print('min/max x: {} {}'.format(xx.min(), xx.max())) print('min/max y: {} {}'.format(yy.min(), yy.max())) pointData = grid_mapper.createPointData(yy, xx) yyCells, xxCells, cellData = grid_mapper.createCellData(yy, xx) pointCube = iris.cube.Cube(pointData, var_name='pointData', standard_name='air_temperature', cell_methods=None) yyCoord = iris.coords.AuxCoord(yy, var_name='yy') xxCoord = iris.coords.AuxCoord(xx, var_name='xx') pointCube.add_aux_coord(yyCoord, data_dims=(0, 1)) pointCube.add_aux_coord(xxCoord, data_dims=(0, 1)) cellCube = iris.cube.Cube(cellData, var_name='cellData', standard_name='air_temperature') yyBounds, yyMid = createBoundsArray(yy) xxBounds, xxMid = createBoundsArray(xx) cellAuxYY = iris.coords.AuxCoord(yyMid, var_name='yyMid', bounds=yyBounds) cellAuxXX = iris.coords.AuxCoord(xxMid, var_name='xxMid', bounds=xxBounds) cellCube.add_aux_coord(cellAuxYY, data_dims=(0, 1)) cellCube.add_aux_coord(cellAuxXX, data_dims=(0, 1)) return iris.cube.CubeList([pointCube, cellCube])