PIC-IRIS / PH5

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

[BUG] ph5tostationxml generates xml with incorrect response information for ph5 with multiple instrument gains #528

Closed Stephen-Veitch closed 3 months ago

Stephen-Veitch commented 5 months ago

BUG: When requesting a response-level stationXML across multiple arrays from a ph5 with SmartSolos using two different gains, ph5tostationxml will generate a stationXML with identical response information for all instruments, regardless of gain setting.

The response information in the output stationXML is consistent with the gain settings for the instruments in the lowest numbered array requested, regardless of the order they are requested within the command line, ie ph5tostationxml -n master.ph5 -a 001,002 --level=response ... and ph5tostationxml -n master.ph5 -a 002,003 --level=response ... Will produce identical stationXMLs with response information from array 001 applied to all channels in the in the file.

Similarly, ph5tostationxml -n master.ph5 -a 002,003 --level=response ... will generate a stationXML with response information from array 002 applied to all stations/channels in arrays 002 and 003, regardless of the true gain settings of each station/channel.

Requesting stationXMLs for each array individually (assuming--as is the SoP for PIC ph5 archives--that all station/channels within each array are set to the same gain setting) produces stationXMLs with correct responses.

Desired Behaviour: At a minimum, ph5tostationxml should be able to generate a response-level stationXML with correct response information across multiple arrays for archives with consistent sensor-types, but different gain settings in cases where gains are consistent within arrays, but not across the entire archive.

Ideally, a requested stationXML should be able handle mixed gain settings within a single array, however since splitting stations with distinct gains in to different arrays is SoP for PIC projects at current time, ability to return correct responses for mixed-gains within a single array is a lower-priority goal.

Archives with mixed-gain arrays (and stations/id_s) exist in archive at current. So fix should be able to handle this.

To Reproduce: Commands are listed above. This bug was generated from the ph5 for 24-004 in which arrays 001,003,005,006 are smartsolos set to 36db and arrays 002,004 are smartsolos set to 18db

Other: Not tested or addressed here, but this should also be tested for archives with varied sample rates between channels/arrays.

Stephen-Veitch commented 5 months ago

This bug affects ph5ws and the MDA:

For ph5ws stationXML requests, ph5ws returns response information consistent with 36db regardless of how the request is formed, and regardless of whether the request includes a mix of 36db and 18db stations, or only 18dB stations. This is inconsistent with a locally run ph5tostationXML which will return proper responses if only stations with 18db are requested.

See the following links for example requests: The field of interest in these is: (sensitivity for 36 db ~= 4902075, 18db ~= 612756) `

############` Stationwise request for 10001 (36db) and 20120 (18db ) [https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=10001,20120&loc=*&cha=*&sta[…]ime=2024-02-29T00:00:00&level=response&format=xml&nodata=404](https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=10001,20120&loc=*&cha=*&starttime=2024-01-01T00:00:00&endtime=2024-02-29T00:00:00&level=response&format=xml&nodata=404) Stationwise request for only 20120 [https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=20120&loc=*&cha=*&starttime[…]ime=2024-02-29T00:00:00&level=response&format=xml&nodata=404](https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=20120&loc=*&cha=*&starttime=2024-01-01T00:00:00&endtime=2024-02-29T00:00:00&level=response&format=xml&nodata=404) Stationwise request for 40033 (18db) [https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=40033&loc=*&cha=*&starttime[…]ime=2024-02-29T00:00:00&level=response&format=xml&nodata=404](https://service.iris.edu/ph5ws/station/1/query?net=XW&sta=40033&loc=*&cha=*&starttime=2024-01-01T00:00:00&endtime=2024-02-29T00:00:00&level=response&format=xml&nodata=404) Arraywise Request for array 002 (18db): https://service.iris.edu/ph5ws/station/1/query?level=response&format=xml&reportnum=24-004&arrayid=002&component=*&receiver=*&nodata=404 For the MDA, this bug is visible in the response graphs on the channel pages. For example: Both https://ds.iris.edu/mda/XW/10001/--/DPZ/?starttime=2024-01-10&endtime=2024-02-07 and https://ds.iris.edu/mda/XW/20120/--/DPZ/?starttime=2024-01-12&endtime=2024-02-12 Show a sensativity of 4902075 (36dB). Correctly for station 10001 and erroneously for station 20120. For this archive Stations 1????,3????,5????,6???? have gain set to 36dB, and 2???? & 4???? have a gain set to 18db