NCAR / NCAR/wrf-python

getvar returns ['GSW' is not a valid variable name]; extract_vars returns [got multiple values for argument 'timeidx']

Open
#238 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
498
Forks
178
PR merge metrics
No merged PRs in 30d

Description

Dear all,

I'm now working on an issue that needs the net heat flux at surface.
To calculate it, I need the variables including GSW, GLW, TSK, EMISS, GRDFLX, HFX, and LH.
The others are easily obtainded by wrf.getvar function, but I failed in getting the variable GSW, and the error message is here:

gsw = wrf.getvar(wrflist, "GSW", timeidx=t,  @method="cat")
  File "/Users/abc/anaconda3/envs/pygmt/lib/python3.10/site-packages/wrf/ro
utines.py", line 352, in getvar
    raise ValueError("'{}' is not a valid variable name".format(varname))
ValueError: 'GSW' is not a valid variable name

I checked the wrfout file and confirmed there is a variable named 'GSW' (I could also plot it):

float GSW(Time, south_north, west_east) ;
		GSW:FieldType = 104 ;
		GSW:MemoryOrder = "XY " ;
		GSW:description = "NET SHORT WAVE FLUX AT GROUND SURFACE" ;
		GSW:units = "W m-2" ;
		GSW:stagger = "" ;
		GSW:coordinates = "XLONG XLAT XTIME" ;

After that, I tried to use wrf.extract_vars to get the variables that originally embedded in the wrfout file, but I also got error

gsw = wrf.extract_vars(wrflist, "GSW", timeidx=t, method="cat")
TypeError: extract_vars() got multiple values for argument 'timeidx'

The argument 'timeidx=t' works fine in other variables such as GLW, etc.

Is this a bug or I need special way to extract GSW? For now, I could only get 'SWDOWN' and 'ALBEDO' seperately and calculate GSW by myself.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report names wrf.getvar, wrf.extract_vars, and routines.py around line 352. Read those entry points and reproduce both calls against a wrfout file containing GSW; done means the supported extraction behavior is clear and the invalid-name or duplicate-timeidx failure is resolved or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.