{"action":"created","issue":{"url":"https://api.github.com/repos/obspy/obspy/issues/1594","repository_url":"https://api.github.com/repos/obspy/obspy","labels_url":"https://api.github.com/repos/obspy/obspy/issues/1594/labels{/name}","comments_url":"https://api.github.com/repos/obspy/obspy/issues/1594/comments","events_url":"https://api.github.com/repos/obspy/obspy/issues/1594/events","html_url":"https://github.com/obspy/obspy/issues/1594","id":190079763,"number":1594,"title":"remove_response output unit","user":{"login":"rdno","id":77037,"avatar_url":"https://avatars.githubusercontent.com/u/77037?v=3","gravatar_id":"","url":"https://api.github.com/users/rdno","html_url":"https://github.com/rdno","followers_url":"https://api.github.com/users/rdno/followers","following_url":"https://api.github.com/users/rdno/following{/other_user}","gists_url":"https://api.github.com/users/rdno/gists{/gist_id}","starred_url":"https://api.github.com/users/rdno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdno/subscriptions","organizations_url":"https://api.github.com/users/rdno/orgs","repos_url":"https://api.github.com/users/rdno/repos","events_url":"https://api.github.com/users/rdno/events{/privacy}","received_events_url":"https://api.github.com/users/rdno/received_events","type":"User","site_admin":false},"labels":[{"id":36865675,"url":"https://api.github.com/repos/obspy/obspy/labels/.core","name":".core","color":"0b02e1","default":false},{"id":37301337,"url":"https://api.github.com/repos/obspy/obspy/labels/.signal","name":".signal","color":"0b02e1","default":false},{"id":456129202,"url":"https://api.github.com/repos/obspy/obspy/labels/priority:%20high","name":"priority: high","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-17T15:33:47Z","updated_at":"2016-11-18T14:21:05Z","closed_at":null,"body":"Hi,\r\n\r\nI was testing instrument response removal with two different files (RESP file and Station.xml). I noticed that while output unit is velocity, outputs are matched. However, when output unit is velocity they are different.\r\n\r\nI am using the `simulate` method for RESP file and `remove_response` method for Station.xml file.\r\n\r\nCodes I have used and their plots are below:\r\n```python\r\nsac_file = \"seis/obsd/RSSD.IU.10.LHZ.obs.sac\"\r\nresp_file = \"seis/obsd/RESP.IU.RSSD.10.BHZ\"\r\nstaxml = \"staxml/IU.RSSD.xml\"\r\npre_filt = [0.007273, 0.009091, 0.022222, 0.026667]\r\nst = obspy.read(sac_file)\r\nseedresp = {'filename': resp_file,\r\n            'units': 'VEL'}\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.simulate(paz_remove=None, pre_filt=pre_filt, seedresp=seedresp)\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n\r\ninv = obspy.read_inventory(staxml)\r\nst2 = obspy.read(sac_file)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.remove_response(output=\"VEL\", inventory=inv, pre_filt=pre_filt,\r\n                    zero_mean=False, taper=False)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n```\r\n\r\n![resp_vs_xml](https://cloud.githubusercontent.com/assets/77037/20393756/5353eaf6-acdd-11e6-825d-5beaadbcc6bd.png)\r\n\r\n```python\r\nsac_file = \"seis/obsd/RSSD.IU.10.LHZ.obs.sac\"\r\nresp_file = \"seis/obsd/RESP.IU.RSSD.10.BHZ\"\r\nstaxml = \"staxml/IU.RSSD.xml\"\r\npre_filt = [0.007273, 0.009091, 0.022222, 0.026667]\r\n\r\nst = obspy.read(sac_file)\r\nseedresp = {'filename': resp_file,\r\n            'units': 'DISP'}\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.simulate(paz_remove=None, pre_filt=pre_filt, seedresp=seedresp)\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n\r\ninv = obspy.read_inventory(staxml)\r\nst2 = obspy.read(sac_file)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.remove_response(output=\"DISP\", inventory=inv, pre_filt=pre_filt,\r\n                    zero_mean=False, taper=False)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n```\r\n\r\n![resp_vs_xml_in_disp](https://cloud.githubusercontent.com/assets/77037/20393807/8713c258-acdd-11e6-8200-a8b4b41b69d6.png)\r\n\r\nIf the output unit is set to velocity in `remove_response`, the integral of the output is consistent with the `simulate` (with displacement output):\r\n```python\r\nst = obspy.read(sac_file)\r\nseedresp = {'filename': resp_file,\r\n            'units': 'DISP'}\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.simulate(paz_remove=None, pre_filt=pre_filt, seedresp=seedresp)\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n\r\ninv = obspy.read_inventory(staxml)\r\nst2 = obspy.read(sac_file)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.remove_response(output=\"VEL\", inventory=inv, pre_filt=pre_filt,\r\n                    zero_mean=False, taper=False)\r\nst2.integrate()\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n```\r\n![resp_vs_xml_in_disp_integral_of_xml](https://cloud.githubusercontent.com/assets/77037/20394503/00cdf058-ace0-11e6-9dce-39418c6a5964.png)\r\n\r\nCheck if the integral of `VEL` is equals to `DISP`:\r\n```python\r\ninv = obspy.read_inventory(staxml)\r\nst = obspy.read(sac_file)\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.remove_response(output=\"VEL\", inventory=inv, pre_filt=pre_filt,\r\n                   zero_mean=False, taper=False)\r\nst.integrate()\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n\r\ninv = obspy.read_inventory(staxml)\r\nst2 = obspy.read(sac_file)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.remove_response(output=\"DISP\", inventory=inv, pre_filt=pre_filt,\r\n                    zero_mean=False, taper=False)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n```\r\n![xmls](https://cloud.githubusercontent.com/assets/77037/20394891/621891c8-ace1-11e6-9f0e-e948dcc72f49.png)\r\n\r\nSame check for RESP file:\r\n```python\r\nst = obspy.read(sac_file)\r\nseedresp = {'filename': resp_file,\r\n            'units': 'VEL'}\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.simulate(paz_remove=None, pre_filt=pre_filt, seedresp=seedresp)\r\nst.integrate()\r\nst.detrend(\"demean\")\r\nst.detrend(\"linear\")\r\nst.taper(max_percentage=0.05)\r\nst.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n\r\nst2 = obspy.read(sac_file)\r\nseedresp = {'filename': resp_file,\r\n            'units': 'DISP'}\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.simulate(paz_remove=None, pre_filt=pre_filt, seedresp=seedresp)\r\nst2.detrend(\"demean\")\r\nst2.detrend(\"linear\")\r\nst2.taper(max_percentage=0.05)\r\nst2.filter(\"bandpass\", freqmin=1.0/110, freqmax=1.0/45)\r\n```\r\n![resps](https://cloud.githubusercontent.com/assets/77037/20394912/6d704ac0-ace1-11e6-82ac-72725a32f749.png)\r\n---\r\nData files I have used: [datas.zip](https://github.com/obspy/obspy/files/597749/datas.zip)\r\n\r\nIt seems like there is a problem with `remove_response`'s units. I have also tested with `SAC`. It is consistent with `simulate` output. Are there anything wrong with the usage of `remove_response` in these examples? If so, let me know.\r\n\r\nThanks. "},"comment":{"url":"https://api.github.com/repos/obspy/obspy/issues/comments/261542556","html_url":"https://github.com/obspy/obspy/issues/1594#issuecomment-261542556","issue_url":"https://api.github.com/repos/obspy/obspy/issues/1594","id":261542556,"user":{"login":"megies","id":1842780,"avatar_url":"https://avatars.githubusercontent.com/u/1842780?v=3","gravatar_id":"","url":"https://api.github.com/users/megies","html_url":"https://github.com/megies","followers_url":"https://api.github.com/users/megies/followers","following_url":"https://api.github.com/users/megies/following{/other_user}","gists_url":"https://api.github.com/users/megies/gists{/gist_id}","starred_url":"https://api.github.com/users/megies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megies/subscriptions","organizations_url":"https://api.github.com/users/megies/orgs","repos_url":"https://api.github.com/users/megies/repos","events_url":"https://api.github.com/users/megies/events{/privacy}","received_events_url":"https://api.github.com/users/megies/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T14:21:05Z","updated_at":"2016-11-18T14:21:05Z","body":"> Do you have an advice on how to select the water_level value? Doesn't high values have potential to cause problems, too? For this example, water_level as low as 70 seems to give the \"right\" result.\r\n\r\nUsing water level in response removal always needs the user to set sane values, and those values depend dramatically on *a)* the shape of the response curve (as the water level is relative to the lowest point in the inverted spectrum, i.e. relative to the peak of the amplitude response) and *b)* on the frequency range you're actually interested in. So, unfortunately, **there is no universally valid value for the water level**.  For that reason I've added the plot option (`remove_response(..., plot=True)`) to see exactly what is happening to your data. Obviously, higher values of the water level lead to potentially over-corrected \"blown-up\" parts in the result, and low values might lead to a cut-off in the inverted spectrum in frequency regions you're interested in (and thus potential distortions)."}}
{"actor":{"display_login":"megies"}}