PIC-IRIS / PH5

Library of PH5 clients, apis, and utilities
Other
15 stars 9 forks source link

[BUG] Output from PH5toStationxml does not match resp store in PH5 Pole:PlusError== Pole:minusError==Pole:Value #471

Open timronan opened 3 years ago

timronan commented 3 years ago

Describe the bug PH5tostationxml is outputting stationxml files where Pole:Real:PlusError== Pole:Real:minusError==Pole:Real:Value and Pole:Imaginary:PlusError== Pole:Imaginary:minusError==Pole:Imaginary:Value.

Here is an example:

              <Pole number="0">
                <Real minusError="-21.99" plusError="-21.99">-21.99</Real>
                <Imaginary minusError="22.43" plusError="22.43">22.43</Imaginary>
              </Pole>
              <Pole number="1">
                <Real minusError="-21.99" plusError="-21.99">-21.99</Real>
                <Imaginary minusError="-22.43" plusError="-22.43">-22.43</Imaginary>
              </Pole>
            </PolesZeros>

This is definitively occurring ph5tostationxml because if the statement print(response_file_das_a) is added to line 470 in ph5tostationxml the output from the store response file is returned to the screen which shows:

#       Complex poles:
#         i  real          imag          real_error    imag_error
B053F15-18    0 -2.199000E+01  2.243000E+01  0.000000E+00  0.000000E+00
B053F15-18    1 -2.199000E+01 -2.243000E+01  0.000000E+00  0.000000E+00

and is what we expected based on the input response.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior: Run PH5toStationxml on any PH5 experiment that has poles and zeros. Inspect the output from the Poles and zeros.

Expected behavior

#       =======================================
#       +               +--------------------------------------------+                +
#       +               |   Response (Poles & Zeros),  N301 ch DPZ   |                +
#       +               +--------------------------------------------+                +
#       
B053F03     Transfer function type:                A [Laplace Transform (Rad/sec)]
B053F04     Stage sequence number:                 1
B053F05     Response in units lookup:              M/S - velocity in meters per second
B053F06     Response out units lookup:             V - emf in volts
B053F07     A0 normalization factor:               0.999813
B053F08     Normalization frequency:               40
B053F09     Number of zeroes:                      2
B053F14     Number of poles:                       2
#       Complex zeroes:
#         i  real          imag          real_error    imag_error
B053F10-13    0  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
B053F10-13    1  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
#       Complex poles:
#         i  real          imag          real_error    imag_error
B053F15-18    0 -2.199000E+01  2.243000E+01  0.000000E+00  0.000000E+00
B053F15-18    1 -2.199000E+01 -2.243000E+01  0.000000E+00  0.000000E+00

Should accurately be reflected in output stationxml document.

timronan commented 3 years ago

https://github.com/PIC-IRIS/PH5/blob/3f37169a9444ff787ae5913f277fa926665dd562/ph5/clients/ph5tostationxml.py#L469

Creates this issue and it is very likely occurring in the Obspy read_inventory.

If response_file_das_a, referenced on line 465, is printed the result is as expected:

#       =======================================
#       +               +--------------------------------------------+                +
#       +               |   Response (Poles & Zeros),  N401 ch DPZ   |                +
#       +               +--------------------------------------------+                +
#       
B053F03     Transfer function type:                A [Laplace Transform (Rad/sec)]
B053F04     Stage sequence number:                 1
B053F05     Response in units lookup:              M/S - velocity in meters per second
B053F06     Response out units lookup:             V - emf in volts
B053F07     A0 normalization factor:               0.999813
B053F08     Normalization frequency:               40
B053F09     Number of zeroes:                      2
B053F14     Number of poles:                       2
#       Complex zeroes:
#         i  real          imag          real_error    imag_error
B053F10-13    0  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
B053F10-13    1  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
#       Complex poles:
#         i  real          imag          real_error    imag_error
B053F15-18    0 -2.199000E+01  2.243000E+01  0.000000E+00  0.000000E+00
B053F15-18    1 -2.199000E+01 -2.243000E+01  0.000000E+00  0.000000E+00

When print(dl_resp.get_paz()) is added after line 470 and before line 471 the content below is returned:

Response type: PolesZerosResponseStage, Stage Sequence Number: 1
    From M/S (Velocity in Meters per Second) to V (Volts)
    Stage gain: 76.7144, defined at 40.00 Hz
    Transfer function type: LAPLACE (RADIANS/SECOND)
    Normalization factor: 0.999813, Normalization frequency: 40.00 Hz
    Poles: (-21.99+22.43j), (-21.99-22.43j)
    Zeros: 0j, 0j

These are inconsistent pole and zero representations.

There does not seem to be an easy method for changing the plusError and minusError for obspy_types.ComplexWithUncertainties. Please correct me if I am wrong so this issue can be overridden.

timronan commented 3 years ago

This issue is originating in, and has been posted in Obspy, with seemingly no way to directly correct it in PH5.

https://github.com/obspy/obspy/issues/2864

I am unsure how to move forwards with this issue at this moment.