obspy.io.mseed.util.set_flags_in_fixed_headers

set_flags_in_fixed_headers(filename, flags)[source]

Updates a given MiniSEED file with some fixed header flags.

Parameters:
  • filename (str) – Name of the MiniSEED file to be changed

  • flags (dict) –

    The flags to update in the MiniSEED file

    Flags are stored as a nested dictionary:

    { trace_id:
        { flag_group:
            { flag_name: flag_value,
                         ...
            },
            ...
        },
        ...
    }
    

    with:

    • trace_id

      A string identifying the trace. A string looking like NETWORK.STATION.LOCATION.CHANNEL is expected, the values will be compared to those found in the fixed header of every record. An empty field will be interpreted as “every possible value”, so "..." will apply to every single trace in the file. Padding spaces are ignored.

    • flag_group

      Which flag group is to be changed. One of 'activity_flags', 'io_clock_flags', 'data_qual_flags' is expected. Invalid flag groups raise a ValueError.

    • flag_name

      The name of the flag. Possible values are matched with obspy.io.mseed.headers.FIXED_HEADER_ACTIVITY_FLAGS, FIXED_HEADER_IO_CLOCK_FLAGS or FIXED_HEADER_DATA_QUAL_FLAGS depending on the flag_group. Invalid flags raise a ValueError.

    • flag_value

      The value you want for this flag. Expected value is a bool (always True/False) or a dict to store the moments and durations when this flag is True. Expected syntax for this dict is accurately described in obspy.io.mseed.util._check_flag_value.

Raises:
  • IOError – if the file is not a MiniSEED file

  • ValueError – if one of the flag group, flag name or flag value is incorrect

Example: to add a Calibration Signals Present flag (which belongs to the Activity Flags section of the fixed header) to every record, flags should be:

{ "..." : { "activity_flags" : { "calib_signal" : True }}}

Example: to add a Event in Progress flag (which belongs to the Activity Flags section of the fixed header) from 2009/12/23 06:00:00 to 2009/12/23 06:30:00, from 2009/12/24 10:00:00 to 2009/12/24 10:30:00 and at precise times 2009/12/26 18:00:00 and 2009/12/26 18:04:00, flags should be:

date1 = UTCDateTime("2009-12-23T06:00:00.0")
date2 = UTCDateTime("2009-12-23T06:30:00.0")
date3 = UTCDateTime("2009-12-24T10:00:00.0")
date4 = UTCDateTime("2009-12-24T10:30:00.0")
date5 = UTCDateTime("2009-12-26T18:00:00.0")
date6 = UTCDateTime("2009-12-26T18:04:00.0")
{ "..." :
    { "activity_flags" :
        { "event_in_progress" :
            {"INSTANT" : [date5, date6],
            "DURATION" : [(date1, date2), (date3, date4)]}}}}

Alternative way to mark duration:

{ "..." :
    { "activity_flags" :
        { "event_in_progress" :
            { "INSTANT" : [date5, date6],
              "DURATION" : [date1, date2, date3, date4]}}}}