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_wps_write_int does not write correct level into the file #212

Closed
levinzx opened this issue Jun 10, 2024 · 1 comment
Closed

wrf_wps_write_int does not write correct level into the file #212

levinzx opened this issue Jun 10, 2024 · 1 comment

Comments

@levinzx
Copy link

levinzx commented Jun 10, 2024

Hello,

I'm using NCL function wrf_wps_write_int to convert NetCDF variables into WPS intermediate format. However, the function does not write the level correctly. No matter what value is provided, the function writes level=0 into the file.

Here is a sample code,
f = addfile("ta_6hrPlevPt_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_201001010600-201501010000.nc", "r")
ta = f->ta(0:ntime-1,:,:,:)
lat := f->lat
lon := f->lon
plev := f->plev
nlev = dimsizes(plev)
nlats = dimsizes(lat)

FIELD_T          = "TT" 
UNITS_T          = "K" 
DESC_T           = "Temperature"

opt                            = True 
opt@projection        = 4                 ; "Guassian Grid" 
opt@date                 = DATE 
opt@map_source     = "MPI-ESM1-2-LR" 
opt@startloc            = "SWCORNER"
opt@startlon            = lon(0) 
opt@startlat             = lat(0) 
opt@deltalon           = lon(1) - lon(0) 
opt@deltalat            = lat(1) - lat(0)
opt@nlats                = nlats
opt@is_wind_earth_relative = False
opt@level                = 100000

wrf_wps_write_int(WPS_IM_root_name,FIELD_T,UNITS_T,DESC_T,ta(0,0,:,:),opt)
print(opt)

The output messages are as follows,

DONE WRITING TT (level=     0.) for time 2010-01-01_06 to IM Format 

Variable: opt 
Type: logical 
Total Size: 4 bytes 
            1 values 
Number of Dimensions: 1 
Dimensions and sizes:   [1] 
Coordinates: 
Number Of Attributes: 11 
  level :       100000 
  is_wind_earth_relative :      False 
  nlats :       96 
  deltalat :    1.849637559339129 
  deltalon :    1.875 
  startlat :    -88.57216851400727 
  startlon :       0 
  startloc :    SWCORNER 
  map_source :  MPI-ESM1-2-LR 
  date :        2010-01-01_06 
  projection :  4 

I have tested the function on different HPCs from NCAR and NERSC with NCL installed (V6.6.2) and the problem persists. I'm not sure whether there's a bug in my script or in the source code. May I get some attention to it?

@levinzx
Copy link
Author

levinzx commented Jun 10, 2024

It turned out to be a mismatch of the required data type for opt@level and plev from the dataset. When convert plev to float or integer, the function works as supposed.

@levinzx levinzx closed this as completed Jun 10, 2024
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