[Thread Prev][Thread Next][Index]

[ferret_users] RE: sampling point data from a 3D grid



Hello all,

I answered this question after looking through the documentation more. For future users who want to sample their 3D gridded data to point data form (that is, in 1D), I'll show what I did.

After sampling your 3D data onto 2 dimensions (lon,lat) using samplexy, it appears the best thing to do is use the @weq transformation. The information is held there in the documentation, so look for @WEQ on the ferret page for exactly the same thing I'm writing here.

1. identify correct depth levels
    let zero_at_my_zees = MY_DEPTHS - z[g=MY_NEW_2D_GRID]         ! In this case MY_DEPTHS is a x*y*z length 1D array, while MY_NEW_2D_GRID is a x*y*z by z 2D array.
2. create the weighting for interpolating
    let kernal = zero_at_my_zees[z=@weq:0]
3. Apply the weights to the depths chosen by @WEQ
    let integrand = kernal*MY_VARIABLE
4. sum the weighted depths to get the interpolated value on your new x*y*z 1D array
    let MY_NEW_1D_GRID = integrand[z=@sum]
  
You now have a 1D array of your 3D gridded variable (MY_VARIABLE) that is interpolated onto your lon, lat, depth point coordinates.

Hope that helps people in the future.

Pearse



From: owner-ferret_users@xxxxxxxx [owner-ferret_users@xxxxxxxx] on behalf of Pearse J. Buchanan [pearseb@xxxxxxxxxxxxx]
Sent: 08 May 2018 16:45
To: ferret_users@xxxxxxxx
Subject: [ferret_users] sampling point data from a 3D grid

Hello dear ferret user community,

I see there is a great function "samplexy" for sampling point data from a 2D gridded field.

After looking around in the documentation for a little while, I couldn't find an example showing how one might perform the same sampling from a 3D field. I understand that this might be more complicated because interpolation becomes tricky in 3 dimensions.

Is there a similar function, or capability using a combination of functions, that allows the user to sample point data in 3D space?

Let's say I have three 1D columns of data, each holding lon (x), lat (y) and depth (z) coordinates. Because these are 1D columns corresponding to every location that I have sampled, they are x*y*z long. Now I have a gridded data set A that is in 3D at different coordinates. I understand that we can easily retrieve data from A at x and y points at each z level using "samplexy". Then I have a new data set, on a x*y by z grid, with data points that do not correspond to my x and y locations very usefully masked out. What I am finding difficult is to place this x*y by z dataset onto a x*y*z grid, which is equivalent to my 1D arrays of lon (x), lat (y) and depth (z).

I have tried "reshape", as per the example in the user guide documentation. This gives me my 1D column of x*y*z length, masked out at the right places. However, for some reason this command converts all the gridded data of A into zeros.

Any help would be very much appreciated. I'm sure someone out there has tried this before.

Pearse

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement