Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cdm/core/src/main/java/ucar/nc2/constants/CDM.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CDM {
public static final String ABBREV = "abbreviation";
public static final String ADD_OFFSET = "add_offset";
public static final String CONVENTIONS = "Conventions";
public static final String CF_VERSION = "CF-1.9";
public static final String DESCRIPTION = "description";
public static final String FILL_VALUE = "_FillValue";
public static final String HISTORY = "history";
Expand Down
21 changes: 15 additions & 6 deletions cdm/core/src/main/java/ucar/nc2/ft/DsgFeatureCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import ucar.nc2.Variable;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.time.CalendarDateRange;
import ucar.nc2.time.CalendarDateUnit;
import java.util.List;
Expand Down Expand Up @@ -36,20 +37,20 @@ public interface DsgFeatureCollection {
ucar.nc2.constants.FeatureType getCollectionFeatureType();

/**
* The name of time unit.
* The name of time unit, if there is a time axis.
*
* @return name of time unit string, may not be null
* @return name of time unit string, may be null
*/
@Nonnull
@Nullable
String getTimeName();


/**
* The time unit.
* The time unit, if there is a time axis.
*
* @return time unit, may not be null
* @return time unit, may be null
*/
@Nonnull
@Nullable
CalendarDateUnit getTimeUnit();

/**
Expand All @@ -68,6 +69,14 @@ public interface DsgFeatureCollection {
@Nullable
String getAltUnits();

/**
* The list of coordinate variables in the collection
*
* @return the list of coordinate variables, may be empty but not null;
*/
@Nonnull
List<CoordinateAxis> getCoordinateVariables();

/*
* Other variables needed for completeness, eg joined coordinate variables
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,6 @@ private static FeatureDataset wrapUnknown(NetcdfDataset ncd, ucar.nc2.util.Cance
if (ft != null)
return wrap(ft, ncd, task, errlog);

/*
* grids dont usually have a FeatureType attribute, so check these fist
* if (isGrid(ncd.getCoordinateSystems())) {
* ucar.nc2.dt.grid.GridDataset gds = new ucar.nc2.dt.grid.GridDataset(ncd); // LOOK
* if (gds.getGrids().size() > 0) {
* if (debug) System.out.println(" wrapUnknown found grids ");
* return gds;
* }
* }
*/

// find a Factory that claims this dataset
Object analysis = null;
FeatureDatasetFactory useFactory = null;
Expand All @@ -355,16 +344,6 @@ private static FeatureDataset wrapUnknown(NetcdfDataset ncd, ucar.nc2.util.Cance
}
}

/*
* try again as a Grid
* if (null == useFactory) {
* // if no datatype was requested, give em a GridDataset only if some Grids are found.
* ucar.nc2.dt.grid.GridDataset gds = new ucar.nc2.dt.grid.GridDataset(ncd);
* if (gds.getGrids().size() > 0)
* return gds;
* }
*/

// Fail
if (null == useFactory) {
errlog.format("Failed (wrapUnknown) to find Datatype Factory for= %s%n", ncd.getLocation());
Expand All @@ -375,26 +354,6 @@ private static FeatureDataset wrapUnknown(NetcdfDataset ncd, ucar.nc2.util.Cance
return useFactory.open(null, ncd, analysis, task, errlog);
}

/*
* static private boolean isGrid(java.util.List<CoordinateSystem> csysList) {
* CoordinateSystem use = null;
* for (CoordinateSystem csys : csysList) {
* if (use == null) use = csys;
* else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size())
* use = csys;
* }
*
* if (use == null) return false;
* CoordinateAxis lat = use.getLatAxis();
* CoordinateAxis lon = use.getLonAxis();
* if ((lat != null) && (lat.getSize() <= 1)) return false; // COARDS singletons
* if ((lon != null) && (lon.getSize() <= 1)) return false;
*
* // hueristics - cant say i like this, multidim point features could easily violate
* return (use.getRankDomain() > 2) && (use.getRankDomain() <= use.getRankRange());
* }
*/

/**
* Determine if factory type matches wanted feature type.
*
Expand Down
30 changes: 22 additions & 8 deletions cdm/core/src/main/java/ucar/nc2/ft/point/DsgCollectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package ucar.nc2.ft.point;

import ucar.nc2.Variable;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.DsgFeatureCollection;
import ucar.nc2.time.CalendarDateRange;
import ucar.nc2.time.CalendarDateUnit;
Expand All @@ -27,6 +28,7 @@ public abstract class DsgCollectionImpl implements DsgFeatureCollection {
protected String altName = "altitude";
protected String altUnits;
protected CollectionInfo info;
protected List<CoordinateAxis> coordVars;
protected List<Variable> extras; // variables needed to make CF/DSG writing work

protected DsgCollectionImpl(String name, CalendarDateUnit timeUnit, String altUnits) {
Expand All @@ -35,13 +37,19 @@ protected DsgCollectionImpl(String name, CalendarDateUnit timeUnit, String altUn
this.altUnits = altUnits;
}

protected DsgCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
protected DsgCollectionImpl(String name, List<CoordinateAxis> coordVars) {
this.name = name;
this.timeName = timeName;
this.timeUnit = timeUnit;
this.altName = altName;
this.altUnits = altUnits;
this.coordVars = coordVars;

for (CoordinateAxis coord : coordVars) {
if (coord.getAxisType().isTime()) {
this.timeUnit = CalendarDateUnit.of(null, coord.getUnitsString());
this.timeName = coord.getShortName();
} else if (coord.getAxisType().isVert()) {
this.altUnits = coord.getUnitsString();
this.altName = coord.getShortName();
}
}
}

@Nonnull
Expand All @@ -50,13 +58,13 @@ public String getName() {
return name;
}

@Nonnull
@Nullable
@Override
public String getTimeName() {
return timeName;
}

@Nonnull
@Nullable
@Override
public CalendarDateUnit getTimeUnit() {
return timeUnit;
Expand All @@ -74,6 +82,12 @@ public String getAltUnits() {
return altUnits;
}

@Nonnull
@Override
public List<CoordinateAxis> getCoordinateVariables() {
return this.coordVars;
}

@Nonnull
public List<Variable> getExtraVariables() {
return (extras == null) ? new ArrayList<>() : extras;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nonnull;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.PointFeature;
import ucar.nc2.ft.PointFeatureCollection;
import ucar.nc2.ft.PointFeatureIterator;
Expand All @@ -28,9 +30,8 @@ protected PointCollectionImpl(String name, CalendarDateUnit timeUnit, String alt
super(name, timeUnit, altUnits);
}

protected PointCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
super(name, timeName, timeUnit, altName, altUnits);
protected PointCollectionImpl(String name, List<CoordinateAxis> coordVars) {
super(name, coordVars);
}

@Nonnull
Expand Down Expand Up @@ -61,7 +62,7 @@ protected static class PointCollectionSubset extends PointCollectionImpl {
protected CalendarDateRange filter_date;

public PointCollectionSubset(PointCollectionImpl from, LatLonRect filter_bb, CalendarDateRange filter_date) {
super(from.name, from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
super(from.name, from.timeUnit, from.altUnits);
this.from = from;
this.filter_bb = filter_bb;
this.filter_date = filter_date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/
package ucar.nc2.ft.point;

import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.*;
import ucar.nc2.time.CalendarDateUnit;
import ucar.nc2.constants.FeatureType;
import javax.annotation.Nonnull;
import java.util.List;

/**
* Abstract superclass for multiply nested NestedPointFeatureCollection
Expand All @@ -25,9 +27,8 @@ protected PointFeatureCCCImpl(String name, CalendarDateUnit timeUnit, String alt
this.collectionFeatureType = collectionFeatureType;
}

protected PointFeatureCCCImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits, FeatureType collectionFeatureType) {
super(name, timeName, timeUnit, altName, altUnits);
protected PointFeatureCCCImpl(String name, List<CoordinateAxis> coords, FeatureType collectionFeatureType) {
super(name, coords);
this.collectionFeatureType = collectionFeatureType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
package ucar.nc2.ft.point;

import java.io.IOException;
import java.util.List;
import javax.annotation.Nonnull;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.PointFeatureCC;
import ucar.nc2.ft.PointFeatureIterator;
import ucar.nc2.time.CalendarDateRange;
Expand All @@ -29,9 +31,9 @@ protected PointFeatureCCImpl(String name, CalendarDateUnit timeUnit, String altU
this.collectionFeatureType = collectionFeatureType;
}

protected PointFeatureCCImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName, String altUnits,
FeatureType collectionFeatureType) {
super(name, timeName, timeUnit, altName, altUnits);

protected PointFeatureCCImpl(String name, List<CoordinateAxis> coords, FeatureType collectionFeatureType) {
super(name, coords);
this.collectionFeatureType = collectionFeatureType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

import javax.annotation.Nonnull;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.ProfileFeature;
import ucar.nc2.time.CalendarDateUnit;
import ucar.unidata.geoloc.LatLonPoint;

import java.util.List;

/**
* Abstract superclass for implementations of ProfileFeature.
*
Expand All @@ -31,9 +34,9 @@ public ProfileFeatureImpl(String name, CalendarDateUnit timeUnit, String altUnit
}
}

public ProfileFeatureImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName, String altUnits,
double lat, double lon, double time, int nfeatures) {
super(name, timeName, timeUnit, altName, altUnits);
public ProfileFeatureImpl(String name, List<CoordinateAxis> coords, double lat, double lon, double time,
Comment thread
tdrwenski marked this conversation as resolved.
int nfeatures) {
super(name, coords);
this.latlonPoint = LatLonPoint.create(lat, lon);
this.time = time;
if (nfeatures >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
package ucar.nc2.ft.point;

import java.io.IOException;
import java.util.List;

import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.PointFeatureCCIterator;
import ucar.nc2.ft.TrajectoryProfileFeature;
import ucar.nc2.ft.TrajectoryProfileFeatureCollection;
Expand All @@ -21,9 +24,12 @@

public abstract class SectionCollectionImpl extends PointFeatureCCCImpl implements TrajectoryProfileFeatureCollection {

protected SectionCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
super(name, timeName, timeUnit, altName, altUnits, FeatureType.TRAJECTORY_PROFILE);
protected SectionCollectionImpl(String name, CalendarDateUnit timeUnit, String altUnits) {
super(name, timeUnit, altUnits, FeatureType.TRAJECTORY_PROFILE);
}

protected SectionCollectionImpl(String name, List<CoordinateAxis> coords) {
super(name, coords, FeatureType.TRAJECTORY_PROFILE);
}

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

public abstract class SectionFeatureImpl extends PointFeatureCCImpl implements TrajectoryProfileFeature {

protected SectionFeatureImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
super(name, timeName, timeUnit, altName, altUnits, FeatureType.TRAJECTORY_PROFILE);

protected SectionFeatureImpl(String name, CalendarDateUnit timeUnit, String altUnits) {
super(name, timeUnit, altUnits, FeatureType.TRAJECTORY_PROFILE);
}

/////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Iterator;
import java.util.List;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.ft.PointFeatureCC;
import ucar.nc2.ft.PointFeatureCCIterator;
import ucar.nc2.ft.StationProfileFeature;
Expand All @@ -34,9 +35,8 @@ public StationProfileCollectionImpl(String name, CalendarDateUnit timeUnit, Stri
super(name, timeUnit, altUnits, FeatureType.STATION_PROFILE);
}

public StationProfileCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
super(name, timeName, timeUnit, altName, altUnits, FeatureType.STATION_PROFILE);
public StationProfileCollectionImpl(String name, List<CoordinateAxis> coordVars) {
super(name, coordVars, FeatureType.STATION_PROFILE);
}

// Double-check idiom for lazy initialization of instance fields. See Effective Java 2nd Ed, p. 283.
Expand Down Expand Up @@ -135,7 +135,7 @@ private static class StationProfileFeatureCollectionSubset extends StationProfil
private final List<StationFeature> stations;

StationProfileFeatureCollectionSubset(StationProfileCollectionImpl from, List<StationFeature> stations) {
super(from.getName(), from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
super(from.getName(), from.getTimeUnit(), from.getAltUnits());
this.from = from;
this.stations = stations;
}
Expand Down
Loading