NCAR / cesm-lens-aws

Examples of analysis of CESM LENS data publicly available on Amazon S3 (us-west-2 region) using xarray and dask
https://doi.org/10.26024/wt24-5j82
BSD 3-Clause "New" or "Revised" License
43 stars 23 forks source link

Kay et al. (2015) - compute weighted means #6

Closed andersy005 closed 5 years ago

andersy005 commented 5 years ago

Towards #4

Rendered Notebook: https://nbviewer.jupyter.org/gist/andersy005/00c2798f9200c3a2a14f8ea845ba15a0?flush_cache=true

jhamman commented 5 years ago

thanks @andersy005!

andersy005 commented 5 years ago

Anytime @jhamman

When you get time, can you verify the correctness of my weighted means?

jhamman commented 5 years ago

@andersy005 - do you know if, included in the main LENS archive, there was a 2d field of grid cell areas? If so, we should probably include this (+topography) in the s3 collection of data.

andersy005 commented 5 years ago

do you know if, included in the main LENS archive, there was a 2d field of grid cell areas?

Not that I know of. Ccing @matt-long who may know where these 2d field of grid cell areas might be located at in the LENS archive

If so, we should probably include this (+topography) in the s3 collection of data.

I concur

matt-long commented 5 years ago

To compute the area on the atmospheric grid, you can do the following.

import numpy as np
import xarray as xr

def compute_CAM_fv_grid_area(ds_cam):
    """Compute area on CAM finite volume grid."""

    Re = 6.37122e6 # m, radius of Earth

    # use gaussian weights; make 2D: gw.dims == ('lat',)
    area = ds_cam.gw + 0.0 * ds_cam.lon 
    area = (4.0 * np.pi * Re**2 / area.sum(dim=('lat', 'lon'))) * area # m^2
    area.attrs['units'] = 'm^2'

    return area
andersy005 commented 5 years ago

Thank you, @matt-long!

jhamman commented 5 years ago

I know this is possible, but I don't think it is necessary. CESM is typically run along side a domain file. This file typically includes things like grid cell area, grid cell elevation (or depth), etc. I imagine this is available for the LENS model configuration and we can/should provide it for all the model components (land/atm/ocean).

andersy005 commented 5 years ago

@jhamman,

If you know where these domain files are located at, let me know and I will add them to the S3 bucket.

jhamman commented 5 years ago

I don't know where they are but I wouldn't be surprised if @matt-long or @strandwg know where to find them.