Class MSeed3Record


  • public class MSeed3Record
    extends java.lang.Object
    • Field Detail

      • MINISEED_THREE_MIME

        public static final java.lang.String MINISEED_THREE_MIME
        See Also:
        Constant Field Values
      • TIME_LEAP_SECOND

        public static final java.lang.String TIME_LEAP_SECOND
        See Also:
        Constant Field Values
      • UNKNOWN_DATA_VERSION

        public static final int UNKNOWN_DATA_VERSION
        const for unknown data version, 0
        See Also:
        Constant Field Values
      • recordIndicator

        protected java.lang.String 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

        protected java.lang.String sourceIdStr
      • extraHeadersStr

        protected java.lang.String extraHeadersStr
      • extraHeaders

        protected org.json.JSONObject extraHeaders
      • timeseriesBytes

        protected byte[] timeseriesBytes
      • MAX_DATA_SIZE

        public static long MAX_DATA_SIZE
      • TZ_UTC

        public static final java.time.ZoneId TZ_UTC
      • DEFAULT_RECORD_INDICATOR

        protected static final java.lang.String DEFAULT_RECORD_INDICATOR
        See Also:
        Constant Field Values
      • DEFAULT_MINISEED_VERSION

        protected static final byte DEFAULT_MINISEED_VERSION
        See Also:
        Constant Field Values
      • DEFAULT_START_DAY_OF_YEAR

        public static final int DEFAULT_START_DAY_OF_YEAR
        See Also:
        Constant Field Values
      • DEFAULT_START_NANOSECOND

        public static final int DEFAULT_START_NANOSECOND
        See Also:
        Constant Field Values
    • Constructor Detail

      • MSeed3Record

        public MSeed3Record()
        creates a DataHeader object with nothing set (ie nulls and zeros)
    • Method Detail

      • printASCII

        public void printASCII​(java.io.PrintWriter out)
                        throws java.io.IOException
        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:
        java.io.IOException
      • printASCII

        public void printASCII​(java.io.PrintWriter out,
                               java.lang.String indent)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • printASCII

        public void printASCII​(java.io.PrintWriter out,
                               java.lang.String indent,
                               boolean withData)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • printDataASCII

        public void printDataASCII​(java.io.PrintWriter out)
      • printDataASCII

        public void printDataASCII​(java.io.PrintWriter out,
                                   java.lang.String indent)
      • printData

        public static void printData​(java.io.PrintWriter out,
                                     java.lang.String indent,
                                     int[] data)
      • printData

        public static void printData​(java.io.PrintWriter out,
                                     java.lang.String indent,
                                     short[] data)
      • printData

        public static void printData​(java.io.PrintWriter out,
                                     java.lang.String indent,
                                     float[] data)
      • printData

        public static void printData​(java.io.PrintWriter out,
                                     java.lang.String indent,
                                     double[] data)
      • printDataRawBytes

        public void printDataRawBytes​(java.io.PrintWriter out,
                                      java.lang.String indent)
      • read

        public static MSeed3Record read​(java.io.DataInput in)
                                 throws java.io.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:
        java.io.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 information
        offset - byte offset to begin reading buf
      • write

        public void write​(java.io.OutputStream dos)
                   throws java.io.IOException
        write DataHeader contents to a DataOutput stream
        Parameters:
        dos - DataOutput stream to write to
        Throws:
        java.io.IOException
      • asByteBuffer

        public java.nio.ByteBuffer asByteBuffer()
                                         throws java.io.IOException
        write DataHeader contents as a ByteBuffer
        Throws:
        java.io.IOException
      • toByteArray

        public byte[] toByteArray()
      • getLeapSecInRecord

        public int getLeapSecInRecord()
      • setLeapSecInRecord

        public void setLeapSecInRecord​(int value)
      • setStartDateTime

        public void setStartDateTime​(java.time.ZonedDateTime start)
      • setStartDateTime

        public void setStartDateTime​(java.time.Instant start)
      • getStartDateTime

        public java.time.ZonedDateTime 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

        public java.time.Instant 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

        public java.lang.String getStartTimeString()
        Get the value of startTime.
        Returns:
        Value of startTime.
      • nanosToString

        public static java.lang.String nanosToString​(int nanos)
        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

        public java.time.ZonedDateTime 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

        public java.time.ZonedDateTime 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

        public java.lang.String 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

        public java.lang.String toString()
        Present a default string representation of the contents of this object
        Overrides:
        toString in class java.lang.Object
        Returns:
        formatted string of object contents
      • getExtraHeaders

        public org.json.JSONObject getExtraHeaders()
      • getRecordIndicator

        public java.lang.String getRecordIndicator()
      • setRecordIndicator

        public void setRecordIndicator​(java.lang.String recordIndicator)
      • getFormatVersion

        public byte getFormatVersion()
      • setFormatVersion

        public void setFormatVersion​(byte formatVersion)
      • getFlags

        public byte getFlags()
      • setFlags

        public void setFlags​(byte flags)
      • startFieldsInUtilFormat

        public java.lang.String 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

        public java.lang.String 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

        public java.lang.String getExtraHeadersAsString​(int indent)
      • setExtraHeaders

        public void setExtraHeaders​(java.lang.String extraHeaders)
      • setExtraHeaders

        public void setExtraHeaders​(org.json.JSONObject extraHeaders)
      • getSourceId

        public FDSNSourceId 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

        public java.lang.String getSourceIdStr()
        Gets the raw sourceid header field as a String.
        Returns:
      • setSourceId

        public void setSourceId​(java.lang.String sourceId)
      • setSourceId

        public void setSourceId​(FDSNSourceId sourceId)
      • 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

        public int steim1Timeseries​(int[] data)
                             throws edu.iris.dmc.seedcodec.SteimException,
                                    java.io.IOException
        Throws:
        edu.iris.dmc.seedcodec.SteimException
        java.io.IOException
      • steim1Timeseries

        public int steim1Timeseries​(int[] data,
                                    int maxFrames)
                             throws edu.iris.dmc.seedcodec.SteimException,
                                    java.io.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
        java.io.IOException
      • steim2Timeseries

        public int steim2Timeseries​(int[] data)
                             throws edu.iris.dmc.seedcodec.SteimException,
                                    java.io.IOException
        Throws:
        edu.iris.dmc.seedcodec.SteimException
        java.io.IOException
      • steim2Timeseries

        public int steim2Timeseries​(int[] data,
                                    int maxFrames)
                             throws edu.iris.dmc.seedcodec.SteimException,
                                    java.io.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
        java.io.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.CodecException
        Decompress the data in this record according to the compression type in the header.
        Returns:
        Throws:
        SeedFormatException - if no blockette 1000 present
        edu.iris.dmc.seedcodec.UnsupportedCompressionType
        edu.iris.dmc.seedcodec.CodecException
      • getSize

        public int getSize()
        Gets the number of bytes for this record.
        Returns:
      • getDefaultStartTime

        public static final java.time.ZonedDateTime getDefaultStartTime()