Skip to content

[MISC]: Split _wrf_grid_from_dataset in projection and grid parts, add to public API #175

Open
@thgeorgiou

Description

@thgeorgiou

What is your issue?

Hello all!

In a recent project, I started by doing some preliminary post-processing of all my wrfout files (running them through xwrf, destaggering, removing some variables and computing some others, concatenating) and storing the intermediate files before continuing with my analysis. The WRF projection is helpfully added in the wrf_projection variable but that can't be stored in a netCDF file, so you have to drop it before writing your output.

ds = (
    xr.open_dataset(
        "/path/to/wrfout"
    )
    .xwrf.postprocess()
    .xwrf.destagger()
)

# Do some more processing...

# Write to netCDF
ds.drop_vars('wrf_projection').to_netcdf("/path/to/output")

At this point, if you open your file again, there is no point in running .xwrf.postprocess() because everything is ready. But you also don't have the proj object and you can't make it with xwrf._wrf_grid_from_dataset() since it tries to find the west_east/south_north dimensions for making the grid.

The proposal here is to split _wrf_grid_from_dataset() into two functions, one for creating the proj object (e.g. get_wrf_proj()) and one for creating the (x, y) grid _get_wrf_grid(). The first could be useful outside .xwrf.postprocess() so it would be nice for it to be part of the public API.

I would be happy to write a pull request about this but I didn't want to jump the gun since it adds stuff to the public API.

Thank you for your great work :)

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