Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Land outputs #11

Open
znicholls opened this issue Oct 8, 2020 · 0 comments
Open

Land outputs #11

znicholls opened this issue Oct 8, 2020 · 0 comments

Comments

@znicholls
Copy link

znicholls commented Oct 8, 2020

(And one more...)

I'm trying to reproduce the world, land mask values for CESM2-WACCM r1i1p1f1 ssp585 and am struggling. My script is below

import iris
import numpy as np

tas = iris.load_cube("tas_Amon_CESM2-WACCM_ssp585_r1i1p1f1_gn_201501-210012.nc")
land_frac = iris.load_cube("land_sea_mask_1degree.nc4")

tas_regridded = tas.regrid(land_frac, iris.analysis.Linear())

cosine_latitude_weights = np.cos(np.pi * tas_regridded.coords("latitude")[0].points / 180)
# really stupid way to do to this but fine as a hack
cosine_latitude_weights_lat_lon = []
for i in range(tas_regridded.coords("longitude")[0].shape[0]):
    cosine_latitude_weights_lat_lon.append(cosine_latitude_weights)

cosine_latitude_weights_lat_lon = np.vstack(cosine_latitude_weights_lat_lon).T

tas_regridded_weighted_mean = tas_regridded.collapsed(
    ["longitude", "latitude"],
    iris.analysis.MEAN,
    weights=(land_frac.data > 0.999).astype(int) * np.broadcast_to(cosine_latitude_weights_lat_lon, tas_regridded.shape)
)

tas_regridded_weighted_mean.data[:5]
tas_regridded_weighted_mean.data[:5] - 273.15
# gives 5.454, 5.387, 7.496, 10.090, 12.722

For 2015-01
I get: 5.454 C
You report: -0.106 C

For 2015-02
I get: 5.387 C
You report: -0.364 C

For 2015-05
I get: 12.722 C
You report: 7.01 C

This seems a large difference to put down only to regridding?

@znicholls znicholls mentioned this issue Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant