# envelope + nomalize trace

**URL:** <https://discourse.obspy.org/t/envelope-nomalize-trace/517>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [March 28, 2016, 11:47am UTC](https://discourse.obspy.org/t/envelope-nomalize-trace/517 "2016-03-28T11:47:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolaos\_Triantafyll](https://discourse.obspy.org/user_avatar/discourse.obspy.org/nikolaos_triantafyll/32/264_2.png) [@Nikolaos\_Triantafyll](https://discourse.obspy.org/u/Nikolaos_Triantafyll)\
**Post date:** [March 28, 2016, 11:47am UTC](https://discourse.obspy.org/t/envelope-nomalize-trace/517/1 "2016-03-28T11:47:50Z")

</div>

Dear all,

1)  
I'm trying to envelope a trace using the obspy.signal.filter.envelope function.

I get this warning:  
/usr/local/lib/python2.7/dist-packages/obspy/signal/filter.py:209: RuntimeWarning: invalid value encountered in sqrt  
&nbsp;&nbsp;&nbsp;data = (data \*\* 2 + hilb \*\* 2) \*\* 0.5

Does anyone know, what is this?

What's the difference by using the obspy.signal.cpxtrace.envelope function?

2)  
After the filter.envelope, I'm trying to normalize the trace but I get an "nan" array of data:  
[nan nan nan ..., nan nan nan]

This is not happening though if I use the cpxtrace.envelope function.

Any ideas?

Thank you in advance,

Nikos Triantafyllis

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [March 28, 2016, 1:07pm UTC](https://discourse.obspy.org/t/envelope-nomalize-trace/517/2 "2016-03-28T13:07:19Z")

</div>

Hi Nikos,

can you send a small sample that reproduces the behavior?

I suspect your data is either zero or somehow causes the envelope  
calculation to be unstable. I guess that the data after the envolope  
calculation is all zero -\> then trace.normalize() might create a NaN  
array (ObsPy 1.0.1 fixes this).

If this turns out to be a bug, please open an issue on GitHub.

Cheers!

Lion

---

<div class="post-metadata">

**Author:** ![Nikolaos\_Triantafyll](https://discourse.obspy.org/user_avatar/discourse.obspy.org/nikolaos_triantafyll/32/264_2.png) [@Nikolaos\_Triantafyll](https://discourse.obspy.org/u/Nikolaos_Triantafyll)\
**Post date:** [March 28, 2016, 10:29pm UTC](https://discourse.obspy.org/t/envelope-nomalize-trace/517/3 "2016-03-28T22:29:42Z")

</div>

Hi Lion,

I attach a python script and the mseed file.

Thank you again,  
Nikos

[data\_HNN.mseed](https://discourse.obspy.org/uploads/short-url/r2Ycs8EP0Aw4dSQzGTMqFzGchNL.mseed) (75.5 KB)

[envel.py](https://discourse.obspy.org/uploads/short-url/gxxBVRuEGqkQpwucJD01XBrP2A7.py) (1.23 KB)
