source: trunk/src/scripts_Laura/ARCTIC/Travail_CEN/bina.py @ 56

Last change on this file since 56 was 40, checked in by lahlod, 10 years ago

scripts ajoutes apres CEN

File size: 1.1 KB
Line 
1import numpy as np
2from numpy import *
3
4def bina(x, dx, x0, x1):
5    #
6    # [i, nbins] = bin(x, dx, x0, x1);
7    #
8    # Returns the vector of indices, starting from 1,
9    # corresponding to the chosen bin size, dx,
10    # start x0 and end x1. If x1 is omitted, x1 = max(x) - dx/2.
11    # If x0 is omitted, x0 = min(x) + dx/2. If dx is omitted, the data
12    # are divided into 10 classes. Note that outliers are not removed.
13    #
14    # Tested under MatLab 4.2, 5.0, and 5.1.
15    #
16
17    # 17.1.97, Oyvind.Breivik@gfi.uib.no.
18    #
19    # Oyvind Breivik
20    # Department of Geophysics
21    # University of Bergen
22    # NORWAY
23    #if nargin < 2:
24    #    dx = (max(x) - min(x)) / N
25    #end
26    #if nargin < 3:
27    #x0 = min(x)
28    #end
29    #if nargin < 4:
30    #x1 = max(x) + dx
31    #end
32   
33    nn=size(x)
34    indic = zeros(nn, float)
35   
36    nbins= round((x1 - x0)/dx) + 1
37   
38    for kk in range(0,nn): indic[kk] = round((x[kk] - x0)/dx) + 1
39    #indicp=((x - x0)/dx) + 1
40    #indic = indicp.round();
41
42    #if nargout > 1:
43    nnbins = nbins
44    print size(x), indic
45    return indic
46    #end
Note: See TracBrowser for help on using the repository browser.