[ncl-talk] averaging of height levels

Gurer, Kemal@ARB kemal.gurer at arb.ca.gov
Tue Oct 20 17:15:15 MDT 2020


Hello again,

I forgot to include the mid-level information about the zhalf1, zhalf2:

Variable: zz1
Type: float
Total Size: 2286144 bytes
            571536 values
Number of Dimensions: 3
Dimensions and sizes:   [latitude | 98] x [longitude | 108] x [levs | 54]
Coordinates:
            latitude: [31.6178..42.50189]
            longitude: [-129.0292..-113.0208]
            levs: [9.96921e+36..9.96921e+36]
Number Of Attributes: 1
  _FillValue :  9.96921e+36
(0)     min=-64.3161   max=28858.8

Variable: zhalf1
Type: float
Total Size: 2286144 bytes
            571536 values
Number of Dimensions: 3
Dimensions and sizes:   [levs | 54] x [latitude | 98] x [longitude | 108]
Coordinates:
            levs: [9.96921e+36..9.96921e+36]
            latitude: [31.6178..42.50189]
            longitude: [-129.0292..-113.0208]
Number Of Attributes: 1
  _FillValue :  9.96921e+36

Variable: zz2
Type: float
Total Size: 2286144 bytes
            571536 values
Number of Dimensions: 3
Dimensions and sizes:   [latitude | 98] x [longitude | 108] x [levs | 54]
Coordinates:
            latitude: [31.6178..42.50189]
            longitude: [-129.0292..-113.0208]
            levs: [9.96921e+36..9.96921e+36]
Number Of Attributes: 1
  _FillValue :  9.96921e+36
(0)     min=-64.3161   max=28858.8

Variable: zhalf2
Type: float
Total Size: 2286144 bytes
            571536 values
Number of Dimensions: 3
Dimensions and sizes:   [levs | 54] x [latitude | 98] x [longitude | 108]
Coordinates:
            levs: [9.96921e+36..9.96921e+36]
            latitude: [31.6178..42.50189]
            longitude: [-129.0292..-113.0208]
Number Of Attributes: 1
  _FillValue :  9.96921e+36

---------------------------------------------------------
Also, the additional information about zfull variable:

Variable: zfull
Type: float
Total Size: 2370816 bytes
            592704 values
Number of Dimensions: 3
Dimensions and sizes:   [latitude | 98] x [longitude | 108] x [nVertLevelsP1 | 56]
Coordinates:
            latitude: [31.6178..42.50189]
            longitude: [-129.0292..-113.0208]
Number Of Attributes: 2
  long_name :   Geometric height of layer interfaces
  units :       m MSL
(0)     Geometric height of layer interfaces (m MSL) : min=-74.3167   max=29983.8

Thanks again for your help.

Kemal.

From: Gurer, Kemal at ARB
Sent: Tuesday, October 20, 2020 4:10 PM
To: Dennis Shea <shea at ucar.edu>; ncl-talk at ucar.edu
Subject: RE: [ncl-talk] averaging of height levels

Hello Dennis,

I agree with you. I always included the outcome of my code in the past, but this time knowing almost for sure that I am making an obvious error somewhere that I cannot see, I assumed someone who is more experienced than me would catch it right away. I am sorry for not sending a complete question.

Here is my code in attempting to calculate the mid-level heights from full level heights via two method:

; ------- 1st variable and method ------------------------------------------------------

    zz1 = new((/nlats, nlons, nlevs-1/),"float")

    zz1!0 = "latitude"
    zz1!1 = "longitude"
    zz1!2 = "levs"
    zz1&latitude = latitude
    zz1&longitude = longitude
    zz1&levs = levs

    do i=0,nlevs-2
      zz1(:,:,i) = 0.5 * (zfull(:,:,i)+zfull(:,:,i+1))
    end do

    printVarSummary(zz1)
    printMinMax(zz1,0)

    zhalf1 = zz1(levs|:,latitude|:,longitude|:)
    printVarSummary(zhalf1)

; ------- 2nd variable and method ------------------------------------------------------

    zz2 = new((/nlats, nlons, nlevs-1/),"float")

    zz2!0 = "latitude"
    zz2!1 = "longitude"
    zz2!2 = "levs"
    zz2&latitude = latitude
    zz2&longitude = longitude
    zz2&levs = levs

    zz2 = 0.5*( zfull(:,:,0:nlevs-2) + zfull(:,:,1:nlevs-1) )

    printVarSummary(zz2)
    printMinMax(zz2,0)

    zhalf2 = zz2(levs|:,latitude|:,longitude|:)
    printVarSummary(zhalf2)
; -------------------------------------------------------------

Here is the outcome of zfull values at zfull(0,0,:)

zfull =
  0, 20, 44, 72.8, 107.4, 148.8, 198.6, 258.3, 330, 416, 519.2, 643, 791.6,
    969.9001, 1183.9, 1440.7, 1748.8, 2118.6, 2562.3, 3094.8, 3733.8, 4483.8,
    5233.799, 5983.799, 6733.8, 7483.799, 8233.8, 8983.8, 9733.8, 10483.8,
    11233.8, 11983.8, 12733.8, 13483.8, 14233.8, 14983.8, 15733.8, 16483.8,
    17233.8, 17983.8, 18733.8, 19483.8, 20233.8, 20983.8, 21733.8, 22483.8,
    23233.8, 23983.8, 24733.8, 25483.8, 26233.8, 26983.8, 27733.8, 28483.8,
    29233.8, 29983.8, 0, 20, 44, 72.8, 107.4, 148.8, 198.6, 258.3, 330, 416,
    519.2, 643, 791.6, 969.9, 1183.9, 1440.7, 1748.8, 2118.6, 2562.3, 3094.8,
    3733.8, 4483.8, 5233.8, 5983.8, 6733.8, 7483.8, 8233.8, 8983.8, 9733.8,
    10483.8, 11233.8, 11983.8, 12733.8, 13483.8, 14233.8, 14983.8, 15733.8,
    16483.8, 17233.8, 17983.8, 18733.8, 19483.8, 20233.8, 20983.8, 21733.8,
    22483.8, 23233.8, 23983.8, 24733.8, 25483.8, 26233.8, 26983.8,
  27733.8, 28483.8, 29233.8, 29983.8

Here is the outcome of both zhalf1 and zhalf2 at (0,0,:) point:

zhalf1 and 2 =
  9.999999, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9.999999, 10, 10, 10, 10, 10,
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
    10, 10, 10, 9.999999, 10, 10, 10, 9.999999, 10, 10, 10, 10, 10, 10, 10,
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 423.6477,
    378.6578, 662.8945, 1097.154, 1152.52, 1072.004, 1299.672, 1005.835,
    592.6567, 270.4732, 318.5765, 13.87211, 13.37675, 10, 10, 49.30841,
    48.51982, 38.2547, 10.43509, 20.66064, 89.90919, 139.163, 114.4501,
    201.582, 276.1719,
  10, 10, 10, 10, 10, 10, 10,

Thank you for your time and expertise. With regards,

Kemal.

From: Dennis Shea <shea at ucar.edu<mailto:shea at ucar.edu>>
Sent: Tuesday, October 20, 2020 3:40 PM
To: Gurer, Kemal at ARB <kemal.gurer at arb.ca.gov<mailto:kemal.gurer at arb.ca.gov>>
Cc: ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] averaging of height levels

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
It is ALWAYS best to include the output from printVarSummary when submitting a question.

printVarSummary(zfull)
===
To me, what you have done is correct.

A statement like: "since the half height levels are strange"

does not tell people much. What is "strange" about the values?



On Mon, Oct 19, 2020 at 4:15 PM Gurer, Kemal at ARB via ncl-talk <ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>> wrote:
Hi ncl’ers,

I have a 3d array for the full model height levels, say, zfull(nlat,nlon,nlevs). I want to calculate the midpoints of the height levels of the full model heights and put it into a new  array, say zhalf(nlat,nlon,nlevs-1). The following code:

    do i=0,nlevs-2
       zhalf(:,:,i) = 0.5 * (zfull(:,:,i)+zfull(:,:,i+1))
    end do

or, the following code:

   zhalf = 0.5*( zfull(:,:,0:nlevs-2) + zfull(:,:,1:nlevs-1) )

generates some data, but I don’t know and think what I am doing is right since the half height levels are strange. How can I calculate the mid-points of height levels of a 3d array of height levels?

Thank you for your help.

_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk<https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.ucar.edu%2Fmailman%2Flistinfo%2Fncl-talk&data=04%7C01%7Ckemal.gurer%40arb.ca.gov%7C376868c05d8949d02fd208d875490c46%7C9de5aaee778840b1a438c0ccc98c87cc%7C0%7C1%7C637388303889058510%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=S3UXIQA1eaE5UYi4IPkCMCQGsq9REgS9eTY9loUEHys%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201020/1b21afeb/attachment.html>


More information about the ncl-talk mailing list