Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@krischer
Copy link
Member

@krischer krischer commented Jul 28, 2016

Another last minute fix for 1.0.2!! Very small fix but it solves a nasty problem. Includes a regression test.

This fixes an issue when manually settings poles and zeros in a response object and serializing to StationXML. StationXML requires numbers attributes which have to be written.

# cut down to a single channel.
inv = obspy.read_inventory()
inv.networks = inv[:1]
inv[0].stations = inv[0][:1]
inv[0][0].channels = inv[0][0][:1]

# Manually set the poles and zeros - thus these are cast to our
# custom classes but number are not yet set.
inv[0][0][0].response.response_stages[0].poles = [0 + 1j, 2 + 3j]
inv[0][0][0].response.response_stages[0].zeros = [0 + 1j, 2 + 3j]

inv.write("test.xml", format="stationxml")

Output without this PR:

              <Zero>
                <Real>0.0</Real>
                <Imaginary>1.0</Imaginary>
              </Zero>
              <Zero>
                <Real>2.0</Real>
                <Imaginary>3.0</Imaginary>
              </Zero>
              <Pole>
                <Real>0.0</Real>
                <Imaginary>1.0</Imaginary>
              </Pole>
              <Pole>
                <Real>2.0</Real>
                <Imaginary>3.0</Imaginary>
              </Pole>

Output with this PR:

              <Zero number="0">
                <Real>0.0</Real>
                <Imaginary>1.0</Imaginary>
              </Zero>
              <Zero number="1">
                <Real>2.0</Real>
                <Imaginary>3.0</Imaginary>
              </Zero>
              <Pole number="0">
                <Real>0.0</Real>
                <Imaginary>1.0</Imaginary>
              </Pole>
              <Pole number="1">
                <Real>2.0</Real>
                <Imaginary>3.0</Imaginary>
              </Pole>

@krischer krischer added bug confirmed bug .io issues generally related to our read/write plugins labels Jul 28, 2016
@krischer krischer added this to the 1.0.2 milestone Jul 28, 2016
@krischer krischer self-assigned this Jul 28, 2016
@megies megies merged commit 0a70bd2 into obspy:maintenance_1.0.x Jul 28, 2016
@megies megies deleted the manual_paz_setting branch July 28, 2016 21:20
megies added a commit that referenced this pull request Aug 3, 2016
1.0.2: (doi: 10.5281/zenodo.49636)
 - obspy.core:
   * Added workaround for numpy issue where many FFTs of various lengths fill
     a cache that never gets cleared, effectively creating a memory leak
     (see #1424).
   * Trace.filter and Stream.filter don't work on masked arrays anymore because
     it produced unpredictable results due to the un-initialized data-chunk.
     The uninitialized masked gap is now also initialized to np.nan in case
     of floating point data which and a consistent fill value in case of
     integer data. (see #1363)
 - obspy.clients.fdsn:
   * Fixing issue with location codes potentially resulting in unwanted data
     to be requested. (see #1422)
   * Included low-gain seismometers in default channel filters in
     mass-downloader, also included non-oriented channels by default
     (see #1373).
 - obspy.db:
   * Fixed a bug in obspy-indexer command line script (see #1369,
     command line script was not working, probably since 0.10.0)
 - obspy.imaging:
   * Fixed a bug that leads to pressure/tension color blending when plotting
     semi-transparent DC beachball patches (i.e. with "alpha" not equal to 1,
     see #1464)
   * Fixed a bug when plotting non-DC beachball patches without fill colors
     (i.e. with "nofill=True", see #1464)
   * Fix arbitrary units in waveform section plot's offset axis, making it
     possible to add customizations to the plot afterwards (see #1382, see
     #1383)
 - obspy.io.ascii:
   * Fixed a bug that lead to wrong header information in output files when
     writing non-integer sampling rate data to SLIST or TSPAIR formats
     (see #1447)
- obspy.io.cmtsolution:
   * Make sure newer CMTSOLUTION files can also be read (see #1479).
 - obspy.io.gse2:
   * Fixed a bug that could lead to network code not present in GSE2 output
     (see #1448)
 - obspy.io.mseed:
   * Fixed a bug in obspy-mseed-recordanalyzer (see #1386)
 - obspy.io.nlloc:
   * Use geographic coordinates from the NonLinLoc Hypocenter-Phase file if
     no custom coordinate converter is provided. (see #1390)
   * Fix reading NonLinLoc Hypocenter-Phase files with more than one
     hypocenter in it. (see #1480)
   * Fix reading NonLinLoc Hypocenter-Phase files with unicode characters in
     them. (see #1483)
 - obspy.io.quakeml:
   * Fixed issue with improperly raised warnings when the same file is read
     twice. (#1376)
   * Fix writing empty network/station/channel codes in WaveformStreamID
     objects to QuakeML. (see #1483)
 - obspy.io.sac:
   * Try to set SAC distances (dist, az, baz, gcarc) on read, if "lcalda" is
     true.  If "dist" header is found, distances aren't calculated.
   * SACTrace class returns header values as native Python types instead of
     NumPy types.
   * SACTrace.iqual is no longer accepts enumerated string values, but
     arbitrary integer values. (see #1472)
   * SACTrace.read now replaces non-ASCII and null-termination characters in
     string headers with whitespace unless the "debug_strings=True" flag is
     used. (see #1432)
 - obspy.io.stationxml:
   * Always set the number attribute for poles and zeros. (see #1481)
 - obspy.signal:
   * PPSD.plot(): fix plotting of percentiles, mode and mean and setting
     period limits when using "xaxis_frequency=True" (see #1406, #1416)
   * Work around a bug in SciPy that results in wrong results for bandpass
     filter when using Nyquist frequency (or higher) as high corner of the
     passband (see #1451)
 - obspy.taup:
   * Fixing path for Pn. (see #1392)
aringler-usgs pushed a commit that referenced this pull request Jun 26, 2020
1.0.2: (doi: 10.5281/zenodo.49636)
 - obspy.core:
   * Added workaround for numpy issue where many FFTs of various lengths fill
     a cache that never gets cleared, effectively creating a memory leak
     (see #1424).
   * Trace.filter and Stream.filter don't work on masked arrays anymore because
     it produced unpredictable results due to the un-initialized data-chunk.
     The uninitialized masked gap is now also initialized to np.nan in case
     of floating point data which and a consistent fill value in case of
     integer data. (see #1363)
 - obspy.clients.fdsn:
   * Fixing issue with location codes potentially resulting in unwanted data
     to be requested. (see #1422)
   * Included low-gain seismometers in default channel filters in
     mass-downloader, also included non-oriented channels by default
     (see #1373).
 - obspy.db:
   * Fixed a bug in obspy-indexer command line script (see #1369,
     command line script was not working, probably since 0.10.0)
 - obspy.imaging:
   * Fixed a bug that leads to pressure/tension color blending when plotting
     semi-transparent DC beachball patches (i.e. with "alpha" not equal to 1,
     see #1464)
   * Fixed a bug when plotting non-DC beachball patches without fill colors
     (i.e. with "nofill=True", see #1464)
   * Fix arbitrary units in waveform section plot's offset axis, making it
     possible to add customizations to the plot afterwards (see #1382, see
     #1383)
 - obspy.io.ascii:
   * Fixed a bug that lead to wrong header information in output files when
     writing non-integer sampling rate data to SLIST or TSPAIR formats
     (see #1447)
- obspy.io.cmtsolution:
   * Make sure newer CMTSOLUTION files can also be read (see #1479).
 - obspy.io.gse2:
   * Fixed a bug that could lead to network code not present in GSE2 output
     (see #1448)
 - obspy.io.mseed:
   * Fixed a bug in obspy-mseed-recordanalyzer (see #1386)
 - obspy.io.nlloc:
   * Use geographic coordinates from the NonLinLoc Hypocenter-Phase file if
     no custom coordinate converter is provided. (see #1390)
   * Fix reading NonLinLoc Hypocenter-Phase files with more than one
     hypocenter in it. (see #1480)
   * Fix reading NonLinLoc Hypocenter-Phase files with unicode characters in
     them. (see #1483)
 - obspy.io.quakeml:
   * Fixed issue with improperly raised warnings when the same file is read
     twice. (#1376)
   * Fix writing empty network/station/channel codes in WaveformStreamID
     objects to QuakeML. (see #1483)
 - obspy.io.sac:
   * Try to set SAC distances (dist, az, baz, gcarc) on read, if "lcalda" is
     true.  If "dist" header is found, distances aren't calculated.
   * SACTrace class returns header values as native Python types instead of
     NumPy types.
   * SACTrace.iqual is no longer accepts enumerated string values, but
     arbitrary integer values. (see #1472)
   * SACTrace.read now replaces non-ASCII and null-termination characters in
     string headers with whitespace unless the "debug_strings=True" flag is
     used. (see #1432)
 - obspy.io.stationxml:
   * Always set the number attribute for poles and zeros. (see #1481)
 - obspy.signal:
   * PPSD.plot(): fix plotting of percentiles, mode and mean and setting
     period limits when using "xaxis_frequency=True" (see #1406, #1416)
   * Work around a bug in SciPy that results in wrong results for bandpass
     filter when using Nyquist frequency (or higher) as high corner of the
     passband (see #1451)
 - obspy.taup:
   * Fixing path for Pn. (see #1392)
aringler-usgs pushed a commit that referenced this pull request Jun 26, 2020
1.0.2: (doi: 10.5281/zenodo.49636)
 - obspy.core:
   * Added workaround for numpy issue where many FFTs of various lengths fill
     a cache that never gets cleared, effectively creating a memory leak
     (see #1424).
   * Trace.filter and Stream.filter don't work on masked arrays anymore because
     it produced unpredictable results due to the un-initialized data-chunk.
     The uninitialized masked gap is now also initialized to np.nan in case
     of floating point data which and a consistent fill value in case of
     integer data. (see #1363)
 - obspy.clients.fdsn:
   * Fixing issue with location codes potentially resulting in unwanted data
     to be requested. (see #1422)
   * Included low-gain seismometers in default channel filters in
     mass-downloader, also included non-oriented channels by default
     (see #1373).
 - obspy.db:
   * Fixed a bug in obspy-indexer command line script (see #1369,
     command line script was not working, probably since 0.10.0)
 - obspy.imaging:
   * Fixed a bug that leads to pressure/tension color blending when plotting
     semi-transparent DC beachball patches (i.e. with "alpha" not equal to 1,
     see #1464)
   * Fixed a bug when plotting non-DC beachball patches without fill colors
     (i.e. with "nofill=True", see #1464)
   * Fix arbitrary units in waveform section plot's offset axis, making it
     possible to add customizations to the plot afterwards (see #1382, see
     #1383)
 - obspy.io.ascii:
   * Fixed a bug that lead to wrong header information in output files when
     writing non-integer sampling rate data to SLIST or TSPAIR formats
     (see #1447)
- obspy.io.cmtsolution:
   * Make sure newer CMTSOLUTION files can also be read (see #1479).
 - obspy.io.gse2:
   * Fixed a bug that could lead to network code not present in GSE2 output
     (see #1448)
 - obspy.io.mseed:
   * Fixed a bug in obspy-mseed-recordanalyzer (see #1386)
 - obspy.io.nlloc:
   * Use geographic coordinates from the NonLinLoc Hypocenter-Phase file if
     no custom coordinate converter is provided. (see #1390)
   * Fix reading NonLinLoc Hypocenter-Phase files with more than one
     hypocenter in it. (see #1480)
   * Fix reading NonLinLoc Hypocenter-Phase files with unicode characters in
     them. (see #1483)
 - obspy.io.quakeml:
   * Fixed issue with improperly raised warnings when the same file is read
     twice. (#1376)
   * Fix writing empty network/station/channel codes in WaveformStreamID
     objects to QuakeML. (see #1483)
 - obspy.io.sac:
   * Try to set SAC distances (dist, az, baz, gcarc) on read, if "lcalda" is
     true.  If "dist" header is found, distances aren't calculated.
   * SACTrace class returns header values as native Python types instead of
     NumPy types.
   * SACTrace.iqual is no longer accepts enumerated string values, but
     arbitrary integer values. (see #1472)
   * SACTrace.read now replaces non-ASCII and null-termination characters in
     string headers with whitespace unless the "debug_strings=True" flag is
     used. (see #1432)
 - obspy.io.stationxml:
   * Always set the number attribute for poles and zeros. (see #1481)
 - obspy.signal:
   * PPSD.plot(): fix plotting of percentiles, mode and mean and setting
     period limits when using "xaxis_frequency=True" (see #1406, #1416)
   * Work around a bug in SciPy that results in wrong results for bandpass
     filter when using Nyquist frequency (or higher) as high corner of the
     passband (see #1451)
 - obspy.taup:
   * Fixing path for Pn. (see #1392)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug confirmed bug .io issues generally related to our read/write plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants