Пример #1
0
        public float ReadFloatAttribute(string attributeName)
        {
            float ret = 0.0f;

            ucar.nc2.Attribute attrib = _file.findGlobalAttribute(attributeName);
            if (attrib.getDataType().isIntegral())
            {
                ret = (attrib.getValue(0) as java.lang.Number).intValue();
            }
            else if (attrib.getDataType().isFloatingPoint())
            {
                ret = (attrib.getValue(0) as java.lang.Float).floatValue();
            }
            return(ret);
        }
Пример #2
0
        private void _getMinAndInterval(ucar.nc2.Variable var, string minMaxStr, out double interval, out double minVal, out double count)
        {
            ucar.ma2.Array dataArr    = _util.GetAllVariableData(var);
            bool           stepExists = false;

            interval = 1.0; minVal = double.MaxValue; count = 0;
            java.util.List ncVarAtt = var.getAttributes();
            for (int attCount = 0; attCount < ncVarAtt.size(); attCount++)
            {
                ucar.nc2.Attribute varAtt  = (ucar.nc2.Attribute)ncVarAtt.get(attCount);
                string             attName = varAtt.getName();
                if (attName == "step")
                {
                    java.lang.Number attVal = (java.lang.Number)varAtt.getValue(0);
                    interval   = attVal.doubleValue();
                    stepExists = true;
                }
            }

            double prevVal = 0.0;
            int    minCount = 0, maxCount = (int)dataArr.getSize() - 1; count = 0;

            if (!string.IsNullOrEmpty(minMaxStr))
            {
                minCount = Convert.ToInt32(minMaxStr.Split(':')[0]);
                maxCount = Convert.ToInt32(minMaxStr.Split(':')[1]);
                count    = maxCount - minCount + 1;
            }
            else
            {
                count = maxCount + 1;
            }

            for (int dCount = minCount; dCount <= maxCount; dCount++)
            {
                ucar.ma2.Index dIndex = dataArr.getIndex();
                double         data   = dataArr.getDouble(dIndex.set(dCount));
                if (minVal >= data)
                {
                    minVal = data;
                }
                if (!stepExists)
                {
                    if (dCount > 0)
                    {
                        prevVal  = dataArr.getDouble(dIndex.set(dCount - 1));
                        interval = data - prevVal;
                    }
                }
            }
        }
Пример #3
0
 public string ReadStringAttribute(string attributeName)
 {
     ucar.nc2.Attribute attribute =
         _file.findGlobalAttribute("SIMULATION_START_DATE");
     return(attribute.getValue(0) as string);
 }