Polar Module
- pywrfkit.polar.convert_to_polar(variable, radius=5, resolution=None, coords=('hurricane_radial_distance_x', 'hurricane_radial_distance_y'))[source]
Convert Cartesian coordinates to polar coordinates and interpolate values.
This function takes a variable in Cartesian coordinates and converts it to polar coordinates. It then interpolates the values onto the new polar grid.
- Parameters:
variable (xarray.DataArray) – The variable to convert, typically wind speed or another meteorological variable.
radius (float, optional) – The maximum radius for polar coordinates in degrees. Defaults to 5.
resolution (float, optional) – The resolution of the polar grid. If None, it’s calculated from the input data. Defaults to None.
coords (tuple, optional) – The names of the x and y coordinate variables in the input data. Defaults to (‘hurricane_radial_distance_x’, ‘hurricane_radial_distance_y’).
- Returns:
A new DataArray with the variable interpolated onto a polar grid. The dimensions are ‘angle’ (in radians) and ‘radius’ (in km).
- Return type:
Notes
The function assumes that the input coordinates are in degrees and converts the radius to km (multiplied by 111.11).
The interpolation is performed using linear interpolation with NaN fill values for points outside the original grid.
This function assumes the input data is in Cartesian coordinates.
- pywrfkit.polar.get_polar_from_file(filename, radius=5, resolution=0.1)[source]
Given a NetCDF filename, load the dataset and return a new xarray.Dataset containing model_outputs and merra_pcp in polar coordinates.
- Parameters:
- Returns:
polar_ds – Dataset with variables ‘model_outputs_polar’ and ‘merra_pcp_polar’.
- Return type: