# Removing Instrument Response - Velocity or Displacement for beamforming

**URL:** <https://discourse.obspy.org/t/removing-instrument-response-velocity-or-displacement-for-beamforming/1185>\
**Category:** Usage Questions\
**Created:** [February 15, 2021, 2:59pm UTC](https://discourse.obspy.org/t/removing-instrument-response-velocity-or-displacement-for-beamforming/1185 "2021-02-15T14:59:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ds784](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@ds784](https://discourse.obspy.org/u/ds784)\
**Post date:** [February 15, 2021, 2:59pm UTC](https://discourse.obspy.org/t/removing-instrument-response-velocity-or-displacement-for-beamforming/1185/1 "2021-02-15T14:59:42Z")

</div>

Hi, I am looking to carry out some beamforming to determine the incoming direction of secondary microseisms in a frequency range of 0.125-0.5 Hz. I am a bit confused about how to remove the instrument response in the proper way without introducing artefacts.  
I am currently removing the mean and linear trend (from each 2-hr time series) followed by pre-filtering before converting to displacement with remove\_response and finally resampling to 1 Hz (from 50 Hz). Is this the correct order of processing steps, and I am also confused as to whether I should be converting to displacement or velocity (have seen both done in papers on the subject).  
Thanks, here is the code.

```python
n=0
Archive='/raid1/ds784/trash/' #path to where data is stored
st = Stream()
for file in sorted(glob.glob(Archive + '3_clean_data_2/'+'*HZ*')):
        n=n+1
        try:
            #extract file name and path
            filename=file.split('/')[-1]
            print(filename,n,"/",len(glob.glob(Archive + '3_clean_data_2/'+'*HZ*')))
            outpath=out_dir
    
            #read in file
            st = read(file)
            print(st)
            st_copy=st.copy()
            
            #demean and detrend data
            #st_copy.plot()
            st_copy.detrend("demean")
            st_copy.detrend("linear")
    
            pre_filt = [0.04, 0.08, 10, 20]
            #Remove instrument reponse

            st_copy.remove_response(output="DISP", inventory=inv, pre_filt=pre_filt, zero_mean=False, taper=True)
            #st_copy.plot()
            
            st_copy.resample(1)
            #st_copy.plot()
            #merge gaps
            #st_copy.merge(method=0, fill_value='interpolate')            
            
            #write out file (over-writing original)
            st_copy.write(outpath+filename,format='MSEED')
            print('writing: ',outpath+filename)
        except:
            print('failed on file:', file)

```

---

<div class="post-metadata">

**Author:** ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)\
**Post date:** [February 22, 2021, 2:09pm UTC](https://discourse.obspy.org/t/removing-instrument-response-velocity-or-displacement-for-beamforming/1185/2 "2021-02-22T14:09:30Z")

</div>

Hi, I think most common is response removal to velocity, because that is the observable modern seismometers record.

For resampling you can use the decimate method, which is sufficient in your case.
