Skip to content

Commit

Permalink
create FieldIpml with time object
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanho committed Mar 1, 2024
1 parent 680c585 commit 92353f3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/ucar/visad/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -3439,9 +3439,46 @@ public static FieldImpl makeTimeField(List ranges, List times)
return fi;
}

/**
* Make a time field
*
* @param ranges ranges for each time
* @param time list of times
*
* @return the time field
*
* @throws RemoteException Java RMI problem
* @throws VisADException VisAD problem
*/
public static FieldImpl[] makeTimeField(Data[] ranges, Object time) // List times)
throws VisADException, RemoteException {
FieldImpl [] fi = new FieldImpl[ranges.length];
List times = Arrays.asList(time);
Set timeSet = makeTimeSet(times);
int setSize = ranges.length;

Object obj = times.get(0);
DateTime dttm = null;
if (obj instanceof DateTime) {
dttm = (DateTime) obj;
} else if (obj instanceof Date) {
dttm = new CalendarDateTime((Date) obj);
} else {
throw new IllegalArgumentException("Unknown date type:" + obj);
}


for (int i = 0; i < setSize; i++) {
Data range = ranges[i];
if (range == null) {
continue;
}
FieldImpl fii = new FieldImpl(new FunctionType(dttm.getType(),
range.getType()), timeSet);
fii.setSample(i, range, false, false);
fi[i] = fii;
}
return fi;
}

/**
* This makes a field of T->range for the times in the list.
Expand Down

0 comments on commit 92353f3

Please sign in to comment.