Changeset 1228 for SHX


Ignore:
Timestamp:
24.07.2017 10:48:48 (2 years ago)
Author:
klaus
Message:

command ampstats (amplitude statistics)

Location:
SHX/trunk/SeismicHandler/commands
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • SHX/trunk/SeismicHandler/commands/create.py

    r1172 r1228  
    1616#    along with SHX.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
     18import numpy as np 
    1819from SeismicHandler.basics.command import BaseCommand 
    1920from SeismicHandler.basics.error import ShxError 
     
    5051       * KUEPPER - kuepper impulse at position <p1>, width <p2> and order <p3> 
    5152       * SIN - sinus wave train with frequency <p1> and phase <p2> 
    52        * RANDOM - random trace 
     53       * RANDOM - random trace, uniform 
     54       * RANDOM_NORMAL - random trace, normal/gauss, <p1> pos, <p2> width  
     55       *  
    5356 
    5457     * <dt> ''parameter type: real''[[BR]] 
     
    131134 
    132135    def _random(self): 
    133         prng = CMWC() 
    134         for i in range(len(self.values)): 
    135             self.values[i] = prng.random() * 2 * self.amplitude - 1 
     136        # CMWC based on random.random is terribly bad, replaced by numpy 
     137        #prng = CMWC() 
     138        #for i in range(len(self.values)): 
     139        #    self.values[i] = prng.random() * 2 * self.amplitude - 1 
     140        self.values = (np.random.random(len(self.values))-0.5)*2.*self.amplitude 
     141 
     142    def _random_normal(self, pos, width): 
     143        self.values = (np.random.normal(pos,width, 
     144            len(self.values))-0.5)*2.*self.amplitude 
     145 
    136146 
    137147    #@timeit 
     
    154164                } 
    155165            ] 
    156         elif _type == "gauss": 
     166        elif _type in ("gauss","random_normal"): 
    157167            # position, width 
    158168            queries = [ 
     
    258268            method(*parameters) 
    259269        except Exception, e: 
    260             raise ShxError("library call failed: %s", e) 
     270            raise ShxError("library call failed: %s" % repr(e)) 
    261271 
    262272        # construct obspy.trace 
  • SHX/trunk/SeismicHandler/commands/spectrogram.py

    r1191 r1228  
    8686     and writes the output to file SPEC.DAT (SH). 
    8787    """ 
    88     numberOfParameters = [1,3,4] 
     88    numberOfParameters = [1,2,3,4,5,6] 
    8989    parameterQueries = [ 
    9090        { 
Note: See TracChangeset for help on using the changeset viewer.