Java Code Examples for ucar.nc2.constants.AxisType#Time
The following examples show how to use
ucar.nc2.constants.AxisType#Time .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DapperDataset.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static PointObsDataset factory(NetcdfDataset ds) throws IOException { Variable latVar = null, timeVar = null; // identify key variables List axes = ds.getCoordinateAxes(); for (int i = 0; i < axes.size(); i++) { CoordinateAxis axis = (CoordinateAxis) axes.get(i); if (axis.getAxisType() == AxisType.Lat) latVar = axis; if (axis.getAxisType() == AxisType.Time) timeVar = axis; } // lat, lon are always in the outer; gotta use name to fetch wrapping variable Structure outerSequence = getWrappingParent(ds, latVar); // depth may be in inner or outer boolean isProfile = getWrappingParent(ds, timeVar) == outerSequence; if (isProfile) return new DapperPointDataset(ds); else return new DapperStationDataset(ds); }
Example 2
Source File: Time2DOffsetCoordSys.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private CoverageCoordAxis makeScalarTimeCoord(double val, CoverageCoordAxis1D runAxisSubset) { String name = "constantForecastTime"; String desc = "forecast time"; AttributeContainerMutable atts = new AttributeContainerMutable(name); atts.addAttribute(new Attribute(CDM.UNITS, runAxisSubset.getUnits())); atts.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME)); atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); atts.addAttribute(new Attribute(CF.CALENDAR, runAxisSubset.getCalendar().toString())); CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(name, runAxisSubset.getUnits(), desc, DataType.DOUBLE, AxisType.Time, atts, CoverageCoordAxis.DependenceType.scalar, null, CoverageCoordAxis.Spacing.regularPoint, 1, val, val, 0.0, null, null); builder.setIsSubset(true); return new CoverageCoordAxis1D(builder); }
Example 3
Source File: Cosmic1Convention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) { String name = v.getShortName(); if (name.equals("time")) { return AxisType.Time; } if (name.equals("Lat") || name.equals("GEO_lat")) { return AxisType.Lat; } if (name.equals("Lon") || name.equals("GEO_lon")) { return AxisType.Lon; } // if (name.equals("xLeo") ) return AxisType.GeoX; // if (name.equals("yLeo") ) return AxisType.GeoY; if (name.equals("MSL_alt")) { return AxisType.Height; } return null; }
Example 4
Source File: M3IOConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected AxisType getAxisType(VariableDS.Builder ve) { String vname = ve.shortName; if (vname.equalsIgnoreCase("x")) return AxisType.GeoX; if (vname.equalsIgnoreCase("y")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("time")) return AxisType.Time; if (vname.equalsIgnoreCase("level")) return AxisType.GeoZ; return null; }
Example 5
Source File: Cosmic1Convention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) { String name = v.getShortName(); if (name.equals("time")) { return AxisType.Time; } if (name.equals("Lat") || name.equals("GEO_lat")) { return AxisType.Lat; } if (name.equals("Lon") || name.equals("GEO_lon")) { return AxisType.Lon; } // if (name.equals("xLeo") ) return AxisType.GeoX; // if (name.equals("yLeo") ) return AxisType.GeoY; if (name.equals("MSL_alt")) { return AxisType.Height; } return null; }
Example 6
Source File: GDVConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected AxisType getAxisType(VariableDS.Builder v) { String vname = v.shortName; if (vname.equalsIgnoreCase("x") || findAlias(v).equalsIgnoreCase("x")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon") || vname.equalsIgnoreCase("longitude") || findAlias(v).equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y") || findAlias(v).equalsIgnoreCase("y")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat") || vname.equalsIgnoreCase("latitude") || findAlias(v).equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("lev") || findAlias(v).equalsIgnoreCase("lev") || (vname.equalsIgnoreCase("level") || findAlias(v).equalsIgnoreCase("level"))) return AxisType.GeoZ; if (vname.equalsIgnoreCase("z") || findAlias(v).equalsIgnoreCase("z") || (vname.equalsIgnoreCase("altitude") || vname.equalsIgnoreCase("depth"))) return AxisType.Height; if (vname.equalsIgnoreCase("time") || findAlias(v).equalsIgnoreCase("time")) return AxisType.Time; return super.getAxisType(v); }
Example 7
Source File: ADASConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) { Variable v = (Variable) ve; String vname = v.getShortName(); if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag")) return AxisType.GeoZ; if (vname.equalsIgnoreCase("Z")) return AxisType.Height; if (vname.equalsIgnoreCase("time")) return AxisType.Time; String unit = ve.getUnitsString(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; } return null; }
Example 8
Source File: ADASConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected AxisType getAxisType(VariableDS.Builder vb) { String vname = vb.shortName; if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag")) return AxisType.GeoZ; if (vname.equalsIgnoreCase("Z")) return AxisType.Height; if (vname.equalsIgnoreCase("time")) return AxisType.Time; String unit = vb.getUnits(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; } return null; }
Example 9
Source File: Suomi.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) { String name = v.getShortName(); if (name.equals("time_offset")) return AxisType.Time; if (name.equals("lat")) return AxisType.Lat; if (name.equals("lon")) return AxisType.Lon; if (name.equals("height")) return AxisType.Height; return null; }
Example 10
Source File: WRFConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) { Variable v = (Variable) ve; String vname = v.getShortName(); if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag")) return AxisType.GeoZ; if (vname.equalsIgnoreCase("Z")) return AxisType.Height; if (vname.equalsIgnoreCase("time") || vname.equalsIgnoreCase("times")) return AxisType.Time; String unit = ve.getUnitsString(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; } return null; }
Example 11
Source File: WRFConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @Nullable protected AxisType getAxisType(VariableDS.Builder v) { String vname = v.shortName; if (vname.equalsIgnoreCase("x") || vname.equalsIgnoreCase("x_stag")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y") || vname.equalsIgnoreCase("y_stag")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("z") || vname.equalsIgnoreCase("z_stag")) return AxisType.GeoZ; if (vname.equalsIgnoreCase("Z")) return AxisType.Height; if (vname.equalsIgnoreCase("time") || vname.equalsIgnoreCase("times")) return AxisType.Time; String unit = v.getUnits(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; } return null; }
Example 12
Source File: NUWGConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected AxisType getAxisType(VariableDS.Builder v) { String vname = v.shortName; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase(xaxisName)) return AxisType.GeoX; if (vname.equalsIgnoreCase(yaxisName)) return AxisType.GeoY; if (vname.equalsIgnoreCase("record")) return AxisType.Time; String dimName = v.getFirstDimensionName(); if ((dimName != null) && dimName.equalsIgnoreCase("record")) { // wow thats bad! return AxisType.Time; } String unit = v.getUnits(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; if (SimpleUnit.isCompatible("sec", unit)) return null; } return AxisType.GeoZ; // AxisType.GeoZ; }
Example 13
Source File: NUWGConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) { Variable v = (Variable) ve; String vname = v.getShortName(); if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase(xaxisName)) return AxisType.GeoX; if (vname.equalsIgnoreCase(yaxisName)) return AxisType.GeoY; if (vname.equalsIgnoreCase("record")) return AxisType.Time; Dimension dim = v.getDimension(0); if ((dim != null) && dim.getShortName().equalsIgnoreCase("record")) { // wow thats bad! return AxisType.Time; } String unit = ve.getUnitsString(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; if (SimpleUnit.isCompatible("sec", unit)) return null; } return AxisType.GeoZ; // AxisType.GeoZ; }
Example 14
Source File: CoardsConventions.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override @Nullable protected AxisType getAxisType(VariableDS.Builder vb) { String unit = vb.getUnits(); if (unit == null) { return null; } unit = unit.trim(); if (unit.equalsIgnoreCase("degrees_east") || unit.equalsIgnoreCase("degrees_E") || unit.equalsIgnoreCase("degreesE") || unit.equalsIgnoreCase("degree_east") || unit.equalsIgnoreCase("degree_E") || unit.equalsIgnoreCase("degreeE")) { return AxisType.Lon; } if (unit.equalsIgnoreCase("degrees_north") || unit.equalsIgnoreCase("degrees_N") || unit.equalsIgnoreCase("degreesN") || unit.equalsIgnoreCase("degree_north") || unit.equalsIgnoreCase("degree_N") || unit.equalsIgnoreCase("degreeN")) { return AxisType.Lat; } if (SimpleUnit.isDateUnit(unit)) { return AxisType.Time; } // look for other z coordinate if (SimpleUnit.isCompatible("mbar", unit)) { return AxisType.Pressure; } if (unit.equalsIgnoreCase("level") || unit.equalsIgnoreCase("layer") || unit.equalsIgnoreCase("sigma_level")) { return AxisType.GeoZ; } String positive = vb.getAttributeContainer().findAttributeString(CF.POSITIVE, null); if (positive != null) { if (SimpleUnit.isCompatible("m", unit)) { return AxisType.Height; } else { return AxisType.GeoZ; } } // a bad idea, but CDC SST relies on it : // :Source = "NOAA/National Climatic Data Center"; // :Contact = "Dick Reynolds, email: [email protected] & Chunying Liu, email: [email protected]"; // :netcdf_Convention = "COARDS"; // if (checkForMeter && SimpleUnit.isCompatible("m", unit)) // return AxisType.Height; return null; }
Example 15
Source File: COARDSConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected AxisType getAxisType(NetcdfDataset ncDataset, VariableEnhanced v) { String unit = v.getUnitsString(); if (unit == null) return null; unit = unit.trim(); if (unit.equalsIgnoreCase("degrees_east") || unit.equalsIgnoreCase("degrees_E") || unit.equalsIgnoreCase("degreesE") || unit.equalsIgnoreCase("degree_east") || unit.equalsIgnoreCase("degree_E") || unit.equalsIgnoreCase("degreeE")) return AxisType.Lon; if (unit.equalsIgnoreCase("degrees_north") || unit.equalsIgnoreCase("degrees_N") || unit.equalsIgnoreCase("degreesN") || unit.equalsIgnoreCase("degree_north") || unit.equalsIgnoreCase("degree_N") || unit.equalsIgnoreCase("degreeN")) return AxisType.Lat; if (SimpleUnit.isDateUnit(unit)) { return AxisType.Time; } // look for other z coordinate if (SimpleUnit.isCompatible("mbar", unit)) return AxisType.Pressure; if (unit.equalsIgnoreCase("level") || unit.equalsIgnoreCase("layer") || unit.equalsIgnoreCase("sigma_level")) return AxisType.GeoZ; String positive = ncDataset.findAttValueIgnoreCase((Variable) v, CF.POSITIVE, null); if (positive != null) { if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; else return AxisType.GeoZ; } // a bad idea, but CDC SST relies on it : // :Source = "NOAA/National Climatic Data Center"; // :Contact = "Dick Reynolds, email: [email protected] & Chunying Liu, email: [email protected]"; // :netcdf_Convention = "COARDS"; // if (checkForMeter && SimpleUnit.isCompatible("m", unit)) // return AxisType.Height; return null; }
Example 16
Source File: AWIPSsatConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected AxisType getAxisType(NetcdfDataset ds, VariableEnhanced ve) { Variable v = (Variable) ve; String vname = v.getShortName(); String units = v.getUnitsString(); if (units.equalsIgnoreCase(CDM.LON_UNITS)) return AxisType.Lon; if (units.equalsIgnoreCase(CDM.LAT_UNITS)) return AxisType.Lat; if (vname.equalsIgnoreCase("x")) return AxisType.GeoX; if (vname.equalsIgnoreCase("lon")) return AxisType.Lon; if (vname.equalsIgnoreCase("y")) return AxisType.GeoY; if (vname.equalsIgnoreCase("lat")) return AxisType.Lat; if (vname.equalsIgnoreCase("record")) return AxisType.Time; Dimension dim = v.getDimension(0); if ((dim != null) && dim.getShortName().equalsIgnoreCase("record")) return AxisType.Time; String unit = ve.getUnitsString(); if (unit != null) { if (SimpleUnit.isCompatible("millibar", unit)) return AxisType.Pressure; if (SimpleUnit.isCompatible("m", unit)) return AxisType.Height; } return AxisType.GeoZ; }
Example 17
Source File: CoordinateSystem.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Constructor. * * @param ds the containing dataset * @param axes Collection of type CoordinateAxis, must be at least one. * @param coordTrans Collection of type CoordinateTransform, may be empty or null. * @deprecated Use CoordinateSystem.builder() */ @Deprecated public CoordinateSystem(NetcdfDataset ds, Collection<CoordinateAxis> axes, Collection<CoordinateTransform> coordTrans) { this.ds = ds; this.coordAxes = new ArrayList<>(axes); this.name = makeName(coordAxes); if (coordTrans != null) this.coordTrans = new ArrayList<>(coordTrans); for (CoordinateAxis axis : coordAxes) { // look for AxisType AxisType axisType = axis.getAxisType(); if (axisType != null) { if (axisType == AxisType.GeoX) xAxis = lesserRank(xAxis, axis); if (axisType == AxisType.GeoY) yAxis = lesserRank(yAxis, axis); if (axisType == AxisType.GeoZ) zAxis = lesserRank(zAxis, axis); if (axisType == AxisType.Time) tAxis = lesserRank(tAxis, axis); if (axisType == AxisType.Lat) latAxis = lesserRank(latAxis, axis); if (axisType == AxisType.Lon) lonAxis = lesserRank(lonAxis, axis); if (axisType == AxisType.Height) hAxis = lesserRank(hAxis, axis); if (axisType == AxisType.Pressure) pAxis = lesserRank(pAxis, axis); if (axisType == AxisType.Ensemble) ensAxis = lesserRank(ensAxis, axis); if (axisType == AxisType.RadialAzimuth) aziAxis = lesserRank(aziAxis, axis); if (axisType == AxisType.RadialDistance) radialAxis = lesserRank(radialAxis, axis); if (axisType == AxisType.RadialElevation) elevAxis = lesserRank(elevAxis, axis); } // collect dimensions List<Dimension> dims = axis.getDimensionsAll(); domain.addAll(dims); } }
Example 18
Source File: Time2DCoordSys.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private CoverageCoordAxis makeCFTimeCoord(CoverageCoordAxis1D runAxisSubset, CoverageCoordAxis1D timeAxisSubset) { String name = timeAxisSubset.getName() + "Forecast"; String desc = "forecast time"; AttributeContainerMutable atts = new AttributeContainerMutable(name); atts.addAttribute(new Attribute(CDM.UNITS, runAxisSubset.getUnits())); atts.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME)); atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); atts.addAttribute(new Attribute(CF.CALENDAR, runAxisSubset.getCalendar().toString())); if (runAxisSubset.getNcoords() == 1) { CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(); builder.name = name; builder.units = runAxisSubset.getUnits(); builder.description = desc; builder.dataType = DataType.DOUBLE; builder.axisType = AxisType.Time; builder.attributes = atts; builder.dependenceType = CoverageCoordAxis.DependenceType.dependent; builder.setDependsOn(timeAxisSubset.getName()); builder.spacing = timeAxisSubset.getSpacing(); builder.ncoords = timeAxisSubset.ncoords; builder.isSubset = true; // conversion from timeOffset to runtime units double offset = timeAxisSubset.getOffsetInTimeUnits(runAxis.getRefDate(), timeAxisSubset.getRefDate()); switch (timeAxisSubset.getSpacing()) { case regularInterval: case regularPoint: builder.startValue = timeAxisSubset.getStartValue() + offset; builder.endValue = timeAxisSubset.getEndValue() + offset; break; case contiguousInterval: case irregularPoint: case discontiguousInterval: builder.values = timeAxisSubset.getValues(); // this is a copy for (int i = 0; i < builder.values.length; i++) builder.values[i] += offset; break; } return new CoverageCoordAxis1D(builder); } return null; }
Example 19
Source File: HdfEos.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private AxisType addAxisType(Variable.Builder v) { String name = v.shortName; if (name.equalsIgnoreCase("Latitude") || name.equalsIgnoreCase("GeodeticLatitude")) { v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString())); v.addAttribute(new Attribute(CDM.UNITS, CDM.LAT_UNITS)); return AxisType.Lat; } else if (name.equalsIgnoreCase("Longitude")) { v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString())); v.addAttribute(new Attribute(CDM.UNITS, CDM.LON_UNITS)); return AxisType.Lon; } else if (name.equalsIgnoreCase("Time")) { v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); if (v.getAttributeContainer().findAttribute(CDM.UNITS) == null) { /* * from http://newsroom.gsfc.nasa.gov/sdptoolkit/hdfeosfaq.html * HDF-EOS uses the TAI93 (International Atomic Time) format. This means that time is stored as the number of * elapsed seconds since January 1, 1993 (negative values represent times prior to this date). * An 8 byte floating point number is used, producing microsecond accuracy from 1963 (when leap second records * became available electronically) to 2100. The SDP Toolkit provides conversions from other date formats to and * from TAI93. Other representations of time can be entered as ancillary data, if desired. * For lists and descriptions of other supported time formats, consult the Toolkit documentation or write to * [email protected]. */ v.addAttribute(new Attribute(CDM.UNITS, "seconds since 1993-01-01T00:00:00Z")); v.addAttribute(new Attribute(CF.CALENDAR, "TAI")); /* * String tit = ncfile.findAttValueIgnoreCase(v, "Title", null); * if (tit != null && tit.contains("TAI93")) { * // Time is given in the TAI-93 format, i.e. the number of seconds passed since 01-01-1993, 00:00 UTC. * v.addAttribute(new Attribute(CDM.UNITS, "seconds since 1993-01-01T00:00:00Z")); * v.addAttribute(new Attribute(CF.CALENDAR, "TAI")); * } else { // who the hell knows ?? * v.addAttribute(new Attribute(CDM.UNITS, "seconds since 1970-01-01T00:00:00Z")); * } */ } return AxisType.Time; } else if (name.equalsIgnoreCase("Pressure")) { v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Pressure.toString())); return AxisType.Pressure; } else if (name.equalsIgnoreCase("Altitude")) { v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Height.toString())); v.addAttribute(new Attribute(CF.POSITIVE, CF.POSITIVE_UP)); // probably return AxisType.Height; } return null; }
Example 20
Source File: Time2DOffsetCoordSys.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private CoverageCoordAxis makeCFTimeCoord(CoverageCoordAxis1D runAxisSubset, CoverageCoordAxis1D timeAxisSubset) { String name = timeAxisSubset.getName() + "Forecast"; String desc = "forecast time"; AttributeContainerMutable atts = new AttributeContainerMutable(name); atts.addAttribute(new Attribute(CDM.UNITS, runAxisSubset.getUnits())); atts.addAttribute(new Attribute(CF.STANDARD_NAME, CF.TIME)); atts.addAttribute(new Attribute(CDM.LONG_NAME, desc)); atts.addAttribute(new Attribute(CF.CALENDAR, runAxisSubset.getCalendar().toString())); if (runAxisSubset.getNcoords() == 1) { CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder(); builder.name = name; builder.units = runAxisSubset.getUnits(); builder.description = desc; builder.dataType = DataType.DOUBLE; builder.axisType = AxisType.Time; builder.attributes = atts; builder.dependenceType = CoverageCoordAxis.DependenceType.dependent; builder.setDependsOn(timeAxisSubset.getName()); builder.spacing = timeAxisSubset.getSpacing(); builder.ncoords = timeAxisSubset.ncoords; builder.isSubset = true; // conversion from timeOffset to runtime units double offset = timeAxisSubset.getOffsetInTimeUnits(runAxis.getRefDate(), timeAxisSubset.getRefDate()); switch (timeAxisSubset.getSpacing()) { case regularInterval: case regularPoint: builder.startValue = timeAxisSubset.getStartValue() + offset; builder.endValue = timeAxisSubset.getEndValue() + offset; break; case contiguousInterval: case irregularPoint: case discontiguousInterval: builder.values = timeAxisSubset.getValues(); // this is a copy for (int i = 0; i < builder.values.length; i++) builder.values[i] += offset; break; } return new CoverageCoordAxis1D(builder); } return null; }