From 823f7f324ea94132defe5e54c85b8dc4710baefe Mon Sep 17 00:00:00 2001
From: "Michele.Maris" <michele.maris@inaf.it>
Date: Wed, 2 Aug 2023 11:58:01 +0200
Subject: [PATCH] u

---
 src/yapsut/colored_noise.py | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/yapsut/colored_noise.py b/src/yapsut/colored_noise.py
index 055d7f4..9a16723 100644
--- a/src/yapsut/colored_noise.py
+++ b/src/yapsut/colored_noise.py
@@ -42,8 +42,12 @@ class gaussian_colored_noise :
       return self._freq
    @property
    def ps_shape(self) :
-      """the spectral shape: ps_shape=P(f)**0.5"""
-      return self._S
+      """the spectral shape: ps_shape=P(f)"""
+      return self._S2
+   @property
+   def ps_shape_integral(self) :
+      """the spectral shape integral  (excluding the freq=0 sample)"""
+      return self._ps_shape_integral
    @property
    def seed(self) :
       """the seed of the random number generator"""
@@ -95,20 +99,30 @@ Keywords:
       pl=self.alpha
       with np.errstate(divide='ignore'):
          x=self.fknee/np.where(self._freq==0, np.inf , self._freq)
-         self._S=(1+x**pl)**0.5
+         self._S2=(1+x**pl)
       #
       if self._zero_policy=='0' :
-         self._S[0]=0.
+         self._S2[0]=0.
       elif self._zero_policy=='1' :
-         self._S[0]=1.
+         self._S2[0]=1.
       elif self._zero_policy=='M' :
-         self._S[0]=self.wn_mean
+         self._S2[0]=self.wn_mean
       elif self._zero_policy=='100x1' :
-         self._S[0]=1 if fknee>ff[1] else (1+100*(self.fknee/self._freq[1])**pl)**0.5
+         self._S2[0]=(1+100*(self.fknee/self._freq[1])**pl)
       else : # self._zero_policy=='I' :
          # left things as they are
          pass
       #
+      self._S=self._S2**0.5
+      #
+      x=self.freq[1:]
+      y=self._S2[1:]
+      self._ps_shape_integral=((y[1:]+y[:-1])*(x[1:]-x[:-1])).sum()/2*2
+      #
+   def __len__(self) :
+      return self._N
+   def __str__(self) :
+      return str((self.N,self.wn_mean,self.wn_sigma,self.fknee,self.alpha,self.seed,self._zero_policy))
    def __call__(self,OutAll=False) :
       """computes the colored noise, if OutAll == False returns just the cn if True returns 
       (colored_noise,white_noise,colored_noise_rfft, colored_noise_shape, white_noise_rfft, original_white_noise)
-- 
GitLab