Class MSeed3Record

java.lang.Object
edu.sc.seis.seisFile.mseed3.MSeed3Record

public class MSeed3Record extends Object
  • Field Details

    • MINISEED_THREE_MIME

      public static final String MINISEED_THREE_MIME
      See Also:
    • TIME_LEAP_SECOND

      public static final String TIME_LEAP_SECOND
      See Also:
    • UNKNOWN_DATA_VERSION

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

      protected 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 String sourceIdStr
    • sourceId

      protected FDSNSourceId sourceId
    • extraHeadersStr

      protected String 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

      public static final ZoneId TZ_UTC
    • ZULU

      public static final String ZULU
      See Also:
    • FDSN_PREFIX

      public static final String 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

      protected static final String 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

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

      public void printASCII(PrintWriter out, String indent) throws IOException
      Throws:
      IOException
    • printASCII

      public void printASCII(PrintWriter out, String indent, boolean withData) throws IOException
      Throws:
      IOException
    • printDataASCII

      public void printDataASCII(PrintWriter out)
    • printDataASCII

      public void printDataASCII(PrintWriter out, String indent)
    • printData

      public static void printData(PrintWriter out, String indent, int[] data)
    • printData

      public static void printData(PrintWriter out, String indent, short[] data)
    • printData

      public static void printData(PrintWriter out, String indent, float[] data)
    • printData

      public static void printData(PrintWriter out, String indent, double[] data)
    • printDataRawBytes

      public void printDataRawBytes(PrintWriter out, String indent)
    • read

      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 information
      offset - byte offset to begin reading buf
    • write

      public void write(OutputStream dos) throws IOException
      write DataHeader contents to a DataOutput stream
      Parameters:
      dos - DataOutput stream to write to
      Throws:
      IOException
    • fromByteBuffer

      public static MSeed3Record fromByteBuffer(ByteBuffer buf) throws IOException, SeedFormatException
      read record contents from a ByteBuffer
      Throws:
      IOException
      SeedFormatException
    • asByteBuffer

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

      public byte[] toByteArray()
    • getLeapSecInRecord

      public int getLeapSecInRecord()
    • setLeapSecInRecord

      public void setLeapSecInRecord(int value)
    • setStartDateTime

      public void setStartDateTime(ZonedDateTime start)
    • setStartDateTime

      public void setStartDateTime(Instant start)
    • getStartDateTime

      public 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 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 String getStartTimeString()
      Get the value of startTime.
      Returns:
      Value of startTime.
    • nanosToString

      public static 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 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 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 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 String toString()
      Present a default string representation of the contents of this object
      Overrides:
      toString in class Object
      Returns:
      formatted string of object contents
    • getExtraHeaders

      public org.json.JSONObject getExtraHeaders()
    • getRecordIndicator

      public String getRecordIndicator()
    • setRecordIndicator

      public void setRecordIndicator(String recordIndicator)
    • getFormatVersion

      public byte getFormatVersion()
    • setFormatVersion

      public void setFormatVersion(byte formatVersion)
    • getFlags

      public byte getFlags()
    • setFlags

      public void setFlags(byte flags)
    • startFieldsInUtilFormat

      public 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 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 String getExtraHeadersAsString(int indent)
    • setExtraHeaders

      public void setExtraHeaders(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 String getSourceIdStr()
      Gets the raw sourceid header field as a String.
      Returns:
    • setSourceId

      public void setSourceId(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, IOException
      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

      public int steim2Timeseries(int[] data) throws edu.iris.dmc.seedcodec.SteimException, IOException
      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.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 ZonedDateTime getDefaultStartTime()