Ignore:
Timestamp:
08/22/14 15:06:02 (10 years ago)
Author:
lahlod
Message:

other_scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scripts_Laura/ARCTIC/Travail_CEN/cartesian_grid_test.py

    r46 r56  
    3232    # definition of the new cartesian grid (x, y) # 
    3333    ###############################################  
    34     x0 = -3000. # min limit of grid 
    35     x1 = 2500. # max limit of grid 
     34    x0 = -3000. # min x limit of grid (in km) 
     35    x1 = 2500. # max x limit of grid (in km) 
    3636    xvec = np.arange(x0, x1+dx, dx) 
    3737    nx = len(xvec)  
    38     y0 = -3000. # min limit of grid 
    39     y1 = 3000. # max limit of grid 
     38    y0 = -3000. # min y limit of grid (in km) 
     39    y1 = 3000. # max y limit of grid (in km) 
    4040    yvec = np.arange(y0, y1+dy, dy) 
    4141    ny = len(yvec) 
    42     xgrid_cart, ygrid_cart= np.meshgrid(xvec, yvec) # new cartesian grid (centered on North pole) 
     42    xgrid_cart, ygrid_cart= np.meshgrid(xvec, yvec) # new cartesian grid (centered on North pole [x, y] = [0, 0]) 
    4343 
    4444 
     
    4646    # calculation of the new gridding # 
    4747    ###################################  
    48     zgrid_output = np.zeros([ny, nx, nb_days], float) 
    49     ngrid_output = np.zeros([ny, nx, nb_days], float) 
    50     z2grid_output = np.zeros([ny, nx, nb_days], float) 
    51     sigmagrid_output = np.zeros([ny, nx, nb_days], float) 
    52     bblat = nonzero(lati >= 65.) # only select high latitude values of z 
     48    zgrid_output = np.zeros([ny, nx, nb_days], float) # 3D-array of data in new cartesian grid 
     49    ngrid_output = np.zeros([ny, nx, nb_days], float) # 3D-array of number of data in each grid cell of new cartesian grid 
     50    z2grid_output = np.zeros([ny, nx, nb_days], float) # 3D-array of data*data in new cartesian grid 
     51    sigmagrid_output = np.zeros([ny, nx, nb_days], float) # 3D-array of std of data in each grid cell of new cartesian grid 
     52    bblat = nonzero(lati >= 65.) # only select high latitude observations (above 65° lat) 
    5353    for ijr in range (0, nb_days): # loop on time - here time = days 
    5454        bbjour = nonzero(jour[bblat] == ijr + 1.)[0] 
     
    6161        # origin of the (x, y) grid : (x=0, y=0) <=> (lon=0, lat=0)  
    6262        L = len(z) 
    63         Rt = 6371. 
    64         alpha = (pi*Rt)/180. 
     63        Rt = 6371. # radius of earth 
     64        alpha = (pi*Rt)/180. # convertion from deg to rad angles 
    6565        beta = pi/180. 
    66         x = np.zeros([L], float) 
    67         y = np.zeros([L], float) 
     66        x = np.zeros([L], float) # x coordinates of new cartesian grid 
     67        y = np.zeros([L], float) # y coordinates of new cartesian grid 
    6868        for k in range (0, L): 
    6969                if ((longitude[k] >= 0.) & (longitude[k] <= 90.)): # 4eme quadrant 
     
    9090                        ix[i] = 0 
    9191                else: 
    92                         ix[i] = math.ceil((x[i] - x0) / dx) - 1 # associates each x vakue to a cell number 
     92                        ix[i] = math.ceil((x[i] - x0) / dx) - 1 # associates each x value to a cell number 
    9393        i = 0 
    9494        iy = np.zeros([L], int)  
     
    101101        # calculation of distances between point M(x,y) and 4 grid points of its belonging cell # 
    102102        ######################################################################################### 
    103         close_point = np.zeros([L, 2], int) 
     103        close_point = np.zeros([L, 2], int) # for x- and y-axis, 2D-array of closest grid cell of new cartesian grid to observation  
    104104        k = 0 
    105105        for k in range (0, L): # boucle sur les points M (x et y) 
     
    108108                d3 = sqrt(((x[k] - xvec[ix[k]]) ** 2) + ((y[k] - yvec[iy[k] + 1]) ** 2)) 
    109109                d4 = sqrt(((x[k] - xvec[ix[k] + 1]) ** 2) + ((y[k] - yvec[iy[k] + 1]) ** 2)) 
    110                 d_vec = np.array([d1, d2, d3, d4]) 
     110                d_vec = np.array([d1, d2, d3, d4]) # vector of distances between observation and each closer grid_cell of new cartesian grid 
    111111                ind = np.where(d_vec == min(d_vec)) # finds the smallest distance between the 4 points of the grid 
    112112                point_vec = np.array([(ix[k], iy[k]), (ix[k] + 1, iy[k]), (ix[k], iy[k] + 1), (ix[k] + 1, iy[k] + 1)])  
Note: See TracChangeset for help on using the changeset viewer.