// Extended format observation reader.
private ValidObservation readNextExtendedObservation(String[] fields,
int obNum) throws ObservationValidationError {
ValidObservation observation = commonReadNextObservation(fields,
obNum);
String uncertaintyStr = fields[3].trim();
if (!isNA(uncertaintyStr)) {
double uncertainty = uncertaintyValueValidator
.validate(uncertaintyStr);
observation.getMagnitude().setUncertainty(uncertainty);
}
String filter = fields[4].trim();
SeriesType band = SeriesType.getSeriesFromShortName(filter);
observation.setBand(band);
String transformedStr = fields[5].trim();
if (!isNA(transformedStr)) {
boolean transformed = transformedValidator
.validate(transformedStr);
// Defaults to false.
observation.setTransformed(transformed);
}
// ValidObservation defaults to STD.
String mtypeStr = fields[6].trim();
MTypeType mtype = null;
if (!isNA(mtypeStr)) {
if ("DIF".equals(mtypeStr)) {
mtype = MTypeType.DIFF;
} else if ("STD".equals(mtypeStr)) {
mtype = MTypeType.STD;
} else if ("ABS".equals(mtypeStr)) {
mtype = MTypeType.STD;
}
}
if (mtype != null) {
observation.setMType(mtype);
}
String cname = fields[7].trim();
if (isNA(cname)) {
if (mtype == MTypeType.DIFF) {
throw new ObservationValidationError(
"Magnitude type is differential but there is no CNAME.");
} else {
cname = "";
}
} else {
cname += ": ";
}
String cmagStr = fields[8].trim();
if (!isNA(cmagStr)) {
// Note: Could CKMagValidator here, but its max field width
// seems not to represent the reality of some instrumental
// magnitudes, for example.
double cmag = magnitudeValueValidator.validate(cmagStr);
observation.setCMag(cname + cmag);
}
String kname = fields[9].trim();
if (isNA(kname)) {
kname = "";
} else {
kname += ": ";
}
String kmagStr = fields[10].trim();
if (!isNA(kmagStr)) {
// Note: Could CKMagValidator here, but its max field width
// seems not to represent the reality of some instrumental
// magnitudes, for example.
double kmag = magnitudeValueValidator.validate(kmagStr);
observation.setKMag(kname + kmag);
}
String airmass = fields[11].trim();
if (!isNA(airmass)) {
observation.setAirmass(airmass);
}
String group = fields[12].trim();
if (group.length() > 5) {
throw new ObservationValidationError(
"GROUP has more than 5 characters.");
}
String chart = fields[13].trim();
if (!isNA(chart)) {
observation.setCharts(chart);
}
handleComments(fields[14].trim(), group, observation);
return observation;