Skip to content

tsout_seriesReader with no specified heights crashes #108

@hawbecker

Description

@hawbecker

When calling tsout_seriesReader with a specified list of heights, the code works as expected. However, when removing a specification for 'heights' in the call, the code crashes with the following error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-36-4a42bcaa73f3> in <module>
     40                                                                      select_tower=['FN{}'.format(fino)],
     41                                                                      #heights=[10.0],
---> 42                                                                      height_var='ph'
     43                                                                     )
     44             wrf_twrs[case]['FN{}'.format(fino)].to_netcdf(twr_path)

~/Code/Python/mmctools/mmctools/wrf/utils.py in tsout_seriesReader(fdir, restarts, simulation_start_time, domain_of_interest, structure, time_step, heights, height_var, select_tower)
   1132     dsF = combine_towers(fdir,restarts,simulation_start_time,tower_names,
   1133                          structure=structure, time_step=time_step,
-> 1134                          heights=heights, height_var=height_var)
   1135     return dsF
   1136 

~/Code/Python/mmctools/mmctools/wrf/utils.py in combine_towers(fdir, restarts, simulation_start, fname, structure, time_step, dx, dy, heights, height_var, agl, verbose, **kwargs)
   1041                                height_var=height_var,
   1042                                agl=agl,
-> 1043                                **kwargs)
   1044             data.append(ds)
   1045         data_block = xr.combine_by_coords(data)

~/Code/Python/mmctools/mmctools/wrf/utils.py in to_xarray(self, start_time, time_unit, time_step, heights, height_var, agl, structure, **kwargs)
    641                 time_unit=time_unit, time_step=time_step,
    642                 heights=heights, height_var=height_var, agl=agl,
--> 643                 **kwargs)
    644         ds = df.to_xarray()
    645 

~/Code/Python/mmctools/mmctools/wrf/utils.py in to_dataframe(self, start_time, time_unit, time_step, unstagger, heights, height_var, agl, exclude)
    500             else:
    501                 nz = self.nz
--> 502             datadict = self._create_datadict(varns,unstagger)
    503             if hasattr(self, height_var):
    504                 # heights (constant in time) were separately calculated

~/Code/Python/mmctools/mmctools/wrf/utils.py in _create_datadict(self, varns, unstagger, staggered_vars)
    378                         # don't throw a warning if w is already unstaggered by the code
    379                         # last value is (w(model top) + 0.0)/2.0
--> 380                         assert np.all(tsdata[:,-1] == 0), 'Unexpected nonzero value for '+varn
    381                     # drop the trailing 0 for already unstaggered quantities
    382                     datadict[varn] = tsdata[:,:-1].ravel()

AssertionError: Unexpected nonzero value for qv

For reference, this is called with the following command:

wrf_twrs[case]['FN{}'.format(fino)] = tsout_seriesReader(fdir='/glade/scratch/hawbecke/WRF/MMC/FINO1/20100512_to_20100526/ERA5_MYJ_CHRN_ER5_NOSK_3DOM/',
                                                         restarts=['FINO_2010051212'],
                                                         simulation_start_time=['2010-05-12 12:00:00'],
                                                         domain_of_interest='d03',
                                                         structure='unordered',
                                                         time_step=3.0,
                                                         select_tower=['FN1'],
                                                         #heights=[10.0],
                                                         height_var='ph'
                                                        )

I believe the issue in this is due to the fact that we are checking to make sure the top values for each variable (besides temperature) are at 0.0 assuming that the top of the tslist files is the model top. This is not always the case, however. In this simulation, I am specifying that only the lowest 51 levels should be output to the tslist files. Moving forward, we need to figure out a way to parse / check for interpolation without relying on the top value.

Metadata

Metadata

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