retVal.append( HeaderInfoTitle.FILE_ID.toString() ); retVal.append( ": "); retVal.append( this.fileIdAtt.getStringValue()); retVal.append( "\n"); retVal.append( HeaderInfoTitle.DATA_SET_ID.toString() ); retVal.append( ": " ); retVal.append( this.datasetIdAtt.getStringValue() ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.RECORD_BYTES.toString() ); retVal.append( ": " ); retVal.append( this.recordSizeInBytes ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numHeaderRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ); retVal.append( ": " ); retVal.append( this.suborbitHistoryAtt.getStringValue() ); retVal.append( "\n" );
String fullHeader = new String( b ); if ( ! fullHeader.startsWith( HeaderInfoTitle.FILE_ID.toString() ) ) throw new IOException( "Invalid DMSP file: header does not start with \"" + HeaderInfoTitle.FILE_ID.toString() + "\"." ); int endOfHeaderIndex = fullHeader.indexOf( HeaderInfoTitle.END_HEADER.toString() ); if ( endOfHeaderIndex == -1 ) throw new IOException( "Invalid DMSP file: header does not end with \"" + HeaderInfoTitle.END_HEADER.toString() + "\"." ); if (HeaderInfoTitle.getTitle(curHeaderTitle) == null) throw new IOException("Invalid DMSP file: header line <" + curHeaderLine + "> contains invalid title.");
String time = headerInfo.get( HeaderInfoTitle.START_TIME_UTC.toString()); String startDateTimeUTC = headerInfo.get( HeaderInfoTitle.START_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { time = headerInfo.get( HeaderInfoTitle.END_TIME_UTC.toString()); String endDateTimeUTC = headerInfo.get( HeaderInfoTitle.END_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { this.startDateLocalAtt = new Attribute( this.startDateLocalAttName, HeaderInfoTitle.START_DATE_LOCAL.toString()); this.startTimeLocalAtt = new Attribute( this.startTimeLocalAttName, HeaderInfoTitle.START_TIME_LOCAL.toString()); String startLatLon = headerInfo.get( HeaderInfoTitle.START_LAT_LON.toString()); String[] latLon = startLatLon.split( " "); Double lat, lon; String endLatLon = headerInfo.get( HeaderInfoTitle.END_LAT_LON.toString()); latLon = endLatLon.split( " "); if ( latLon.length != 2) throw new IOException( "Invalid DMSP file: end lat/lon <" + endLatLon + "> invalid."); this.startSubsolarCoordsAtt = new Attribute( this.startSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_SUBSOLAR_COORD.toString())); this.endSubsolarCoordsAtt = new Attribute( this.endSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_SUBSOLAR_COORD.toString())); this.startLunarCoordsAtt = new Attribute( this.startLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_LUNAR_COORD.toString())); this.endLunarCoordsAtt = new Attribute( this.endLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_LUNAR_COORD.toString()));
String time = headerInfo.get( HeaderInfoTitle.START_TIME_UTC.toString()); String startDateTimeUTC = headerInfo.get( HeaderInfoTitle.START_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { time = headerInfo.get( HeaderInfoTitle.END_TIME_UTC.toString()); String endDateTimeUTC = headerInfo.get( HeaderInfoTitle.END_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { this.startDateLocalAtt = new Attribute( this.startDateLocalAttName, HeaderInfoTitle.START_DATE_LOCAL.toString()); this.startTimeLocalAtt = new Attribute( this.startTimeLocalAttName, HeaderInfoTitle.START_TIME_LOCAL.toString()); String startLatLon = headerInfo.get( HeaderInfoTitle.START_LAT_LON.toString()); String[] latLon = startLatLon.split( " "); Double lat, lon; String endLatLon = headerInfo.get( HeaderInfoTitle.END_LAT_LON.toString()); latLon = endLatLon.split( " "); if ( latLon.length != 2) throw new IOException( "Invalid DMSP file: end lat/lon <" + endLatLon + "> invalid."); this.startSubsolarCoordsAtt = new Attribute( this.startSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_SUBSOLAR_COORD.toString())); this.endSubsolarCoordsAtt = new Attribute( this.endSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_SUBSOLAR_COORD.toString())); this.startLunarCoordsAtt = new Attribute( this.startLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_LUNAR_COORD.toString())); this.endLunarCoordsAtt = new Attribute( this.endLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_LUNAR_COORD.toString()));
String time = headerInfo.get( HeaderInfoTitle.START_TIME_UTC.toString()); String startDateTimeUTC = headerInfo.get( HeaderInfoTitle.START_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { time = headerInfo.get( HeaderInfoTitle.END_TIME_UTC.toString()); String endDateTimeUTC = headerInfo.get( HeaderInfoTitle.END_DATE_UTC.toString()) + "T" + time.substring( 0, time.indexOf( '.')+4) + "Z"; try { this.startDateLocalAtt = new Attribute( this.startDateLocalAttName, HeaderInfoTitle.START_DATE_LOCAL.toString()); this.startTimeLocalAtt = new Attribute( this.startTimeLocalAttName, HeaderInfoTitle.START_TIME_LOCAL.toString()); String startLatLon = headerInfo.get( HeaderInfoTitle.START_LAT_LON.toString()); String[] latLon = startLatLon.split( " "); Double lat, lon; String endLatLon = headerInfo.get( HeaderInfoTitle.END_LAT_LON.toString()); latLon = endLatLon.split( " "); if ( latLon.length != 2) throw new IOException( "Invalid DMSP file: end lat/lon <" + endLatLon + "> invalid."); this.startSubsolarCoordsAtt = new Attribute( this.startSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_SUBSOLAR_COORD.toString())); this.endSubsolarCoordsAtt = new Attribute( this.endSubsolarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_SUBSOLAR_COORD.toString())); this.startLunarCoordsAtt = new Attribute( this.startLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.START_LUNAR_COORD.toString())); this.endLunarCoordsAtt = new Attribute( this.endLunarCoordsAttName, headerInfo.get(HeaderInfoTitle.END_LUNAR_COORD.toString()));
String fullHeader = new String( b, CDM.utf8Charset); if ( ! fullHeader.startsWith( HeaderInfoTitle.FILE_ID.toString() ) ) throw new IOException( "Invalid DMSP file: header does not start with \"" + HeaderInfoTitle.FILE_ID.toString() + "\"." ); int endOfHeaderIndex = fullHeader.indexOf( HeaderInfoTitle.END_HEADER.toString() ); if ( endOfHeaderIndex == -1 ) throw new IOException( "Invalid DMSP file: header does not end with \"" + HeaderInfoTitle.END_HEADER.toString() + "\"." );
String fullHeader = new String( b, CDM.utf8Charset); if ( ! fullHeader.startsWith( HeaderInfoTitle.FILE_ID.toString() ) ) throw new IOException( "Invalid DMSP file: header does not start with \"" + HeaderInfoTitle.FILE_ID.toString() + "\"." ); int endOfHeaderIndex = fullHeader.indexOf( HeaderInfoTitle.END_HEADER.toString() ); if ( endOfHeaderIndex == -1 ) throw new IOException( "Invalid DMSP file: header does not end with \"" + HeaderInfoTitle.END_HEADER.toString() + "\"." ); if (HeaderInfoTitle.getTitle(curHeaderTitle) == null) throw new IOException("Invalid DMSP file: header line <" + curHeaderLine + "> contains invalid title.");
retVal.append( HeaderInfoTitle.FILE_ID.toString() ); retVal.append( ": "); retVal.append( this.fileIdAtt.getStringValue()); retVal.append( "\n"); retVal.append( HeaderInfoTitle.DATA_SET_ID.toString() ); retVal.append( ": " ); retVal.append( this.datasetIdAtt.getStringValue() ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.RECORD_BYTES.toString() ); retVal.append( ": " ); retVal.append( this.recordSizeInBytes ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numHeaderRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ); retVal.append( ": " ); retVal.append( this.suborbitHistoryAtt.getStringValue() ); retVal.append( "\n" );
retVal.append( HeaderInfoTitle.FILE_ID.toString() ); retVal.append( ": "); retVal.append( this.fileIdAtt.getStringValue()); retVal.append( "\n"); retVal.append( HeaderInfoTitle.DATA_SET_ID.toString() ); retVal.append( ": " ); retVal.append( this.datasetIdAtt.getStringValue() ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.RECORD_BYTES.toString() ); retVal.append( ": " ); retVal.append( this.recordSizeInBytes ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numHeaderRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.NUM_RECORDS.toString() ); retVal.append( ": " ); retVal.append( this.numRecords ); retVal.append( "\n" ); retVal.append( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ); retVal.append( ": " ); retVal.append( this.suborbitHistoryAtt.getStringValue() ); retVal.append( "\n" );
numSamplesPerBand = Integer.parseInt( headerInfo.get( HeaderInfoTitle.SAMPLES_PER_BAND.toString()) ); numSamplesPerBandDim = new Dimension( this.numSamplesPerBandDimName, nominalResolutionAtt = new Attribute( nominalResolutionAttName, headerInfo.get(HeaderInfoTitle.NOMINAL_RESOLUTION.toString())); bandsPerScanlineAtt = new Attribute( bandsPerScanlineAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BANDS_PER_SCANLINE.toString()))); bytesPerSampleAtt = new Attribute( bytesPerSampleAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTES_PER_SAMPLE.toString()))); byteOffsetBand1Att = new Attribute( byteOffsetBand1AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_1.toString()))); byteOffsetBand2Att = new Attribute( byteOffsetBand2AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_2.toString()))); band1Att = new Attribute( band1AttName, headerInfo.get( HeaderInfoTitle.BAND_1.toString())); band2Att = new Attribute( band2AttName, headerInfo.get( HeaderInfoTitle.BAND_2.toString())); bandOrganizationAtt = new Attribute( bandOrganizationAttName, headerInfo.get(HeaderInfoTitle.ORGANIZATION.toString())); thermalOffsetAtt = new Attribute( thermalOffsetAttName, headerInfo.get(HeaderInfoTitle.THERMAL_OFFSET.toString())); thermalScaleAtt = new Attribute( thermalScaleAttName, headerInfo.get(HeaderInfoTitle.THERMAL_SCALE.toString())); percentDaylightAtt = new Attribute( percentDaylightAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_DAYLIGHT.toString()))); percentFullMoonAtt = new Attribute( percentFullMoonAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_FULL_MOON.toString()))); percentTerminatorEvidentAtt = new Attribute( percentTerminatorEvidentAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_TERMINATOR_EVIDENT.toString())));
numSamplesPerBand = Integer.parseInt( headerInfo.get( HeaderInfoTitle.SAMPLES_PER_BAND.toString()) ); numSamplesPerBandDim = new Dimension( this.numSamplesPerBandDimName, nominalResolutionAtt = new Attribute( nominalResolutionAttName, headerInfo.get(HeaderInfoTitle.NOMINAL_RESOLUTION.toString())); bandsPerScanlineAtt = new Attribute( bandsPerScanlineAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BANDS_PER_SCANLINE.toString()))); bytesPerSampleAtt = new Attribute( bytesPerSampleAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTES_PER_SAMPLE.toString()))); byteOffsetBand1Att = new Attribute( byteOffsetBand1AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_1.toString()))); byteOffsetBand2Att = new Attribute( byteOffsetBand2AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_2.toString()))); band1Att = new Attribute( band1AttName, headerInfo.get( HeaderInfoTitle.BAND_1.toString())); band2Att = new Attribute( band2AttName, headerInfo.get( HeaderInfoTitle.BAND_2.toString())); bandOrganizationAtt = new Attribute( bandOrganizationAttName, headerInfo.get(HeaderInfoTitle.ORGANIZATION.toString())); thermalOffsetAtt = new Attribute( thermalOffsetAttName, headerInfo.get(HeaderInfoTitle.THERMAL_OFFSET.toString())); thermalScaleAtt = new Attribute( thermalScaleAttName, headerInfo.get(HeaderInfoTitle.THERMAL_SCALE.toString())); percentDaylightAtt = new Attribute( percentDaylightAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_DAYLIGHT.toString()))); percentFullMoonAtt = new Attribute( percentFullMoonAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_FULL_MOON.toString()))); percentTerminatorEvidentAtt = new Attribute( percentTerminatorEvidentAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_TERMINATOR_EVIDENT.toString())));
numSamplesPerBand = Integer.parseInt( headerInfo.get( HeaderInfoTitle.SAMPLES_PER_BAND.toString()) ); numSamplesPerBandDim = new Dimension( this.numSamplesPerBandDimName, nominalResolutionAtt = new Attribute( nominalResolutionAttName, headerInfo.get(HeaderInfoTitle.NOMINAL_RESOLUTION.toString())); bandsPerScanlineAtt = new Attribute( bandsPerScanlineAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BANDS_PER_SCANLINE.toString()))); bytesPerSampleAtt = new Attribute( bytesPerSampleAttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTES_PER_SAMPLE.toString()))); byteOffsetBand1Att = new Attribute( byteOffsetBand1AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_1.toString()))); byteOffsetBand2Att = new Attribute( byteOffsetBand2AttName, Integer.valueOf(headerInfo.get(HeaderInfoTitle.BYTE_OFFSET_BAND_2.toString()))); band1Att = new Attribute( band1AttName, headerInfo.get( HeaderInfoTitle.BAND_1.toString())); band2Att = new Attribute( band2AttName, headerInfo.get( HeaderInfoTitle.BAND_2.toString())); bandOrganizationAtt = new Attribute( bandOrganizationAttName, headerInfo.get(HeaderInfoTitle.ORGANIZATION.toString())); thermalOffsetAtt = new Attribute( thermalOffsetAttName, headerInfo.get(HeaderInfoTitle.THERMAL_OFFSET.toString())); thermalScaleAtt = new Attribute( thermalScaleAttName, headerInfo.get(HeaderInfoTitle.THERMAL_SCALE.toString())); percentDaylightAtt = new Attribute( percentDaylightAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_DAYLIGHT.toString()))); percentFullMoonAtt = new Attribute( percentFullMoonAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_FULL_MOON.toString()))); percentTerminatorEvidentAtt = new Attribute( percentTerminatorEvidentAttName, Double.valueOf(headerInfo.get(HeaderInfoTitle.PERCENT_TERMINATOR_EVIDENT.toString())));
/** * Parse the file header information about the file (e.g., file ID, dataset ID, * record size, number of records) and create netCDF attributes and dimensions * where appropriate. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleFileInformation() throws IOException { fileIdAtt = new Attribute( this.fileIdAttName, headerInfo.get(HeaderInfoTitle.FILE_ID.toString() ) ); datasetIdAtt = new Attribute( this.datasetIdAttName, headerInfo.get(HeaderInfoTitle.DATA_SET_ID.toString() ) ); recordSizeInBytes = Integer.parseInt( headerInfo.get( HeaderInfoTitle.RECORD_BYTES.toString() ) ); numRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_RECORDS.toString() ) ); numHeaderRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ) ); numDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_DATA_RECORDS.toString() ) ); numDataRecordsDim = new Dimension( this.numDataRecordsDimName, numDataRecords, true, true, false); numArtificialDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_ARTIFICIAL_DATA_RECORDS.toString() ) ); if ( numHeaderRecords + numDataRecordsDim.getLength() + numArtificialDataRecords != numRecords ) { throw new IOException( "Invalid DMSP file: the number of header records <" + this.numHeaderRecords + ">, data records <" + this.numDataRecordsDim.getLength() + ">, and artificial data records <" + this.numArtificialDataRecords + "> is not equal to total records <" + this.numRecords + ">." ); } this.headerSizeInBytes = this.numHeaderRecords * this.recordSizeInBytes; if ( numRecords * ((long) this.recordSizeInBytes) != this.actualSize ) { throw new IOException( "Invalid DMSP file: the number of records <" + this.numRecords + "> times the record size <" + this.recordSizeInBytes + "> does not equal the size of the file <" + this.actualSize + ">." ); } }
/** * Parse the file header information about the file (e.g., file ID, dataset ID, * record size, number of records) and create netCDF attributes and dimensions * where appropriate. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleFileInformation() throws IOException { fileIdAtt = new Attribute( this.fileIdAttName, headerInfo.get(HeaderInfoTitle.FILE_ID.toString() ) ); datasetIdAtt = new Attribute( this.datasetIdAttName, headerInfo.get(HeaderInfoTitle.DATA_SET_ID.toString() ) ); recordSizeInBytes = Integer.parseInt( headerInfo.get( HeaderInfoTitle.RECORD_BYTES.toString() ) ); numRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_RECORDS.toString() ) ); numHeaderRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ) ); numDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_DATA_RECORDS.toString() ) ); numDataRecordsDim = new Dimension( this.numDataRecordsDimName, numDataRecords, true, true, false); numArtificialDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_ARTIFICIAL_DATA_RECORDS.toString() ) ); if ( numHeaderRecords + numDataRecordsDim.getLength() + numArtificialDataRecords != numRecords ) { throw new IOException( "Invalid DMSP file: the number of header records <" + this.numHeaderRecords + ">, data records <" + this.numDataRecordsDim.getLength() + ">, and artificial data records <" + this.numArtificialDataRecords + "> is not equal to total records <" + this.numRecords + ">." ); } this.headerSizeInBytes = this.numHeaderRecords * this.recordSizeInBytes; if ( numRecords * this.recordSizeInBytes != this.actualSize ) { throw new IOException( "Invalid DMSP file: the number of records <" + this.numRecords + "> times the record size <" + this.recordSizeInBytes + "> does not equal the size of the file <" + this.actualSize + ">." ); } }
/** * Parse the processing/history information from the header. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleProcessingInformation() throws IOException { suborbitHistoryAtt = new Attribute( this.suborbitHistoryAttName, (String) headerInfo.get( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ) ); processingSystemAtt = new Attribute( this.processingSystemAttName, (String) headerInfo.get( HeaderInfoTitle.PROCESSING_SYSTEM.toString() ) ); String processingDateString = (String) headerInfo.get( HeaderInfoTitle.PROCESSING_DATE.toString() ); try { processingDate = DateFormatHandler.ALT_DATE_TIME.getDateFromDateTimeString( processingDateString ); } catch ( ParseException e ) { throw new IOException( "Invalid DMSP file: processing date string <" + processingDateString + "> not parseable: " + e.getMessage() ); } processingDateAtt = new Attribute( this.processingDateAttName, DateFormatHandler.ISO_DATE_TIME.getDateTimeStringFromDate( processingDate ) ); }
/** * Parse the file header information about the file (e.g., file ID, dataset ID, * record size, number of records) and create netCDF attributes and dimensions * where appropriate. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleFileInformation() throws IOException { fileIdAtt = new Attribute( this.fileIdAttName, headerInfo.get(HeaderInfoTitle.FILE_ID.toString() ) ); datasetIdAtt = new Attribute( this.datasetIdAttName, headerInfo.get(HeaderInfoTitle.DATA_SET_ID.toString() ) ); recordSizeInBytes = Integer.parseInt( headerInfo.get( HeaderInfoTitle.RECORD_BYTES.toString() ) ); numRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_RECORDS.toString() ) ); numHeaderRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_HEADER_RECORDS.toString() ) ); numDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_DATA_RECORDS.toString() ) ); numDataRecordsDim = new Dimension( this.numDataRecordsDimName, numDataRecords, true, true, false); numArtificialDataRecords = Integer.parseInt( headerInfo.get( HeaderInfoTitle.NUM_ARTIFICIAL_DATA_RECORDS.toString() ) ); this.headerSizeInBytes = this.numHeaderRecords * this.recordSizeInBytes; if ( numRecords * ((long) this.recordSizeInBytes) != this.actualSize ) { throw new IOException( "Invalid DMSP file: the number of records <" + this.numRecords + "> times the record size <" + this.recordSizeInBytes + "> does not equal the size of the file <" + this.actualSize + ">." ); } }
/** * Parse the processing/history information from the header. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleProcessingInformation() throws IOException { suborbitHistoryAtt = new Attribute( this.suborbitHistoryAttName, (String) headerInfo.get( HeaderInfoTitle.SUBORBIT_HISTORY.toString() ) ); processingSystemAtt = new Attribute( this.processingSystemAttName, (String) headerInfo.get( HeaderInfoTitle.PROCESSING_SYSTEM.toString() ) ); String processingDateString = (String) headerInfo.get( HeaderInfoTitle.PROCESSING_DATE.toString() ); try { processingDate = DateFormatHandler.ALT_DATE_TIME.getDateFromDateTimeString( processingDateString ); } catch ( ParseException e ) { throw new IOException( "Invalid DMSP file: processing date string <" + processingDateString + "> not parseable: " + e.getMessage() ); } processingDateAtt = new Attribute( this.processingDateAttName, DateFormatHandler.ISO_DATE_TIME.getDateTimeStringFromDate( processingDate ) ); }
/** * Parse the processing/history information from the header. * * @throws IOException if any problems reading the file (or validating the file). */ private void handleProcessingInformation() throws IOException { suborbitHistoryAtt = new Attribute(this.suborbitHistoryAttName, headerInfo.get(HeaderInfoTitle.SUBORBIT_HISTORY.toString())); processingSystemAtt = new Attribute(this.processingSystemAttName, headerInfo.get(HeaderInfoTitle.PROCESSING_SYSTEM.toString())); String processingDateString = headerInfo.get(HeaderInfoTitle.PROCESSING_DATE.toString()); try { processingDate = DateFormatHandler.ALT_DATE_TIME.getDateFromDateTimeString( processingDateString ); } catch ( ParseException e ) { throw new IOException( "Invalid DMSP file: processing date string <" + processingDateString + "> not parseable: " + e.getMessage() ); } processingDateAtt = new Attribute( this.processingDateAttName, DateFormatHandler.ISO_DATE_TIME.getDateTimeStringFromDate( processingDate ) ); }
/** * Parse the satellite information from the header. */ private void handleSatelliteInformation() { spacecraftIdAtt = new Attribute( this.spacecraftIdAttName, headerInfo.get(HeaderInfoTitle.SPACECRAFT_ID.toString())); noradIdAtt = new Attribute( this.noradIdAttName, headerInfo.get(HeaderInfoTitle.NORAD_ID.toString())); }
/** * Parse the sensor information from the header. */ private void handleQCInformation() { // QC flags qcFlagsAtt = new Attribute( qcFlagsAttName, headerInfo.get(HeaderInfoTitle.QC_FLAGS.toString())); }