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

wrf-python producing spurious results #207

Closed
freecodegaku opened this issue May 16, 2023 · 8 comments · Fixed by #211
Closed

wrf-python producing spurious results #207

freecodegaku opened this issue May 16, 2023 · 8 comments · Fixed by #211
Assignees
Labels
bug Something isn't working

Comments

@freecodegaku
Copy link

Running wrf-python with python=>3.11 produces different results to those from ncl e.g for example when using Python 3.11.3 on [https://www.dropbox.com/s/szxm475isnlnufh/wrfout_d01_1989-04-28_01?dl=0](https://www.dropbox.com/s/szxm475isnlnufh/wrfout_d01_1989-04-28_01?dl=0](https://www.dropbox.com/s/szxm475isnlnufh/wrfout_d01_1989-04-28_01?dl=0](https://www.dropbox.com/s/szxm475isnlnufh/wrfout_d01_1989-04-28_01?dl=0)

import wrf as wrf
from netCDF4 import Dataset as dataset
import numpy as np
f = "wrfout_d01_1989-04-28_01";

ds = dataset(f)
x = wrf.getvar(ds, "tk", timeidx = wrf.ALL_TIMES)
print(np.min(x), " ", np.max(x))

gives a min of 121.18885 and max of 495.5703. While using ncl

begin
    f = "wrfout_d01_1989-04-28_01";
    a = addfile(f, "r")
    x = wrf_user_getvar(a, "tk", -1)
    print(min(x))
    print(max(x))
end

produces a min of 185.3759 and max 316.4777.

Running the python code with python version <=3.10.10 produces the same results as ncl i.e. 185.3759 and max 316.4777.

@freecodegaku freecodegaku changed the title wrf-python producing wrong results when using Python 3.10.11+ and 3.11.x wrf-python producing spurious results when using Python 3.10.11+ and 3.11.x May 16, 2023
@erogluorhan
Copy link
Collaborator

Hi @freecodegaku thanks for reporting this; it's interesting! We will look into this as soon as we can.

@kafitzgerald kafitzgerald added the bug Something isn't working label Jun 5, 2023
@kafitzgerald
Copy link
Collaborator

Just noting that I was able to replicate this issue.

I can try to look into this some this week, but we should probably pin to Python <3.11 for the time being.

@fraDMbo98
Copy link

I run the example script in the reference guide (https://wrf-python.readthedocs.io/en/latest/plot.html) using the same netcdf file used there. I got this unphysical result:
slp_us

I used:
python 3.10.9
netcdf4 1.6.3
matplotlib 3.7.1
cartopy 0.21.1

I tried both on windows 10 and linux, obtaining the same result.

Probably it's something related to the bug observed by @freecodegaku, even if I got this with a version of python<3.11.

@sinan0310
Copy link

I run the example script in the reference guide (https://wrf-python.readthedocs.io/en/latest/plot.html) using the same netcdf file used there. I got this unphysical result: slp_us

I used: python 3.10.9 netcdf4 1.6.3 matplotlib 3.7.1 cartopy 0.21.1

I tried both on windows 10 and linux, obtaining the same result.

Probably it's something related to the bug observed by @freecodegaku, even if I got this with a version of python<3.11.

Had the same issue, Installed python3.9 and for now everything seems fine

@kafitzgerald kafitzgerald self-assigned this Jun 10, 2023
@Cat7102
Copy link

Cat7102 commented Jun 12, 2023

I run the example script in the reference guide (https://wrf-python.readthedocs.io/en/latest/plot.html) using the same netcdf file used there. I got this unphysical result: slp_us

I used: python 3.10.9 netcdf4 1.6.3 matplotlib 3.7.1 cartopy 0.21.1

I tried both on windows 10 and linux, obtaining the same result.

Probably it's something related to the bug observed by @freecodegaku, even if I got this with a version of python<3.11.

I also met this problem with python3.9, wrf-python1.4.1, netcdf1.6.2, and I guess the main reason is the "slp" in getvar function. Then I create a environment with python3.7, the problem solved.

@uegajde
Copy link

uegajde commented Jun 14, 2023

the reason looks like to be numpy/numpy#23651
is your numpy version 1.24.3?

@kafitzgerald
Copy link
Collaborator

Thanks for pointing that out.

I haven't time to dig into this much, but that aligns with my current suspicions as well.

@kafitzgerald kafitzgerald changed the title wrf-python producing spurious results when using Python 3.10.11+ and 3.11.x wrf-python producing spurious results Jun 15, 2023
@kafitzgerald
Copy link
Collaborator

the reason looks like to be numpy/numpy#23651 is your numpy version 1.24.3?

Looks like that's the case. Pinning numpy fixes this issue and the additional/related test failures I see. Numpy just released 1.24.3 less than two months ago and dropped support for Python 3.7 so older environments and Python versions likely wouldn't be impacted.

I'll throw in a PR to pin numpy.

@freecodegaku, @Cat7102, @sinan0310 if you're still having issues with a numpy version other than 1.24.3, please let us know. Thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants