Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed Handle multiple different time and altitude axes for GridAsPoint writer #1241

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
6f452f7
add timeName property with getter for DSG feature collection
mnlerman Jun 30, 2023
db4eab5
add timeName to DSG feature collection constructors
mnlerman Jun 30, 2023
6dbe983
rework writeHeader include all variables in the subset and use the co…
mnlerman Jun 30, 2023
579d250
write the record with the true name of the time coordinate if we can …
mnlerman Jun 30, 2023
dab3a40
remove unused argument from writeHeader. The StationPointFeature argu…
mnlerman Jun 30, 2023
74b1489
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Jun 30, 2023
98001a9
add coordinates outside of loop
mnlerman Jul 7, 2023
72bd77b
set timeName
mnlerman Jul 7, 2023
d998199
always add default time coordinate. add conditional to prevent duplic…
mnlerman Jul 7, 2023
672ef82
add constructors with timeName argument
mnlerman Jul 7, 2023
698c260
move everything I can to outside of the inner for loop
mnlerman Jul 19, 2023
b295e5f
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Jul 26, 2023
df60461
Merge remote-tracking branch 'origin/ncj-cf-point-writer' into ncj-cf…
mnlerman Jul 26, 2023
34989c0
rework header and record writing
mnlerman Aug 8, 2023
f1bdd82
apply spotless
mnlerman Aug 8, 2023
86a7793
return the number of records written plus small cleanups
mnlerman Aug 10, 2023
3e7da13
get correct variable name for matching
mnlerman Aug 11, 2023
5ecde7d
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Aug 24, 2023
e4b4475
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Aug 30, 2023
7cb43fb
loop over the station and break after one loop
mnlerman Sep 7, 2023
4966c05
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Sep 20, 2023
991c873
remove unused method, change argument type and use peeking iterator i…
mnlerman Sep 20, 2023
25f9485
Merge remote-tracking branch 'origin/ncj-cf-point-writer' into ncj-cf…
mnlerman Sep 20, 2023
600dc75
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Sep 20, 2023
7889139
add station index to test a collection of variables and stations at once
mnlerman Sep 21, 2023
38a4f9e
add test for multiple time series
mnlerman Sep 21, 2023
845369d
add check for time name
mnlerman Sep 22, 2023
a16f773
add check for time name
mnlerman Sep 22, 2023
a2ab0f7
Merge remote-tracking branch 'origin/ncj-cf-point-writer' into ncj-cf…
mnlerman Sep 22, 2023
b2951f3
add the beginings of tests for coverage as a profile with more than o…
mnlerman Sep 25, 2023
33d4782
build up test for two time axes for profiles. Add new function for te…
mnlerman Sep 25, 2023
0200404
add timeName arguments to constructors methods and method calls
mnlerman Sep 25, 2023
c7f1999
add ncml to use for testing
mnlerman Sep 27, 2023
ee7a77e
add tests for altitude name
mnlerman Sep 27, 2023
93c53d5
add altName attribute and add/change constructors to pass it up the c…
mnlerman Sep 27, 2023
c45fd86
remove unused constructors
mnlerman Sep 27, 2023
8fb11ba
spotless
mnlerman Sep 27, 2023
ed3fa61
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Sep 27, 2023
bbff255
use actual altName instead of generic stationAltName
mnlerman Sep 27, 2023
e6d7c4a
Merge remote-tracking branch 'origin/ncj-cf-point-writer' into ncj-cf…
mnlerman Sep 27, 2023
1c6fec6
move altName assignment to scope where its needed
mnlerman Sep 27, 2023
61f1da5
add altName to point writer. write header and write data
mnlerman Sep 27, 2023
e52089a
delet commented code
mnlerman Sep 27, 2023
d23434d
delete commented code
mnlerman Sep 27, 2023
9ec6658
remove old writeRecord method
mnlerman Sep 27, 2023
d684334
change condition and altName to be specific to the points in the station
mnlerman Oct 9, 2023
ad8b8bf
don't need to add station altitude variable for every station (just n…
mnlerman Oct 9, 2023
c66b052
move writeHeader outside of loop and loop over PointFeatureCollection…
mnlerman Oct 11, 2023
d55fe01
add constructors and getters for altName and timeName
mnlerman Oct 12, 2023
e093678
fix conditionals, use right timeName and altCoodName, loop over all s…
mnlerman Oct 12, 2023
c044d90
write header by looping over all stations in the StationTimeSeriesFea…
mnlerman Oct 12, 2023
bcd8403
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Oct 12, 2023
0d82bd4
use alt coord name instead of station alt name
mnlerman Oct 16, 2023
ffddf23
write altitude coordinate if it's not null
mnlerman Oct 16, 2023
915f783
write altitude if the point has an altitude, not the station
mnlerman Oct 16, 2023
a53f2c3
Merge remote-tracking branch 'origin/ncj-cf-point-writer' into ncj-cf…
mnlerman Oct 16, 2023
60696f9
don't add varaibles that are already there
mnlerman Oct 17, 2023
3fa6d3c
spotless
mnlerman Oct 17, 2023
9e5ab33
swap method ordering so that the PR dif is more clear
mnlerman Oct 18, 2023
e046a4a
dereference and remove old writeRecord method
mnlerman Oct 18, 2023
1cb89cc
constructors inside of private classes are private
mnlerman Oct 19, 2023
96ac0b9
use new constructor
mnlerman Oct 19, 2023
0a822f4
move timename write into conditional so it doesn't get written twice
mnlerman Oct 19, 2023
a8c3fb1
use new constructor
mnlerman Oct 19, 2023
8697d6c
Merge branch 'Unidata:maint-5.x' into ncj-cf-point-writer
mnlerman Oct 19, 2023
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
17 changes: 17 additions & 0 deletions cdm/core/src/main/java/ucar/nc2/ft/DsgFeatureCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public interface DsgFeatureCollection {
@Nonnull
ucar.nc2.constants.FeatureType getCollectionFeatureType();

/**
* The name of time unit.
*
* @return name of time unit string, may not be null
*/
@Nonnull
String getTimeName();


/**
* The time unit.
*
Expand All @@ -43,6 +52,14 @@ public interface DsgFeatureCollection {
@Nonnull
CalendarDateUnit getTimeUnit();

/**
* The altitude name string if it exists.
*
* @return altitude name string, may be null
*/
@Nullable
String getAltName();

/**
* The altitude unit string if it exists.
*
Expand Down
25 changes: 25 additions & 0 deletions cdm/core/src/main/java/ucar/nc2/ft/point/DsgCollectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,54 @@
public abstract class DsgCollectionImpl implements DsgFeatureCollection {

protected String name;
protected String timeName;
protected CalendarDateUnit timeUnit;
protected String altName;
protected String altUnits;
protected CollectionInfo info;
protected List<Variable> extras; // variables needed to make CF/DSG writing work

protected DsgCollectionImpl(String name, CalendarDateUnit timeUnit, String altUnits) {
this.name = name;
this.timeName = "time";
this.altName = "altitude";
this.timeUnit = timeUnit;
this.altUnits = altUnits;
}

protected DsgCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
this.name = name;
this.timeName = timeName;
this.timeUnit = timeUnit;
this.altName = altName;
this.altUnits = altUnits;
}

@Nonnull
@Override
public String getName() {
return name;
}

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

@Nonnull
@Override
public CalendarDateUnit getTimeUnit() {
return timeUnit;
}

@Nullable
@Override
public String getAltName() {
return altName;
}

@Nullable
@Override
public String getAltUnits() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ 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);
}

@Nonnull
@Override
public FeatureType getCollectionFeatureType() {
Expand Down Expand Up @@ -56,7 +61,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.getTimeUnit(), from.getAltUnits());
super(from.name, from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
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 @@ -29,6 +29,12 @@ 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);
this.collectionFeatureType = collectionFeatureType;
}

// All features in this collection have this feature type
@Nonnull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ public StationProfileFeatureImpl(String name, String desc, String wmoId, double
this.timeSeriesNpts = npts;
}

public StationProfileFeatureImpl(String name, String desc, String wmoId, double lat, double lon, double alt,
String timeName, CalendarDateUnit timeUnit, String altName, String altUnits, int npts) {
super(name, timeName, timeUnit, altName, altUnits, FeatureType.STATION_PROFILE);
station = new StationImpl(name, desc, wmoId, lat, lon, alt, npts);
this.timeSeriesNpts = npts;
}

public StationProfileFeatureImpl(Station s, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits, int npts) {
super(s.getName(), timeName, timeUnit, altName, altUnits, FeatureType.STATION_PROFILE);
this.station = s;
this.timeSeriesNpts = npts;
}

public StationProfileFeatureImpl(Station s, CalendarDateUnit timeUnit, String altUnits, int npts) {
super(s.getName(), timeUnit, altUnits, FeatureType.STATION_PROFILE);
this.station = s;
Expand Down Expand Up @@ -120,7 +134,7 @@ public static class StationProfileFeatureSubset extends StationProfileFeatureImp
private final CalendarDateRange dateRange;

public StationProfileFeatureSubset(StationProfileFeatureImpl from, CalendarDateRange filter_date) {
super(from.station, from.getTimeUnit(), from.getAltUnits(), -1);
super(from.station, from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits(), -1);
this.from = from;
this.dateRange = filter_date;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class StationTimeSeriesCollectionFlattened extends PointCollectionImpl {
protected StationTimeSeriesCollectionImpl from;

public StationTimeSeriesCollectionFlattened(StationTimeSeriesCollectionImpl from, CalendarDateRange dateRange) {
super(from.getName(), from.getTimeUnit(), from.getAltUnits());
super(from.getName(), from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
this.from = from;
if (dateRange != null) {
getInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public StationTimeSeriesCollectionImpl(String name, CalendarDateUnit timeUnit, S
super(name, timeUnit, altUnits, FeatureType.STATION);
}

public StationTimeSeriesCollectionImpl(String name, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits) {
super(name, timeName, timeUnit, altName, altUnits, FeatureType.STATION);
}

// Double-check idiom for lazy initialization of instance fields. See Effective Java 2nd Ed, p. 283.
protected StationHelper getStationHelper() {
if (stationHelper == null) {
Expand Down Expand Up @@ -130,7 +135,7 @@ private static class StationSubset extends StationTimeSeriesCollectionImpl {
private final List<StationFeature> stations;

StationSubset(StationTimeSeriesCollectionImpl from, List<StationFeature> stations) {
super(from.getName(), from.getTimeUnit(), from.getAltUnits());
super(from.getName(), from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
this.stations = stations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public StationTimeSeriesFeatureImpl(String name, String desc, String wmoId, doub
s = new StationFeatureImpl(name, desc, wmoId, lat, lon, alt, npts, sdata);
}

public StationTimeSeriesFeatureImpl(String name, String desc, String wmoId, double lat, double lon, double alt,
String timeName, CalendarDateUnit timeUnit, String altName, String altUnits, int npts, StructureData sdata) {
super(name, timeName, timeUnit, altName, altUnits);
s = new StationFeatureImpl(name, desc, wmoId, lat, lon, alt, npts, sdata);
}

public StationTimeSeriesFeatureImpl(StationFeature s, CalendarDateUnit timeUnit, String altUnits, int nfeatures) {
super(s.getName(), timeUnit, altUnits);
this.s = s;
Expand All @@ -40,6 +46,16 @@ public StationTimeSeriesFeatureImpl(StationFeature s, CalendarDateUnit timeUnit,
}
}

public StationTimeSeriesFeatureImpl(StationFeature s, String timeName, CalendarDateUnit timeUnit, String altName,
String altUnits, int nfeatures) {
super(s.getName(), timeName, timeUnit, altName, altUnits);
this.s = s;
if (nfeatures >= 0) {
getInfo(); // create the object
info.nfeatures = nfeatures;
}
}

@Override
public String getWmoId() {
return s.getWmoId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ private class StationFeatureStream extends StationTimeSeriesFeatureImpl {
PointIteratorStream riter;

StationFeatureStream(StationTimeSeriesFeature s, CalendarDateRange dateRange) {
super(s, StationCollectionStream.this.getTimeUnit(), StationCollectionStream.this.getAltUnits(), -1);
super(s, s.getTimeName(), StationCollectionStream.this.getTimeUnit(), s.getAltName(),
StationCollectionStream.this.getAltUnits(), -1);
this.stnFeature = s;
if (dateRange != null) {
getInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ public boolean hasCoords() {
return (timeVE != null) && (latVE != null) && (lonVE != null);
}

public String getTimeName() {
try {
return timeVE.axisName;
} catch (Exception e) {
throw new IllegalArgumentException("Error on time name string = " + timeVE.axisName + " == " + e.getMessage());
}
}

public CalendarDateUnit getTimeUnit() {
try {
return CalendarDateUnit.of(null, timeVE.getUnitsString()); // LOOK dont know the calendar
Expand All @@ -475,6 +483,14 @@ public CalendarDateUnit getTimeUnit() {
}
}

public String getAltName() {
if (altVE != null)
return altVE.axisName;
if (stnAltVE != null)
return stnAltVE.axisName;
return null;
}

public String getAltUnits() {
if (altVE != null)
return altVE.getUnitsString(); // fishy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class StandardPointCollectionImpl extends PointCollectionImpl {
private NestedTable ft;

StandardPointCollectionImpl(NestedTable ft, CalendarDateUnit timeUnit, String altUnits) {
super(ft.getName(), timeUnit, altUnits);
super(ft.getName(), ft.getTimeName(), timeUnit, ft.getAltName(), altUnits);
this.ft = ft;
this.extras = ft.getExtras();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
public class StandardProfileCollectionImpl extends PointFeatureCCImpl implements ProfileFeatureCollection {
private NestedTable ft;

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

StandardProfileCollectionImpl(NestedTable ft, CalendarDateUnit timeUnit, String altUnits) {
super(ft.getName(), timeUnit, altUnits, FeatureType.PROFILE);
super(ft.getName(), ft.getTimeName(), timeUnit, ft.getAltName(), altUnits, FeatureType.PROFILE);
this.ft = ft;
this.extras = ft.getExtras();
}
Expand Down Expand Up @@ -133,7 +134,7 @@ private static class StandardProfileCollectionSubset extends StandardProfileColl
LatLonRect boundingBox;

StandardProfileCollectionSubset(StandardProfileCollectionImpl from, LatLonRect boundingBox) {
super(from.getName() + "-subset", from.getTimeUnit(), from.getAltUnits());
super(from.getName() + "-subset", from.getTimeName(), from.getTimeUnit(), from.getAltName(), from.getAltUnits());
this.from = from;
this.boundingBox = boundingBox;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class StandardStationCollectionImpl extends StationTimeSeriesCollectionIm
private NestedTable ft;

StandardStationCollectionImpl(NestedTable ft, CalendarDateUnit timeUnit, String altUnits) {
super(ft.getName(), timeUnit, altUnits);
super(ft.getName(), ft.getTimeName(), timeUnit, ft.getAltName(), altUnits);
this.ft = ft;
this.extras = ft.getExtras();
}
Expand Down Expand Up @@ -73,7 +73,8 @@ private class StandardStationFeatureImpl extends StationTimeSeriesFeatureImpl {
StructureData stationData;

StandardStationFeatureImpl(StationFeature s, CalendarDateUnit dateUnit, StructureData stationData, int recnum) {
super(s, dateUnit, StandardStationCollectionImpl.this.getAltUnits(), -1);
super(s, StandardStationCollectionImpl.this.getTimeName(), dateUnit,
StandardStationCollectionImpl.this.getAltName(), StandardStationCollectionImpl.this.getAltUnits(), -1);
this.recnum = recnum;
this.stationData = stationData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ private class StandardStationProfileFeature extends StationProfileFeatureImpl {
Cursor cursor;

StandardStationProfileFeature(Station s, Cursor cursor, StructureData stationProfileData, int recnum) {
super(s, StandardStationProfileCollectionImpl.this.getTimeUnit(),
super(s, StandardStationProfileCollectionImpl.this.getTimeName(),
StandardStationProfileCollectionImpl.this.getTimeUnit(),
StandardStationProfileCollectionImpl.this.getAltName(),
StandardStationProfileCollectionImpl.this.getAltUnits(), -1);
this.cursor = cursor;
// this.recnum = recnum;
Expand Down
Loading