当前位置: 首页>>代码示例>>Java>>正文


Java Dimension类代码示例

本文整理汇总了Java中ucar.nc2.Dimension的典型用法代码示例。如果您正苦于以下问题:Java Dimension类的具体用法?Java Dimension怎么用?Java Dimension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Dimension类属于ucar.nc2包,在下文中一共展示了Dimension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMetadataAndDataVariablesForScalars

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Creates metadata and data variables for the given exchangeItems and/or ensembleExchangeItems in the given netcdfFile, if not present yet.
 * Each exchangeItem stores a scalar timeseries for a single location (and a single ensemble member).
 * All exchangeItems must use the same ensemble member indices.
 */
public static void createMetadataAndDataVariablesForScalars(NetcdfFileWriter netcdfFileWriter,
															List<IExchangeItem> exchangeItems, Map<String, Map<Integer, IExchangeItem>> ensembleExchangeItems, Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap, String stationNameVarName,
															String stationDimensionVarName,
															int stationCount, int ensembleMemberCount) {

	//create stations variable.
	Dimension stationDimension = createStationsVariable(netcdfFileWriter, stationNameVarName, stationDimensionVarName, stationCount);

	//create realization variable.
	Dimension realizationDimension = null;
	if (ensembleMemberCount > 0) {
		realizationDimension = createRealizationVariable(netcdfFileWriter, ensembleMemberCount);
	}

	//create data variables.
	NetcdfUtils.createDataVariables(netcdfFileWriter, exchangeItems, ensembleExchangeItems, realizationDimension, stationDimension, timeInfoTimeDimensionMap, null);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:23,代码来源:NetcdfUtils.java

示例2: createMetadataAndDataVariablesForGrids

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Creates metadata for the given exchangeItem in the given netcdfFile, if not present yet.
 */
public static void createMetadataAndDataVariablesForGrids(NetcdfFileWriter netcdfFileWriter, List<IExchangeItem> exchangeItems, Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap,
		Map<IGeometryInfo, GridVariableProperties> geometryInfoGridVariablePropertiesMap) {

	int[] uniqueTimeVariableCount = new int[]{0};
	int[] uniqueGeometryCount = new int[]{0};
	for (IExchangeItem exchangeItem : exchangeItems) {
		//create time coordinate variable, if not present yet.
		Dimension timeDimension = null;
		ITimeInfo timeInfo = exchangeItem.getTimeInfo();
		if (timeInfo != null && timeInfo.getTimes() != null) {//if variable depends on time.
			timeDimension = createTimeVariable(netcdfFileWriter, timeInfo, uniqueTimeVariableCount, timeInfoTimeDimensionMap);
		}

		//create spatial coordinate variables, if not present yet.
		//this only adds spatial dimensions, this does not add spatial variables with coordinates,
		//because the coordinates are usually not available in exchangeItems that come from models.
		if (!GeometryUtils.isScalar(exchangeItem.getGeometryInfo())) {//if grid.
			createGridVariables(netcdfFileWriter, exchangeItem.getGeometryInfo(), uniqueGeometryCount, geometryInfoGridVariablePropertiesMap);
		}

		//create data variable.
		createDataVariable(netcdfFileWriter, exchangeItem, timeDimension, null, null, geometryInfoGridVariablePropertiesMap);
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:28,代码来源:NetcdfUtils.java

示例3: createTimeVariable

import ucar.nc2.Dimension; //导入依赖的package包/类
private static Dimension createTimeVariable(NetcdfFileWriter netcdfFileWriter, ITimeInfo timeInfo, int[] uniqueTimeVariableCount, Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap) {
	Dimension timeDimension = timeInfoTimeDimensionMap.get(timeInfo);

	if (timeDimension == null) {//if timeVariable with correct times not yet present.
		//create time dimension and variable.
		//for each unique timeDimension use a unique numbered variable name, like e.g.
		//time, time2, time3, etc.
		uniqueTimeVariableCount[0]++;
		String postfix = uniqueTimeVariableCount[0] <= 1 ? "" : String.valueOf(uniqueTimeVariableCount[0]);
		String timeVariableName = TIME_VARIABLE_NAME + postfix;
		int timeCount = timeInfo.getTimes().length;
		timeDimension = createTimeVariable(netcdfFileWriter, timeVariableName, timeCount, NetcdfUtils.createTimeUnitString());

		//put timeDimension in map so that it can be re-used later by other variables in the same file.
		timeInfoTimeDimensionMap.put(timeInfo, timeDimension);
	}

	return timeDimension;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:20,代码来源:NetcdfUtils.java

示例4: createDataVariables

import ucar.nc2.Dimension; //导入依赖的package包/类
private static void createDataVariables(NetcdfFileWriter netcdfFileWriter, Collection<IExchangeItem> exchangeItems, Dimension realizationDimension, Dimension stationDimension,
		Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap, Map<IGeometryInfo, GridVariableProperties> geometryInfoGridVariablePropertiesMap, int[] uniqueTimeVariableCount) {

	for (IExchangeItem item : exchangeItems) {
		String variableName = getVariableName(item);
		if (netcdfFileWriter.findVariable(variableName) != null) {//if variable already exists.
			//if the variable already exists, we do not need to add it again. This can happen for scalar time series.
			continue;
		}

		//if variable does not exist yet.
		//create time coordinate variable, if not present yet.
		//assume that all exchangeItems for a given parameter have identical time records. TODO validate this. AK
		Dimension timeDimension = null;
		ITimeInfo timeInfo = item.getTimeInfo();
		if (timeInfo != null && timeInfo.getTimes() != null) {//if variable depends on time.
			timeDimension = createTimeVariable(netcdfFileWriter, timeInfo, uniqueTimeVariableCount, timeInfoTimeDimensionMap);
		}
		NetcdfUtils.createDataVariable(netcdfFileWriter, item, timeDimension, realizationDimension, stationDimension, geometryInfoGridVariablePropertiesMap);
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:22,代码来源:NetcdfUtils.java

示例5: writeMetadata

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Writes all metadata variables for the given maps to the given netcdfFile, i.e. times and spatial coordinates.
 */
public static void writeMetadata(NetcdfFileWriter netcdfFileWriter, Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap,
								 Map<IGeometryInfo, GridVariableProperties> geometryInfoGridVariablePropertiesMap,
								 String stationNameVarName,
								 List<String> stationIdList, List<Integer> ensembleMemberIndexList) throws Exception {

	//write time variable values.
	NetcdfUtils.writeTimeVariablesValues(netcdfFileWriter, timeInfoTimeDimensionMap);

	//write geometry variable values.
	NetcdfUtils.writeGridVariablesValues(netcdfFileWriter, geometryInfoGridVariablePropertiesMap);

	//write station_id if available.
	NetcdfUtils.writeStationIdVariableValues(netcdfFileWriter, stationNameVarName, stationIdList);

	//write realization variable values.
	NetcdfUtils.writeRealizationVariableValues(netcdfFileWriter, ensembleMemberIndexList);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:21,代码来源:NetcdfUtils.java

示例6: writeTimeVariablesValues

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Write values for all time variables that are present.
 *
 * @param netcdfFileWriter
 * @param timeInfoTimeDimensionMap
 * @throws Exception
 */
public static void writeTimeVariablesValues(NetcdfFileWriter netcdfFileWriter,
		Map<ITimeInfo, Dimension> timeInfoTimeDimensionMap) throws Exception {

	for (Map.Entry<ITimeInfo, Dimension> entry : timeInfoTimeDimensionMap.entrySet()) {
		ITimeInfo timeInfo = entry.getKey();
		Dimension timeDimension = entry.getValue();

		Variable timeVariable = netcdfFileWriter.findVariable(timeDimension.getShortName());
		String timeUnitString = timeVariable.findAttribute(UNITS_ATTRIBUTE_NAME).getStringValue();
		DateUnit dateUnit = new DateUnit(timeUnitString);

		double[] times = timeInfo.getTimes();
		ArrayDouble.D1 timesArray = new ArrayDouble.D1(times.length);
		for (int n = 0; n < times.length; n++) {
			double newTime = dateUnit.makeValue(new Date(Time.mjdToMillies(times[n])));
			timesArray.set(n, newTime);
		}

		netcdfFileWriter.write(timeVariable, timesArray);
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:29,代码来源:NetcdfUtils.java

示例7: writeEmpty

import ucar.nc2.Dimension; //导入依赖的package包/类
public void writeEmpty (String netcdfFilename) throws Exception {
    ArrayList<Dimension> dimList = new ArrayList<Dimension>();
    IntermediateNetcdfFile nfile;
    try {
        nfile = new IntermediateNetcdfFile(netcdfFilename, false);
    } catch (LASException e) {
        throw new Exception("Cannot create empty file.");
    }
    NetcdfFileWriteable netcdfFile = nfile.getNetcdfFile();
    Dimension index = netcdfFile.addDimension("index", 1);
    dimList.add(index);
    netcdfFile.addVariable(time, DataType.DOUBLE, dimList);
    ArrayDouble.D1 data = new ArrayDouble.D1(1);
    Double d = new Double("-9999.");
    data.set(0, d);
    netcdfFile.addGlobalAttribute("query_result", "No data found to match this request.");
    netcdfFile.create();
    netcdfFile.write(time, data);
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:20,代码来源:TabledapTool.java

示例8: hasGeoYAxisWithLatEquivalence

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Checks for geo Y axis with lat equivalence.
 * 
 * @return true if GeoX axis exists among coordinate axes and if there is a longitude variable equivalence
 *         (Variable whose name is 'longitude' and with at least two dimensions X/Y).
 * @throws MotuException
 */
public boolean hasGeoYAxisWithLatEquivalence() throws MotuException {
    CoordinateAxis coord = getGeoYAxis();
    if (coord == null) {
        return false;
    }

    Variable var = findLatitudeIgnoreCase();

    if (var == null) {
        return false;
    }

    List<Dimension> listDims = var.getDimensions();

    return hasGeoXYDimensions(listDims);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:24,代码来源:NetCdfReader.java

示例9: hasGeoXAxisWithLonEquivalence

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Checks for geo X axis with lon equivalence.
 * 
 * @return true if GeoX axis exists among coordinate axes and if there is a longitude variable
 *         equivalence) (Variable whose name isa longitude name' and with at least two dimensions X/Y).
 * @throws MotuException
 */
public boolean hasGeoXAxisWithLonEquivalence() throws MotuException {
    CoordinateAxis coord = getGeoXAxis();
    if (coord == null) {
        return false;
    }

    Variable var = findLongitudeIgnoreCase();

    if (var == null) {
        return false;
    }

    List<Dimension> listDims = var.getDimensions();

    return hasGeoXYDimensions(listDims);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:24,代码来源:NetCdfReader.java

示例10: getCoordinateVariable

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Gets the coordinate variable.
 * 
 * @param dim the dim
 * @param ds the ds
 * 
 * @return the coordinate variable
 * @throws MotuException
 * 
 */
public static CoordinateAxis getCoordinateVariable(Dimension dim, NetcdfDataset ds) throws MotuException {

    Variable variable = null;
    try {
        variable = NetCdfReader.getVariable(dim.getName(), ds);
    } catch (NetCdfVariableNotFoundException e) {
        throw new MotuException(
                ErrorType.NETCDF_LOADING,
                String.format("Error in getCoordinateVariable - Unable to get variable '%s'", dim.getName()),
                e);
    }

    if (variable == null) {
        return null;
    }
    if (!variable.isCoordinateVariable()) {
        return null;
    }
    if (!(variable instanceof CoordinateAxis)) {
        return null;
    }

    return (CoordinateAxis) variable;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:35,代码来源:NetCdfReader.java

示例11: getCoordinateVariables

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Gets the coordinate variables.
 * 
 * @param var the var
 * @param ds the net cdf dataset
 * 
 * @return the coordinate variables
 * 
 * @throws MotuNotImplementedException the motu not implemented exception
 * @throws MotuException the net cdf variable not found exception
 */
public static List<Variable> getCoordinateVariables(Variable var, NetcdfDataset ds) throws MotuNotImplementedException, MotuException {

    List<Variable> listCoordVars = new ArrayList<Variable>();

    if (var instanceof CoordinateAxis) {
        return listCoordVars;
    }

    List<Dimension> listDims = var.getDimensions();
    for (Dimension dim : listDims) {
        Variable dimCoordVars = NetCdfReader.getCoordinateVariable(dim, ds);
        listCoordVars.add(dimCoordVars);
    }

    return listCoordVars;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:28,代码来源:NetCdfReader.java

示例12: getDimensionsAsString

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Gets the dimensions as string.
 * 
 * @return the dimensions as a string.
 */
public String getDimensionsAsString() {
    StringBuffer buff = new StringBuffer();
    int count = dimensionsSize();
    if (count <= 0) {
        return "-";
    }
    buff.append("(");
    for (int i = 0; i < count; i++) {
        Dimension dim = this.dimensions.get(i);
        if (i > 0) {
            buff.append(", ");
        }
        buff.append(dim.getName());
    }
    buff.append(")");
    return buff.toString();
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:23,代码来源:ParameterMetaData.java

示例13: getOutputDimensionValues

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Gets the lengths of each output dimension of a variable .
 * 
 * @param var varaible to get dimension
 * @return an array that contains the lengths of each dimension of the variable
 */
public int[] getOutputDimensionValues(Variable var) {

    int rank = var.getRank();
    int[] outDimValues = new int[rank];

    for (int i = 0; i < rank; i++) {
        outDimValues[i] = -1;
        Dimension outDim = dimHash.get(var.getDimension(i).getName());
        if (outDim == null) {
            continue;
        }
        outDimValues[i] = outDim.getLength();
    }
    return outDimValues;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:22,代码来源:NetCdfWriter.java

示例14: initGeoYAxisWithLatEquivalence

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Checks for geo Y axis with lat equivalence.
 * 
 * @param netCdfReader the net cdf reader
 * 
 * @return true if GeoX axis exists among coordinate axes and if there is a longitude variable equivalence
 *         (Variable whose name is 'longitude' and with at least two dimensions X/Y).
 * 
 * @throws MotuException the motu exception
 */
public void initGeoYAxisWithLatEquivalence(ProductMetaData productMetaData) throws MotuException {
    CoordinateAxis coord = productMetaData.getGeoYAxis();
    if (coord == null) {
        productMetaData.setGeoYAxisWithLatEquivalence(false);
    }

    ParameterMetaData parameterMetaData = productMetaData.findLatitudeIgnoreCase();

    if (parameterMetaData == null) {
        productMetaData.setGeoYAxisWithLatEquivalence(false);
    } else {
        List<Dimension> listDims = parameterMetaData.getDimensions();
        productMetaData.setGeoYAxisWithLatEquivalence(netCdfReader.hasGeoXYDimensions(listDims));
    }

}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:27,代码来源:OpenDapProductMetadataReader.java

示例15: initGeoXAxisWithLatEquivalence

import ucar.nc2.Dimension; //导入依赖的package包/类
/**
 * Checks for geo X axis with lon equivalence.
 * 
 * @param netCdfReader the net cdf reader
 * 
 * @return true if GeoX axis exists among coordinate axes and if there is a longitude variable equivalence
 *         (Variable whose name is 'longitude' and with at least two dimensions X/Y).
 * 
 * @throws MotuException the motu exception
 */
public void initGeoXAxisWithLatEquivalence(ProductMetaData productMetaData) throws MotuException {
    CoordinateAxis coord = productMetaData.getGeoXAxis();
    if (coord == null) {
        productMetaData.setGeoXAxisWithLatEquivalence(false);
    }

    ParameterMetaData parameterMetaData = productMetaData.findLongitudeIgnoreCase();

    if (parameterMetaData == null) {
        productMetaData.setGeoXAxisWithLatEquivalence(false);
    } else {
        List<Dimension> listDims = parameterMetaData.getDimensions();
        productMetaData.setGeoXAxisWithLatEquivalence(netCdfReader.hasGeoXYDimensions(listDims));
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:26,代码来源:OpenDapProductMetadataReader.java


注:本文中的ucar.nc2.Dimension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。