-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix stats for climatology maps #977
Conversation
The area weights (and not just the fields themselves) need to be masked to exclude land.
@golaz, I really though I had the stats fixed after #860 and #861 but clearly I messed up big time! My only defense, and it's a weak one, is that it seems pretty odd that |
TestingI ran the I also computed the mean outside of MPAS-Analysis using both the MPAS data before remapping: #!/usr/bin/env python
import xarray as xr
mesh_filename = '/lcrc/group/e3sm/public_html/inputdata/share/meshes/mpas/ocean/IcoswISC30E3r5.20231120.nc'
sst_filename = '/lcrc/group/e3sm2/ac.wlin/E3SMv3_dev/20231122.v3b02-Icos30.piControl.chrysalis/post/analysis/mpas_analysis/ts_0001-0300_climo_0251-0300/clim/mpas/avg/masked/sst_IcoswISC30E3r5/mpaso_ANN_025101_030012_climo.nc'
ds_mesh = xr.open_dataset(mesh_filename)
ds_sst = xr.open_dataset(sst_filename)
area = ds_mesh.areaCell
mean_sst = ((ds_sst.timeMonthly_avg_activeTracers_temperature * area).sum() /
area.sum())
print(mean_sst.values) The result is: And the remapped data: #!/usr/bin/env python
import xarray as xr
sst_filname = '/lcrc/group/e3sm2/ac.wlin/E3SMv3_dev/20231122.v3b02-Icos30.piControl.chrysalis/post/analysis/mpas_analysis/ts_0001-0300_climo_0251-0300/clim/mpas/avg/remapped/sst_IcoswISC30E3r5_to_0.5x0.5degree/mpaso_ANN_025101_030012_climo.nc'
ds_sst = xr.open_dataset(sst_filname)
area = ds_sst.area
sst = ds_sst.timeMonthly_avg_activeTracers_temperature
mask = sst.notnull()
mean_sst = ((sst * area).sum() / area.where(mask).sum())
print(mean_sst.values)
mean_sst = ((sst * area).sum() / area.sum())
print(mean_sst.values) The results are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @xylar for the super quick fix!
@xylar , thanks for fixing this so quickly. I agree that the behavior is confusing. For my own scripts, I typically use This bug also explains why SST RMSE metrics were always much smaller from MPAS-Analysis than from E3SM Diags. Something I had noticed a while ago, but did not dig into. |
@golaz, thanks for the advice on @milenaveneziani, I agree with your slack comment, I prefer the |
Thanks @milenaveneziani and @golaz! @proteanplanet, I think this has enough eyes on it already so I'll remove you as a reviewer. You have a busy week ahead of you! |
The area weights (and not just the fields themselves) need to be masked to exclude land.
Before this fix:
![image](https://private-user-images.githubusercontent.com/4179064/288840825-94e0371c-39f2-4b7c-9086-6c7f4de90b4a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNjQyODksIm5iZiI6MTczOTI2Mzk4OSwicGF0aCI6Ii80MTc5MDY0LzI4ODg0MDgyNS05NGUwMzcxYy0zOWYyLTRiN2MtOTA4Ni02YzdmNGRlOTBiNGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMDg1MzA5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWQ5N2QwZGUxNGI3NTlmZGY3YzEwNjQ5YmM1YzIwZmYwODRmNzdiNDY4MTg4ZGFjOWQzNDhjODQ0NzkwZGQ0OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ZXuTsntd_HsMEHt9HudSF0WGVybsk3HLheduUpLQqN0)
![image](https://private-user-images.githubusercontent.com/4179064/288841000-be46d6f9-2d63-4247-a9ec-85c3a3d0d53e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNjQyODksIm5iZiI6MTczOTI2Mzk4OSwicGF0aCI6Ii80MTc5MDY0LzI4ODg0MTAwMC1iZTQ2ZDZmOS0yZDYzLTQyNDctYTllYy04NWMzYTNkMGQ1M2UucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMDg1MzA5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDExMGNiYjE3NjkzYjljZWVhODE5MmI1Y2RhNjAzOWI5ZWZkYTY1YzA1ZTE2MGMyN2FjN2FhNzM4ZDdjOGRkNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.b7oNxiwUgVMex2JOsx7iS-pEvaC7QwI8Tc5BG40qjsE)
Note: mean of 12.36
But this time series of SST:
After the fix:
![image](https://private-user-images.githubusercontent.com/4179064/288841117-8e05c92e-faea-4b1e-9df8-093e7b206cc9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNjQyODksIm5iZiI6MTczOTI2Mzk4OSwicGF0aCI6Ii80MTc5MDY0LzI4ODg0MTExNy04ZTA1YzkyZS1mYWVhLTRiMWUtOWRmOC0wOTNlN2IyMDZjYzkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMDg1MzA5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NjgxODUxY2FhNDRiNWUxN2JiMmZlZWZkODUxYWI5MDA3ZDE2NDlmZWNjMjdkZDY3MDNiNTAwYzQzMjE0ZGQ0YyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.arJoTzga89R1qr6UL-rmWh-t6UYxynhnzXVaOB35WyM)