Java Code Examples for ucar.nc2.constants.CDM#LON_UNITS
The following examples show how to use
ucar.nc2.constants.CDM#LON_UNITS .
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: AWIPSConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, int n, String xname) { double min = findAttributeDouble(ds, "xMin"); double max = findAttributeDouble(ds, "xMax"); double d = findAttributeDouble(ds, "dx"); if (Double.isNaN(min) || Double.isNaN(max) || Double.isNaN(d)) return null; CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, CDM.LON_UNITS, "longitude"); v.setValues(n, min, d); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString())); double maxCalc = min + d * n; parseInfo.format("Created Lon Coordinate Axis (max calc= %f shoule be = %f)%n", maxCalc, max); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("%n"); return v; }
Example 2
Source File: ThreddsMetadata.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setBoundingBox(LatLonRect bb) { LatLonPointImpl llpt = bb.getLowerLeftPoint(); LatLonPointImpl urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new Range(llpt.getLongitude(), bb.getWidth(), 0.0, CDM.LON_UNITS); this.northsouth = new Range(llpt.getLatitude(), height, 0.0, CDM.LAT_UNITS); if ((bb.getWidth() > 358) && (height > 178)) setGlobal(true); // LOOK ?? }
Example 3
Source File: GradsDimension.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Make a new GradsDimension from the values * * @param name the dimension name * @param size the dimension size * @param mapping the dimension mapping type */ public GradsDimension(String name, int size, String mapping) { this.name = name; this.size = size; this.mapping = mapping; levels = new ArrayList<>(); if (name.equalsIgnoreCase(GradsDataDescriptorFile.XDEF)) { unitName = CDM.LON_UNITS; } else if (name.equalsIgnoreCase(GradsDataDescriptorFile.YDEF)) { unitName = CDM.LAT_UNITS; } else if (name.equalsIgnoreCase(GradsDataDescriptorFile.ZDEF)) { unitName = "hPa"; } }
Example 4
Source File: AWIPSsatConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, int nx, String xname) { CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, CDM.LON_UNITS, "longitude"); v.setValues(nx, startx, dx); parseInfo.format("Created X Coordinate Axis = "); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("%n"); return v; }
Example 5
Source File: NsslRadarMosaicConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addCoordSystem(NetcdfDataset ds) { double lat = ds.findGlobalAttributeIgnoreCase("Latitude").getNumericValue().doubleValue(); double lon = ds.findGlobalAttributeIgnoreCase("Longitude").getNumericValue().doubleValue(); double dlat = ds.findGlobalAttributeIgnoreCase("LatGridSpacing").getNumericValue().doubleValue(); double dlon = ds.findGlobalAttributeIgnoreCase("LonGridSpacing").getNumericValue().doubleValue(); int time = ds.findGlobalAttributeIgnoreCase("Time").getNumericValue().intValue(); if (debug) System.out.println(ds.getLocation() + " Lat/Lon=" + lat + "/" + lon); int nlat = ds.findDimension("Lat").getLength(); int nlon = ds.findDimension("Lon").getLength(); // add lat CoordinateAxis v = new CoordinateAxis1D(ds, null, "Lat", DataType.FLOAT, "Lat", CDM.LAT_UNITS, "latitude coordinate"); v.setValues(nlat, lat, -dlat); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString())); ds.addCoordinateAxis(v); // add lon v = new CoordinateAxis1D(ds, null, "Lon", DataType.FLOAT, "Lon", CDM.LON_UNITS, "longitude coordinate"); v.setValues(nlon, lon, dlon); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString())); ds.addCoordinateAxis(v); // add time ds.addDimension(null, new Dimension("Time", 1)); v = new CoordinateAxis1D(ds, null, "Time", DataType.INT, "Time", "seconds since 1970-1-1 00:00:00", "time coordinate"); v.setValues(1, time, 1); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis(v); }
Example 6
Source File: NUWGConvention.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
CoordinateAxis makeXCoordAxis(NetcdfDataset ds, String xname) { CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, (0 == grid_code) ? CDM.LON_UNITS : "km", "synthesized X coord"); v.addAttribute( new Attribute(_Coordinate.AxisType, (0 == grid_code) ? AxisType.Lon.toString() : AxisType.GeoX.toString())); v.setValues(nx, startx, dx); ds.addCoordinateAxis(v); return v; }
Example 7
Source File: GempakStationFileIOSP.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Make a station variable * * @param varname variable name * @param firstDim station dimension * @return corresponding variable */ protected Variable makeStationVariable(String varname, Dimension firstDim) { String longName = varname; String unit = null; DataType type = DataType.CHAR; List<Dimension> dims = new ArrayList<>(); List<Attribute> attrs = new ArrayList<>(); if (firstDim != null) { dims.add(firstDim); } switch (varname) { case GempakStation.STID: longName = "Station identifier"; dims.add(DIM_LEN8); break; case GempakStation.STNM: longName = "WMO station id"; type = DataType.INT; break; case GempakStation.SLAT: longName = "latitude"; unit = CDM.LAT_UNITS; type = DataType.FLOAT; attrs.add(new Attribute(CF.STANDARD_NAME, "latitude")); break; case GempakStation.SLON: longName = "longitude"; unit = CDM.LON_UNITS; type = DataType.FLOAT; attrs.add(new Attribute(CF.STANDARD_NAME, "longitude")); break; case GempakStation.SELV: longName = "altitude"; unit = "meter"; type = DataType.FLOAT; attrs.add(new Attribute(CF.POSITIVE, CF.POSITIVE_UP)); attrs.add(new Attribute(CF.STANDARD_NAME, CF.STATION_ALTITUDE)); break; case GempakStation.STAT: longName = "state or province"; dims.add(DIM_LEN2); break; case GempakStation.COUN: longName = "country code"; dims.add(DIM_LEN2); break; case GempakStation.STD2: longName = "Extended station id"; dims.add(DIM_LEN4); break; case GempakStation.SPRI: longName = "Station priority"; type = DataType.INT; break; case GempakStation.SWFO: longName = "WFO code"; dims.add(DIM_LEN4); break; case GempakStation.WFO2: longName = "Second WFO code"; dims.add(DIM_LEN4); break; } Variable v = new Variable(ncfile, null, null, varname); v.setDataType(type); v.addAttribute(new Attribute(CDM.LONG_NAME, longName)); if (unit != null) { v.addAttribute(new Attribute(CDM.UNITS, unit)); } if (type == DataType.FLOAT) { v.addAttribute(new Attribute(CDM.MISSING_VALUE, RMISS)); } else if (type == DataType.INT) { v.addAttribute(new Attribute(CDM.MISSING_VALUE, IMISS)); } if (!attrs.isEmpty()) { for (Attribute attr : attrs) { v.addAttribute(attr); } } if (!dims.isEmpty()) { v.setDimensions(dims); } else { v.setDimensions((String) null); } return v; }
Example 8
Source File: ThreddsMetadata.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public GeospatialCoverage(LatLonRect bb, CoordinateAxis1D vaxis, double dX, double dY) { if (bb == null) { this.eastwest = null; this.northsouth = null; this.isGlobal = false; this.names = null; } else { LatLonPoint llpt = bb.getLowerLeftPoint(); LatLonPoint urpt = bb.getUpperRightPoint(); double height = urpt.getLatitude() - llpt.getLatitude(); this.eastwest = new GeospatialRange(llpt.getLongitude(), bb.getWidth(), dX, CDM.LON_UNITS); this.northsouth = new GeospatialRange(llpt.getLatitude(), height, dY, CDM.LAT_UNITS); if ((bb.getWidth() >= (360 - dX)) && (height >= (180 - dY))) { this.isGlobal = true; // serialize isGlobal this.names = new ArrayList<>(); this.names.add(new Vocab("global", null)); } else { this.isGlobal = false; this.names = null; } } if (vaxis == null) { this.updown = null; this.zpositive = null; } else { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new GeospatialRange(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { boolean isPositive = SimpleUnit.isCompatible("m", units); this.zpositive = isPositive ? CF.POSITIVE_UP : CF.POSITIVE_DOWN; } else { this.zpositive = CF.POSITIVE_UP; } } }