Package edu.sc.seis.seisFile.mseed3
Class MSeed3Record
java.lang.Object
edu.sc.seis.seisFile.mseed3.MSeed3Record
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
protected int
static final long
protected int
protected static final byte
protected static final String
static final int
static final int
static final int
static final int
static final int
static final int
protected org.json.JSONObject
protected int
protected String
static final String
static final int
protected byte
protected byte
protected int
static final long
static final int
static long
static final String
protected int
protected int
static final int
protected int
protected byte
protected int
protected String
protected double
static final long
protected int
protected FDSNSourceId
protected byte
protected String
static final int
static final String
protected byte[]
protected byte
static final ZoneId
static final int
const for unknown data version, 0protected int
static final String
-
Constructor Summary
ConstructorsConstructorDescriptioncreates a DataHeader object with nothing set (ie nulls and zeros) -
Method Summary
Modifier and TypeMethodDescriptionwrite DataHeader contents as a ByteBufferint
edu.iris.dmc.seedcodec.DecompressedData
Decompress the data in this record according to the compression type in the header.static MSeed3Record
fromByteBuffer
(ByteBuffer buf) read record contents from a ByteBufferint
int
static final ZonedDateTime
org.json.JSONObject
getExtraHeadersAsString
(int indent) int
byte
getFlags()
byte
int
getHour()
the derived last sample time for this record adjusted for leap seconds.get the time of the last sample of the record, derived from Start time, sample rate, and number of samples -1.int
int
int
int
the predicted start time for the record following this one adjusted for leap seconds.byte
int
long
double
Gets sample rate/period value from header.int
int
getSize()
Gets the number of bytes for this record.Gets the sourceId parsed as a FDSN source id.byte
Gets the raw sourceid header field as a String.Start time as a Date.Get the value of startTime.byte[]
byte
int
getYear()
boolean
boolean
boolean
boolean
static String
nanosToString
(int nanos) Converts nanoseconds to string to append to time, removing trailing zeros to be 3, 6 or 9 digits.boolean
Checks if the record covers a time range that might contain a leap second, effectively if it crosses midnight on Dec 31 or June 30.void
printASCII
(PrintWriter out) Writes an ASCII version of the record header.void
printASCII
(PrintWriter out, String indent) void
printASCII
(PrintWriter out, String indent, boolean withData) static void
printData
(PrintWriter out, String indent, double[] data) static void
printData
(PrintWriter out, String indent, float[] data) static void
printData
(PrintWriter out, String indent, int[] data) static void
printData
(PrintWriter out, String indent, short[] data) void
void
printDataASCII
(PrintWriter out, String indent) void
printDataRawBytes
(PrintWriter out, String indent) protected int
read
(byte[] buf, int offset) populates this object with Fixed Section Data Header info.static MSeed3Record
Instantiate an object of this class and read an FSDH byte stream into it, parsing the contents into the instance variables of this object, which represent the individual FSDH fields.double
Calculate sample period value from header.double
Calculate sample rate value from header.void
setClockLocked
(boolean b) void
setDayOfYear
(int dayOfYear) void
setExtraHeaders
(String extraHeaders) void
setExtraHeaders
(org.json.JSONObject extraHeaders) void
setFlags
(byte flags) void
setFormatVersion
(byte formatVersion) void
setHour
(int hour) void
setLeapSecInRecord
(int value) void
setMinute
(int minute) void
setNanosecond
(int nanosecond) void
setNumSamples
(int numSamples) void
setPublicationVersion
(byte publicationVersion) void
setRecordCRC
(int recordCRC) void
setRecordIndicator
(String recordIndicator) void
setSampleRatePeriod
(double sampleRatePeriod) Sets sample rate/period value in header.void
setSecond
(int second) void
setSourceId
(FDSNSourceId sourceId) void
setSourceId
(String sourceId) void
setStartDateTime
(Instant start) void
setStartDateTime
(ZonedDateTime start) void
setTimeseries
(double[] data) void
setTimeseries
(float[] data) void
setTimeseries
(int[] data) void
setTimeseries
(short[] data) void
setTimeseriesBytes
(byte[] timeseriesBytes) void
setTimeseriesEncodingFormat
(byte timeseriesEncodingFormat) void
setTimeTagQuestionable
(boolean b) void
setYear
(int year) int
steim1Timeseries
(int[] data) int
steim1Timeseries
(int[] data, int maxFrames) Encodes data via Steim1, up to maxFrames number of 64 byte frames.int
steim2Timeseries
(int[] data) int
steim2Timeseries
(int[] data, int maxFrames) Encodes data via Steim2, up to maxFrames number of 64 byte frames.byte[]
toString()
Present a default string representation of the contents of this objectvoid
write
(OutputStream dos) write DataHeader contents to a DataOutput stream
-
Field Details
-
MINISEED_THREE_MIME
- See Also:
-
TIME_LEAP_SECOND
- See Also:
-
UNKNOWN_DATA_VERSION
public static final int UNKNOWN_DATA_VERSIONconst for unknown data version, 0- See Also:
-
recordIndicator
-
formatVersion
protected byte formatVersion -
flags
protected byte flags -
year
protected int year -
dayOfYear
protected int dayOfYear -
hour
protected int hour -
minute
protected int minute -
second
protected int second -
nanosecond
protected int nanosecond -
sampleRatePeriod
protected double sampleRatePeriod -
timeseriesEncodingFormat
protected byte timeseriesEncodingFormat -
publicationVersion
protected byte publicationVersion -
numSamples
protected int numSamples -
recordCRC
protected int recordCRC -
sourceIdByteLength
protected byte sourceIdByteLength -
extraHeadersByteLength
protected int extraHeadersByteLength -
dataByteLength
protected int dataByteLength -
sourceIdStr
-
sourceId
-
extraHeadersStr
-
extraHeaders
protected org.json.JSONObject extraHeaders -
timeseriesBytes
protected byte[] timeseriesBytes -
CRC_OFFSET
public static final int CRC_OFFSET- See Also:
-
MAX_DATA_SIZE
public static long MAX_DATA_SIZE -
TZ_UTC
-
ZULU
- See Also:
-
FDSN_PREFIX
- See Also:
-
NETWORK_CODE_LENGTH
public static final int NETWORK_CODE_LENGTH- See Also:
-
STATION_CODE_LENGTH
public static final int STATION_CODE_LENGTH- See Also:
-
LOCATION_CODE_LENGTH
public static final int LOCATION_CODE_LENGTH- See Also:
-
CHANNEL_CODE_LENGTH
public static final int CHANNEL_CODE_LENGTH- See Also:
-
FIXED_HEADER_SIZE
public static final int FIXED_HEADER_SIZE- See Also:
-
DEFAULT_RECORD_INDICATOR
- See Also:
-
DEFAULT_MINISEED_VERSION
protected static final byte DEFAULT_MINISEED_VERSION- See Also:
-
SEC_NANOS
public static final long SEC_NANOS- See Also:
-
DAY_NANOS
public static final long DAY_NANOS- See Also:
-
LAST_SEC_NANOS
public static final long LAST_SEC_NANOS- See Also:
-
DEFAULT_START_YEAR
public static final int DEFAULT_START_YEAR- See Also:
-
DEFAULT_START_DAY_OF_YEAR
public static final int DEFAULT_START_DAY_OF_YEAR- See Also:
-
DEFAULT_START_HOUR
public static final int DEFAULT_START_HOUR- See Also:
-
DEFAULT_START_MINUTE
public static final int DEFAULT_START_MINUTE- See Also:
-
DEFAULT_START_SECOND
public static final int DEFAULT_START_SECOND- See Also:
-
DEFAULT_START_NANOSECOND
public static final int DEFAULT_START_NANOSECOND- See Also:
-
-
Constructor Details
-
MSeed3Record
public MSeed3Record()creates a DataHeader object with nothing set (ie nulls and zeros)
-
-
Method Details
-
printASCII
Writes an ASCII version of the record header. This is not meant to be a definitive ascii representation, merely to give something to print for debugging purposes. Ideally each field of the header should be printed in the order is appears in the header in a visually appealing way.- Parameters:
out
- a Writer- Throws:
IOException
-
printASCII
- Throws:
IOException
-
printASCII
- Throws:
IOException
-
printDataASCII
-
printDataASCII
-
printData
-
printData
-
printData
-
printData
-
printDataRawBytes
-
read
public static MSeed3Record read(DataInput in) throws IOException, SeedFormatException, FDSNSourceIdException Instantiate an object of this class and read an FSDH byte stream into it, parsing the contents into the instance variables of this object, which represent the individual FSDH fields.- Parameters:
in
- miniSEED3 data stream .- Returns:
- an object of this class with fields filled from 'in' parameter
- Throws:
IOException
SeedFormatException
FDSNSourceIdException
-
read
protected int read(byte[] buf, int offset) populates this object with Fixed Section Data Header info.- Parameters:
buf
- data buffer containing FSDH informationoffset
- byte offset to begin reading buf
-
write
write DataHeader contents to a DataOutput stream- Parameters:
dos
- DataOutput stream to write to- Throws:
IOException
-
fromByteBuffer
read record contents from a ByteBuffer- Throws:
IOException
SeedFormatException
-
asByteBuffer
write DataHeader contents as a ByteBuffer- Throws:
IOException
-
toByteArray
public byte[] toByteArray() -
getLeapSecInRecord
public int getLeapSecInRecord() -
setLeapSecInRecord
public void setLeapSecInRecord(int value) -
setStartDateTime
-
setStartDateTime
-
getStartDateTime
Start time as a Date. This adjusts for possible leap seconds, but will be wrong during a leap second. In particular, the returned value is the same if the seconds field is 59 or 60, as if the 59th second repeats. -
getStartInstant
-
possibleLeapSecond
public boolean possibleLeapSecond()Checks if the record covers a time range that might contain a leap second, effectively if it crosses midnight on Dec 31 or June 30. This does not imply that the date actually has a leap second, just that it could.- Returns:
-
getStartTimeString
Get the value of startTime.- Returns:
- Value of startTime.
-
nanosToString
Converts nanoseconds to string to append to time, removing trailing zeros to be 3, 6 or 9 digits. Includes decimal separator if needed.- Parameters:
nanos
-- Returns:
-
getLastSampleTime
the derived last sample time for this record adjusted for leap seconds. In the case of a leap second in a record, getLastSampleTime() minus getStartDateTime() is NOT equal to (numSamples-1) * samplePeriod. Also, in case of a record ending in a leap second, the seconds field in the date will be 59, ie it is as if the 59th second repeats. -
getPredictedNextRecordStartTime
the predicted start time for the record following this one adjusted for leap seconds. In the case of a leap second in a record, getPredictedNextRecordStartTime() minus getStartDateTime() is NOT equal to (numSamples) * samplePeriod. Also, in case of a record starting in a leap second, the seconds field in the date will be 59, ie it is as if the 59th second repeats. -
getLastSampleTimeString
get the time of the last sample of the record, derived from Start time, sample rate, and number of samples -1.- Returns:
- the value of end time
-
getSamplePeriodAsNanos
public long getSamplePeriodAsNanos() -
isStartTimeInLeapSecond
public boolean isStartTimeInLeapSecond() -
isEndTimeInLeapSecond
public boolean isEndTimeInLeapSecond() -
isTimeTagQuestionable
public boolean isTimeTagQuestionable() -
setTimeTagQuestionable
public void setTimeTagQuestionable(boolean b) -
isClockLocked
public boolean isClockLocked() -
setClockLocked
public void setClockLocked(boolean b) -
toString
Present a default string representation of the contents of this object -
getExtraHeaders
public org.json.JSONObject getExtraHeaders() -
getRecordIndicator
-
setRecordIndicator
-
getFormatVersion
public byte getFormatVersion() -
setFormatVersion
public void setFormatVersion(byte formatVersion) -
getFlags
public byte getFlags() -
setFlags
public void setFlags(byte flags) -
startFieldsInUtilFormat
-
getYear
public int getYear() -
setYear
public void setYear(int year) -
getDayOfYear
public int getDayOfYear() -
setDayOfYear
public void setDayOfYear(int dayOfYear) -
getHour
public int getHour() -
setHour
public void setHour(int hour) -
getMinute
public int getMinute() -
setMinute
public void setMinute(int minute) -
getSecond
public int getSecond() -
setSecond
public void setSecond(int second) -
getNanosecond
public int getNanosecond() -
setNanosecond
public void setNanosecond(int nanosecond) -
getSampleRatePeriod
public double getSampleRatePeriod()Gets sample rate/period value from header. Is rate if positive, period if negative.- Returns:
-
setSampleRatePeriod
public void setSampleRatePeriod(double sampleRatePeriod) Sets sample rate/period value in header. Is rate if positive, period if negative. -
samplingAsRate
public double samplingAsRate()Calculate sample rate value from header. This is always positive, even if value is negative, indicating a period in the header.- Returns:
- sample rate as a non-negative number (Hz)
-
samplingAsPeriod
public double samplingAsPeriod()Calculate sample period value from header. This is always positive, even if value is negative, indicating a period in the header.- Returns:
- sample period as a non-negative number (seconds)
-
getTimeseriesEncodingFormat
public byte getTimeseriesEncodingFormat() -
getTimeseriesEncodingFormatName
-
setTimeseriesEncodingFormat
public void setTimeseriesEncodingFormat(byte timeseriesEncodingFormat) -
getPublicationVersion
public byte getPublicationVersion() -
setPublicationVersion
public void setPublicationVersion(byte publicationVersion) -
getNumSamples
public int getNumSamples() -
setNumSamples
public void setNumSamples(int numSamples) -
getRecordCRC
public int getRecordCRC() -
setRecordCRC
public void setRecordCRC(int recordCRC) -
getExtraHeadersAsString
-
setExtraHeaders
-
setExtraHeaders
public void setExtraHeaders(org.json.JSONObject extraHeaders) -
getSourceId
Gets the sourceId parsed as a FDSN source id. If the source is is not parsable as an FDSN source id, returns null- Returns:
-
getSourceIdStr
Gets the raw sourceid header field as a String.- Returns:
-
setSourceId
-
setSourceId
-
getSourceIdByteLength
public byte getSourceIdByteLength() -
calcExtraHeadersByteLength
public int calcExtraHeadersByteLength() -
getExtraHeadersByteLength
public int getExtraHeadersByteLength() -
getDataByteLength
public int getDataByteLength() -
getTimeseriesBytes
public byte[] getTimeseriesBytes() -
setTimeseriesBytes
public void setTimeseriesBytes(byte[] timeseriesBytes) -
setTimeseries
public void setTimeseries(short[] data) -
setTimeseries
public void setTimeseries(int[] data) -
steim1Timeseries
- Throws:
edu.iris.dmc.seedcodec.SteimException
IOException
-
steim1Timeseries
public int steim1Timeseries(int[] data, int maxFrames) throws edu.iris.dmc.seedcodec.SteimException, IOException Encodes data via Steim1, up to maxFrames number of 64 byte frames. If maxFrames is zero, encodes all samples.- Parameters:
data
-maxFrames
-- Returns:
- Throws:
edu.iris.dmc.seedcodec.SteimException
IOException
-
steim2Timeseries
- Throws:
edu.iris.dmc.seedcodec.SteimException
IOException
-
steim2Timeseries
public int steim2Timeseries(int[] data, int maxFrames) throws edu.iris.dmc.seedcodec.SteimException, IOException Encodes data via Steim2, up to maxFrames number of 64 byte frames. If maxFrames is zero, encodes all samples.- Parameters:
data
-maxFrames
-- Returns:
- Throws:
edu.iris.dmc.seedcodec.SteimException
IOException
-
setTimeseries
public void setTimeseries(float[] data) -
setTimeseries
public void setTimeseries(double[] data) -
decompress
public edu.iris.dmc.seedcodec.DecompressedData decompress() throws SeedFormatException, edu.iris.dmc.seedcodec.UnsupportedCompressionType, edu.iris.dmc.seedcodec.CodecExceptionDecompress the data in this record according to the compression type in the header.- Returns:
- Throws:
SeedFormatException
- if no blockette 1000 presentedu.iris.dmc.seedcodec.UnsupportedCompressionType
edu.iris.dmc.seedcodec.CodecException
-
getSize
public int getSize()Gets the number of bytes for this record.- Returns:
-
getDefaultStartTime
-