Skip to content

Issue converting WRF namelist into ERF input #40

@Robson-Passos

Description

@Robson-Passos

I am experiencing issues when trying to convert the WRF namelist into ERF input.

I have WRF namelist configured with two domains (max_dom = 2) and I want to process the initial conditions from WRF to generate inputs for ERF. However, I am getting assertion errors.

It looks like erftools is parsing the namelist incorrectly:

Instead of loading dx = [9000, 3000]

It only parses dx = [9000]

This leads to the following error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 wrf = WRFInputDeck('/media/robson/HD12/WRF2ERF/INPUTS_WRF/namelist.input')
      3 wrf.process_initial_conditions('/media/robson/HD12/WRF2ERF/INPUTS_WRF/wrfinput_d01.nc',
      4                                landuse_table_path='/media/robson/HD12/WRF2ERF/INPUTS_WRF/LANDUSE.TBL',
      5                                write_hgt='terrain_height.txt',
      6                                write_z0='roughness_height.txt')
      7 wrf.write_inputfile('inputs')

File /media/robson/HD12/WRF2ERF/erftools/preprocessing/wrf_inputs.py:46, in WRFInputDeck.__init__(self, nmlpath, tslist, verbosity)
     44     self.nml = f90nml.read(f)
     45 self.time_control = TimeControl(self.nml['time_control'])
---> 46 self.domains = Domains(self.nml['domains'])
     47 self.physics = Physics(self.nml['physics'])
     48 self.dynamics = Dynamics(self.nml['dynamics'])

File /media/robson/HD12/WRF2ERF/erftools/wrf/namelist.py:135, in Domains.__init__(self, nmldict)
    133 super().__init__(nmldict)
    134 self.parse_time_integration()
--> 135 self.parse_grid()

File /media/robson/HD12/WRF2ERF/erftools/wrf/namelist.py:181, in Domains.parse_grid(self)
    179     assert self.j_parent_start[0] == 1
    180 for dom in range(1,self.max_dom):
--> 181     assert (self.dx[dom-1]/self.dx[dom] == self.parent_grid_ratio[dom])
    182     assert (self.dy[dom-1]/self.dy[dom] == self.parent_grid_ratio[dom])
    183 self.eta_levels = self.getarrayvar('eta_levels',optional=True)

IndexError: list index out of range

I am running using the code bellow:

wrf = WRFInputDeck('/path/to/namelist.input')
wrf.process_initial_conditions(
    '/path/to/wrfinput_d01.nc',
    landuse_table_path='/path/to/LANDUSE.TBL',
    write_hgt='terrain_height.txt',
    write_z0='roughness_height.txt'
)
wrf.write_inputfile('inputs')

Here are the WRF input (Google Drive folder) files and the WRF namelist.

https://drive.google.com/drive/folders/1sf-7RYVLe27OP4Zcumi8Y0TR46g1mU72?usp=drive_link

namelist.txt

LANDUSE.txt

Thank you in advance,
Robson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions